Priyan RockZ
Priyan RockZ

Reputation: 1615

OpenERP set field readonly when form onload

Please advice me on how to set form's field to readonly when form onload. i need to do it from python function (not in view.xml with attr invisible option).

form onload if user company based then need to company readonly, if user department based then need to company and department readonly

Please help me to implement this

or include its in below function

def _default_company(self, cr, uid, context=None):
    user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
    if user.company_id:
        [here add code to set department field readonly]
        return user.company_id.id

Upvotes: 0

Views: 613

Answers (1)

simahawk
simahawk

Reputation: 2431

you cannot alter fields' "visual" parameters from _default setup. You can override fields_view_get method in order to override fields' properties dynamically. You can also do this on a per-view basis if you need it, by checking the id or the name or the type of the view. Look at the manual and grep into addons folder to find real examples.

Upvotes: 1

Related Questions