Odoo Help


This community 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.


Can anyone clearly explain property.fields. ??

Pankaj Moolrajani
on 1/31/14, 12:14 AM 2,512 views

Hello Guys,

I am a newbie to openerp. i was going throught the documentation of openerp and came across propery.fields. The documentation does not explains it clearly. i am confused, so i would appreciate if any of experts or experienced people can help me out in understanding the following things about property.fields.

1.) its purpose, why to use it?
2.) How to use it ?
3.) An example will be a great help if you can provide one...

Pankaj Moorlajani

this does not explains the purpose of using and why to use it ???, unerstanding the technical implementation of this is not worth unless i am able to understand its purpose and functionality...

Pankaj Moolrajani
on 1/31/14, 3:19 AM

Atul Kumar jain

--Atul Kumar jain--
| 5 3 7
Indore, India
--Atul Kumar jain--


Atul Kumar jain
On 2/28/14, 2:22 AM

Property Fields

Declaring a property

A property is a special field: fields.property.

class res_partner(osv.osv):
_name = "res.partner"
_inherit = "res.partner"
_columns = {
                    string="Sale Pricelist",
                            group_name="Pricelists Properties"),

Then you have to create the default value in a .XML file for this property:

<record model="ir.property" id="property_product_pricelist">
<field name="name">property_product_pricelist</field>
<field name="fields_id" search="[('model','=','res.partner'),
<field name="value" eval="'product.pricelist,'+str(list0)"/>



if the default value points to a resource from another module, you can use the ref function like this:

<field name="value" eval="'product.pricelist,'+str(ref('module.data_id'))"/>

Putting properties in forms

To add properties in forms, just put the <properties/> tag in your form. This will automatically add all properties fields that are related to this object. The system will add properties depending on your rights. (some people will be able to change a specific property, others won't).

Properties are displayed by section, depending on the group_name attribute. (It is rendered in the client like a separator tag).

How does this work ?

The fields.property class inherits from fields.function and overrides the read and write method. The type of this field is many2one, so in the form a property is represented like a many2one function.

But the value of a property is stored in the ir.property class/table as a complete record. The stored value is a field of type reference (not many2one) because each property may point to a different object. If you edit properties values (from the administration menu), these are represented like a field of type reference.

When you read a property, the program gives you the property attached to the instance of object you are reading. If this object has no value, the system will give you the default property.

The definition of a property is stored in the ir.model.fields class like any other fields. In the definition of the property, you can add groups that are allowed to change to property.

Using properties or normal fields

When you want to add a new feature, you will have to choose to implement it as a property or as normal field. Use a normal field when you inherit from an object and want to extend this object. Use a property when the new feature is not related to the object but to an external concept.

Here are a few tips to help you choose between a normal field or a property:

Normal fields extend the object, adding more features or data.

A property is a concept that is attached to an object and have special features:

Different value for the same property depending on the company

Rights management per field

It's a link between resources (many2one)

Example 1: Account Receivable

The default "Account Receivable" for a specific partner is implemented as a property because:

    This is a concept related to the account chart and not to the partner, so it is an account property that is visible on a partner form. Rights have to be managed on this fields for accountants, these are not the same rights that are applied to partner objects. So you have specific rights just for this field of the partner form: only accountants may change the account receivable of a partner.

    This is a multi-company field: the same partner may have different account receivable values depending on the company the user belongs to. In a multi-company system, there is one account chart per company. The account receivable of a partner depends on the company it placed the sale order.

    The default account receivable is the same for all partners and is configured from the general property menu (in administration).
On 2/23/15, 12:10 PM

Simple answer is here https://www.odoo.com/forum/help-1/question/beginner-question-about-functional-fields-and-property-fields-77398#answer_77401

On 3/27/15, 1:01 AM



Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)


Asked: 1/31/14, 12:14 AM
Seen: 2512 times
Last updated: 3/27/15, 1:01 AM