Repository navigation
[T3487] Allow invoicing the contract line amount of pricelist products #289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 18.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,6 +53,10 @@ def _compute_display_name(self): | |
| quantity = fields.Integer(default=1, required=True) | ||
| subtotal = fields.Float(compute="_compute_subtotal", store=True) | ||
| pricelist_item_count = fields.Integer(related="product_id.pricelist_item_count") | ||
| amount_from_pricelist = fields.Boolean( | ||
| compute="_compute_amount_from_pricelist", | ||
| help="The invoiced price comes from the pricelist instead of the line price.", | ||
| ) | ||
|
|
||
| _sql_constraints = [ | ||
| ( | ||
|
|
@@ -67,6 +71,11 @@ def _compute_subtotal(self): | |
| for contract_line in self: | ||
| contract_line.subtotal = contract_line.amount * contract_line.quantity | ||
|
|
||
| @api.depends("product_id") | ||
| def _compute_amount_from_pricelist(self): | ||
| for line in self: | ||
| line.amount_from_pricelist = line.pricelist_item_count > 0 | ||
|
Comment on lines
+74
to
+77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If a pricelist item is added or removed after a contract line’s price-choice flag has been read in the same request, and that flag is not invalidated, invoice creation or updates can use the old price source. The flag reads Knowledge Base Used: Recurring contracts and invoicing
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In theory: if a pricelist item is added or removed earlier in the same request, the cached value could be outdated. But its fix wouldn't help. Odoo's own pricelist_item_count has no dependencies at all (it just counts records), so declaring it as a dependency triggers nothing. It isn't a regression either: the old code read the same pricelist_item_count with exactly the same caching. In practice, a pricelist rule is never changed and a contract invoiced in the same request. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right. Adding Tip: You can customize Greptile's behavior for this repo with |
||
|
|
||
| @api.onchange("product_id") | ||
| def on_change_product_id(self): | ||
| for line in self.filtered("product_id"): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no direct invoice test for a product-specific pricelist item or an override that uses the contract line amount. The existing fixture uses a global item and defines no test of its own. This is a non-blocking coverage gap, but a later pricing change could restore the wrong sponsorship charge without a test catching it. Add creation and update tests for both price choices.
Knowledge Base Used: Recurring contracts and invoicing
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Artifacts
Invoice price-choice verification script
Invoice pricing before the change
Invoice pricing after the change
Targeted Odoo test collection failure