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
=== modified file 'mrp/mrp.py'
--- mrp/mrp.py 2011-11-25 13:23:07 +0000
+++ mrp/mrp.py 2012-03-02 12:17:21 +0000
@@ -240,8 +240,25 @@
240 return False240 return False
241 level -= 1241 level -= 1
242 return True242 return True
243
244 def _check_product(self, cr, uid, ids, context=None):
245 all_prod = []
246 boms = self.browse(cr, uid, ids, context=context)
247 def check_bom(boms):
248 res = True
249 for bom in boms:
250 if bom.product_id.id in all_prod:
251 res = res and False
252 all_prod.append(bom.product_id.id)
253 lines = bom.bom_lines
254 if lines:
255 res = res and check_bom([bom_id for bom_id in lines if bom_id not in boms])
256 return res
257 return check_bom(boms)
258
243 _constraints = [259 _constraints = [
244 (_check_recursion, 'Error ! You can not create recursive BoM.', ['parent_id'])260 (_check_recursion, 'Error ! You can not create recursive BoM.', ['parent_id']),
261 (_check_product, 'BoM line product should not be same as BoM product.', ['product_id'])
245 ]262 ]
246263
247264