Skip to Content
Menu
This question has been flagged
1 Reply
2537 Views

Hi,

I need an ID record, but even if it doesn't exist, it still returns an ID.

                        bom_id = self.env['mrp.bom'].search([('code''=' , (values.get('code')))]).id
                        print(bom_id)
                        if not bom_id :                 
                            bom_vals['product_tmpl_id'] = self.find_product(values.get('code'))
                            bom_vals['code'] = values.get('code')           
                            bom_vals['category'] = values.get('category')
                            bom = bom_obj.create(bom_vals)
                            res = self.create_bom(values,bom.id)                                
                        else:
                            raise UserError('bom is available')


Even if the bom is not available, it still display a message.
please help me.

Avatar
Discard
Best Answer

Hi,

You mean this line,

bom_id = self.env['mrp.bom'].search([('code''=' , (values.get('code')))]).id


If this is returning any value it means there will be record in corresponding model having the code in search condition. If you feel the code is working wrongly, print and see what you have in the values.get('code') and make a search it from the search view and see.

If this is not the line creating the issue, it will be better if you can specify the line.


Thanks

Avatar
Discard