Merge lp:~numerigraphe/openobject-addons/trunk-stock-qty-help into lp:openobject-addons

Proposed by Numérigraphe
Status: Merged
Merged at revision: 7619
Proposed branch: lp:~numerigraphe/openobject-addons/trunk-stock-qty-help
Merge into: lp:openobject-addons
Diff against target: 99 lines (+45/-6)
1 file modified
stock/stock.py (+45/-6)
To merge this branch: bzr merge lp:~numerigraphe/openobject-addons/trunk-stock-qty-help
Reviewer Review Type Date Requested Status
Ferdinand functional Pending
OpenERP Core Team Pending
Review via email: mp+94175@code.launchpad.net

Description of the change

It is a common mistake of OpenERP users to change the quantity directly on stock moves instead of using the "process wizard".
- they often decrease the quantity and expect a back order to be created
- they don't naturally understand that they must change this quantity in order to accept a partial delivery as complete
Too make this clear I suggest to :
- rename the quantity fields to "Ordered quantity"
- add help texts
- add a warning popup when users decrease the quantity

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'stock/stock.py'
2--- stock/stock.py 2012-02-15 18:00:28 +0000
3+++ stock/stock.py 2012-02-29 11:12:21 +0000
4@@ -1572,10 +1572,28 @@
5 'date_expected': fields.datetime('Scheduled Date', states={'done': [('readonly', True)]},required=True, select=True, help="Scheduled date for the processing of this move"),
6 'product_id': fields.many2one('product.product', 'Product', required=True, select=True, domain=[('type','<>','service')],states={'done': [('readonly', True)]}),
7
8- 'product_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product UoM'), required=True,states={'done': [('readonly', True)]}),
9+ 'product_qty': fields.float('Ordered quantity',
10+ digits_compute=dp.get_precision('Product UoM'), required=True,
11+ states={'done': [('readonly', True)]},
12+ help="This is the quantity of products from an inventory "
13+ "point of view. For moves in the state 'done', this is the "
14+ "quantity of products that were actually moved. For other "
15+ "moves, this is the quantity of product that is planned to "
16+ "be moved. Lowering this quantity does not generate a "
17+ "backorder. Changing this quantity on assigned moves affects "
18+ "the product reservation, and should be done with care."),
19 'product_uom': fields.many2one('product.uom', 'Unit of Measure', required=True,states={'done': [('readonly', True)]}),
20- 'product_uos_qty': fields.float('Quantity (UOS)', digits_compute=dp.get_precision('Product UoM'), states={'done': [('readonly', True)]}),
21- 'product_uos': fields.many2one('product.uom', 'Product UOS', states={'done': [('readonly', True)]}),
22+ 'product_uos_qty': fields.float('Ordered quantity (UOS)',
23+ digits_compute=dp.get_precision('Product UoM'),
24+ states={'done': [('readonly', True)]},
25+ help="This is the quantity of products from a sales or invoicing "
26+ "point of view. For moves in the state 'done', this is the "
27+ "quantity of products that were actually moved. For other "
28+ "moves, this is the quantity of product that is planned to "
29+ "be moved. Lowering this quantity does not generate a "
30+ "backorder. Changing this quantity on assigned moves affects "
31+ "the product reservation, and should be done with care."),
32+ 'product_uos': fields.many2one('product.uom', 'Unit of Sale', states={'done': [('readonly', True)]}),
33 'product_packaging': fields.many2one('product.packaging', 'Packaging', help="It specifies attributes of packaging like type, quantity of packaging,etc."),
34
35 '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."),
36@@ -1762,19 +1780,30 @@
37 result = {
38 'product_uos_qty': 0.00
39 }
40+ warning = {}
41
42 if (not product_id) or (product_qty <=0.0):
43 return {'value': result}
44
45 product_obj = self.pool.get('product.product')
46 uos_coeff = product_obj.read(cr, uid, product_id, ['uos_coeff'])
47+
48+ # Warn if the quantity was decreased
49+ for move in self.read(cr, uid, ids, ['product_qty']):
50+ if product_qty < move['product_qty']:
51+ warning.update({
52+ 'title': _('Warning: No Back Order'),
53+ 'message': _("By changing the quantity here, you accept the "
54+ "new quantity as complete: OpenERP will not "
55+ "automatically generate a Back Order.") })
56+ break
57
58 if product_uos and product_uom and (product_uom != product_uos):
59 result['product_uos_qty'] = product_qty * uos_coeff['uos_coeff']
60 else:
61 result['product_uos_qty'] = product_qty
62
63- return {'value': result}
64+ return {'value': result, 'warning': warning}
65
66 def onchange_uos_quantity(self, cr, uid, ids, product_id, product_uos_qty,
67 product_uos, product_uom):
68@@ -1788,19 +1817,29 @@
69 result = {
70 'product_qty': 0.00
71 }
72+ warning = {}
73
74 if (not product_id) or (product_uos_qty <=0.0):
75 return {'value': result}
76
77 product_obj = self.pool.get('product.product')
78 uos_coeff = product_obj.read(cr, uid, product_id, ['uos_coeff'])
79+
80+ # Warn if the quantity was decreased
81+ for move in self.read(cr, uid, ids, ['product_uos_qty']):
82+ if product_uos_qty < move['product_uos_qty']:
83+ warning.update({
84+ 'title': _('Warning: No Back Order'),
85+ 'message': _("By changing the quantity here, you accept the "
86+ "new quantity as complete: OpenERP will not "
87+ "automatically generate a Back Order.") })
88+ break
89
90 if product_uos and product_uom and (product_uom != product_uos):
91 result['product_qty'] = product_uos_qty / uos_coeff['uos_coeff']
92 else:
93 result['product_qty'] = product_uos_qty
94-
95- return {'value': result}
96+ return {'value': result, 'warning': warning}
97
98 def onchange_product_id(self, cr, uid, ids, prod_id=False, loc_id=False,
99 loc_dest_id=False, address_id=False):

Subscribers

People subscribed via source and target branches

to all changes: