odoo/tutorials#1297

Created by Tishbian Meshach S (times)

Blocked

label
odoo-dev:19.0-fix-sale-discount-update-orderlines-times
head
eda77ae8123a57b5cdcfaf81c4c80833d298fbba
odoo/tutorials
19.0 #1297 missing r+
master

[FIX] sale_management: update global discount when order lines change

Ensure the global discount value dynamically updates or resets when order lines are modified, utilizing a centralized field synchronized with manual line updates.

The implementation covers:
- Dynamic Updates & Synchronization: Syncs a new global_discount_percentage field with modifications made directly to the line description, re-triggering calculation via an @api.onchange decorator when the subtotal changes.
- Regex Parsing & Strict Validation: Dynamically extracts percentages using regex (r"(\d+(?:.\d+)?)%"), and raises a strict UserError fallback if the format does not conform to a valid floating-point representation.
- Localized Precision Formatting: Leverages decimal.precision configurations and float_repr inside localized translation strings (self.env._) to ensure the order line description matches system rounding guidelines perfectly.
- Automatic Removal: Cleanly identifies and purges global discount lines from the order recordset if all standard merchant product lines are fully deleted.
- Line Partitioning: Segregates product and discount collections via standard framework operators to prevent cascading dependency loops during matrix evaluation.

Task Reference: 6245598