From 68015f9f9f385501b16181241c0bd6ff2ffe71aa Mon Sep 17 00:00:00 2001 From: Numerigraphe - Lionel Sausin Date: Wed, 22 Feb 2012 15:26:09 +0100 Subject: [PATCH 1/2] [IMP] explicit help texts on stock move quantities lp bug: https://launchpad.net/bugs/904118 fixed bzr revid: ls@numerigraphe.fr-20120222142609-in23kx3atgeefig2 --- addons/stock/stock.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 885f7cd2077..5b8edce471d 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1572,10 +1572,28 @@ 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 UoM'), required=True,states={'done': [('readonly', True)]}), + 'product_qty': fields.float('Ordered quantity', + digits_compute=dp.get_precision('Product UoM'), 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 UoM'), states={'done': [('readonly', True)]}), - 'product_uos': fields.many2one('product.uom', 'Product UOS', states={'done': [('readonly', True)]}), + 'product_uos_qty': fields.float('Ordered quantity (UOS)', + digits_compute=dp.get_precision('Product UoM'), + states={'done': [('readonly', True)]}, + help="This is the quantity of products from a sales or invoicing " + "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_uos': fields.many2one('product.uom', 'Unit of Sale', states={'done': [('readonly', True)]}), 'product_packaging': fields.many2one('product.packaging', 'Packaging', help="It specifies attributes of packaging like type, quantity of packaging,etc."), 'location_id': fields.many2one('stock.location', 'Source Location', required=True, select=True,states={'done': [('readonly', True)]}, help="Sets a location if you produce at a fixed location. This can be a partner location if you subcontract the manufacturing operations."), From 9696b43f6c92fb58a5c43bc455088b3ddeb4b8e5 Mon Sep 17 00:00:00 2001 From: Numerigraphe - Lionel Sausin Date: Wed, 29 Feb 2012 12:08:20 +0100 Subject: [PATCH 2/2] [IMP] Warn if the quantity is decreased in the stock moves bzr revid: ls@numerigraphe.fr-20120229110820-7ods08ps2rm0j03o --- addons/stock/stock.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 5b8edce471d..2470ec362d7 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1780,19 +1780,30 @@ 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 + for move in self.read(cr, uid, ids, ['product_qty']): + if product_qty < move['product_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_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): @@ -1806,19 +1817,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, address_id=False):