Merge lp:~openerp-dev/openobject-addons/6.1-opw-581987-rgo into lp:openobject-addons/6.1

Proposed by Ravi Gohil (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/6.1-opw-581987-rgo
Merge into: lp:openobject-addons/6.1
Diff against target: 56 lines (+22/-3)
1 file modified
stock/stock.py (+22/-3)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/6.1-opw-581987-rgo
Reviewer Review Type Date Requested Status
Naresh(OpenERP) Pending
Review via email: mp+137560@code.launchpad.net

Description of the change

Hello,

Currently, there is no restriction on UoM for stock.inventory.line or stock.move objects, one can select any UoM whose UoM category is not same as previous one's.

To reproduce, go to "Warehouse/Inventory Control/Physical Inventories" and in Inventory lines and Stock Moves, you can set the UoM to any type.

To fix this, I introduced "_constraints" for both the objects that will restrict users from setting Product UoM of different UoM category.

This fix also restricts user from altering the records of inventory(inventory lines, stock move) after confirming it.

Kindly review the fix.

Thanks.

To post a comment you must log in.
7091. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

7092. By Ravi Gohil (OpenERP)

[FIX] stock: There is no restriction on UoM for stock moves and stock inventory lines and one can modify the records after confirming the inventory, which shouldn't be allowed : (Maintenance Case : 581987)

Unmerged revisions

7092. By Ravi Gohil (OpenERP)

[FIX] stock: There is no restriction on UoM for stock moves and stock inventory lines and one can modify the records after confirming the inventory, which shouldn't be allowed : (Maintenance Case : 581987)

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-10-05 07:47:57 +0000
3+++ stock/stock.py 2012-12-04 07:02:20 +0000
4@@ -1614,6 +1614,12 @@
5 return False
6 return True
7
8+ def _check_uom(self, cr, uid, ids, context=None):
9+ for move in self.browse(cr, uid, ids, context=context):
10+ if move.product_id.uom_id.category_id.id != move.product_uom.category_id.id:
11+ return False
12+ return True
13+
14 _constraints = [
15 (_check_tracking,
16 'You must assign a production lot for this product',
17@@ -1622,7 +1628,9 @@
18 ['location_id','location_dest_id']),
19 (_check_product_lot,
20 'You try to assign a lot which is not from the same product',
21- ['prodlot_id'])]
22+ ['prodlot_id']),
23+ (_check_uom, 'UoM categories Mismatch: The move UOM and the product UOM must be in the same category.',
24+ ['product_uom'])]
25
26 def _default_location_destination(self, cr, uid, context=None):
27 """ Gets default address of partner for destination location
28@@ -2619,8 +2627,8 @@
29 'name': fields.char('Inventory Reference', size=64, required=True, readonly=True, states={'draft': [('readonly', False)]}),
30 'date': fields.datetime('Creation Date', required=True, readonly=True, states={'draft': [('readonly', False)]}),
31 'date_done': fields.datetime('Date done'),
32- 'inventory_line_id': fields.one2many('stock.inventory.line', 'inventory_id', 'Inventories', states={'done': [('readonly', True)]}),
33- 'move_ids': fields.many2many('stock.move', 'stock_inventory_move_rel', 'inventory_id', 'move_id', 'Created Moves'),
34+ 'inventory_line_id': fields.one2many('stock.inventory.line', 'inventory_id', 'Inventories', readonly=True, states={'draft': [('readonly', False)]}),
35+ 'move_ids': fields.many2many('stock.move', 'stock_inventory_move_rel', 'inventory_id', 'move_id', 'Created Moves', readonly=True, states={'draft': [('readonly', False)]}),
36 'state': fields.selection( (('draft', 'Draft'), ('done', 'Done'), ('confirm','Confirmed'),('cancel','Cancelled')), 'State', readonly=True, select=True),
37 'company_id': fields.many2one('res.company', 'Company', required=True, select=True, readonly=True, states={'draft':[('readonly',False)]}),
38
39@@ -2758,6 +2766,17 @@
40 'state': fields.related('inventory_id','state',type='char',string='State',readonly=True),
41 }
42
43+ def _check_uom(self, cr, uid, ids, context=None):
44+ for line in self.browse(cr, uid, ids, context=context):
45+ if line.product_id.uom_id.category_id.id != line.product_uom.category_id.id:
46+ return False
47+ return True
48+
49+ _constraints = [
50+ (_check_uom, 'UoM categories Mismatch: The line UOM and the product UOM must be in the same category.',
51+ ['product_uom'])
52+ ]
53+
54 def on_change_product_id(self, cr, uid, ids, location_id, product, uom=False, to_date=False):
55 """ Changes UoM and name if product_id changes.
56 @param location_id: Location id