问题描述
我想做的是为产品创建一个custom.modify.price
模型,在该模型中,我可以选择某个条件来选择产品,然后填写一个百分比影响所有先前选择的价格。我希望它为选择中的每个产品在另一个模型custom.sale.price
中创建一个新记录,并且每个记录都应保存在其中创建它的ID
记录中的custom.modify.price
。 many2one
字段。事情是,我可以通过覆盖custom.sale.price
custom.modify.price
方法并为其提供值来创建此create
的新记录,但是我无法以当前{ {1}}的“尚未创建” ID
记录
custom.modify.price
解决方法
您需要创建custom.modify.price
并用结果id
更新值,然后创建custom.sale.price
@api.model
def create(self,vals):
result = super(CustomModifyPrice,self).create(vals)
values = {'modification_id': result.id,...}
self.env['custom.sale.price'].create(values)
return result