1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
odoo.define('mail/static/src/models/notification/notification.js', function (require) {
'use strict';
const { registerNewModel } = require('mail/static/src/model/model_core.js');
const { attr, many2one } = require('mail/static/src/model/model_field.js');
function factory(dependencies) {
class Notification extends dependencies['mail.model'] {
//----------------------------------------------------------------------
// Public
//----------------------------------------------------------------------
/**
* @static
* @param {Object} data
* @return {Object}
*/
static convertData(data) {
const data2 = {};
if ('failure_type' in data) {
data2.failure_type = data.failure_type;
}
if ('id' in data) {
data2.id = data.id;
}
if ('notification_status' in data) {
data2.notification_status = data.notification_status;
}
if ('notification_type' in data) {
data2.notification_type = data.notification_type;
}
if ('res_partner_id' in data) {
if (!data.res_partner_id) {
data2.partner = [['unlink-all']];
} else {
data2.partner = [
['insert', {
display_name: data.res_partner_id[1],
id: data.res_partner_id[0],
}],
];
}
}
return data2;
}
//----------------------------------------------------------------------
// Private
//----------------------------------------------------------------------
/**
* @override
*/
static _createRecordLocalId(data) {
return `${this.modelName}_${data.id}`;
}
}
Notification.fields = {
failure_type: attr(),
id: attr(),
message: many2one('mail.message', {
inverse: 'notifications',
}),
notification_status: attr(),
notification_type: attr(),
partner: many2one('mail.partner'),
};
Notification.modelName = 'mail.notification';
return Notification;
}
registerNewModel('mail.notification', factory);
});
|