[FIX] purchase: dropshipping sequence in multi company
Usecase to reproduce: - Create 2 sequence for PO(one for each company) - Create a product with dropshipping - Connect on the demo user with an active company different than the admin company - Create a SO for this product It will create a PO with the admin's company sequence. It happens because _run_buy use a sudo since SO user don't always have the purchase and inventory rights. However the company is not forced and thus the used company for sequence is the admin company. opw-1860802
This commit is contained in:
committed by
Nicolas Martinelli
parent
52f323545a
commit
d0dc4c60bd
@@ -909,7 +909,8 @@ class ProcurementRule(models.Model):
|
||||
cache[domain] = po
|
||||
if not po:
|
||||
vals = self._prepare_purchase_order(product_id, product_qty, product_uom, origin, values, partner)
|
||||
po = self.env['purchase.order'].sudo().create(vals)
|
||||
company_id = values.get('company_id') and values['company_id'].id or self.env.user.company_id.id
|
||||
po = self.env['purchase.order'].with_context(force_company=company_id).sudo().create(vals)
|
||||
cache[domain] = po
|
||||
elif not po.origin or origin not in po.origin.split(', '):
|
||||
if po.origin:
|
||||
|
||||
Reference in New Issue
Block a user