diff --git a/addons/stock/i18n/stock.pot b/addons/stock/i18n/stock.pot index daae3a0fc74..805485062d1 100644 --- a/addons/stock/i18n/stock.pot +++ b/addons/stock/i18n/stock.pot @@ -51,6 +51,12 @@ msgstr "" msgid " (reserved)" msgstr "" +#. module: stock +#: code:addons/stock/stock.py:2954 +#, python-format +msgid "You cannot have two inventory adjustements in state 'in Progess' with the same product(%s), same location(%s), same package, same owner and same lot. Please first validate the first inventory adjustement with this product before creating another one." +msgstr "" + #. module: stock #: code:addons/stock/stock.py:3090 #, python-format diff --git a/addons/stock/stock.py b/addons/stock/stock.py index a4deff3d161..8cef6087172 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2942,6 +2942,18 @@ class stock_inventory_line(osv.osv): 'product_uom_id': lambda self, cr, uid, ctx=None: self.pool['ir.model.data'].get_object_reference(cr, uid, 'product', 'product_uom_unit')[1] } + def create(self, cr, uid, values, context=None): + product_obj = self.pool.get('product.product') + dom = [('product_id', '=', values.get('product_id')), ('inventory_id.state', '=', 'confirm'), + ('location_id', '=', values.get('location_id')), ('partner_id', '=', values.get('partner_id')), + ('package_id', '=', values.get('package_id')), ('prod_lot_id', '=', values.get('prod_lot_id'))] + res = self.search(cr, uid, dom, context=context) + if res: + location = self.pool['stock.location'].browse(cr, uid, values.get('location_id'), context=context) + product = product_obj.browse(cr, uid, values.get('product_id'), context=context) + raise Warning(_("You cannot have two inventory adjustements in state 'in Progess' with the same product(%s), same location(%s), same package, same owner and same lot. Please first validate the first inventory adjustement with this product before creating another one.") % (product.name, location.name)) + return super(stock_inventory_line, self).create(cr, uid, values, context=context) + def _get_quants(self, cr, uid, line, context=None): quant_obj = self.pool["stock.quant"] dom = [('company_id', '=', line.company_id.id), ('location_id', '=', line.location_id.id), ('lot_id', '=', line.prod_lot_id.id),