[FIX] website_sale: calculate the tax for no_variant product in cart
Reproduction: 1. Install eCommerce and accounting 2. Go to Accounting->Configuration->Taxes, add one sale tax 15%, and one 0%. Both taxes are included in the price. 3. Go to Configuration-> Fiscal Position, create a new one “test” which applies the tax mapping from 15% sale tax to the 0%. Check “Detect Automatically”, set country group as Europe 4. Go to Website->Orders->Customers, set the country of the portal user, Joel Willis, as Luxembourg. In Sales&Purchase->Fiscal Information set the fiscal position as “test” 5. Go to Website->Products->Product Variants, create a new one “test_tax_prod” with price 110, and sale tax 15%, can be sold, can be purchased and consumable. 6. Go to Website->Configuration->Attribute, create a new product attribute “test” with Display Type as Ratio, Variant Creation Mode as Never. Create a value “a” in its attribute values 7. Go to Website->Products->Products, find test_tax_prod, go to its variant tab, set attribute as “test” with value “a”, publish this product 8. Open an incognito tab, login as “portal” pwd: portal, search the product “test_tax_prod”, set the price list as “public price list”, the price is 95.65 on the page. Add it to the cart, the price is 110 Reason: When we update the order_line, we should update the price based on the fiscal position for the no_variant products too. However, based on the current workflow, the price is computed in method _website_product_id_change before an order line is created. Thus for no_variant products, the price is not updated. Fix: This issue is fixed in saas-15.3 by rewriting the workflow and calculating the price through an on_change function here: https://github.com/odoo/odoo/blob/saas-15.3/addons/sale/models/sale_order_line.py#L588-L605 In v13, we don’t have this on_change method to compute the new price, so a similar price update can be created in the cart update for website_sale. This fix solution was created here: https://github.com/odoo/odoo/commit/ea259218196b2d9dc71beffea697025580c6d696 However, new price computation issues can happen when combining two pricelists, here: https://github.com/odoo/odoo/commit/8d6a2ca0f3dcf8f8cf4679da2b3ce582b7826391 Thus the fix is eventually done in _website_product_id_change. Added a new parameter to force checking the orderlines based on the domain. The orderline is created but only can be searched based on the domain. This ensures the price is computed correctly for pricelists and for tax. Added fiscal position test for no variant product opw-2856956 Fix by re-writing in saas-15.3: https://github.com/odoo/odoo/blob/saas-15.3/addons/sale/models/sale_order_line.py#L588-L605 First related fix: https://github.com/odoo/odoo/commit/ea259218196b2d9dc71beffea697025580c6d696 Second fix to patch for the first fix: https://github.com/odoo/odoo/commit/8d6a2ca0f3dcf8f8cf4679da2b3ce582b7826391 closes odoo/odoo#101087 X-original-commit: d8a730f5 Signed-off-by:William Braeckman (wbr) <wbr@odoo.com> Signed-off-by:
Liu Jinjiu (jili) <jili@odoo.com>
Showing
- addons/website_event_sale/models/sale_order.py 1 addition, 1 deletionaddons/website_event_sale/models/sale_order.py
- addons/website_sale/models/sale_order.py 2 additions, 2 deletionsaddons/website_sale/models/sale_order.py
- addons/website_sale/tests/test_website_sale_product_attribute_value_config.py 75 additions, 0 deletions...tests/test_website_sale_product_attribute_value_config.py
Please register or sign in to comment