Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
It is simple as the name suggests. Means its a field, related to another model through a field on the same model.
We use them normally when we need to fetch some value from another model (say model_B) and we already have one field in current model (say model_A) which is linked to that model (for eg. a many2one field). So through that many2one field we can reach model_B and fetch the value to our related field.
Suppose I want to show qty_available of a product on the sale order line. So through the product_id (many2one) field you can reach product.template model and fetch the qty_available. Here the qty_avail field is related to product_id.qty_available
_inherit = "sale.order.line"
qty_avail = fields.Float(related="product_id.qty_available", string="Quantity Available", readonly=True)
One thing to note is that, both the field types should be same. That means here the qty_avail and qty_available
Hope this helps!
In sort ,it use the HAS-A relation in between entity , and help in simplifying your task .
the Changes will always reflect in both the related model simultaneously .
Lets' take an example:
if i have a model student.student and student.student have a Many2one field associated with res.partner .
At the time of creation :
if you will make the name and email as the related field , it will automatically fill the data ( name , email) in the student.student from res.partner
This save the end-user time.
At time of updation :
in future if you want to change the email and also want to synchronize the records between entity , here related field will also help you.
if you change the email and name here, it will automatically update the email , name of res.partner also .
try these link for reference :
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 5/6/16, 5:26 AM|
|Seen: 816 times|
|Last updated: 1/28/18, 6:08 AM|