From 55131b8f5becdd3d4776f4c3e7e4288a0b185706 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Fri, 28 Sep 2018 14:50:18 +0200 Subject: [REF] website, *: add automatic context for call_kw rpc * web_editor, website_blog, website_crm_partner_assign, website_links, website_livechat, website_mail_channel, website_mass_mailing, website_slides Calling a model's method thanks to an RPC will now always send the web_editor context automatically, making sure the method gets the website_id all the time, removing the need to guess the current website (now the get_current_website method uses the context website_id if any). Note: other routes already have the website_id via request.env.context if they correctly set website=True (this commit also adds website=True for scss files customization routes). --- .../static/src/js/website_mass_mailing.editor.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'addons/website_mass_mailing/static/src') diff --git a/addons/website_mass_mailing/static/src/js/website_mass_mailing.editor.js b/addons/website_mass_mailing/static/src/js/website_mass_mailing.editor.js index 9b69dedd7b5..bb85683b2a7 100644 --- a/addons/website_mass_mailing/static/src/js/website_mass_mailing.editor.js +++ b/addons/website_mass_mailing/static/src/js/website_mass_mailing.editor.js @@ -24,7 +24,7 @@ var mass_mailing_common = options.Class.extend({ model: 'mail.mass_mailing.list', method: 'name_search', args: ['', []], - context: weContext.get(), + context: weContext.get(), // TODO use this._rpc }); }, }); @@ -54,10 +54,10 @@ options.registry.newsletter_popup = mass_mailing_common.extend({ select_mailing_list: function (previewMode, value) { var self = this; return this._super(previewMode, value).then(function (mailing_list_id) { - ajax.jsonRpc('/web/dataset/call', 'call', { + self._rpc({ model: 'mail.mass_mailing.list', method: 'read', - args: [[parseInt(mailing_list_id)], ['popup_content'], weContext.get()], + args: [[parseInt(mailing_list_id)], ['popup_content']], }).then(function (data) { self.$target.find(".o_popup_content_dev").empty(); if (data && data[0].popup_content) { @@ -84,13 +84,12 @@ web_editor.Class.include({ } var content = $('#wrapwrap .o_popup_content_dev').html(); var newsletter_id = $target.parent().attr('data-list-id'); - ajax.jsonRpc('/web/dataset/call', 'call', { + this._rpc({ model: 'mail.mass_mailing.list', method: 'write', args: [ parseInt(newsletter_id), {'popup_content':content}, - weContext.get() ], }); } -- cgit v1.2.3