From 0012eb4c9704dd3430e024d0ce0e7bcb39c3c416 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Tue, 17 Oct 2017 16:59:38 +0200 Subject: [PATCH] [FIX] website_sale: included taxes considered as discount in the shop Steps to reproduce the bug: - In Sales settings, set "Tax display" as "Show line subtotals without taxes" - Create an article A with a customer tax set as price-inclusive. - associate on an other article B the pricelist P with a discount_policy set as "without_discount" - Ensure that the pricelist P is used in the shop. -Go to the shop Bug: The article A is considered as discounted but the price is full. The prices with included taxes were considered as discounted because lst_price - webstie_price were always greater than 0. When the "Show line subtotals without taxes" is checked for Tax display, the field website_price never includes the taxes. That's why the included taxes are substracted from the website_price. opw:776526 --- addons/website_sale/models/product.py | 6 ++++++ addons/website_sale/views/templates.xml | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/addons/website_sale/models/product.py b/addons/website_sale/models/product.py index 6c50e86c2b1..8d33629e927 100644 --- a/addons/website_sale/models/product.py +++ b/addons/website_sale/models/product.py @@ -3,6 +3,7 @@ from odoo import api, fields, models, tools, _ import odoo.addons.decimal_precision as dp from odoo.tools.translate import html_translate +from odoo.tools import float_is_zero class ProductStyle(models.Model): @@ -139,6 +140,7 @@ class ProductTemplate(models.Model): website_price = fields.Float('Website price', compute='_website_price', digits=dp.get_precision('Product Price')) website_public_price = fields.Float('Website public price', compute='_website_price', digits=dp.get_precision('Product Price')) + website_price_difference = fields.Boolean('Website price difference', compute='_website_price') def _website_price(self): # First filter out the ones that have no variant: @@ -148,6 +150,7 @@ class ProductTemplate(models.Model): for template, product in zip(self, self.mapped('product_variant_id')): template.website_price = product.website_price template.website_public_price = product.website_public_price + template.website_price_difference = product.website_price_difference def _default_website_sequence(self): self._cr.execute("SELECT MIN(website_sequence) FROM %s" % self._table) @@ -188,6 +191,7 @@ class Product(models.Model): website_price = fields.Float('Website price', compute='_website_price', digits=dp.get_precision('Product Price')) website_public_price = fields.Float('Website public price', compute='_website_price', digits=dp.get_precision('Product Price')) + website_price_difference = fields.Boolean('Website price difference', compute='_website_price') def _website_price(self): qty = self._context.get('quantity', 1.0) @@ -204,6 +208,8 @@ class Product(models.Model): for p, p2 in zip(self, self2): taxes = partner.property_account_position_id.map_tax(p.taxes_id.sudo().filtered(lambda x: x.company_id == company_id)) p.website_price = taxes.compute_all(p2.price, pricelist.currency_id, quantity=qty, product=p2, partner=partner)[ret] + price_without_pricelist = taxes.compute_all(p.list_price, pricelist.currency_id)[ret] + p.website_price_difference = False if float_is_zero(price_without_pricelist - p.website_price, precision_rounding=pricelist.currency_id.rounding) else True p.website_public_price = taxes.compute_all(p2.lst_price, quantity=qty, product=p2, partner=partner)[ret] @api.multi diff --git a/addons/website_sale/views/templates.xml b/addons/website_sale/views/templates.xml index 060206aaab5..381648690da 100644 --- a/addons/website_sale/views/templates.xml +++ b/addons/website_sale/views/templates.xml @@ -102,7 +102,7 @@
- + @@ -587,7 +587,7 @@

@@ -997,7 +997,7 @@
- +