How I wanna check if the product_id of a new line added to the mrp.bom.line (Many2many) is equal to a fixed id ('=17'), which may never be added to a BoM. But I can't seem to do this cus he stores the new line as a "NewId", he only writes it to the database when I press the SAVE button. I understood that the NewId is some sort of ID saved in the cache. How can I delete this line when it is equal tot 17?
@api.onchange('bom_line_ids')
def methodA(self):
list = []
fixed_list = [17]
for i in self.bom_line_ids:
list.append(i.product_id.id)
for j in list:
if j in fixed_list:
HERE DELETE THIS MRP.BOM.LINE AND PRINT WARNING MESSAGE
warning_message = "Product: " + self.env['product.template'].search([('id','=',j)]).name + " can't be added to the BoM.\n Please select another product."
return { 'warning': {'title': 'Product error', 'message':warning_message} }