From a04e1bf6e0d2df0c01e4e2702bf13689942875e4 Mon Sep 17 00:00:00 2001 From: "Andrea Grazioso (agr-odoo)" Date: Tue, 27 Sep 2022 16:14:47 +0000 Subject: [PATCH] [FIX] website_sale: fiscal position application Have the following taxes: - Tax A: 15%, included in price - Tax B: 21%, included in price Create a product P with list price 115 and tax A Have a fiscal positions FPOS configured with: - Detect Automatically checked - Country: Belgium - Map tax on product: A -> B Open a web shop session as guest, add P to cart Go to checkout: Price total will be 115 Fill address details with Belgium address Go to confirmation page Error: Price total will be 100. In the application of fiscal position the wrong unit price is used opw-2973879 closes odoo/odoo#105061 X-original-commit: 0a8394055221e48c610ad51eef21eb1a16f1e9f9 Signed-off-by: William Braeckman (wbr) Signed-off-by: Grazioso Andrea (agr) --- ...test_website_sale_product_attribute_value_config.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/website_sale/tests/test_website_sale_product_attribute_value_config.py b/addons/website_sale/tests/test_website_sale_product_attribute_value_config.py index 1513f65f4be..70c429391b1 100644 --- a/addons/website_sale/tests/test_website_sale_product_attribute_value_config.py +++ b/addons/website_sale/tests/test_website_sale_product_attribute_value_config.py @@ -170,14 +170,14 @@ class TestWebsiteSaleProductAttributeValueConfig(AccountTestInvoicingCommon, Tes @tagged('post_install', '-at_install', 'product_pricelist') class TestWebsiteSaleProductPricelist(AccountTestInvoicingCommon, TestSaleProductAttributeValueCommon): def test_cart_update_with_fpos(self): - # We will test that the mapping of an 10% included tax by a 0% by a fiscal position is taken into account when updating the cart + # We will test that the mapping of an 10% included tax by a 6% by a fiscal position is taken into account when updating the cart self.env.user.partner_id.country_id = False current_website = self.env['website'].get_current_website() pricelist = current_website.get_current_pricelist() (self.env['product.pricelist'].search([]) - pricelist).write({'active': False}) # Add 10% tax on product tax10 = self.env['account.tax'].create({'name': "Test tax 10", 'amount': 10, 'price_include': True, 'amount_type': 'percent'}) - tax0 = self.env['account.tax'].create({'name': "Test tax 0", 'amount': 0, 'price_include': True, 'amount_type': 'percent'}) + tax6 = self.env['account.tax'].create({'name': "Test tax 6", 'amount': 6, 'price_include': True, 'amount_type': 'percent'}) test_product = self.env['product.template'].create({ 'name': 'Test Product', @@ -196,14 +196,14 @@ class TestWebsiteSaleProductPricelist(AccountTestInvoicingCommon, TestSaleProduc pricelist.discount_policy = 'without_discount' - # Create fiscal position mapping taxes 10% -> 0% + # Create fiscal position mapping taxes 10% -> 6% fpos = self.env['account.fiscal.position'].create({ 'name': 'test', }) self.env['account.fiscal.position.tax'].create({ 'position_id': fpos.id, 'tax_src_id': tax10.id, - 'tax_dest_id': tax0.id, + 'tax_dest_id': tax6.id, }) so = self.env['sale.order'].create({ 'partner_id': self.env.user.partner_id.id, @@ -219,7 +219,7 @@ class TestWebsiteSaleProductPricelist(AccountTestInvoicingCommon, TestSaleProduc sol._compute_tax_id() with MockRequest(self.env, website=current_website, sale_order_id=so.id): so._cart_update(product_id=test_product.product_variant_id.id, line_id=sol.id, set_qty=2) - self.assertEqual(round(sol.price_total), 100, "100$ with 50% discount + 0% tax (mapped from fp 10% -> 0%)") + self.assertEqual(round(sol.price_total), 106, "2 units @ 100$ with 50% discount + 6% tax (mapped from fp 10% -> 6%)") def test_cart_update_with_fpos_no_variant_product(self): # We will test that the mapping of an 10% included tax by a 0% by a fiscal position is taken into account when updating the cart for no_variant product