Help

4

Explain fields.property()

Avatar
Antanas

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()

Avatar
Discard
2 Answers
9
Avatar
vim24
Best Answer

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 :)

Avatar
Discard
3
Avatar
yeshwanth
Best Answer

REFER: 

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

Avatar
Discard