odoo/tutorials#1310
Created by Tishbian Meshach S (times)
Blocked
- Merge method
- Review
-
CI
- ci/style: (runtime 10s)
- ci/tutorial: (runtime 125s)
- label
- odoo-dev:19.0-add-purchase-global-discount-times
- head
- b330c03bac6ca67363e8d849977d1984f14a7c66
| odoo/tutorials | |
|---|---|
| 19.0 | #1310 missing r+ |
| master |
[ADD] purchase: add global discount wizard for purchase orders
Introduced a transient wizard to apply an order-wide discount to purchase order lines based on an amount or percentage.
Rationale:
Purchasing teams need a fast, error-free way to distribute global vendor discounts across all order lines. Manually calculating line-level deductions is slow and prone to discrepancy. This wizard allows users to enter a fixed cash value or a total percentage, automatically deriving the relative values and updating all linked line items in bulk.
Technical choices:
- Created the 'purchase.order.discount' TransientModel to capture input without database bloat.
- Implemented an '@api.onchange' trigger utilizing a clean helper method to compute proportional percentage values dynamically when an amount is specified.
- Wrapped execution contexts using 'with_company(self.company_id)' to ensure correct multi-company record updating behavior.
- Injected an execution button cleanly under the 'order_line' field in the inherited purchase order view using precise XPath positioning.
Task Reference: 6253108