xml - OpenERP - Compare fields using external id? -


is possible compare fields in views using external id (not internal one). need because need hide fields depending on fields. can make work using internal database id. if user chooses example country (in view checks countries id), if id matches in view compared, shows field. example this:

<field name="some_field"     attrs="{'invisible': [('country_id','!=',10)]}" /> 

this 1 works, not reliable. imagine if id change (for example installing module id taken other country), show some_field when different country chosen. , not intended. thought using external id, provide when adding data tables in xml files. id static , should same database install module (because id provided in module itself, not created database automatically). there way use same feature, using external id? of course maybe knows better approach solve such problem?

p.s. adding field boolean show hide some_field not option, because depends entirely on specific values added on module install.

you can use fields_view_get add functionality. example

def fields_view_get(self, cr, uid, view_id=none, view_type='form', context=none, toolbar=false, submenu=false):     if context none:context = {}     res = super(your_osv_class_name, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=false)     doc = etree.xml(res['arch'])     nodes = doc.xpath("//field[@name='some_field']")     id_found = self.pool.get('res.country').search(cr, uid,[('name','=','india')])[0]     #or try search id using external id     node in nodes:         node.set('attrs', "{'invisible':[('country_id','=',%s)]}"%id_found)         setup_modifiers(node, res['fields']['some_field'])     res['arch'] = etree.tostring(doc)     return res 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -