[19.0][MIG] sale_triple_discount: Migration to 19.0#3965
[19.0][MIG] sale_triple_discount: Migration to 19.0#3965
Conversation
af79003 to
a3fe9ea
Compare
|
@sbejaoui Hi, could you check this PR? |
OCA Transbot updated translations from Transifex [UPD] Update sale_triple_discount.pot
Currently translated at 100,0% (5 of 5 strings) Translation: sale-workflow-10.0/sale-workflow-10.0-sale_triple_discount Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-10-0/sale-workflow-10-0-sale_triple_discount/nl_NL/
Currently translated at 100.0% (5 of 5 strings) Translation: sale-workflow-10.0/sale-workflow-10.0-sale_triple_discount Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-10-0/sale-workflow-10-0-sale_triple_discount/nl_NL/
…onsistency [FIX] sale_triple_discount: Invalidating the cache of specific records before recomputing price and discount [UPD] Update sale_triple_discount.pot Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: sale-workflow-10.0/sale-workflow-10.0-sale_triple_discount Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-10-0/sale-workflow-10-0-sale_triple_discount/
…3 in the computation
[UPD] Update sale_triple_discount.pot
[UPD] Update sale_triple_discount.pot Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: sale-workflow-12.0/sale-workflow-12.0-sale_triple_discount Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-12-0/sale-workflow-12-0-sale_triple_discount/
[UPD] Update sale_triple_discount.pot [UPD] README.rst
Currently translated at 100.0% (11 of 11 strings) Translation: sale-workflow-14.0/sale-workflow-14.0-sale_triple_discount Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-14-0/sale-workflow-14-0-sale_triple_discount/it/ [UPD] README.rst [UPD] README.rst
Currently translated at 0.0% (0 of 11 strings) Translation: sale-workflow-14.0/sale-workflow-14.0-sale_triple_discount Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-14-0/sale-workflow-14-0-sale_triple_discount/fr/
[UPD] Update sale_triple_discount.pot [UPD] README.rst
Currently translated at 100.0% (12 of 12 strings) Translation: sale-workflow-16.0/sale-workflow-16.0-sale_triple_discount Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_triple_discount/it/
Currently translated at 100.0% (12 of 12 strings) Translation: sale-workflow-16.0/sale-workflow-16.0-sale_triple_discount Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_triple_discount/de/
Currently translated at 100.0% (12 of 12 strings) Translation: sale-workflow-16.0/sale-workflow-16.0-sale_triple_discount Translate-URL: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_triple_discount/pt_BR/
Method 'invalidate_cache' is deprecated. To invalidate specific field's value into the cache for a recordset we must use the 'invalidate_recordset' method on the recordset itself.
When computing the amount total on a sale.order.line, we now avoid to play with the cache since this change introduced in OCA@e3e59ba introduces a decline in performance. When the cache in invalidated, fields are flushed to the database and depending computed fields are recomputed..... This ultimately leads to temporary inconsistencies breaking others addons relaying on this one. Moreover, the method used in this original commit 'self.invalidate_cache(fnames=self._discount_fields(), ids=self.ids)' is deprecated and the use of the recommended new one lead to others side effects. The original approach is replaced by a contextual method modifying only the discount field when we need it's needed to don't break code relaying on the fact that the discount field is the total discount to apply to a line. This contextual method ensures that the original value is properly restored on exit and that it will not trigger additional recompute due to the temporary change of the discount value
add an inverse to the standard discount field, which resets the three discounts and sets discount1 with the value coming from the inverse. this way, any standard process like pricelists will integrate with this logic out of the box, without extra customization
a3fe9ea to
7db7948
Compare
|
/ocabot migration sale_triple_discount |
|
@lef-adhoc could you change the class text-right to text-end? text-right is obsolete and has no effect. Thanks! |
7db7948 to
cc16164
Compare
alexey-pelykh
left a comment
There was a problem hiding this comment.
Migration Review
Good migration overall. The core discount logic, ORM patterns, view XML, and tests are solid. A few issues to address:
Blocking
-
Translation template mismatch -- The
.potfile (and all.pofiles) reference%(dic_type)sbut the Python source uses%(disc_type)s. These are different placeholder names. The.potneeds regeneration to match the actual source string. Translations referencing the wrong placeholder will produce aKeyErrorat runtime. -
_compute_discountsreturnsTrue-- Odoo 19.0 compute methods should not return a value. ReturningTrueis a legacy pattern. Remove thereturn Truestatement.
Non-blocking
-
CI is red -- All three test workflows are failing. The "Detect unreleased dependencies" failure is expected given the dependency on
OCA/account-invoicing#2144. However, the actual test runs also fail, which should be investigated once the dependency PR is merged. -
_additive_discountclamps negatives to 0 -- The additive method returns 0 for negative sums, but the multiplicative method allows negative results (surcharges). This behavioral inconsistency could confuse users if additive mode is ever fully enabled. Since additive is currently blocked via_discounting_type_additive_not_allowed, this is informational only. -
createoverride fragility -- The logic increatethat conditionally calls_compute_discountsbased on comparingdiscountanddiscount1values withvalsis complex and could be fragile across Odoo upgrades. Consider adding a comment explaining the exact scenario this handles (e.g., whendiscountcomes from a pricelist vs when it is manually set).
| raise ValidationError( | ||
| self.env._( | ||
| "Sale order line %(name)s has unknown discounting type " | ||
| "%(disc_type)s", |
There was a problem hiding this comment.
The .pot and .po files contain %(dic_type)s but this code passes disc_type= as the keyword argument. The translation template is out of sync with the source. Regenerate the .pot to fix; otherwise translated error messages will raise KeyError at runtime.
| # calling super ensures the cache is coherent before applying the inverse | ||
| super()._compute_discount() | ||
| self._inverse_discount() | ||
| return True |
There was a problem hiding this comment.
Compute methods in Odoo 19.0 should not return a value. Remove the return True.
Based on this pr: #3889
Depends on: