You are on page 1of 8

Beginner question about functional fields and property fields? | Odoo https://www.odoo.com/forum/help-1/question/beginner-question-abo...

Odoo Help
(/forum/help-1)

About This Community


0


Beginner question about
 functional fields and property This community is for
professionals and

fields? (/forum/help-1/question enthusiasts of our


products and services.
/beginner-question-about-  Read Guidelines
(/forum/help-1/faq)

functional-fields-and-property-
fields-77398) Question tools
function_field (/forum/help-1/tag/2444/questions) property.fields (/forum/help-1/tag/3232/questions)
odooopenerp
suporte@projetaty.com.br
SUBSCRIBE
 By () on 2/23/15, 1:28 PM • 2,248 views
2 follower(s)
Anyone tell me what is fnct_search, fnct_inv in fucntion field and what
is prorperty field? 

 Reply  Comment  Share


Stats
    Flag

1 de 8 06-10-2016 21:06
Beginner question about functional fields and property fields? | Odoo https://www.odoo.com/forum/help-1/question/beginner-question-abo...


(/)  APPS (/forum/help-1/user/286082)
TOUR (/PAGE/TOUR) PRICING (/PRICING) COMMUNITY (/PAGE/COMMUNITY)
SANDRO REGIS TRY IT FREE (/TRIAL
DOCS (/PAGE/DOCS)
5 Dhinesh - Technical Consultant, Sodexis Inc
Asked: 2/23/15, 1:28
 PM
(/forum/help-1/user/286082)
On (/forum/help-1/question/beginner-question-about-functional-fields- Seen: 2248 times
and-property-fields-77398#answer_77401) 2/23/15, 1:37 PM
Last updated:
Property Fields: 3/16/15, 9:10 AM
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

2 de 8 06-10-2016 21:06
Beginner question about functional fields and property fields? | Odoo https://www.odoo.com/forum/help-1/question/beginner-question-abo...

gives you the property attached to the instance of object you are reading. If
(/) APPS TOUR (/PAGE/TOUR) PRICING TRY IT FREE (/TRIAL
this object has no value, the system will give(/PRICING) COMMUNITY
you the default property.(/PAGE/COMMUNITY)
SANDRO REGIS
DOCS (/PAGE/DOCS)

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. (https://doc.odoo.com/6.0/developer


/2_5_Objects_Fields_Methods/field_type/)

Functional Fields:

3 de 8 06-10-2016 21:06
Beginner question about functional fields and property fields? | Odoo https://www.odoo.com/forum/help-1/question/beginner-question-abo...

A functional field is a field whose value is calculated by a function (rather


(/) APPS TOUR TRY IT FREE (/TRIAL
than being stored in (/PAGE/TOUR)
the database). PRICING (/PRICING) COMMUNITY (/PAGE/COMMUNITY)
SANDRO REGIS
DOCS (/PAGE/DOCS)

Parameters:

fnct, arg=None, fnct_inv=None, fnct_inv_arg=None, type="float",


fnct_search=None, obj=None, method=False, store=False, multi=False

where

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.

Comment    Flag


 zbik
0 (/forum/help-1/user/34055) (/forum/help-1/user/34055)

On (/forum/help-1/question/beginner-question-about-functional-fields-
and-property-fields-77398#answer_77400) 2/23/15, 1:36 PM

4 de 8 06-10-2016 21:06
Beginner question about functional fields and property fields? | Odoo https://www.odoo.com/forum/help-1/question/beginner-question-abo...

The best answer can be found in the documentation (https://doc.odoo.com


(/) APPS TOUR (/PAGE/TOUR) PRICING (/PRICING) COMMUNITY (/PAGE/COMMUNITY)
SANDRO REGIS TRY IT FREE (/TRIAL
DOCS (/PAGE/DOCS)
/6.0/developer/2_5_Objects_Fields_Methods/field_type/).

Comment    Flag

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!

            

POST ANSWER

5 de 8 06-10-2016 21:06
Beginner question about functional fields and property fields? | Odoo https://www.odoo.com/forum/help-1/question/beginner-question-abo...

(/) APPS TOUR (/PAGE/TOUR) PRICING (/PRICING) COMMUNITY (/PAGE/COMMUNITY)


SANDRO REGIS TRY IT FREE (/TRIAL
DOCS (/PAGE/DOCS)

Community Services About us

Github Upgrade Our company (/page


(https://github.com (https://upgrade.odoo.com)/about-us)
/odoo/odoo) Contact (/page
Find a partner Odoo is a suite of open source business apps
Download (/page /contactus) that cover all your company needs: CRM,
(/partners)
/download) eCommerce, accounting, inventory, point of sale,
Become a partner Events (/event)
Runbot (/page/become- Blog (/blog/) project management, etc.

(http://runbot.odoo.com a-partner) Customers (/blog/6)


Odoo's unique value proposition is to be at the
/runbot/repo/git-
Education (/page Jobs (/jobs) same time very easy to use and fully integrated.
github-com-odoo-
/education-program)
enterprise-7) Legal Info (/page
Translations Security (/page /legal)
(https://github.com /security)
/odoo/odoo
/wiki/Translations)

Mailing Lists (/page


/odoo-community)
Forum (/forum
/help-1)

6 de 8 06-10-2016 21:06
Beginner question about functional fields and property fields? | Odoo https://www.odoo.com/forum/help-1/question/beginner-question-abo...

PRICING (/PRICING) COMMUNITY (/PAGE/COMMUNITY)


SANDRO REGIS TRY IT FREE (/TRIAL
DOCS (/PAGE/DOCS)

7 de 8 06-10-2016 21:06
Beginner question about functional fields and property fields? | Odoo https://www.odoo.com/forum/help-1/question/beginner-question-abo...

(/) APPS TOUR (/PAGE/TOUR) PRICING (/PRICING) COMMUNITY (/PAGE/COMMUNITY)


SANDRO REGIS TRY IT FREE (/TRIAL
DOCS (/PAGE/DOCS)

8 de 8 06-10-2016 21:06

You might also like