From b793e23ae53b5f1edab8c98bbed7ac5f5f921280 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 8 May 2018 10:57:53 +0200 Subject: [PATCH] [FIX] stock: incorrect PO sequence - Create 2 companies A & B - Create a sequence for PO in each company - Set User A in Company A and Admin in Company B - Create a MTO product with a 'Buy' route - Create a SO with User A using the product, validate The PO created uses the sequence for Company B instead of Company A. The creation is done as `sudo`, and ultimately `next_by_code` will use the company of the Admin. opw-1839656 --- addons/stock/models/procurement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock/models/procurement.py b/addons/stock/models/procurement.py index 6f8402c1fe7..49f65a8f61c 100644 --- a/addons/stock/models/procurement.py +++ b/addons/stock/models/procurement.py @@ -77,7 +77,7 @@ class ProcurementRule(models.Model): data = self._get_stock_move_values(product_id, product_qty, product_uom, location_id, name, origin, values, group_id) # Since action_confirm launch following procurement_group we should activate it. - move = self.env['stock.move'].sudo().create(data) + move = self.env['stock.move'].sudo().with_context(force_company=data.get('company_id', False)).create(data) move._action_confirm() return True