Merge lp:~openerp-dev/openobject-addons/trunk-bug-953324-mma into lp:openobject-addons

Proposed by Mayur Maheshwari(OpenERP)
Status: Work in progress
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-bug-953324-mma
Merge into: lp:openobject-addons
Diff against target: 44 lines (+20/-0)
1 file modified
stock/stock.py (+20/-0)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-bug-953324-mma
Reviewer Review Type Date Requested Status
Purnendu Singh (OpenERP) (community) Needs Fixing
Review via email: mp+97197@code.launchpad.net

Description of the change

Hello,

       stock: I Have added check_uom constraints in stock.move and stock.inventory.line Object

Thanks.
mma

To post a comment you must log in.
Revision history for this message
Purnendu Singh (OpenERP) (purnendu-singh) wrote :

it can be fix by implementing on_change on UMO directly!!!

Thanks,
Purnendu Singh

review: Needs Fixing
Revision history for this message
Amit Parik (amit-parik) wrote :

Hello Purnendu,

I think Mayur is correct, cause If some one try to import the inventory form csv file and he used the wrong uom for then product then on_change will not raise.

So As per my Opinion check_uom constraint is better way to do this.

Thank you!

Unmerged revisions

6670. By Juan Márquez

[FIX]stock: added check_uom constraints in stock.move and stock.inventory.line Object

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-28 14:08:16 +0000
3+++ stock/stock.py 2012-03-13 11:35:23 +0000
4@@ -1610,6 +1610,13 @@
5 if (record.state=='done') and (record.location_dest_id.usage == 'view' or record.location_id.usage == 'view'):
6 return False
7 return True
8+
9+ def _check_uom(self, cr, uid, ids, context=None):
10+ for move in self.browse(cr, uid, ids, context=context):
11+ product = self.pool.get('product.product').browse(cr, uid, move.product_id.id, context=context)
12+ if product.uom_id.category_id.id != move.product_uom.category_id.id:
13+ return False
14+ return True
15
16 _constraints = [
17 (_check_tracking,
18@@ -1617,6 +1624,8 @@
19 ['prodlot_id']),
20 (_check_location, 'You can not move products from or to a location of the type view.',
21 ['location_id','location_dest_id']),
22+ (_check_uom, 'UoM categories Mismatch: The move UOM and the product UOM must be in the same category.',
23+ ['product_uom']),
24 (_check_product_lot,
25 'You try to assign a lot which is not from the same product',
26 ['prodlot_id'])]
27@@ -2749,6 +2758,17 @@
28 'state': fields.related('inventory_id','state',type='char',string='State',readonly=True),
29 }
30
31+ def _check_uom(self, cr, uid, ids, context=None):
32+ for line in self.browse(cr, uid, ids, context=context):
33+ product = self.pool.get('product.product').browse(cr, uid, line.product_id.id, context=context)
34+ if product.uom_id.category_id.id != line.product_uom.category_id.id:
35+ return False
36+ return True
37+
38+ _constraints = [
39+ (_check_uom, 'UoM categories Mismatch: The line UOM and the product UOM must be in the same category.', ['product_uom']),
40+ ]
41+
42 def on_change_product_id(self, cr, uid, ids, location_id, product, uom=False, to_date=False):
43 """ Changes UoM and name if product_id changes.
44 @param location_id: Location id

Subscribers

People subscribed via source and target branches

to all changes: