From 0955eb0a8471f78dbfedd703e5c32a3038784645 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?=
Date: Wed, 20 Mar 2024 13:52:28 +0100
Subject: [PATCH] [MIG] mail_activity_plan: Migration to 16.0
TT48098
---
mail_activity_plan/README.rst | 12 +--
mail_activity_plan/__manifest__.py | 4 +-
.../static/description/index.html | 9 +-
.../static/src/js/mail_activity_plan.esm.js | 95 +++++++++++++++++++
.../static/src/js/mail_activity_plan.js | 67 -------------
.../tests/test_mail_activity_plan.py | 16 +---
6 files changed, 112 insertions(+), 91 deletions(-)
create mode 100644 mail_activity_plan/static/src/js/mail_activity_plan.esm.js
delete mode 100644 mail_activity_plan/static/src/js/mail_activity_plan.js
diff --git a/mail_activity_plan/README.rst b/mail_activity_plan/README.rst
index d66aa1c321..77dba3d371 100644
--- a/mail_activity_plan/README.rst
+++ b/mail_activity_plan/README.rst
@@ -7,7 +7,7 @@ Mail activity plan
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- !! source digest: sha256:ef0f39ca052a255455cd55b617ae72f2cfbc5d5a1810f73dd081c00c61f0bcd8
+ !! source digest: sha256:72b1f01ff803c46c44584bbf0c9daebdc530d4b095e410d3fa4abef26586e7a7
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@@ -17,13 +17,13 @@ Mail activity plan
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github
- :target: https://github.com/OCA/social/tree/15.0/mail_activity_plan
+ :target: https://github.com/OCA/social/tree/16.0/mail_activity_plan
:alt: OCA/social
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/social-15-0/social-15-0-mail_activity_plan
+ :target: https://translation.odoo-community.org/projects/social-16-0/social-16-0-mail_activity_plan
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
- :target: https://runboat.odoo-community.org/builds?repo=OCA/social&target_branch=15.0
+ :target: https://runboat.odoo-community.org/builds?repo=OCA/social&target_branch=16.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -60,7 +60,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues `_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
-`feedback `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -101,6 +101,6 @@ Current `maintainer `__:
|maintainer-victoralmau|
-This module is part of the `OCA/social `_ project on GitHub.
+This module is part of the `OCA/social `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/mail_activity_plan/__manifest__.py b/mail_activity_plan/__manifest__.py
index cb5b373dbc..a4f1546885 100644
--- a/mail_activity_plan/__manifest__.py
+++ b/mail_activity_plan/__manifest__.py
@@ -2,7 +2,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Mail activity plan",
- "version": "15.0.1.0.1",
+ "version": "16.0.1.0.0",
"category": "Social Network",
"website": "https://github.com/OCA/social",
"author": "Tecnativa, Odoo Community Association (OCA)",
@@ -18,7 +18,7 @@
"demo": ["demo/mail_activity_plan_demo.xml"],
"assets": {
"web.assets_backend": [
- "mail_activity_plan/static/src/js/mail_activity_plan.js",
+ "mail_activity_plan/static/src/js/mail_activity_plan.esm.js",
],
},
"maintainers": ["victoralmau"],
diff --git a/mail_activity_plan/static/description/index.html b/mail_activity_plan/static/description/index.html
index d495aa7df5..310dd5372c 100644
--- a/mail_activity_plan/static/description/index.html
+++ b/mail_activity_plan/static/description/index.html
@@ -1,3 +1,4 @@
+
@@ -366,9 +367,9 @@ Mail activity plan
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!! source digest: sha256:ef0f39ca052a255455cd55b617ae72f2cfbc5d5a1810f73dd081c00c61f0bcd8
+!! source digest: sha256:72b1f01ff803c46c44584bbf0c9daebdc530d4b095e410d3fa4abef26586e7a7
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-
![Try me on Runboat](https://img.shields.io/badge/runboat-Try%20me-875A7B.png)
+
![Try me on Runboat](https://img.shields.io/badge/runboat-Try%20me-875A7B.png)
This module allows to define activity plans linked to any document type that allows to
plan activities, and later launch them from the documents.
Table of contents
@@ -407,7 +408,7 @@
Bugs are tracked on GitHub Issues.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
-feedback.
+feedback.
Do not contact contributors directly about support or help with technical issues.
diff --git a/mail_activity_plan/static/src/js/mail_activity_plan.esm.js b/mail_activity_plan/static/src/js/mail_activity_plan.esm.js
new file mode 100644
index 0000000000..6e51663ec1
--- /dev/null
+++ b/mail_activity_plan/static/src/js/mail_activity_plan.esm.js
@@ -0,0 +1,95 @@
+/** @odoo-module **/
+
+import {FormController} from "@web/views/form/form_controller";
+import {ListController} from "@web/views/list/list_controller";
+import {onWillStart} from "@odoo/owl";
+import {useService} from "@web/core/utils/hooks";
+import {_lt} from "@web/core/l10n/translation";
+import {patch} from "@web/core/utils/patch";
+
+patch(FormController.prototype, "mail_activity_plan.FormControllerPatch", {
+ async _actionWizardMailActivityPlan() {
+ this.actionService.doAction(
+ "mail_activity_plan.action_wizard_mail_activity_plan",
+ {
+ additionalContext: {
+ default_res_model: this.props.resModel,
+ active_ids: [this.props.resId],
+ },
+ on_close: () => {
+ this.update({}, {reload: false});
+ },
+ }
+ );
+ },
+ setup() {
+ this._super();
+ this.actionService = useService("action");
+ this.orm = useService("orm");
+ onWillStart(async () => {
+ await this._showWizardMailActivityPlan();
+ });
+ },
+ async _showWizardMailActivityPlan() {
+ const planCount = await this.orm.call(
+ "mail.activity.plan",
+ "get_total_plans_from_model",
+ [this.props.resModel]
+ );
+ this.showWizardMailActivityPlan = planCount !== 0;
+ },
+ getActionMenuItems() {
+ const actionMenus = this._super();
+ if (actionMenus && this.showWizardMailActivityPlan) {
+ actionMenus.other.push({
+ description: _lt("Launch Activity Plan"),
+ callback: () => this._actionWizardMailActivityPlan(),
+ });
+ }
+ return actionMenus;
+ },
+});
+
+patch(ListController.prototype, "mail_activity_plan", {
+ async _actionWizardMailActivityPlan() {
+ const resIds = await this.getSelectedResIds();
+ this.actionService.doAction(
+ "mail_activity_plan.action_wizard_mail_activity_plan",
+ {
+ additionalContext: {
+ default_res_model: this.props.resModel,
+ active_ids: resIds,
+ },
+ on_close: () => {
+ this.update({}, {reload: false});
+ },
+ }
+ );
+ },
+ setup() {
+ this._super();
+ this.actionService = useService("action");
+ this.orm = useService("orm");
+ onWillStart(async () => {
+ await this._showWizardMailActivityPlan();
+ });
+ },
+ async _showWizardMailActivityPlan() {
+ const planCount = await this.orm.call(
+ "mail.activity.plan",
+ "get_total_plans_from_model",
+ [this.props.resModel]
+ );
+ this.showWizardMailActivityPlan = planCount !== 0;
+ },
+ getActionMenuItems() {
+ const actionMenus = this._super();
+ if (actionMenus && this.showWizardMailActivityPlan) {
+ actionMenus.other.push({
+ description: _lt("Launch Activity Plan"),
+ callback: () => this._actionWizardMailActivityPlan(),
+ });
+ }
+ return actionMenus;
+ },
+});
diff --git a/mail_activity_plan/static/src/js/mail_activity_plan.js b/mail_activity_plan/static/src/js/mail_activity_plan.js
deleted file mode 100644
index 979c482667..0000000000
--- a/mail_activity_plan/static/src/js/mail_activity_plan.js
+++ /dev/null
@@ -1,67 +0,0 @@
-odoo.define("mail_activity_plan.mail_activity_plan", function (require) {
- "use strict";
-
- const ListController = require("web.ListController");
- const FormController = require("web.FormController");
- var core = require("web.core");
- var _t = core._t;
-
- const MailActivityPlanExtension = {
- _showWizardMailActivityPlan: function () {
- return this._rpc({
- model: "mail.activity.plan",
- method: "get_total_plans_from_model",
- args: [this.modelName],
- }).then((planCount) => {
- this.showWizardMailActivityPlan = planCount !== 0;
- });
- },
- willStart: function () {
- return Promise.all([
- this._super.apply(this, arguments),
- this._showWizardMailActivityPlan(),
- ]);
- },
- _getActionMenuItems: function () {
- var menuItems = this._super.apply(this, arguments);
- if (menuItems && this.showWizardMailActivityPlan) {
- menuItems.items.other.push({
- description: _t("Launch Activity Plan"),
- callback: () => this._actionWizardMailActivityPlan(),
- });
- }
- return menuItems;
- },
- };
- ListController.include(MailActivityPlanExtension);
- FormController.include(MailActivityPlanExtension);
-
- ListController.include({
- async _actionWizardMailActivityPlan() {
- const state = this.model.get(this.handle);
- const resIds = await this.getSelectedIdsWithDomain();
- this.do_action("mail_activity_plan.action_wizard_mail_activity_plan", {
- additional_context: {
- default_res_model: state.model,
- active_ids: resIds,
- },
- on_close: () => {
- this.update({}, {reload: false});
- },
- });
- },
- });
- FormController.include({
- async _actionWizardMailActivityPlan() {
- this.do_action("mail_activity_plan.action_wizard_mail_activity_plan", {
- additional_context: {
- default_res_model: this.modelName,
- active_ids: this.model.localIdsToResIds([this.handle]),
- },
- on_close: () => {
- this.update({}, {reload: false});
- },
- });
- },
- });
-});
diff --git a/mail_activity_plan/tests/test_mail_activity_plan.py b/mail_activity_plan/tests/test_mail_activity_plan.py
index 64827f4f74..9c18ec957f 100644
--- a/mail_activity_plan/tests/test_mail_activity_plan.py
+++ b/mail_activity_plan/tests/test_mail_activity_plan.py
@@ -2,24 +2,16 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.exceptions import UserError
-from odoo.tests import Form, common, new_test_user
+from odoo.tests import Form, new_test_user
from odoo.tests.common import users
+from odoo.addons.base.tests.common import BaseCommon
-class TestMailActivityPlan(common.TransactionCase):
+
+class TestMailActivityPlan(BaseCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
- cls.env = cls.env(
- context=dict(
- cls.env.context,
- mail_create_nolog=True,
- mail_create_nosubscribe=True,
- mail_notrack=True,
- no_reset_password=True,
- tracking_disable=True,
- )
- )
cls.user_plan = new_test_user(
cls.env,
login="test_user_plan",