summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorNicolas Galler <ngl@odoo.com>2020-12-31 10:30:43 +0000
committerNicolas Galler <ngl@odoo.com>2021-01-04 14:35:56 +0000
commit592ee14d7fe81e7e5afd23f2bbbdac344eae6060 (patch)
treedf807bbacf66301107d2ca6803464ac4cbdcd895 /addons
parent4d3655304205cc9785ef696a47a17a41242d297a (diff)
[FIX] stock: run scheduler actions as super user
In `run_scheduler`, we are running certain functions as super user to avoid inter company and access rights issues. This commit adds a `sudo()` call to the `action_assign()` call, in case some objects related to the retrieved moves are not accessible. In addition a commit call is moved up to apply after the `procure_orderpoint_confirm` call (as it was, it was applied after the `_action_assign` loop, but there is in fact already a commit in that loop, this lead to a somewhat random behavior where the replenish rules were sometimes rolled back and sometimes not, depending on whether the first iteration of the loop errored out or not) opw-2394706 closes odoo/odoo#64021 X-original-commit: 7a2c23c738daa23ab469f6a780bb7df69a25bec0 Signed-off-by: Nicolas Galler <ngaller@users.noreply.github.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/stock/models/stock_rule.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/addons/stock/models/stock_rule.py b/addons/stock/models/stock_rule.py
index 1146f7d2fec..42efe61db83 100644
--- a/addons/stock/models/stock_rule.py
+++ b/addons/stock/models/stock_rule.py
@@ -501,19 +501,18 @@ class ProcurementGroup(models.Model):
# recomputed
orderpoints.sudo()._compute_qty_to_order()
orderpoints.sudo()._procure_orderpoint_confirm(use_new_cursor=use_new_cursor, company_id=company_id, raise_user_error=False)
+ if use_new_cursor:
+ self._cr.commit()
# Search all confirmed stock_moves and try to assign them
domain = self._get_moves_to_assign_domain(company_id)
moves_to_assign = self.env['stock.move'].search(domain, limit=None,
order='priority desc, date asc')
for moves_chunk in split_every(100, moves_to_assign.ids):
- self.env['stock.move'].browse(moves_chunk)._action_assign()
+ self.env['stock.move'].browse(moves_chunk).sudo()._action_assign()
if use_new_cursor:
self._cr.commit()
- if use_new_cursor:
- self._cr.commit()
-
# Merge duplicated quants
self.env['stock.quant']._quant_tasks()