Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to call and create parent class in account module in OpenERP(Odoo)?

    • 0
    • 0
    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 572
    Comment on it

    In OpenERP first, we create custom module and then create function in your existing module and pass parameter in function name is MaterialsRecursive.

    In below example I have written Python script to Include only parent level class. Like given below python code in .py file :

    def MaterialsRecursive(cr, uid, ids, components, products, bom_lines): 
                    if not bom_lines: 
                        return components 
                    else: 
                        for bom in bom_lines: 
                            if bom.product_id.id not in products: 
                                products.append(bom.product_;id.id) 
                                components.append(bom.id) 
                        product_ids = map(lambda x: x.product_id.id, bom_lines) 
                        sids = self.search(cr, uid, [ 
                                           ('bom_id', '=', False), 
                                           ('product_id', 'in', product_ids) 
                                           ]) 
                        for bom in self.browse(cr, uid, sids): 
                            addMaterialsRecursive(components, products, 
                                                  bom.bom_lines) 
                bom_parent = self.browse(cr, uid, bom_id, context=context) 
                components = [] 
                products = [] 
                addMaterialsRecursive(components, products, bom_parent.bom_lines) 
                result[bom_id] = components 
            return result

 1 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: