2017-10-24 1 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") 

코드 : -

위의 코드와 같이하지만 오류가 같이 나는 many2one 필드를 액세스하고
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") 

. 좀 도와 줄까?

답변

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 객체를 호출하는 동안 최대 재귀 심도가 초과되었습니다"라는 오류가 표시됩니다. –