Quantcast
Channel: OpenERP Help - Individual question feed
Viewing all articles
Browse latest Browse all 6389

How to use python functions in view(xml)?

$
0
0
Hi, I am having a domain filter for object **res.partner** like the below in contacts_view.xml [('department_id','=',context.get('dept'))] I would like to do the following - Get the current user object (my res_user object has id & dept) - i would get the id from context as it's stored by default by session. i like to get the dept from the context I've tried this already from openerp.osv import fields,osv from openerp.tools.translate import _ from decimal import Context class res_partner(osv.osv): _name = "res.partner" _inherit = 'res.partner' def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): res = super(res_partner,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu) if context is None: context={} context.update({ 'dept': 1 }) res.update({ 'context' : context, }) return res res_partner() Still in the filter i am unable to get the dept value from context. How to get the department from the user object in xml? or how to use the python function in xml? This prob is really annoying me so much. Thanks a lot for your time.

Viewing all articles
Browse latest Browse all 6389

Trending Articles