odoo/tutorials#1335
Created by Pranjali Sangavekar (prsan)
Blocked
- Merge method
- Review
-
CI
- ci/style: (runtime 5s)
- ci/tutorial: (runtime 79086s)
- label
- odoo-dev:19.0-imp-sales-orderlines-discount-update-prsan
- head
- b8ef1d2101172f8a514bba85132fc346319b8a25
| odoo/tutorials | |
|---|---|
| 19.0 | #1335 missing statuses missing r+ |
| master |
[IMP] sale: add global discount with automatic recalculation on order…
Problem: When a global discount is applied to a Sale Order, the discount amount is generated based on the current subtotal. However, when order lines are subsequently added, updated, or removed, the discount amount is not recalculated and becomes inconsistent with the current order subtotal.
Additionally, multiple discount lines can be created when applying a new global discount, and discount lines may remain even when all product lines have been removed.
Solution: Implemented automatic synchronization of the global discount with Sale Order lines.
Changes
- Recalculate the global discount when Sale Order lines are:
- Created
- Updated
- Deleted
- Remove the discount line when no product lines remain.
- Ensure only a single global discount line exists at any time.
- Replace the existing discount when a new global discount percentage is applied.
- Keep the stored discount percentage and discount line amount synchronized with the current order subtotal.
<img width="916" height="408" alt="2026-06-08_16-21" src="https://github.com/user-attachments/assets/c919b242-3b54-426e-85ed-bcf3c8e404d5" />