summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold Moyaux <arm@odoo.com>2018-06-26 10:40:01 +0200
committerNicolas Martinelli <nim-odoo@users.noreply.github.com>2018-06-26 13:43:08 +0200
commitd0dc4c60bdda38d4bbd537378e2d6c98675f34c8 (patch)
tree019968b97152bb3b915acd64c0f95eab65a0c1cd
parent52f323545aeaa53be078f8deb633251eef16fc12 (diff)
[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
-rw-r--r--addons/purchase/models/purchase.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py
index 580a44da121..f27545a15ed 100644
--- a/addons/purchase/models/purchase.py
+++ b/addons/purchase/models/purchase.py
@@ -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: