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
=== modified file 'stock/stock.py'
--- stock/stock.py 2012-02-28 14:08:16 +0000
+++ stock/stock.py 2012-03-13 11:35:23 +0000
@@ -1610,6 +1610,13 @@
1610 if (record.state=='done') and (record.location_dest_id.usage == 'view' or record.location_id.usage == 'view'):1610 if (record.state=='done') and (record.location_dest_id.usage == 'view' or record.location_id.usage == 'view'):
1611 return False1611 return False
1612 return True1612 return True
1613
1614 def _check_uom(self, cr, uid, ids, context=None):
1615 for move in self.browse(cr, uid, ids, context=context):
1616 product = self.pool.get('product.product').browse(cr, uid, move.product_id.id, context=context)
1617 if product.uom_id.category_id.id != move.product_uom.category_id.id:
1618 return False
1619 return True
16131620
1614 _constraints = [1621 _constraints = [
1615 (_check_tracking,1622 (_check_tracking,
@@ -1617,6 +1624,8 @@
1617 ['prodlot_id']),1624 ['prodlot_id']),
1618 (_check_location, 'You can not move products from or to a location of the type view.',1625 (_check_location, 'You can not move products from or to a location of the type view.',
1619 ['location_id','location_dest_id']),1626 ['location_id','location_dest_id']),
1627 (_check_uom, 'UoM categories Mismatch: The move UOM and the product UOM must be in the same category.',
1628 ['product_uom']),
1620 (_check_product_lot,1629 (_check_product_lot,
1621 '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',
1622 ['prodlot_id'])]1631 ['prodlot_id'])]
@@ -2749,6 +2758,17 @@
2749 'state': fields.related('inventory_id','state',type='char',string='State',readonly=True),2758 'state': fields.related('inventory_id','state',type='char',string='State',readonly=True),
2750 }2759 }
27512760
2761 def _check_uom(self, cr, uid, ids, context=None):
2762 for line in self.browse(cr, uid, ids, context=context):
2763 product = self.pool.get('product.product').browse(cr, uid, line.product_id.id, context=context)
2764 if product.uom_id.category_id.id != line.product_uom.category_id.id:
2765 return False
2766 return True
2767
2768 _constraints = [
2769 (_check_uom, 'UoM categories Mismatch: The line UOM and the product UOM must be in the same category.', ['product_uom']),
2770 ]
2771
2752 def on_change_product_id(self, cr, uid, ids, location_id, product, uom=False, to_date=False):2772 def on_change_product_id(self, cr, uid, ids, location_id, product, uom=False, to_date=False):
2753 """ Changes UoM and name if product_id changes.2773 """ Changes UoM and name if product_id changes.
2754 @param location_id: Location id2774 @param location_id: Location id

Subscribers

People subscribed via source and target branches

to all changes: