8000 [IMP] mail: move activity model to common · odoo/odoo@754e92a · GitHub
[go: up one dir, main page]

Skip to content

Commit 754e92a

Browse files
[IMP] mail: move activity model to common
Part-of: #189598 Related: odoo/enterprise#75172 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
1 parent bf7059f commit 754e92a

File tree

8 files changed

+189
-220
lines changed

8 files changed

+189
-220
lines changed

addons/calendar/static/src/activity/activity_model_patch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Activity } from "@mail/core/web/activity_model";
1+
import { Activity } from "@mail/core/common/activity_model";
22
import { assignIn } from "@mail/utils/common/misc";
33
import { patch } from "@web/core/utils/patch";
44

addons/mail/static/src/core/common/@types/models.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
declare module "models" {
2+
import { Activity as ActivityClass } from "@mail/core/common/activity_model";
23
import { Attachment as AttachmentClass } from "@mail/core/common/attachment_model";
34
import { CannedResponse as CannedResponseClass } from "@mail/core/common/canned_response_model";
45
import { ChatHub as ChatHubClass } from "@mail/core/common/chat_hub_model";
@@ -19,6 +20,7 @@ declare module "models" {
1920
import { Volume as VolumeClass } from "@mail/core/common/volume_model";
2021

2122
// define interfaces for jsdoc, including with patches
23+
export interface Activity extends ActivityClass {}
2224
export interface Attachment extends AttachmentClass {}
2325
export interface CannedResponse extends CannedResponseClass {}
2426
export interface ChatHub extends ChatHubClass {}
@@ -45,6 +47,7 @@ declare module "models" {
4547
"Composer": Composer,
4648
"Failure": Failure,
4749
"ir.attachment": Attachment,
50+
"mail.activity": Activity,
4851
"mail.canned.response": CannedResponse,
4952
"mail.followers": Follower,
5053
"mail.link.preview": LinkPreview,
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import { Record } from "@mail/core/common/record";
2+
import { assignDefined } from "@mail/utils/common/misc";
3+
4+
export class Activity extends Record {
5+
static name = "mail.activity";
6+
static id = "id";
7+
/** @type {Object.<number, import("models").Activity>} */
8+
static records = {};
9+
/** @returns {import("models").Activity} */
10+
static get(data) {
11+
return super.get(data);
12+
}
13+
/**
14+
* @template T
15+
* @param {T} data
16+
* @param {Object} [param1]
17+
* @param {boolean} param1.broadcast
18+
* @returns {T extends any[] ? import("models").Activity[] : import("models").Activity}
19+
*/
20+
static insert(data, { broadcast = true } = {}) {
21+
return super.insert(...arguments);
22+
}
23+
/**
24+
* @param {Object} data
25+
* @param {Object} [param1]
26+
* @param {boolean} param1.broadcast
27+
* @returns {import("models").Activity}
28+
*/
29+
static _insert(data, { broadcast = true } = {}) {
30+
/** @type {import("models").Activity} */
31+
const activity = this.preinsert(data);
32+
assignDefined(activity, data);
33+
if (broadcast) {
34+
this.store.activityBroadcastChannel?.postMessage({
35+
type: "INSERT",
36+
payload: activity.serialize(),
37+
});
38+
}
39+
return activity;
40+
}
41+
42+
/** @type {number} */
43+
id;
44+
/** @type {boolean} */
45+
active;
46+
/** @type {string} */
47+
activity_category;
48+
/** @type {[number, string]} */
49+
activity_type_id;
50+
/** @type {string|false} */
51+
activity_decoration;
52+
/** @type {Object[]} */
53+
attachment_ids;
54+
/** @type {boolean} */
55+
can_write;
56+
/** @type {'suggest'|'trigger'} */
57+
chaining_type;
58+
/** @type {luxon.DateTime} */
59+
create_date = Record.attr(undefined, { type: "datetime" });
60+
/** @type {[number, string]} */
61+
create_uid;
62+
/** @type {luxon.DateTime} */
63+
date_deadline = Record.attr(undefined, { type: "date" });
64+
/** @type {luxon.DateTime} */
65+
date_done = Record.attr(undefined, { type: "date" });
66+
/** @type {string} */
67+
display_name;
68+
/** @type {boolean} */
69+
has_recommended_activities;
70+
/** @type {string} */
71+
feedback;
72+
/** @type {string} */
73+
icon = "fa-tasks";
74+
/** @type {Object[]} */
75+
mail_template_ids;
76+
note = Record.attr("", { html: true });
77+
persona = Record.one("Persona");
78+
/** @type {number|false} */
79+
previous_activity_type_id;
80+
/** @type {number|false} */
81+
recommended_activity_type_id;
82+
/** @type {string} */
83+
res_model;
84+
/** @type {[number, string]} */
85+
res_model_id;
86+
/** @type {number} */
87+
res_id;
88+
/** @type {string} */
89+
res_name;
90+
/** @type {number|false} */
91+
request_partner_id;
92+
/** @type {'overdue'|'planned'|'today'} */
93+
state;
94+
/** @type {string} */
95+
summary;
96+
/** @type {[number, string]} */
97+
user_id;
98+
/** @type {string} */
99+
write_date;
100+
/** @type {[number, string]} */
101+
write_uid;
102+
}
103+
104+
Activity.register();

addons/mail/static/src/core/common/store_service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class Store extends BaseStore {
5353
Failure;
5454
/** @type {typeof import("@mail/core/common/attachment_model").Attachment} */
5555
["ir.attachment"];
56-
/** @type {typeof import("@mail/core/web/activity_model").Activity} */
56+
/** @type {typeof import("@mail/core/common/activity_model").Activity} */
5757
["mail.activity"];
5858
/** @type {typeof import("@mail/core/common/canned_response_model").CannedResponse} */
5959
["mail.canned.response"];
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
declare module "models" {
2-
import { Activity as ActivityClass } from "@mail/core/web/activity_model";
1+
import { DateTime } from "luxon";
32

4-
export interface Activity extends ActivityClass {}
3+
declare module "models" {
54
export interface Discuss {
65
inbox: Thread,
76
stared: Thread,
@@ -15,8 +14,4 @@ declare module "models" {
1514
export interface Thread {
1615
recipients: Follower[],
1716
}
18-
19-
export interface Models {
20-
"mail.activity": Activity,
21-
}
2217
}

addons/mail/static/src/core/web/activity_model.js

Lines changed: 0 additions & 210 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0