[FIX] purchase: Drop shipping with no access to Purchase

Let's consider a Sales user U with no access to Purhcase

Steps to reproduce the bug:
- Create a SO with one line with the drop shipping route
- Validate the SO

Bug:

 A access error was raised because the user has no access right on
Purchase.

opw:1851301
This commit is contained in:
Goffin Simon
2018-06-05 11:29:26 +02:00
parent d2b7be055a
commit a5e6afe559
+3 -3
View File
@@ -904,12 +904,12 @@ class ProcurementRule(models.Model):
if domain in cache:
po = cache[domain]
else:
po = self.env['purchase.order'].search([dom for dom in domain])
po = self.env['purchase.order'].sudo().search([dom for dom in domain])
po = po[0] if po else False
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'].create(vals)
po = self.env['purchase.order'].sudo().create(vals)
cache[domain] = po
elif not po.origin or origin not in po.origin.split(', '):
if po.origin:
@@ -930,7 +930,7 @@ class ProcurementRule(models.Model):
break
if not po_line:
vals = self._prepare_purchase_order_line(product_id, product_qty, product_uom, values, po, supplier)
self.env['purchase.order.line'].create(vals)
self.env['purchase.order.line'].sudo().create(vals)
def _get_purchase_schedule_date(self, values):
"""Return the datetime value to use as Schedule Date (``date_planned``) for the