[IMP] website_livechat: better field naming for visitor in channel_info
task-2345866 closes odoo/odoo#59848 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
@@ -33,13 +33,13 @@ class MailChannel(models.Model):
|
||||
visitor = channel.livechat_visitor_id
|
||||
if visitor:
|
||||
channel_infos_dict[channel.id]['visitor'] = {
|
||||
'name': visitor.display_name,
|
||||
'display_name': visitor.display_name,
|
||||
'country_code': visitor.country_id.code.lower() if visitor.country_id else False,
|
||||
'country_id': visitor.country_id.id,
|
||||
'is_connected': visitor.is_connected,
|
||||
'history': self.sudo()._get_visitor_history(visitor),
|
||||
'website': visitor.website_id.name,
|
||||
'lang': visitor.lang_id.name,
|
||||
'website_name': visitor.website_id.name,
|
||||
'lang_name': visitor.lang_id.name,
|
||||
'partner_id': visitor.partner_id.id,
|
||||
}
|
||||
return list(channel_infos_dict.values())
|
||||
|
||||
@@ -42,8 +42,8 @@ QUnit.test('rendering of visitor banner', async function (assert) {
|
||||
display_name: 'Visitor #11',
|
||||
history: 'Home → Contact',
|
||||
is_connected: true,
|
||||
lang: "English",
|
||||
website: "General website",
|
||||
lang_name: "English",
|
||||
website_name: "General website",
|
||||
});
|
||||
this.data['mail.channel'].records.push({
|
||||
channel_type: 'livechat',
|
||||
@@ -139,8 +139,8 @@ QUnit.test('livechat with non-logged visitor should show visitor banner', async
|
||||
display_name: 'Visitor #11',
|
||||
history: 'Home → Contact',
|
||||
is_connected: true,
|
||||
lang: "English",
|
||||
website: "General website",
|
||||
lang_name: "English",
|
||||
website_name: "General website",
|
||||
});
|
||||
this.data['mail.channel'].records.push({
|
||||
channel_type: 'livechat',
|
||||
@@ -180,9 +180,9 @@ QUnit.test('livechat with logged visitor should show visitor banner', async func
|
||||
display_name: 'Visitor #11',
|
||||
history: 'Home → Contact',
|
||||
is_connected: true,
|
||||
lang: "English",
|
||||
lang_name: "English",
|
||||
partner_id: 12,
|
||||
website: "General website",
|
||||
website_name: "General website",
|
||||
});
|
||||
this.data['mail.channel'].records.push({
|
||||
channel_type: 'livechat',
|
||||
|
||||
@@ -18,12 +18,12 @@
|
||||
<span class="o_VisitorBanner_visitor" t-esc="visitor.nameOrDisplayName"/>
|
||||
<span class="o_VisitorBanner_language">
|
||||
<i class="o_VisitorBanner_languageIcon fa fa-comment-o" aria-label="Lang"/>
|
||||
<t t-esc="visitor.lang"/>
|
||||
<t t-esc="visitor.lang_name"/>
|
||||
</span>
|
||||
<t t-if="visitor.website">
|
||||
<t t-if="visitor.website_name">
|
||||
<span class="o_VisitorBanner_website">
|
||||
<i class="o_VisitorBanner_websiteIcon fa fa-globe" aria-label="Website"/>
|
||||
<span t-esc="visitor.website"/>
|
||||
<span t-esc="visitor.website_name"/>
|
||||
</span>
|
||||
</t>
|
||||
<div class="o_VisitorBanner_history">
|
||||
|
||||
+1
-1
@@ -39,8 +39,8 @@ QUnit.test('should open chat window on send chat request to website visitor', as
|
||||
assert.expect(3);
|
||||
|
||||
this.data['website.visitor'].records.push({
|
||||
display_name: "Visitor #11",
|
||||
id: 11,
|
||||
name: "Visitor #11",
|
||||
});
|
||||
await this.start({
|
||||
data: this.data,
|
||||
|
||||
@@ -32,11 +32,11 @@ function factory(dependencies) {
|
||||
if ('is_connected' in data) {
|
||||
data2.is_connected = data.is_connected;
|
||||
}
|
||||
if ('lang' in data) {
|
||||
data2.lang = data.lang;
|
||||
if ('lang_name' in data) {
|
||||
data2.lang_name = data.lang_name;
|
||||
}
|
||||
if ('name' in data) {
|
||||
data2.name = data.name;
|
||||
if ('display_name' in data) {
|
||||
data2.display_name = data.display_name;
|
||||
}
|
||||
if ('partner_id' in data) {
|
||||
if (data.partner_id) {
|
||||
@@ -45,8 +45,8 @@ function factory(dependencies) {
|
||||
data2.partner = [['unlink']];
|
||||
}
|
||||
}
|
||||
if ('website' in data) {
|
||||
data2.website = data.website;
|
||||
if ('website_name' in data) {
|
||||
data2.website_name = data.website_name;
|
||||
}
|
||||
return data2;
|
||||
}
|
||||
@@ -88,7 +88,7 @@ function factory(dependencies) {
|
||||
if (this.partner) {
|
||||
return this.partner.nameOrDisplayName;
|
||||
}
|
||||
return this.name;
|
||||
return this.display_name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,6 +113,10 @@ function factory(dependencies) {
|
||||
'partnerCountry',
|
||||
],
|
||||
}),
|
||||
/**
|
||||
* Display name of the visitor.
|
||||
*/
|
||||
display_name: attr(),
|
||||
/**
|
||||
* Browsing history of the visitor as a string.
|
||||
*/
|
||||
@@ -124,15 +128,11 @@ function factory(dependencies) {
|
||||
/**
|
||||
* Name of the language of the visitor. (Ex: "English")
|
||||
*/
|
||||
lang: attr(),
|
||||
/**
|
||||
* Name of the visitor.
|
||||
*/
|
||||
name: attr(),
|
||||
lang_name: attr(),
|
||||
nameOrDisplayName: attr({
|
||||
compute: '_computeNameOrDisplayName',
|
||||
dependencies: [
|
||||
'name',
|
||||
'display_name',
|
||||
'partnerNameOrDisplayName',
|
||||
],
|
||||
}),
|
||||
@@ -156,7 +156,7 @@ function factory(dependencies) {
|
||||
/**
|
||||
* Name of the website on which the visitor is connected. (Ex: "Website 1")
|
||||
*/
|
||||
website: attr(),
|
||||
website_name: attr(),
|
||||
};
|
||||
|
||||
Visitor.modelName = 'website_livechat.visitor';
|
||||
|
||||
@@ -26,9 +26,9 @@ MockModels.patch('website_livechat/static/tests/helpers/mock_models.js', T =>
|
||||
// This should normally not be a field.
|
||||
history: { string: "History", type: 'string'},
|
||||
is_connected: { string: "Is connected", type: 'boolean' },
|
||||
lang: { string: "Language", type: 'string'},
|
||||
lang_name: { string: "Language name", type: 'string'},
|
||||
partner_id: {string: "partner", type: "many2one", relation: 'res.partner'},
|
||||
website: { string: "Website", type: 'string' },
|
||||
website_name: { string: "Website name", type: 'string' },
|
||||
},
|
||||
records: [],
|
||||
},
|
||||
|
||||
@@ -30,14 +30,14 @@ MockServer.include({
|
||||
const visitor = this._getRecords('website.visitor', [['id', '=', channelInfo.livechat_visitor_id]])[0];
|
||||
const country = this._getRecords('res.country', [['id', '=', visitor.country_id]])[0];
|
||||
channelInfo.visitor = {
|
||||
name: visitor.display_name,
|
||||
country_code: country && country.code,
|
||||
country_id: country && country.id,
|
||||
is_connected: visitor.is_connected,
|
||||
display_name: visitor.display_name,
|
||||
history: visitor.history, // TODO should be computed
|
||||
website: visitor.website,
|
||||
lang: visitor.lang,
|
||||
is_connected: visitor.is_connected,
|
||||
lang_name: visitor.lang_name,
|
||||
partner_id: visitor.partner_id,
|
||||
website_name: visitor.website_name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user