从另一个模块访问一些字段,多达2个字段

时间:2017-10-24 12:18:39

标签: xml python-2.7 odoo-10

我在模块中有一些字段,我想访问模块中的多个字段,但无法访问字段。

这是我的代码: -

代码: -

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个字段,但它显示错误。我可以帮忙吗?

1 个答案:

答案 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")