[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) <tic@odoo.com>
This commit is contained in:
Martin Maes
2024-01-05 09:12:54 +00:00
parent 7460aa2c9d
commit 2cbfd87d49
2 changed files with 2 additions and 22 deletions
@@ -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"
@@ -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()