跳至內容
選單
此問題已被標幟
2 回覆
9289 瀏覽次數

can anyone help me

頭像
捨棄
最佳答案

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.


頭像
捨棄
最佳答案

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

頭像
捨棄