From af0d1b565c0d571feca966fa28909484c9d6ee0a Mon Sep 17 00:00:00 2001 From: Jitendra Prajapat Date: Fri, 18 Aug 2023 16:53:37 +0530 Subject: [PATCH] [IMP] purchase: added discount field in Vendor Pricelist In this commit ============== - Added the discount fields to the vendor pricelist and PO line models, making them optional and hidden. - Implemented automatic filling of the discount field on the PO line when the unit price is sourced from the vendor pricelist. - Implemented a mechanism to automatically populate the discount field on the PO line when the unit price is fetched from the vendor pricelist. - Modified the pricing logic to ensure the discount is applied to the tax-excluded price. - PO confirmation process to check if a pricelist already exists for the vendor. If not, a new pricelist line is created, including the discount if it is present. task - 3380306 closes odoo/odoo#126804 Signed-off-by: Arnold Moyaux (arm) --- addons/product/models/product_supplierinfo.py | 4 ++ .../views/product_supplierinfo_views.xml | 2 + addons/purchase/models/purchase.py | 13 +++++- addons/purchase/tests/test_purchase.py | 41 +++++++++++++++++++ addons/purchase/views/purchase_views.xml | 1 + 5 files changed, 60 insertions(+), 1 deletion(-) diff --git a/addons/product/models/product_supplierinfo.py b/addons/product/models/product_supplierinfo.py index 5461d0e983e..5545895383e 100644 --- a/addons/product/models/product_supplierinfo.py +++ b/addons/product/models/product_supplierinfo.py @@ -62,6 +62,10 @@ class SupplierInfo(models.Model): delay = fields.Integer( 'Delivery Lead Time', default=1, required=True, help="Lead time in days between the confirmation of the purchase order and the receipt of the products in your warehouse. Used by the scheduler for automatic computation of the purchase order planning.") + discount = fields.Float( + string="Discount (%)", + digits='Discount', + readonly=False) @api.onchange('product_tmpl_id') def _onchange_product_tmpl_id(self): diff --git a/addons/product/views/product_supplierinfo_views.xml b/addons/product/views/product_supplierinfo_views.xml index e5eea2d7e56..d97d7027ac7 100644 --- a/addons/product/views/product_supplierinfo_views.xml +++ b/addons/product/views/product_supplierinfo_views.xml @@ -32,6 +32,7 @@