鉴于最近一个新的需求,需要给供应商设置一个账期,供应商关联的所有采购单也有一个账期,采购单的账期取供应商的账期,但是也可以用手动修改,折腾半天,总算完成。。。
默认情况下odoo的计算字段不会保存在数据库中,在使用的时候进行计算并返回给前端,可加上store=True进行强制保存,可编辑的话需要加上inverse参数,直接上代码:
confirm_receive_time = fields.Integer(‘采购单账期‘,store=True,null=True,compute=‘_compute_confirm_receive‘,inverse=‘_inverse_confirm_receive_time‘)
@api.depends(‘partner_id.confirm_receive_time‘)
def _compute_confirm_receive(self):
for order in self:
order.confirm_receive_time = order.partner_id.confirm_receive_time
def _inverse_confirm_receive_time(self):
pass
原文:https://www.cnblogs.com/LiQ0112/p/14822743.html