我在模块中有一些字段,我想访问模块中的多个字段,但无法访问字段。
这是我的代码: -
代码: -
class location_rental(models.Model):
_name = "location.rental"
location_id = fields.Char('Location_id', required=True)
location_name = fields.Char("Location Name")
row = fields.Char("Row")
column = fields.Char("Column")
level = fields.Char("Level")
代码: -
class rental_pet(models.Model):
_name = 'rental.pet'
location_id = fields.Many2one('location.rental.location_id', string="Location Id")
row = fields.Many2one("location.rental.row", string="Row")
我正在访问上面代码中显示的很多2个字段,但它显示错误。我可以帮忙吗?
答案 0 :(得分:0)
class rental_pet(models.Model):
_name = 'rental.pet'
location_rental_id = fields.Many2one('location.rental',string="location_rental")
location_id = fields.Char(related='location_rental_id.location_id',string="Location Id")
row = fields.Char(related='location_rental_id.row', string="Row")