Reputation: 111
I have 2 fields in res.partner that I would like to display in a tree view for account.invoice based on the partner_id field. I'm wondering how I can do that (reference another model and field) through the tree view web interface, due to the SaaS version not allowing programmatic access.
Thanks in advance!
Upvotes: 2
Views: 473
Reputation: 14721
create related field in you account.invoice model to the fields of res.partner
x_invoice_preference=fields.Selection(related="partner_id.x_invoice_preference")
it's a good practice to name the related field the same name in the other model
Little exemple :
class class1(models.Model):
_name = 'table1'
name = fields.Char()
class class2(models.Model):
_name = 'table2'
table1_id = fields.Many2one('table1','table 1');
#this how you create a related field in order to
#show it in the form or the tree when you select the value of the many2one field it
# will have the same value of the vield name of the tabl1
name = fields.Char(related="table1_id.name",readonly=True)
#field_name m2onField.field_name
Upvotes: 2