Rifakat Haradwala (OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/6.0-bom_self_recursion-rha into
lp:openobject-addons/6.0.
Requested reviews:
Jay Vora (OpenERP) (jvo-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-bom_self_recursion-rha/+merge/66766
mrp: fixed self reference recursion problem
--
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-bom_self_recursion-rha/+merge/66766
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/6.0-bom_self_recursion-rha.
=== modified file 'mrp/mrp.py'
--- mrp/mrp.py 2011-04-04 11:25:26 +0000
+++ mrp/mrp.py 2011-07-04 10:41:35 +0000
@@ -240,8 +240,26 @@
return False
level -= 1
return True
+
+ def _check_product(self, cr, uid, ids, context=None):
+ all_prod = []
+ boms = self.browse(cr, uid, ids, context=context)
+ def check_bom(boms):
+ res = True
+ for bom in boms:
+ if bom.product_id.id in all_prod:
+ res = res and False
+ all_prod.append(bom.product_id.id)
+ lines = bom.bom_lines
+ if lines:
+ newboms = [a for a in lines if a not in boms]
+ res = res and check_bom(newboms)
+ return res
+ return check_bom(boms)
+
_constraints = [
- (_check_recursion, 'Error ! You can not create recursive BoM.', ['parent_id'])
+ (_check_recursion, 'Error ! You can not create recursive BoM.', ['parent_id']),
+ (_check_product, 'BoM line product should not be same as BoM product.', ['product_id'])
]
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp