[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
This commit is contained in:
Nicolas Martinelli
2018-05-09 11:25:39 +02:00
committed by Nicolas Martinelli
parent 665fcb62cf
commit b793e23ae5
+1 -1
View File
@@ -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