[FIX] mail: keep context when sending a message
When sending a message through the chatter, the user context (including the language) is not sent to the server. This causes issues to render the mail templates in the appropriate language. closes odoo/odoo#29422
This commit is contained in:
@@ -3,6 +3,7 @@ odoo.define('mail.composer.Chatter', function (require) {
|
|||||||
|
|
||||||
var BasicComposer = require('mail.composer.Basic');
|
var BasicComposer = require('mail.composer.Basic');
|
||||||
var mailUtils = require('mail.utils');
|
var mailUtils = require('mail.utils');
|
||||||
|
var session = require('web.session');
|
||||||
|
|
||||||
var core = require('web.core');
|
var core = require('web.core');
|
||||||
var viewDialogs = require('web.view_dialogs');
|
var viewDialogs = require('web.view_dialogs');
|
||||||
@@ -195,7 +196,7 @@ var ChatterComposer = BasicComposer.extend({
|
|||||||
message = _.extend(message, {
|
message = _.extend(message, {
|
||||||
subtype: 'mail.mt_comment',
|
subtype: 'mail.mt_comment',
|
||||||
message_type: 'comment',
|
message_type: 'comment',
|
||||||
context: self.context,
|
context: _.defaults({}, self.context, session.user_context),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Subtype
|
// Subtype
|
||||||
|
|||||||
@@ -1451,6 +1451,55 @@ QUnit.test('chatter: Attachment viewer', function (assert) {
|
|||||||
form.destroy();
|
form.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QUnit.test('chatter: keep context when sending a message', function(assert) {
|
||||||
|
assert.expect(1);
|
||||||
|
var form = createView({
|
||||||
|
View: FormView,
|
||||||
|
model: 'partner',
|
||||||
|
data: this.data,
|
||||||
|
services: this.services,
|
||||||
|
arch: '<form string="Partners">' +
|
||||||
|
'<sheet>' +
|
||||||
|
'<field name="foo"/>' +
|
||||||
|
'</sheet>' +
|
||||||
|
'<div class="oe_chatter">' +
|
||||||
|
'<field name="message_ids" widget="mail_thread"/>' +
|
||||||
|
'</div>' +
|
||||||
|
'</form>',
|
||||||
|
res_id: 2,
|
||||||
|
session: {
|
||||||
|
user_context: {lang: 'en_US'},
|
||||||
|
},
|
||||||
|
mockRPC: function (route, args) {
|
||||||
|
if (args.method === 'message_get_suggested_recipients') {
|
||||||
|
return $.when({2: []});
|
||||||
|
}
|
||||||
|
if (args.method === 'message_post') {
|
||||||
|
assert.deepEqual(args.kwargs.context, {
|
||||||
|
default_model: "partner",
|
||||||
|
default_res_id: 2,
|
||||||
|
lang: "en_US",
|
||||||
|
mail_post_autofollow: true,
|
||||||
|
},
|
||||||
|
"the context is incorrect");
|
||||||
|
return $.when(57923);
|
||||||
|
}
|
||||||
|
if (args.method === 'message_format') {
|
||||||
|
return $.when([{
|
||||||
|
author_id: [42, "Me"],
|
||||||
|
model: 'partner',
|
||||||
|
}]);
|
||||||
|
}
|
||||||
|
return this._super(route, args);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
testUtils.dom.click(form.$('.o_chatter_button_new_message'));
|
||||||
|
testUtils.fields.editInput(form.$('.oe_chatter .o_composer_text_field:first()'), 'Pouet');
|
||||||
|
testUtils.dom.click(form.$('.oe_chatter .o_composer_button_send'));
|
||||||
|
form.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
QUnit.test('form activity widget: read RPCs', function (assert) {
|
QUnit.test('form activity widget: read RPCs', function (assert) {
|
||||||
// Records of model 'mail.activity' may be updated in business flows (e.g.
|
// Records of model 'mail.activity' may be updated in business flows (e.g.
|
||||||
// the date of a 'Meeting' activity is updated when the associated meeting
|
// the date of a 'Meeting' activity is updated when the associated meeting
|
||||||
|
|||||||
Reference in New Issue
Block a user