Skip to content

[ADD] purchase: add global discount wizard for purchase orders#1310

Open
times-odoo wants to merge 1 commit into
odoo:19.0from
odoo-dev:19.0-add-purchase-global-discount-times
Open

[ADD] purchase: add global discount wizard for purchase orders#1310
times-odoo wants to merge 1 commit into
odoo:19.0from
odoo-dev:19.0-add-purchase-global-discount-times

Conversation

@times-odoo
Copy link
Copy Markdown

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

@robodoo
Copy link
Copy Markdown

robodoo commented May 29, 2026

Pull request status dashboard

@times-odoo times-odoo requested a review from mash-odoo May 29, 2026 12:21
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
@times-odoo times-odoo force-pushed the 19.0-add-purchase-global-discount-times branch from 46b6bba to b330c03 Compare May 29, 2026 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants