Hi all, There is a recurrent problem when developing OpenERP modules: I have to make a field of an object to be readonly depending on the groups the users have.
For example, I want that only users from the group 'price_manager' can modify the field 'price_unit' of the object 'sale.order.line'. There are some solutions summarized in https://answers.launchpad.net/openobject-server/+question/178779 but a global accepted solution is yet not established. I found more 'elegant' to create another field as follow 'price_unit_copy': fields.related('price_unit', type="float", readonly=True, store=False, string='Unit Price'), add an onchange function (in field 'price_unit') in the 'sale.order.line' view as follows: def onchange_price_unit(self, cr, uid, ids, price_unit): return {'value': {'price_unit_copy': price_unit}} and finally modify the function 'fields_get' to set the attribute 'invisible' of the fields 'price_unit' and 'price_unit_copy' depending on the user is accessing. Unfortunately for this solution I need to modify the views so they include both fields, instead of the 'price_unit' field. Additionally this may not very secure since I am not forcing a check at write level, only in the view. This may be considered since I sometimes want to save things that are readonly, for example, in this case, I want the user to change the product associated with the order line (and this will change price_unit) but not to allow him to modify it manually. I don't consider using the attribute 'read' and 'write' of the fields because of the last consideration in the previous paragraph. Taking everything into consideration, there is some plan to include some field level permission tuning in the new OpenERP v7.0??? Is there any way to implement some module that can take this into account in a general way?? I don't know how this can be accomplished but I will spend my time developing something like that with some hints BR Damián Soriano _______________________________________________ Mailing list: https://launchpad.net/~openerp-expert-framework Post to : [email protected] Unsubscribe : https://launchpad.net/~openerp-expert-framework More help : https://help.launchpad.net/ListHelp

