diff --git a/addons/purchase_stock/models/stock_rule.py b/addons/purchase_stock/models/stock_rule.py index 829d67b4ad8..b10cd241544 100644 --- a/addons/purchase_stock/models/stock_rule.py +++ b/addons/purchase_stock/models/stock_rule.py @@ -96,7 +96,9 @@ class StockRule(models.Model): vals = rules[0]._prepare_purchase_order(company_id, origins, [p.values for p in procurements]) # The company_id is the same for all procurements since # _make_po_get_domain add the company in the domain. - po = self.env['purchase.order'].with_user(SUPERUSER_ID).with_company(company_id).sudo().create(vals) + # We use SUPERUSER_ID since we don't want the current user to be follower of the PO. + # Indeed, the current user may be a user without access to Purchase, or even be a portal user. + po = self.env['purchase.order'].with_company(company_id).with_user(SUPERUSER_ID).create(vals) else: # If a purchase order is found, adapt its `origin` field. if po.origin: