[FIX] mrp: fix access rights on change.production.qty call
Steps to reproduce: As Admin: 1. Create a Storable product with a Route of Manufacture 2. Create a re-ordering rule for this product. 3. As a user with no MRP access rights, create a sale order with this product and confirm the sale order. This creates a new `mrp.production` record with `sudo()` on line \#85: https://github.com/odoo/odoo/blob/fae59cee91969692c2375b3bd37e914ec0fb606e/addons/mrp/models/stock_rule.py#L85 4. Duplicate sale order and try to confirm again. This produces an access right error because the first loop finds the existing `mrp.production` record and tries to create a `change.production.qty` record. However, the user doesn't have access rights so they get an error. Solution: Add `sudo` to the create call. opw-3508819 closes odoo/odoo#136640 X-original-commit: c5758e122db5396e23a57826a1b12ed7d9765f55 Signed-off-by: Tiffany Chang (tic) <tic@odoo.com> Signed-off-by: Andrew Gavgavian (andg) <andg@odoo.com>
This commit is contained in:
@@ -74,7 +74,7 @@ class StockRule(models.Model):
|
||||
if not mo:
|
||||
new_productions_values_by_company[procurement.company_id.id].append(rule._prepare_mo_vals(*procurement, bom))
|
||||
else:
|
||||
self.env['change.production.qty'].with_context(skip_activity=True).create({
|
||||
self.env['change.production.qty'].sudo().with_context(skip_activity=True).create({
|
||||
'mo_id': mo.id,
|
||||
'product_qty': mo.product_id.uom_id._compute_quantity((mo.product_uom_qty + procurement.product_qty), mo.product_uom_id)
|
||||
}).change_prod_qty()
|
||||
|
||||
Reference in New Issue
Block a user