From 4e1a7c1e631107abe0b7778b03f9b7d58bc55dd3 Mon Sep 17 00:00:00 2001 From: roen-odoo Date: Mon, 27 Feb 2023 12:20:14 +0000 Subject: [PATCH] [FIX] point_of_sale: stop showing changes of fiscal position as discount MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Current behavior: When a fiscal position was applied in the PoS, it was considered as a discount and was shown in the receipt and on the product screen. Steps to reproduce: - Create a product with a price of 10€ with 15% tax included in the price - Create a fiscal position that map the 15% tax to 0% tax - Open a PoS session - Add the product to the order - Apply the fiscal position - The price of the product is now 8.70€ but the order show it as a discount of 1.30€ (e.g 10€ -> 8.70€). opw-3154499 closes odoo/odoo#116918 X-original-commit: d054e7dd2474fad49dab63bf4b2aef09f57780c8 Signed-off-by: Trinh Jacky (trj) Signed-off-by: Engels Robin (roen) --- addons/point_of_sale/static/src/js/models.js | 8 ++-- .../static/tests/tours/ProductScreen.tour.js | 11 +++++ .../tours/helpers/ProductScreenTourMethods.js | 20 +++++++++ addons/point_of_sale/tests/test_frontend.py | 41 +++++++++++++++++++ 4 files changed, 76 insertions(+), 4 deletions(-) diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 6e1eadcd86f..dd051cb3b13 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -2434,16 +2434,16 @@ export class Orderline extends PosModel { return this.get_base_price(); } } - get_taxed_lst_unit_price() { - var lst_price = this.get_lst_price(); + get_taxed_lst_unit_price(){ + var base_price = this.compute_fixed_price(this.get_base_price()); if (this.pos.config.iface_tax_included === "total") { var product = this.get_product(); var taxes_ids = product.taxes_id; var product_taxes = this.pos.get_taxes_after_fp(taxes_ids); - return this.compute_all(product_taxes, lst_price, 1, this.pos.currency.rounding) + return this.compute_all(product_taxes, base_price, 1, this.pos.currency.rounding) .total_included; } - return lst_price; + return base_price; } get_price_without_tax() { return this.get_all_prices().priceWithoutTax; diff --git a/addons/point_of_sale/static/tests/tours/ProductScreen.tour.js b/addons/point_of_sale/static/tests/tours/ProductScreen.tour.js index 74c84f0302a..61eb14b6496 100644 --- a/addons/point_of_sale/static/tests/tours/ProductScreen.tour.js +++ b/addons/point_of_sale/static/tests/tours/ProductScreen.tour.js @@ -136,6 +136,17 @@ registry.category("web_tour.tours").add("ProductScreenTour", { test: true, url: startSteps(); +ProductScreen.do.clickHomeCategory(); +ProductScreen.do.clickDisplayedProduct('Test Product'); +ProductScreen.check.totalAmountIs('100.00'); +ProductScreen.do.changeFiscalPosition('No Tax'); +ProductScreen.check.noDiscountApplied("100.00"); +ProductScreen.check.totalAmountIs('86.96'); + +registry.category("web_tour.tours").add("FiscalPositionNoTax", { test: true, url: "/pos/ui", steps: getSteps() }); + +startSteps(); + ProductScreen.do.enterOpeningAmount('90'); ProductScreen.do.confirmOpeningPopup(); ProductScreen.check.checkSecondCashClosingDetailsLineAmount('10.00', '-'); diff --git a/addons/point_of_sale/static/tests/tours/helpers/ProductScreenTourMethods.js b/addons/point_of_sale/static/tests/tours/helpers/ProductScreenTourMethods.js index d19a65e1e4a..3b81a3ff3cd 100644 --- a/addons/point_of_sale/static/tests/tours/helpers/ProductScreenTourMethods.js +++ b/addons/point_of_sale/static/tests/tours/helpers/ProductScreenTourMethods.js @@ -151,6 +151,18 @@ class Do { }, ]; } + changeFiscalPosition(name) { + return [ + { + content: 'click fiscal position button', + trigger: '.o_fiscal_position_button', + }, + { + content: 'fiscal position screen is shown', + trigger: `.selection-item:contains("${name}")`, + }, + ]; + } } class Check { @@ -262,6 +274,14 @@ class Check { }, ]; } + noDiscountApplied(originalPrice) { + return [ + { + content: 'no discount is applied', + trigger: `.info:not(:contains(${originalPrice}))`, + }, + ]; + } } class Execute { diff --git a/addons/point_of_sale/tests/test_frontend.py b/addons/point_of_sale/tests/test_frontend.py index d7e40ca0b27..f6ca0805c99 100644 --- a/addons/point_of_sale/tests/test_frontend.py +++ b/addons/point_of_sale/tests/test_frontend.py @@ -689,3 +689,44 @@ class TestUi(TestPointOfSaleHttpCommon): pos_session = self.main_pos_config.current_session_id self.assertEqual(len(pos_session.statement_line_ids), 1) self.assertEqual(pos_session.statement_line_ids[0].amount, -10) + + def test_fiscal_position_no_tax(self): + #create a tax of 15% with price included + tax = self.env['account.tax'].create({ + 'name': 'Tax 15%', + 'amount': 15, + 'price_include': True, + 'amount_type': 'percent', + 'type_tax_use': 'sale', + }) + + #create a product with the tax + self.product = self.env['product.product'].create({ + 'name': 'Test Product', + 'taxes_id': [(6, 0, [tax.id])], + 'list_price': 100, + 'available_in_pos': True, + }) + + #create a fiscal position that map the tax to no tax + fiscal_position = self.env['account.fiscal.position'].create({ + 'name': 'No Tax', + 'tax_ids': [(0, 0, { + 'tax_src_id': tax.id, + 'tax_dest_id': False, + })], + }) + + pricelist = self.env['product.pricelist'].create({ + 'name': 'Test Pricelist', + 'discount_policy': 'without_discount', + }) + + self.main_pos_config.write({ + 'tax_regime_selection': True, + 'fiscal_position_ids': [(6, 0, [fiscal_position.id])], + 'available_pricelist_ids': [(6, 0, [pricelist.id])], + 'pricelist_id': pricelist.id, + }) + self.main_pos_config.open_ui() + self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'FiscalPositionNoTax', login="accountman")