From 27825cbf1340bd6b280a494bcb26297cb3cb973e Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Tue, 19 Jun 2018 10:36:07 +0200 Subject: [PATCH] [FIX] sale: unify both pricelist & sale option to show discount Sale module has an option to show or hide discounts on order lines. Pricelist also have a field to include the discount in the price or display the full price strikethroughed. Before this commit: If the sale option was disabled, the pricelist option would be hidden, possibly left enabled. This will cause a strange behavior in frontend where user would still see the strikethroughed price even if the sale module option was disabled. Now: If the sale option got disabled, we also disable the pricelist option Closes #14741 --- addons/sale/models/res_config_settings.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/sale/models/res_config_settings.py b/addons/sale/models/res_config_settings.py index 1b3a9aa53c5..d8fe8daeba5 100644 --- a/addons/sale/models/res_config_settings.py +++ b/addons/sale/models/res_config_settings.py @@ -83,6 +83,12 @@ class ResConfigSettings(models.TransientModel): module_product_email_template = fields.Boolean("Specific Email") module_sale_coupon = fields.Boolean("Coupons & Promotions") + def set_values(self): + super(ResConfigSettings, self).set_values() + if not self.group_discount_per_so_line: + pl = self.env['product.pricelist'].search([('discount_policy', '=', 'without_discount')]) + pl.write({'discount_policy': 'with_discount'}) + @api.onchange('multi_sales_price', 'multi_sales_price_method') def _onchange_sale_price(self): if self.multi_sales_price and not self.multi_sales_price_method: