diff --git a/addons/stock/stock.py b/addons/stock/stock.py index dd041323033..1ac587bad46 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1652,7 +1652,16 @@ class stock_move(osv.osv): 'date_expected': fields.datetime('Scheduled Date', states={'done': [('readonly', True)]},required=True, select=True, help="Scheduled date for the processing of this move"), 'product_id': fields.many2one('product.product', 'Product', required=True, select=True, domain=[('type','<>','service')],states={'done': [('readonly', True)]}), - 'product_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product Unit of Measure'), required=True,states={'done': [('readonly', True)]}), + 'product_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product Unit of Measure'), + required=True,states={'done': [('readonly', True)]}, + help="This is the quantity of products from an inventory " + "point of view. For moves in the state 'done', this is the " + "quantity of products that were actually moved. For other " + "moves, this is the quantity of product that is planned to " + "be moved. Lowering this quantity does not generate a " + "backorder. Changing this quantity on assigned moves affects " + "the product reservation, and should be done with care." + ), 'product_uom': fields.many2one('product.uom', 'Unit of Measure', required=True,states={'done': [('readonly', True)]}), 'product_uos_qty': fields.float('Quantity (UOS)', digits_compute=dp.get_precision('Product Unit of Measure'), states={'done': [('readonly', True)]}), 'product_uos': fields.many2one('product.uom', 'Product UOS', states={'done': [('readonly', True)]}), @@ -1873,19 +1882,31 @@ class stock_move(osv.osv): result = { 'product_uos_qty': 0.00 } + warning = {} if (not product_id) or (product_qty <=0.0): return {'value': result} product_obj = self.pool.get('product.product') uos_coeff = product_obj.read(cr, uid, product_id, ['uos_coeff']) + + # Warn if the quantity was decreased + if ids: + for move in self.read(cr, uid, ids, ['product_qty']): + if product_qty < move['product_qty']: + warning.update({ + 'title': _('Information'), + 'message': _("By changing this quantity here, you accept the " + "new quantity as complete: OpenERP will not " + "automatically generate a back order.") }) + break if product_uos and product_uom and (product_uom != product_uos): result['product_uos_qty'] = product_qty * uos_coeff['uos_coeff'] else: result['product_uos_qty'] = product_qty - return {'value': result} + return {'value': result, 'warning': warning} def onchange_uos_quantity(self, cr, uid, ids, product_id, product_uos_qty, product_uos, product_uom): @@ -1899,19 +1920,29 @@ class stock_move(osv.osv): result = { 'product_qty': 0.00 } + warning = {} if (not product_id) or (product_uos_qty <=0.0): return {'value': result} product_obj = self.pool.get('product.product') uos_coeff = product_obj.read(cr, uid, product_id, ['uos_coeff']) + + # Warn if the quantity was decreased + for move in self.read(cr, uid, ids, ['product_uos_qty']): + if product_uos_qty < move['product_uos_qty']: + warning.update({ + 'title': _('Warning: No Back Order'), + 'message': _("By changing the quantity here, you accept the " + "new quantity as complete: OpenERP will not " + "automatically generate a Back Order.") }) + break if product_uos and product_uom and (product_uom != product_uos): result['product_qty'] = product_uos_qty / uos_coeff['uos_coeff'] else: result['product_qty'] = product_uos_qty - - return {'value': result} + return {'value': result, 'warning': warning} def onchange_product_id(self, cr, uid, ids, prod_id=False, loc_id=False, loc_dest_id=False, partner_id=False):