Odoo Help

Welcome!

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.

4

Explain fields.property()

By
Antanas
on 7/16/13, 8:12 AM 13,462 views

Hello,

I can't find documentation on fields.property() type of fields. How do they work?

As an example: In OpenERP 7, /addons/stock/product.py, starting from line 484 there are property() fields declared:

class product_template(osv.osv):
   _name = 'product.template'
   _inherit = 'product.template'
   _columns = {
       'property_stock_procurement': fields.property(
        'stock.location',
        type='many2one',
        relation='stock.location',
        string="Procurement Location",
        view_load=True,
        domain=[('usage','like','procurement')],
        help="This stock location will be used, instead of the default one, as the source location for stock moves generated by procurements."),
    'property_stock_production': fields.property(
        'stock.location',
        type='many2one',
        relation='stock.location',
        string="Production Location",
        view_load=True,
        domain=[('usage','like','production')],
        help="This stock location will be used, instead of the default one, as the source location for stock moves generated by manufacturing orders."),

In particular, the above declared field 'property_stock_production' does not appear to be in database tables even after 'stock' module installation (checked with Pgadmin). Please explain the purpose and nature of fields.property()

7
vim24
On 7/17/13, 1:29 AM

Fairly decent explanation here: https://doc.openerp.com/trunk/server/03_module_dev_02/#property-fields

In particular:

"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. "

...

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

  • Different value for the same property depending on the company

  • Rights management per field

  • It's a link between resources (many2one)

So yes, it won't show in the database 'stock' table, but it will be in the ir_property table. This allows for different properties for the same object depending on the users current company.

Hope that helps a bit :)

2
yeshwanth
On 3/27/15, 1:01 AM

REFER: 

http://odoo-new-api-guide-line.readthedocs.org/en/latest/fields.html

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

2 follower(s)

Stats

Asked: 7/16/13, 8:12 AM
Seen: 13462 times
Last updated: 7/28/16, 8:08 AM