[IMP] sale: allow override sale_order_discount product

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 <jke@odoo.com>
This commit is contained in:
Jeremy Kersten
2024-02-13 10:08:02 +00:00
parent 6b86fe1fdb
commit bb541a73dc
+8 -3
View File
@@ -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 = [