From a2d71ce0eacfc90706e55ef09e34e0426ff5fd0b Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 24 Apr 2019 08:12:08 +0000 Subject: [PATCH] [FIX] point_of_sale: product valuation at invoice - Create 2 companies A & B - Set the superuser in company A - Create a POS and a user in company B - Create a product P. The 'Inventory Valuation' must be different in both companies: Company A: Periodic (manual) Company B: Perpetual (automated) - Connect with the user in company B - Sell the product P, select a customer and print the invoice The COGS journal entry is not posted. This is because `action_invoice_open` is called as `sudo()`, but ultimately `product.valuation` is called in: https://github.com/odoo/odoo/blob/0cce154794c8de945805d9b9acc4c33e5258191a/addons/stock_account/models/product.py#L325 `product.valuation` is computed based on the property field `property_valuation`, which is therefore company-dependant. Closes #32803 opw-1961861 closes odoo/odoo#32903 Signed-off-by: Nicolas Martinelli (nim) --- addons/point_of_sale/models/pos_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py index 156000df998..f38e19becaa 100644 --- a/addons/point_of_sale/models/pos_order.py +++ b/addons/point_of_sale/models/pos_order.py @@ -728,7 +728,7 @@ class PosOrder(models.Model): if to_invoice: pos_order.action_pos_order_invoice() - pos_order.invoice_id.sudo().action_invoice_open() + pos_order.invoice_id.sudo().with_context(force_company=self.env.user.company_id.id).action_invoice_open() pos_order.account_move = pos_order.invoice_id.move_id return order_ids