我想如何检查添加到 mrp.bom.line (Many2many) 的新行的 product_id 是否等于可能永远不会添加到 BoM 的固定 id ('=17')。但我似乎无法做到这一点,因为他将新行存储为“NewId”,他只在我按下 SAVE 按钮时将其写入数据库。我知道 NewId 是保存在缓存中的某种 ID。当它等于 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} }