From 4de1f925ed79aa077572e406551078749e98d472 Mon Sep 17 00:00:00 2001 From: Lois Rilo Date: Tue, 15 Jan 2019 12:15:07 +0100 Subject: [PATCH] [11.0][FIX] stock_orderpoint_manual_procurement: pass requested_uid in context to be able to have it through a chain of procuremets. --- .../i18n/stock_orderpoint_manual_procurement.pot | 4 ++-- .../wizards/make_procurement_orderpoint.py | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/stock_orderpoint_manual_procurement/i18n/stock_orderpoint_manual_procurement.pot b/stock_orderpoint_manual_procurement/i18n/stock_orderpoint_manual_procurement.pot index be3c67c75..80b9af1d3 100644 --- a/stock_orderpoint_manual_procurement/i18n/stock_orderpoint_manual_procurement.pot +++ b/stock_orderpoint_manual_procurement/i18n/stock_orderpoint_manual_procurement.pot @@ -105,7 +105,7 @@ msgid "Minimum Inventory Rule" msgstr "" #. module: stock_orderpoint_manual_procurement -#: code:addons/stock_orderpoint_manual_procurement/wizards/make_procurement_orderpoint.py:68 +#: code:addons/stock_orderpoint_manual_procurement/wizards/make_procurement_orderpoint.py:72 #, python-format msgid "No reordering rule found!" msgstr "" @@ -139,7 +139,7 @@ msgid "Quantity" msgstr "" #. module: stock_orderpoint_manual_procurement -#: code:addons/stock_orderpoint_manual_procurement/wizards/make_procurement_orderpoint.py:66 +#: code:addons/stock_orderpoint_manual_procurement/wizards/make_procurement_orderpoint.py:70 #, python-format msgid "Quantity must be positive." msgstr "" diff --git a/stock_orderpoint_manual_procurement/wizards/make_procurement_orderpoint.py b/stock_orderpoint_manual_procurement/wizards/make_procurement_orderpoint.py index 0bce7f860..8241eee85 100644 --- a/stock_orderpoint_manual_procurement/wizards/make_procurement_orderpoint.py +++ b/stock_orderpoint_manual_procurement/wizards/make_procurement_orderpoint.py @@ -61,6 +61,10 @@ class MakeProcurementOrderpoint(models.TransientModel): def make_procurement(self): self.ensure_one() errors = [] + # User requesting the procurement is passed by context to be able to + # update final MO, PO or trasfer with that information. + pg_obj = self.env['procurement.group'].with_context( + requested_uid=self.env.user) for item in self.item_ids: if not item.qty: raise ValidationError(_("Quantity must be positive.")) @@ -69,10 +73,9 @@ class MakeProcurementOrderpoint(models.TransientModel): values = item.orderpoint_id._prepare_procurement_values(item.qty) values['date_planned'] = fields.Datetime.to_string( fields.Date.from_string(item.date_planned)) - values['requested_uid'] = self.env.user # Run procurement try: - self.env['procurement.group'].run( + pg_obj.run( item.orderpoint_id.product_id, item.qty, item.uom_id,