From dd0e3fee0216014da6a56f9f1fe3004a67a6d9ab Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 7 Aug 2019 05:59:45 +0000 Subject: [PATCH] [FIX] stock: do not raise error Although this makes sense to warn the user, a `UserError` stops the execution of onchanges but do not prevent saving incorrect settings. A non-blocking warning would be another solution, but one issue remains: a pop-up is raised when the user opens the settings, even if they are unrelated (e.g.: open Website settings, an error message implying Inventory appears). This reverts commit c7beb9994f2b3aecef3f03aa81e0240e0d3eaf71. closes odoo/odoo#35511 Signed-off-by: Nicolas Martinelli (nim) --- addons/stock/i18n/stock.pot | 7 ------- addons/stock/models/res_config_settings.py | 10 +--------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/addons/stock/i18n/stock.pot b/addons/stock/i18n/stock.pot index 09ce03e4859..5faad4e2547 100644 --- a/addons/stock/i18n/stock.pot +++ b/addons/stock/i18n/stock.pot @@ -6495,13 +6495,6 @@ msgstr "" msgid "You need to supply a Lot/Serial number for product %s." msgstr "" -#. module: stock -#: code:addons/stock/models/res_config_settings.py:70 -#, python-format -msgid "You should not remove the 'lots and serial numbers' option while the following products are still tracked by lot or serial number:\n" -" %s" -msgstr "" - #. module: stock #: code:addons/stock/models/product.py:394 #: code:addons/stock/models/product.py:538 diff --git a/addons/stock/models/res_config_settings.py b/addons/stock/models/res_config_settings.py index b39b1a6beaa..ebf7d339d39 100644 --- a/addons/stock/models/res_config_settings.py +++ b/addons/stock/models/res_config_settings.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, fields, models, _ -from odoo.exceptions import UserError +from odoo import api, fields, models class ResConfigSettings(models.TransientModel): @@ -65,13 +64,6 @@ class ResConfigSettings(models.TransientModel): def _onchange_group_stock_production_lot(self): if not self.group_stock_production_lot: self.group_lot_on_delivery_slip = False - tracked_products = self.env['product.template'].search([('tracking', 'in', ['lot', 'serial']),]) - if not self.group_stock_production_lot and tracked_products: - names = ", ".join(tracked_products.mapped('display_name') if len(tracked_products) <= 10 - else tracked_products[:10].mapped('display_name') + ["..."]) - raise UserError(_("You should not remove the 'lots and serial numbers' " - "option while the following products are still tracked by lot " - "or serial number:\n %s") % names) @api.onchange('group_stock_adv_location') def onchange_adv_location(self):