I've inherited res.partner
and added two fields to it.
class Partner(models.Model):
_inherit = 'res.partner'
type = fields.Selection(selection_add=[(('mina', 'Mina'))])
origen = fields.Char(string="Origen")
destino = fields.Char(string="Destino")
I want show these fields, on another model, like this:
class routes(models.Model):
_name = 'routes'
partner = fields.Many2one('res.partner')
orig_ = fields.Char(related="partner.origen", string="Origen", store=True)
dest_ = fields.Char(related="partner.destino", string="Destino", store=True)
These fields are being showed on form view, but they doesn't let me select anything, it's just a Char
type field, like its not related, what could it be the reason?
Related fields are readonly fields, that's why you cannot edit them. If you want to edit them, just use normal Char field. If you want these fields have default values, use default attribute
orig_ = fields.Char(string="Origen", default=lambda self: self.partner.origen)
dest_ = fields.Char(string="Destino", default=lambda self: self.partner.destino)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.