Merge lp:~openerp-dev/openobject-addons/6.0-opw-516475-ado into lp:openobject-addons/6.0

Proposed by Amit Dodiya (OpenERP)
Status: Merged
Approved by: Naresh(OpenERP)
Approved revision: no longer in the source branch.
Merged at revision: 5210
Proposed branch: lp:~openerp-dev/openobject-addons/6.0-opw-516475-ado
Merge into: lp:openobject-addons/6.0
Diff against target: 28 lines (+18/-1)
1 file modified
mrp/mrp.py (+18/-1)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/6.0-opw-516475-ado
Reviewer Review Type Date Requested Status
Naresh(OpenERP) (community) Approve
Jean-Christophe VASSORT Pending
nel Pending
Xavier ALT Pending
Review via email: mp+95546@code.launchpad.net

Description of the change

Hello,

[FIX] When creating BOM it should not allow you to add the same product again in components.

Code is back-ported from trunk.

Thanks,
Amit

To post a comment you must log in.
Revision history for this message
Naresh(OpenERP) (nch-openerp) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'mrp/mrp.py'
2--- mrp/mrp.py 2011-11-25 13:23:07 +0000
3+++ mrp/mrp.py 2012-03-02 12:17:21 +0000
4@@ -240,8 +240,25 @@
5 return False
6 level -= 1
7 return True
8+
9+ def _check_product(self, cr, uid, ids, context=None):
10+ all_prod = []
11+ boms = self.browse(cr, uid, ids, context=context)
12+ def check_bom(boms):
13+ res = True
14+ for bom in boms:
15+ if bom.product_id.id in all_prod:
16+ res = res and False
17+ all_prod.append(bom.product_id.id)
18+ lines = bom.bom_lines
19+ if lines:
20+ res = res and check_bom([bom_id for bom_id in lines if bom_id not in boms])
21+ return res
22+ return check_bom(boms)
23+
24 _constraints = [
25- (_check_recursion, 'Error ! You can not create recursive BoM.', ['parent_id'])
26+ (_check_recursion, 'Error ! You can not create recursive BoM.', ['parent_id']),
27+ (_check_product, 'BoM line product should not be same as BoM product.', ['product_id'])
28 ]
29
30