[FIX] website_sale: apply _fix_tax_included_price similary to sale module

If you had a price with a tax included and the user has fiscal position.
The tax included in the unit price was not substract before the mapping.

Eg: product $115 with tin 15% included in price.
Once in the cart with a fiscal position intracom (0% tva), the unit price
should be 100$ and not 115$.

This commit closes #16022
This commit is contained in:
Jeremy Kersten
2017-03-28 09:35:38 +02:00
parent 6a64d2dd8f
commit 7c95c14c06
2 changed files with 13 additions and 4 deletions
+1
View File
@@ -813,6 +813,7 @@ class SaleOrderLine(models.Model):
@api.multi
def _get_display_price(self, product):
# TO DO: move me in master/saas-16 on sale.order
if self.order_id.pricelist_id.discount_policy == 'without_discount':
from_currency = self.order_id.company_id.currency_id
return from_currency.compute(product.lst_price, self.order_id.pricelist_id.currency_id)
+12 -4
View File
@@ -68,12 +68,18 @@ class SaleOrder(models.Model):
})
product = self.env['product.product'].with_context(product_context).browse(product_id)
pu = product.price
if order.pricelist_id and order.partner_id:
order_line = order._cart_find_product_line(product.id)
if order_line:
pu = self.env['account.tax']._fix_tax_included_price(order_line._get_display_price(product), product.taxes_id, order_line.tax_id)
return {
'product_id': product_id,
'product_uom_qty': qty,
'order_id': order_id,
'product_uom': product.uom_id.id,
'price_unit': product.price,
'price_unit': pu,
}
@api.multi
@@ -144,10 +150,12 @@ class SaleOrder(models.Model):
# update line
values = self._website_product_id_change(self.id, product_id, qty=quantity)
if self.pricelist_id.discount_policy == 'with_discount' and not self.env.context.get('fixed_price'):
values['price_unit'] = order_line._get_display_price(order_line.product_id)
values['price_unit'] = self.env['account.tax']._fix_tax_included_price(
order_line._get_display_price(order_line.product_id),
order_line.product_id.taxes_id,
order_line.tax_id
)
order_line.write(values)