[18.0][ADD]contract_invoice_suspended - #1494
Open
bjouini-acsone wants to merge 1 commit into
Open
Conversation
bjouini-acsone
force-pushed
the
18.0-add-contract_invoice_suspended
branch
2 times, most recently
from
August 4, 2026 10:32
19fdfd7 to
a383014
Compare
bjouini-acsone
force-pushed
the
18.0-add-contract_invoice_suspended
branch
from
August 4, 2026 10:42
a383014 to
36ac1ab
Compare
qgroulard
reviewed
Aug 6, 2026
qgroulard
left a comment
Contributor
There was a problem hiding this comment.
Hi, thanks for this contribution !
It would be nice to provide a bit more context 🙂
Comment on lines
+1
to
+6
| ========================== | ||
| Contract Invoice Suspended | ||
| ========================== | ||
|
|
||
| This module provides functionality to suspend automatic invoicing for | ||
| contracts with configurable reasons and tracking. |
Contributor
There was a problem hiding this comment.
Please follow oca guidelines: https://www.odoo-community.org/readme-structure
Could you please also elaborate? What's the point of this module? How to configure it? etc.
Try to think of this module as if it was completely unknown to you, what would you like to know about it?
Comment on lines
+14
to
+17
| # OCA | ||
| "contract_line_successor", | ||
| # OCA/contract | ||
| "contract_sale", |
Contributor
There was a problem hiding this comment.
Why are these two separated?
Comment on lines
+43
to
+46
| <field | ||
| name="domain_force" | ||
| >['|', ('company_id','=',False), ('company_id','parent_of',company_ids)]</field> | ||
| </record> |
Contributor
There was a problem hiding this comment.
The new convention for multi-company rule is:
[('company_id', 'in', company_ids + [False])]
Comment on lines
+47
to
+83
| @api.depends("parent_id.suspended_reason_category_id") | ||
| def _compute_suspended_reason_category_id(self): | ||
| self.env.cr.execute( | ||
| """ | ||
| WITH RECURSIVE trid(id, parent_id, | ||
| suspended_reason_category_id, final) AS ( | ||
| SELECT | ||
| id, parent_id, id, | ||
| (parent_id IS NULL) as final | ||
| FROM contract_automatic_invoice_suspension_reason | ||
| WHERE id = ANY(%s) | ||
| UNION | ||
| SELECT | ||
| trid.id, ctr.parent_id, ctr.id, | ||
| (ctr.parent_id IS NULL) as final | ||
| FROM contract_automatic_invoice_suspension_reason ctr | ||
| JOIN trid ON (trid.parent_id = ctr.id) | ||
| WHERE NOT trid.final | ||
| ) | ||
| SELECT trid.id, trid.suspended_reason_category_id | ||
| FROM trid | ||
| WHERE final AND id = ANY(%s); | ||
| """, | ||
| [self.ids, self.ids], | ||
| ) | ||
|
|
||
| d = dict(self.env.cr.fetchall()) | ||
| for suspension_reason in self: | ||
| fetched = d.get(suspension_reason.id) | ||
| if fetched is not None: | ||
| suspension_reason.suspended_reason_category_id = fetched | ||
| elif not suspension_reason.parent_id: | ||
| suspension_reason.suspended_reason_category_id = suspension_reason | ||
| else: | ||
| suspension_reason.suspended_reason_category_id = ( | ||
| suspension_reason.parent_id.suspended_reason_category_id | ||
| ) |
Contributor
There was a problem hiding this comment.
This looks super complicated to me.
Why can't we do something like:
Suggested change
| @api.depends("parent_id.suspended_reason_category_id") | |
| def _compute_suspended_reason_category_id(self): | |
| self.env.cr.execute( | |
| """ | |
| WITH RECURSIVE trid(id, parent_id, | |
| suspended_reason_category_id, final) AS ( | |
| SELECT | |
| id, parent_id, id, | |
| (parent_id IS NULL) as final | |
| FROM contract_automatic_invoice_suspension_reason | |
| WHERE id = ANY(%s) | |
| UNION | |
| SELECT | |
| trid.id, ctr.parent_id, ctr.id, | |
| (ctr.parent_id IS NULL) as final | |
| FROM contract_automatic_invoice_suspension_reason ctr | |
| JOIN trid ON (trid.parent_id = ctr.id) | |
| WHERE NOT trid.final | |
| ) | |
| SELECT trid.id, trid.suspended_reason_category_id | |
| FROM trid | |
| WHERE final AND id = ANY(%s); | |
| """, | |
| [self.ids, self.ids], | |
| ) | |
| d = dict(self.env.cr.fetchall()) | |
| for suspension_reason in self: | |
| fetched = d.get(suspension_reason.id) | |
| if fetched is not None: | |
| suspension_reason.suspended_reason_category_id = fetched | |
| elif not suspension_reason.parent_id: | |
| suspension_reason.suspended_reason_category_id = suspension_reason | |
| else: | |
| suspension_reason.suspended_reason_category_id = ( | |
| suspension_reason.parent_id.suspended_reason_category_id | |
| ) | |
| @api.depends("parent_id.suspended_reason_category_id") | |
| def _compute_suspended_reason_category_id(self): | |
| for suspension_reason in self: | |
| suspension_reason.suspended_reason_category_id = ( | |
| suspension_reason.parent_id.suspended_reason_category_id | |
| or suspension_reason | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.