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.
A property is a special field declared as fields.property. It is also called as multi-company field. In database it will not be stored as normal field in respective object table. It will be stored in separate special table called ir_property table.
The fields.property class inherits from fields.function and overrides the read and write method.
When to use it?
Consider 2 companies Company A and Company B.
Company A (US chart of account) - User1
Company B (Indian chart of account) - User2
Each company has its own chart of account. In this case we will use AR and AP as property fields in partner object.
When user1 login and create a customer, he will have AR (Account receivable) and AP (Account payable) as default based on Company A chart of account.
When user2 login and create a customer, he will have AR (Deptors) and AP (Creditors) as default based on Company B chart of account.
The same field acts as different based on the users company. If no value is specified it will return the default value if specified.
The same partner may have different account receivable values depending on the company the user belongs to. 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.
You can ask we can use many2one field. But many2one field values are static and it will not change based on user company.
One interesting thing is:
Properties avoid "spaghetti" code. That means the account module depends on the partner (base) module. But you can install the partner (base) module without the accounting module. If you add a normal field that points to an account in the partner object, both objects will depend on each other. It's much more difficult to maintain and code (for instance, try to remove a table when both tables are pointing to each others.)
One more thing:
In v8, property fields has been deprecated. It was no more called fields.property. Now we can pass it as a boolean parameter for all the fields. company_dependent – whether the field is company-dependent (boolean)
Important columns in db:
name: By convention fields are named as property_field_name. Eg. "property_account_receivable",
type: Eg. "many2one",
company_id: company id,
fields_id: id of field from ir_model_fields,
value_reference: Eg. "account.account,72" (Object relation with id. Stores reference, Different from usual many2one which saves the id only)
res_id: Eg. "res.partner,86" (Object where the field is declared with id). If it is not set, this property will be used as default for all.
For Detailed description link.
A functional field is a field whose value is calculated by a function (rather than being stored in the database).
fnct, arg=None, fnct_inv=None, fnct_inv_arg=None, type="float", fnct_search=None, obj=None, method=False, store=False, multi=False
fnct is the function or method that will compute the field value. It must have been declared before declaring the functional field.
fnct_inv is the function or method that will allow writing values in that field.
type is the field type name returned by the function. It can be any field type name except function.
fnct_search allows you to define the searching behaviour on that field.
method whether the field is computed by a method (of an object) or a global function
store If you want to store field in database or not. Default is False.
multi is a group name. All fields with the same multi parameter will be calculated in a single function call.
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: 2/23/15, 11:28 AM|
|Seen: 3328 times|
|Last updated: 3/16/15, 8:10 AM|