Skip to Content
Menu
This question has been flagged
1439 Views

Hi,

I has problem in import bom.line, for one each bom.line add one bom.

please help me.

        bom_obj = self.env['mrp.bom']
        line_obj = self.env['mrp.bom.line']
        bom = None
        for row in data:
            if bom:
                bom.post()
                bom = None
            bom_vals = {}
            line_vals = {}


            product = self.find_product(data.get('default_code'))
            product_id = self.find_product_finish(data.get('product_tmpl_id'))  
            product_uom = self.find_uom_product(data.get('product_uom_id'))     
            if not bom:
                if product_id:
                    
                    bom_vals['product_tmpl_id'] = self.find_product_finish(data.get('product_tmpl_id'))
                                   
                if product:
                    line_vals['product_id'] = self.find_product(data.get('default_code'))
                if product_uom:
                    line_vals['product_uom_id'] = product_uom   
                    line_vals['product_qty'] = data.get('product_qty')
        bom = bom_obj.create(bom_vals)
        line_vals['bom_id'] = bom.id
        line = bom.bom_line_ids.create(line_vals)
        if bom:
            bom.post()


Avatar
Discard