From: Xavier Morel Date: Fri, 20 Jan 2012 11:05:43 +0000 (+0100) Subject: [ADD] support for 'domain' key in result of onchange handlers X-Git-Tag: 6.1.0-web~511 X-Git-Url: http://git.inspyration.org/?a=commitdiff_plain;h=ee0c76d2c5e19864ddc573dd39a6b606d31b244d;p=odoo%2Fodoo.git [ADD] support for 'domain' key in result of onchange handlers bzr revid: xmo@openerp.com-20120120110543-29ebq5u0ghp32hkv --- ee0c76d2c5e19864ddc573dd39a6b606d31b244d diff --cc addons/web/controllers/main.py index 261d77c,df3163d..7f5b43b --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@@ -838,6 -838,18 +838,36 @@@ class DataSet(openerpweb.Controller) return getattr(req.session.model(model), method)(*args, **kwargs) @openerpweb.jsonrequest + def onchange(self, req, model, method, args, context_id=None): ++ """ Support method for handling onchange calls: behaves much like call ++ with the following differences: ++ ++ * Does not take a domain_id ++ * Is aware of the return value's structure, and will parse the domains ++ if needed in order to return either parsed literal domains (in JSON) ++ or non-literal domain instances, allowing those domains to be used ++ from JS ++ ++ :param req: ++ :type req: web.common.http.JsonRequest ++ :param str model: object type on which to call the method ++ :param str method: name of the onchange handler method ++ :param list args: arguments to call the onchange handler with ++ :param int context_id: index of the context object in the list of ++ arguments ++ :return: result of the onchange call with all domains parsed ++ """ + result = self.call_common(req, model, method, args, context_id=context_id) + if 'domain' not in result: + return result + + result['domain'] = dict( + (k, parse_domain(v, req.session)) + for k, v in result['domain'].iteritems()) + + return result + + @openerpweb.jsonrequest def call(self, req, model, method, args, domain_id=None, context_id=None): return self.call_common(req, model, method, args, domain_id, context_id)