Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Include only parent level class in OpenERP(Odoo)?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 358
    Comment on it

    To Include only parent level class in OpenERP(Odoo) below is the method/code
    In below example I have written Python script to Include only parent level class. You can directly use below python code in .py file :

    1. def addMaterialsRecursive(components, products, bom_lines):
    2. if not bom_lines:
    3. return components
    4. else:
    5. for bom in bom_lines:
    6. if bom.product_id.id not in products:
    7. products.append(bom.product_id.id)
    8. components.append(bom.id)
    9. product_ids = map(lambda x: x.product_id.id, bom_lines)
    10. sids = self.search(cr, uid, [
    11. ('bom_id', '=', False),
    12. ('product_id', 'in', product_ids)
    13. ])
    14. for bom in self.browse(cr, uid, sids):
    15. addMaterialsRecursive(components, products,
    16. bom.bom_lines)
    17. bom_parent = self.browse(cr, uid, bom_id, context=context)
    18. components = []
    19. products = []
    20. addMaterialsRecursive(components, products, bom_parent.bom_lines)
    21. result[bom_id] = components
    22. return result

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: