From bb541a73dc2e76e5234f9a6e92f355a9509e9f89 Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Mon, 12 Feb 2024 14:20:57 +0100 Subject: [PATCH] [IMP] sale: allow override sale_order_discount product MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add method '_get_discount_product' to allow to override the product used by the sale_order_discount wizard. closes odoo/odoo#153652 Signed-off-by: Jérémy Kersten --- addons/sale/wizard/sale_order_discount.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/addons/sale/wizard/sale_order_discount.py b/addons/sale/wizard/sale_order_discount.py index e8356554cae..01e264a5f37 100644 --- a/addons/sale/wizard/sale_order_discount.py +++ b/addons/sale/wizard/sale_order_discount.py @@ -63,16 +63,21 @@ class SaleOrderDiscount(models.TransientModel): return vals - def _create_discount_lines(self): - """Create SOline(s) according to wizard configuration""" + def _get_discount_product(self): + """Return product.product used for discount line""" self.ensure_one() - discount_product = self.company_id.sale_discount_product_id if not discount_product: self.company_id.sale_discount_product_id = self.env['product.product'].create( self._prepare_discount_product_values() ) discount_product = self.company_id.sale_discount_product_id + return discount_product + + def _create_discount_lines(self): + """Create SOline(s) according to wizard configuration""" + self.ensure_one() + discount_product = self._get_discount_product() if self.discount_type == 'amount': vals_list = [