2017-10-24 4 views
0

Ich habe einige Felder in einem Modul, die ich als viele2one Felder in meinem Modul zugreifen möchte, aber nicht auf die Felder zugreifen.Zugriff auf Felder aus einem anderen Modul als many2one Felder

Hier ist mein Code: -

Code: -

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

Code: -

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

I many2one Felder am Zugriff auf die oben angezeigten Code ein, aber es zeigt einen Fehler an. Kann ich Hilfe bekommen?

Antwort

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

Dies sind "char" Felder, aber ich brauche viele2 Felder. –

+0

Sie können diesen Code verwenden: ** row = fields.Many2one ('location.rental', related = 'row', string = "Row") **, aber die Zeile ist in location.rental eindeutig. –

+0

Es zeigt einen Fehler "Laufzeitfehler: maximale Rekursionstiefe beim Aufruf eines Python-Objekts überschritten" beim Anwenden des Codes. –

Verwandte Themen