[FIX] website_sale: include purchase_price in product changes
When changing the pricelist on the shop, if the new one has a different currency and if the cart already contains some products, the purchase price of each product should be updated To reproduce the error: 1. Select Public Pricelist 2. Add the Customizable Desk (Steel, White) 3. Back to shop, select EUR pricelist Error: Consulting the SO on back-end, the purchase price is not converted (and therefore the margin is incorrect) Changing the pricelist on a SO that already contains some lines is not a valid flow. Therefore, the fix must only concern the web-shop. When setting a new pricelist, the request gets the current carte and forces the new pricelist. Therefore, the cart is updated and several values are computed again: https://github.com/odoo/odoo/blob/379f1490c93dc599a74add2d678c18fbba1efa62/addons/website_sale/models/sale_order.py#L142-L149 In the above dictionary, the price unit is based on the new pricelist (new discount, new currency...). When the module `sale_margin` is installed, this dictionary should include the new value of `purchase_price`. By doing this, the `margin` will also have a correct value: https://github.com/odoo/odoo/blob/194ce17436929b74fc3d4c2744853d32bd9d2567/addons/sale_margin/models/sale_order.py#L64-L67 OPW-2585376 closes odoo/odoo#75885 Signed-off-by:Jérémy Kersten (jke) <jke@openerp.com>
Please register or sign in to comment