Attrs in OpenERP/Odoo

Attrs in OpenERP/Odoo

As an OpenERP/Odoo Developer, you might come across such a situation where you would like to make one or some fields readonly or mandatory or hide ('invisible' in OpenERP terminology) based on the values of other fields. Well, then you are getting OpenERP Training just by reading this as the solutions here are explained by well versed OpenERP Trainers. The solution here to your situation is 'attrs'. The attrs is an element in OpenERP which is responsible to alter the attributes of a field, not the value. The 'attrs' attribute can be used to dynamically change the attributes of view components based on the value of other fields. Buttons in OpenERP use states attribute for dynamic visibility, they too can be used with attrs. It can be used on field, page, group, button and notebook tags. Remember, there is no RPC call ever made because this is a pure client side attribute at view level. The structure of ' attrs' is a dictionary carrying the key as the client attribute and value as a set of domain(s),the keys could be:

readonly

invisible

required

Structure : attrs="{'attribute':Domain which is if true, the element will wear the new property 'attribute'}" Syntax of attrs : <field name="value_amount"

You can use any domains here but make sure there will be no server side calls made. So better to be limited at view level. Attrs is reflected at view level per record, and hence that can never be applied at List view/ Tree view level. Hope this makes you hungry to learn more about the beauty of OpenObject Framework. You can take the advantages of learning this greatly with us by attending our trainings. Thanks, Serpent Consulting Services

CONNECT WITH US

SERPENTCS

OUR PARTNERS

SERPENTCS- ABOUT US

Serpent Consulting Services was founded back in
December 2011 with a vision of Mr. Husen Daudi
& Mr. Jay Vora to start a companionship that every
company around the world can relate to; No matter
it is a Multinational Firm or a Small Scale Enterprise.