我在奥多有两门课:opc_taginstellingen en opc_actuelewaardentags。在
在opc_taginstellingen中,我有tagnaam和unit字段。在
在opc_actuelewaardentags中,我还有一个字段tagnaam和unit。在
我要做的是比较tagnaam并从opc_actuelewaardentags中检索单元。在
如果opc_塔格纳姆学院==opc_taginstellingen.tagnaam公司然后检索opc_taginstellingen.单位复制到opc_actuelewaardentags.unit公司. 在
我试过这样做:
class opc_taginstellingen(models.Model):
_name = 'opc_taginstellingen'
tagnaam = fields.Char(string="Tagnaam")
unit = fields.Char(string="unit")
tag_instellingen = fields.Many2one('opc_actuelewaardentags')
class opc_actuelewaardentags(models.Model):
_name = 'opc_actuelewaardentags'
tagnaam = fields.Char(string="Tagnaam")
tag_instelling = fields.One2many(comodel_name='opc_taginstellingen', inverse_name='tag_instellingen')
@api.one
def changeUnit(self):
instellingen = self.env['opc_taginstellingen'].search([('id','=',self.tag_instelling.id)])
ret = ""
for instelling in instellingen:
ret = instelling.unit
print ret
return ret
unit = fields.Char(default=changeUnit, string="unit1")
但是这个代码不起作用。 我想连换衣服的地方都没有。。。在
我也试过了
@api.multi
而不是{
unit = fields.Char(compute='changeUnit', string="unit1")
而不是
unit = fields.Char(default=changeUnit, string="unit1")
有人知道为什么这个代码不起作用吗?在
如果我的解释不清楚,请告诉我。在
相关问题 更多 >
编程相关推荐