2017-10-24 10 views
0

私は自分のモジュールのmany2oneフィールドにアクセスしたいが、フィールドにアクセスすることができないいくつかのフィールドをモジュールに持っています。ここで他のモジュールのいくつかのフィールドにmany2oneフィールドとしてアクセスします。

が私のコードです: -

コード: -

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

上記のコードのように私はmany2oneフィールドにアクセスしていますが、それはエラーを示します。助けてもらえますか?

答えて

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") 
+0

これらは「char」フィールドですが、私はmany2oneフィールドが必要です。 –

+0

このコードを使用することができます:** row = fields.Many2one( 'location.rental'、related = 'row'、string = "Row")**ほとんどの行はlocation.rentalで一意です。 –

+0

コードを適用しているときに、「実行時エラー:Pythonオブジェクトの呼び出し中に最大再帰深度を超過しました」というエラーが表示されます。 –

関連する問題