From 2cbfd87d493d53dc7c52816a590d9bd801bc9224 Mon Sep 17 00:00:00 2001 From: Martin Maes Date: Thu, 4 Jan 2024 11:30:54 +0100 Subject: [PATCH] [FIX] purchase_stock: avoid replenish onchange loop When replenishing a product with a route buy selected on the product form but no vendor added, we fall into an endless loop because the default_get sets the route, which triggers the onchange that return a warning. This will again call the default_get and the loop never ends. The onchange is useless as it's only goal is to display the warning, and as the field is required on the form, the user will not be able to submit it. opw-3653714 closes odoo/odoo#148201 X-original-commit: e7fca1c849652920388526f4797397aa18247204 Signed-off-by: Tiffany Chang (tic) --- addons/purchase_stock/i18n/purchase_stock.pot | 14 -------------- addons/purchase_stock/wizard/product_replenish.py | 10 ++-------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/addons/purchase_stock/i18n/purchase_stock.pot b/addons/purchase_stock/i18n/purchase_stock.pot index c595f43704c..ccbc0f7d789 100644 --- a/addons/purchase_stock/i18n/purchase_stock.pot +++ b/addons/purchase_stock/i18n/purchase_stock.pot @@ -273,13 +273,6 @@ msgstr "" msgid "Go back to the purchase order to generate the vendor bill." msgstr "" -#. module: purchase_stock -#. odoo-python -#: code:addons/purchase_stock/wizard/product_replenish.py:0 -#, python-format -msgid "Go on the product form and add the list of vendors" -msgstr "" - #. module: purchase_stock #: model:ir.model.fields,field_description:purchase_stock.field_vendor_delay_report__id msgid "ID" @@ -803,13 +796,6 @@ msgstr "" msgid "Vendor Lead Time" msgstr "" -#. module: purchase_stock -#. odoo-python -#: code:addons/purchase_stock/wizard/product_replenish.py:0 -#, python-format -msgid "Vendor Not Found in Product %s" -msgstr "" - #. module: purchase_stock #: model_terms:ir.actions.act_window,help:purchase_stock.action_purchase_vendor_delay_report msgid "Vendor On-time Delivery analysis" diff --git a/addons/purchase_stock/wizard/product_replenish.py b/addons/purchase_stock/wizard/product_replenish.py index 9446f5fac08..dbb1cf89947 100644 --- a/addons/purchase_stock/wizard/product_replenish.py +++ b/addons/purchase_stock/wizard/product_replenish.py @@ -42,16 +42,10 @@ class ProductReplenish(models.TransientModel): for rec in self: rec.show_vendor = rec._get_show_vendor(rec.route_id) + # TODO: to remove in master @api.onchange('route_id') def _onchange_route_id(self): - for rec in self: - if rec.route_id == self.env.ref('purchase_stock.route_warehouse0_buy', raise_if_not_found=False) and not rec.product_id.product_tmpl_id.seller_ids: - return { - 'warning': { - 'title': _("Vendor Not Found in Product %s", rec.product_id.name), - 'message': _("Go on the product form and add the list of vendors"), - }, - } + pass def _prepare_run_values(self): res = super()._prepare_run_values()