我正在处理供应商表单视图(res.partner模型)。我已经尝试通过下面的代码获取当前记录的id:
current_id=fields.Integer(compute='get_current_id')
@api.multi
def get_current_id(self):
print self.id
self.current_id=self.id在这段代码中,我得到了错误:"ValueError: Expected : res.partner(1,50)“,这很奇怪,因为50是我当前的记录id,但我不知道为什么它也会得到id 1。当我在pgAdmin中查找它时,我发现1就是"company_id“。为什么当前记录(视图窗体)有两个ids?谢谢。
发布于 2018-08-09 01:18:29
您正在使用@api.multi,因此self可以是多个记录。
您可以尝试:
@api.multi
def get_current_id(self):
for instance in self:
instance.current_id = instance.id或者:
@api.one
def get_current_id(self):
self.current_id = self.idhttps://stackoverflow.com/questions/51750959
复制相似问题