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
=== modified file 'stock/stock.py'
--- stock/stock.py 2012-10-05 07:47:57 +0000
+++ stock/stock.py 2012-12-04 07:02:20 +0000
@@ -1614,6 +1614,12 @@
1614 return False1614 return False
1615 return True1615 return True
16161616
1617 def _check_uom(self, cr, uid, ids, context=None):
1618 for move in self.browse(cr, uid, ids, context=context):
1619 if move.product_id.uom_id.category_id.id != move.product_uom.category_id.id:
1620 return False
1621 return True
1622
1617 _constraints = [1623 _constraints = [
1618 (_check_tracking,1624 (_check_tracking,
1619 'You must assign a production lot for this product',1625 'You must assign a production lot for this product',
@@ -1622,7 +1628,9 @@
1622 ['location_id','location_dest_id']),1628 ['location_id','location_dest_id']),
1623 (_check_product_lot,1629 (_check_product_lot,
1624 'You try to assign a lot which is not from the same product',1630 'You try to assign a lot which is not from the same product',
1625 ['prodlot_id'])]1631 ['prodlot_id']),
1632 (_check_uom, 'UoM categories Mismatch: The move UOM and the product UOM must be in the same category.',
1633 ['product_uom'])]
16261634
1627 def _default_location_destination(self, cr, uid, context=None):1635 def _default_location_destination(self, cr, uid, context=None):
1628 """ Gets default address of partner for destination location1636 """ Gets default address of partner for destination location
@@ -2619,8 +2627,8 @@
2619 'name': fields.char('Inventory Reference', size=64, required=True, readonly=True, states={'draft': [('readonly', False)]}),2627 'name': fields.char('Inventory Reference', size=64, required=True, readonly=True, states={'draft': [('readonly', False)]}),
2620 'date': fields.datetime('Creation Date', required=True, readonly=True, states={'draft': [('readonly', False)]}),2628 'date': fields.datetime('Creation Date', required=True, readonly=True, states={'draft': [('readonly', False)]}),
2621 'date_done': fields.datetime('Date done'),2629 'date_done': fields.datetime('Date done'),
2622 'inventory_line_id': fields.one2many('stock.inventory.line', 'inventory_id', 'Inventories', states={'done': [('readonly', True)]}),2630 'inventory_line_id': fields.one2many('stock.inventory.line', 'inventory_id', 'Inventories', readonly=True, states={'draft': [('readonly', False)]}),
2623 'move_ids': fields.many2many('stock.move', 'stock_inventory_move_rel', 'inventory_id', 'move_id', 'Created Moves'),2631 'move_ids': fields.many2many('stock.move', 'stock_inventory_move_rel', 'inventory_id', 'move_id', 'Created Moves', readonly=True, states={'draft': [('readonly', False)]}),
2624 'state': fields.selection( (('draft', 'Draft'), ('done', 'Done'), ('confirm','Confirmed'),('cancel','Cancelled')), 'State', readonly=True, select=True),2632 'state': fields.selection( (('draft', 'Draft'), ('done', 'Done'), ('confirm','Confirmed'),('cancel','Cancelled')), 'State', readonly=True, select=True),
2625 'company_id': fields.many2one('res.company', 'Company', required=True, select=True, readonly=True, states={'draft':[('readonly',False)]}),2633 'company_id': fields.many2one('res.company', 'Company', required=True, select=True, readonly=True, states={'draft':[('readonly',False)]}),
26262634
@@ -2758,6 +2766,17 @@
2758 'state': fields.related('inventory_id','state',type='char',string='State',readonly=True),2766 'state': fields.related('inventory_id','state',type='char',string='State',readonly=True),
2759 }2767 }
27602768
2769 def _check_uom(self, cr, uid, ids, context=None):
2770 for line in self.browse(cr, uid, ids, context=context):
2771 if line.product_id.uom_id.category_id.id != line.product_uom.category_id.id:
2772 return False
2773 return True
2774
2775 _constraints = [
2776 (_check_uom, 'UoM categories Mismatch: The line UOM and the product UOM must be in the same category.',
2777 ['product_uom'])
2778 ]
2779
2761 def on_change_product_id(self, cr, uid, ids, location_id, product, uom=False, to_date=False):2780 def on_change_product_id(self, cr, uid, ids, location_id, product, uom=False, to_date=False):
2762 """ Changes UoM and name if product_id changes.2781 """ Changes UoM and name if product_id changes.
2763 @param location_id: Location id2782 @param location_id: Location id