3
我如何檢查添加到mrp.bom.line(Many2many)的新行的product_id是否等於固定的id('= 17'),它可能永遠不會被添加到BoM。但我似乎無法做到這一點,他將新行存儲爲「NewId」,他只在按下SAVE按鈕時將其寫入數據庫。我知道NewId是保存在緩存中的某種ID。當它等於17時,我怎麼能刪除這條線?Odoo 8 Many2many驗證並刪除行
@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} }