Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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: odoo@ea25921 However, new price computation issues can happen when combining two pricelists, here: odoo@8d6a2ca 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: odoo@ea25921 Second fix to patch for the first fix: odoo@8d6a2ca closes odoo#99647 Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
- Loading branch information