[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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
</h5>
|
||||
<div itemprop="offers" itemscope="itemscope" itemtype="http://schema.org/Offer" class="product_price" t-if="product.product_variant_ids">
|
||||
<b>
|
||||
<t t-if="(compute_currency(product.lst_price) - product.website_price ) > 0.01 and website.get_current_pricelist().discount_policy=='without_discount'">
|
||||
<t t-if="product.website_price_difference and website.get_current_pricelist().discount_policy=='without_discount'">
|
||||
<del class="text-danger mr8" style="white-space: nowrap;" t-esc="compute_currency(product.website_public_price)" t-options="{'widget': 'monetary', 'display_currency': website.get_current_pricelist().currency_id, 'from_currency': website.currency_id}" />
|
||||
</t>
|
||||
|
||||
@@ -587,7 +587,7 @@
|
||||
<div itemprop="offers" itemscope="itemscope" itemtype="http://schema.org/Offer" class="product_price mt16">
|
||||
<h4 class="oe_price_h4 css_editable_mode_hidden">
|
||||
<span class="text-danger oe_default_price" style="text-decoration: line-through; white-space: nowrap;"
|
||||
t-esc="compute_currency(product.website_public_price)" t-options="{'widget': 'monetary', 'display_currency': website.get_current_pricelist().currency_id, 'from_currency': website.currency_id}" t-att-style="'text-decoration: line-through; white-space: nowrap; ' + '' if (compute_currency(product.lst_price) - product.website_price) > 0.01 and website.get_current_pricelist().discount_policy == 'without_discount' else 'display: none;'"
|
||||
t-esc="compute_currency(product.website_public_price)" t-options="{'widget': 'monetary', 'display_currency': website.get_current_pricelist().currency_id, 'from_currency': website.currency_id}" t-att-style="'text-decoration: line-through; white-space: nowrap; ' + '' if product.website_price_difference and website.get_current_pricelist().discount_policy == 'without_discount' else 'display: none;'"
|
||||
/>
|
||||
<b class="oe_price" style="white-space: nowrap;" t-esc="product.website_price" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"/>
|
||||
<span itemprop="price" style="display:none;" t-esc="product.website_price"/>
|
||||
@@ -997,7 +997,7 @@
|
||||
<div class="text-muted" t-field="product.description_sale" />
|
||||
</td>
|
||||
<td>
|
||||
<t t-if="(compute_currency(product.lst_price) - product.website_price) > 0.01 and website.get_current_pricelist().discount_policy=='without_discount'">
|
||||
<t t-if="product.website_price_difference and website.get_current_pricelist().discount_policy=='without_discount'">
|
||||
<del class="text-danger mr8" style="white-space: nowrap;" t-field="product.lst_price" t-options="{'widget': 'monetary','from_currency': product.currency_id, 'display_currency': website.currency_id}" />
|
||||
</t>
|
||||
<span t-field="product.website_price" style="white-space: nowrap;" t-options="{'widget': 'monetary','display_currency': website.currency_id}" />
|
||||
|
||||
Reference in New Issue
Block a user