CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
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,
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.
About This Community
Odoo Training Center
|Asked: 5/18/16, 12:48 AM|
|Seen: 917 times|
|Last updated: 9/13/17, 6:43 AM|