India

ZestyBeanz Technologies Pvt Ltd 4th Floor, Nila, Technopark Thiruvananthapuram,
India – 695581
Phone: +91 471 4063254
Fax : +91 471 2700171

   .

ZestyBeanz Technologies Pvt Ltd
2987, Manikkath Cross Road
Ravipuram, Kochi, India - 682016
Phone: +91 484 4063254

  UAE

Zesty Labs
Office # 2003, Millennium Plaza Building
Sheikh Zayed Rd, Dubai, UAE
Phone: +971 4333 2222​
Mobile: +971-56-2708993​

  Germany​

ZestyBeanz Technologies GmbH
Reuterstraße 1
90408 Nürnberg
Fon: +49 911 4801 444
Fax: +49 911 4801 445

Reference field in Odoo

Contact Form


sahya's picture

Reference field in Odoo

Reference field in Odoo can be used for storing an arbitrary reference to a model.

This field allows us to select a model and adding a reference to that model. Reference fields are mainly used for showing different model's records as reference in your record.

For example, if you have a model contains various fields and if the records of that model are created from existing models such as Sales order, Purchase Order, Invoice, Project, Voucher etc. and if you need a reference of the model from which your record has been created in your model, then you can use a field of type reference which stores a link to the model from which your record is created.

Reference field stores both the model name and the selected reference id. Reference field have a selection list which is a list of tuples with model and name and list of records of the selected model.

Second area of reference field allows us to select a record of the selected model.

Reference field act like a many2one to the model selected. 

In the db reference field stores both the model name and the id of the record selected. 

<model name>,id

For the above example reference field value will be ‘sale.order,<id>’

We can access the data of a reference field as like from normal many2one field.

For example:  ‘field_name.name’ can be used for getting the name of the record selected if field_name is the name of field of type reference.

A reference field can be declared as below.

Above declaration allows us to select models that have added as referencable models. We can also modify the selection of reference field to select the models as per our requirement.

Referencable Models can be added using the menu Settings -> Technical -> Database Structure -> Referencable Models. We can also give the priority of the model in the reference selection. 

We can also define the list of models in the reference selection.

Above function lists all the models in the selection of reference rather than the models added in Referenceable Models menu.

Hope my presentation was usefull for you . 

Thank you