Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
9288 Vistas

can anyone help me

Avatar
Descartar
Mejor respuesta

Hi Kirubanidhi,

Related Field:

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.

Technical Eg.

from openerp import models, fields

class your_class(models.Model):
_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,

Regards,

Anil.


Avatar
Descartar
Mejor respuesta

Hi kirubanidhi,

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.

Yenthe

Avatar
Descartar