Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
Based on user particular Field readonly applied using field_view_get method
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): res = super(class_name,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu) if 'filed_name' in res['fields'] and uid!=1: res['fields']['filed_name']['readonly'] = True return res
The code worked in version 6.0.4 but in the latest version 7 not working. How to make works?...
Hi, This is solution for that.
from openerp.osv.orm import setup_modifiers def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): res = super(uma_stock_picking_in, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) if view_type == 'form': doc = etree.XML(res['arch']) for node in doc.xpath("//field[@name='min_date']"): node.set('readonly', "0") setup_modifiers(node, res['fields']['min_date']) res['arch'] = etree.tostring(doc) return res
You should notice function setup_modifiers if you want to set option in ['invisible', 'readonly'] because in version 7 when you set readonly or invisible it will generate the modifiers attribute to take care this.
About This Community
This platform 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.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 8/31/13, 10:06 AM|
|Seen: 6739 times|
|Last updated: 1/4/17, 5:00 AM|