[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) <wbr@odoo.com> Signed-off-by: Grazioso Andrea (agr) <agr@odoo.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user