In Odoo V8 and V9 it is no longer a field type but a definition. An example:
line_description = fields.Text(string='Description', related='order_line_id.name')
In this case line_description will contain the value from order_line_id (link to another table), from which it will get the value of the field name.
You simply add related='' to create / use a related field in Odoo 8/9.
1. Functionality : This Related field is being used for fetching the information as in new field in current model/object from the relational field added in current model.
Related field only applies on the Relational field which is taken as Many2one field.
For example if you want to access the partner email or contact in your current model, you need to have partner as Many2one field in your model like wise you can fetch any field information from your relational field.
from openerp import models, fields
_name = 'your.modelname'
partner_id = fields.Many2one("res.partner", "Partner" )
email = fields.Char(related="partner_id.email", string="Email", store=True)
So, In above example email has been fetch from partner. you can fetch any field information in your current model from partner by using related. If you use store=True attribute in your related field it will create column in your table which will be help in search purpose. or else it will just update the value in that field and you cannot use that field in filter.
Hope this will help,
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
About This Community
|Asked: 5/18/16, 12:48 AM|
|Seen: 307 times|
|Last updated: 6/14/16, 7:26 AM|