diff options
| author | Raphael Collet <rco@openerp.com> | 2016-08-05 12:42:00 +0200 |
|---|---|---|
| committer | Raphael Collet <rco@openerp.com> | 2016-08-31 17:21:55 +0200 |
| commit | 16696b2a05529a7cd3d4b9e20ee89a575f3cd9e2 (patch) | |
| tree | f9a16a07f8858f83985a60562f270993363028f3 /addons/web | |
| parent | 604a1c5fcd00674e841f073570979c4c6e5ab621 (diff) | |
[FIX] openerp, web: make `execute` and `call_kw` invoke methods in the new API
Also refactor the test to prevent private methods to be remotely called.
Diffstat (limited to 'addons/web')
| -rw-r--r-- | addons/web/controllers/main.py | 9 | ||||
| -rw-r--r-- | addons/web/static/src/js/web_client.js | 7 |
2 files changed, 8 insertions, 8 deletions
diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index b479f6d97a9..3fcd074aeb0 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -27,7 +27,7 @@ from cStringIO import StringIO import odoo import odoo.modules.registry -from odoo.api import Environment +from odoo.api import call_kw, Environment from odoo.modules import get_resource_path from odoo.tools import topological_sort from odoo.tools.translate import _ @@ -35,6 +35,7 @@ from odoo.tools.misc import str2bool, xlwt from odoo import http from odoo.http import request, serialize_exception as _serialize_exception, content_disposition from odoo.exceptions import AccessError +from odoo.models import check_method_name _logger = logging.getLogger(__name__) @@ -840,10 +841,8 @@ class DataSet(http.Controller): return self._call_kw(model, method, args, {}) def _call_kw(self, model, method, args, kwargs): - if method.startswith('_'): - raise AccessError(_("Underscore prefixed methods cannot be remotely called")) - - return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs) + check_method_name(method) + return call_kw(request.env[model], method, args, kwargs) @http.route('/web/dataset/call', type='json', auth="user") def call(self, model, method, args, domain_id=None, context_id=None): diff --git a/addons/web/static/src/js/web_client.js b/addons/web/static/src/js/web_client.js index 5fc1f3f2796..c6033d6cbad 100644 --- a/addons/web/static/src/js/web_client.js +++ b/addons/web/static/src/js/web_client.js @@ -67,9 +67,9 @@ return AbstractWebClient.extend({ logo_edit: function(ev) { var self = this; ev.preventDefault(); - self.alive(new Model("res.users").get_func("read")(session.uid, ["company_id"])).then(function(res) { + self.alive(new Model("res.users").call("read", [[session.uid], ["company_id"]])).then(function(data) { self.rpc("/web/action/load", { action_id: "base.action_res_company_form" }).done(function(result) { - result.res_id = res.company_id[0]; + result.res_id = data[0].company_id[0]; result.target = "new"; result.views = [[false, 'form']]; result.flags = { @@ -94,7 +94,8 @@ return AbstractWebClient.extend({ var state = $.bbq.getState(true); if (_.isEmpty(state) || state.action === "login") { self.menu.is_bound.done(function() { - new Model("res.users").call("read", [session.uid, ["action_id"]]).done(function(data) { + new Model("res.users").call("read", [[session.uid], ["action_id"]]).done(function(result) { + var data = result[0]; if(data.action_id) { self.action_manager.do_action(data.action_id[0]); self.menu.open_action(data.action_id[0]); |
