From 40248d77ffb37940cb83718a1cae41959e2e8450 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 16 Mar 2016 15:49:45 +0100 Subject: [PATCH] [FIX] stock: Wrong error when you work with lot owner When a stock move was created in a picking with a product set with a unique serial number existing in the stock of a specific owner. If the owner was not specified for the stock move then a wrong message was raised "The serial number 00005 is already in stock.". But the real problem could come from function quants_get_preferred_domain which didn't find the existing quant due to the fact that the system didn't check in the right stock(owner). A new quant was then created with the existing serial number. And a wrong message was raised. opw:671783 --- addons/stock/i18n/stock.pot | 6 ++++++ addons/stock/stock.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/stock/i18n/stock.pot b/addons/stock/i18n/stock.pot index e0391f9f6a4..e223e20044d 100644 --- a/addons/stock/i18n/stock.pot +++ b/addons/stock/i18n/stock.pot @@ -3666,6 +3666,12 @@ msgstr "" msgid "Original Move" msgstr "" +#. module: stock +#: code:addons/stock/stock.py:576 +#, python-format +msgid "Otherwise make sure the right stock/owner is set." +msgstr "" + #. module: stock #: model:ir.model.fields,field_description:stock.field_stock_warehouse_out_type_id msgid "Out Type" diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 2c483c909ce..09ae09f9ebb 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -573,7 +573,7 @@ class stock_quant(osv.osv): ('qty', '>', 0.0), ('location_id.usage', '=', 'internal')], context=context) if other_quants: lot_name = self.pool['stock.production.lot'].browse(cr, uid, lot_id, context=context).name - raise UserError(_('The serial number %s is already in stock') % lot_name) + raise UserError(_('The serial number %s is already in stock.') % lot_name + _("Otherwise make sure the right stock/owner is set.")) #create the quant as superuser, because we want to restrict the creation of quant manually: we should always use this method to create quants quant_id = self.create(cr, SUPERUSER_ID, vals, context=context)