Hi,
I don't know why I get this error: null value in column "product_tmpl_id" violates not-null constraint.
My function has input and output. But the function output is not in the field product_tmpl_id.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi,
I don't know why I get this error: null value in column "product_tmpl_id" violates not-null constraint.
My function has input and output. But the function output is not in the field product_tmpl_id.
Hi,
Here you are creating a record into the model mrp.bom where product_tmpl_id is a required field. Checking your code it seems, you are not checking whether there is a value supplied for the product_tmpl_id during creation.
This error is thrown while the value for a required field is no supplied.
Update your code like this,
mrp_bom_obj = self.env['mrp.bom']
product_id = self.find_product_finish(values.get('name'))
if product_id:
abc = {
'code': values.get('code'),
'category': 'test',
'product_tmpl_id': product_id,
}
bom_id = mrp_bom_obj.create(abc)
@api.multi
def find_product_finish(self, name):
product_obj = self.env['product.template']
product_search = product_obj.search([('name', '=', name)], limit=1)
if product_search:
return product_search.id
else:
raise UserError(_(' %s product are not available.') % name)
Thanks
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up
thank you raphy for solving my problem so many times so far.
If you can also help with the function of adding component to mrp.bom from csv.
(product_id,'product_qty', 'product_uom_id')
for product_id and product_uom_id like product_tmpl_id the function is written
How to put it on the bom_line_id؟
'bom_line_ids':[(6,0,[y.id for y in bom_line_ids])