Files
odoo_source/addons/im_livechat/static/src/models/partner.js
T
Louis Wicket (wil) e16976ddfc [IMP] mail, *: move up model files
Move model definition files from `models/thing/thing.js` to
`models/thing.js` and remove the now empty intermediate directory.

Task-2759582
 * = calendar, crm_livechat, hr, im_livechat, mail_bot, sms, snailmail,
     website_livechat, website_slides

closes odoo/odoo#86464

Related: odoo/enterprise#25291
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2022-03-17 11:27:59 +01:00

43 lines
1.2 KiB
JavaScript

/** @odoo-module **/
import { addFields, addModelMethods, patchModelMethods } from '@mail/model/model_core';
import { attr } from '@mail/model/model_field';
// ensure that the model definition is loaded before the patch
import '@mail/models/partner';
let nextPublicId = -1;
addModelMethods('Partner', {
getNextPublicId() {
const id = nextPublicId;
nextPublicId -= 1;
return id;
},
});
patchModelMethods('Partner', {
convertData(data) {
const data2 = this._super(data);
if ('livechat_username' in data) {
// flux specific, if livechat username is present it means `name`,
// `email` and `im_status` contain `false` even though their value
// might actually exist. Remove them from data2 to avoid overwriting
// existing value (that could be known through other means).
delete data2.name;
delete data2.email;
delete data2.im_status;
data2.livechat_username = data.livechat_username;
}
return data2;
},
});
addFields('Partner', {
/**
* States the specific name of this partner in the context of livechat.
* Either a string or undefined.
*/
livechat_username: attr(),
});