From 034f4c6dd9ebce18127652446b40c66beb1be275 Mon Sep 17 00:00:00 2001 From: Carolina Fernandez Date: Mon, 15 Jan 2024 11:17:08 -0300 Subject: [PATCH] [15.0][IMP] resource_booking: New activity type for resource booking TT47152 --- resource_booking/README.rst | 2 +- resource_booking/__manifest__.py | 4 +- resource_booking/data/mail_data.xml | 10 ++ resource_booking/i18n/ca.po | 23 ++++ resource_booking/i18n/es.po | 23 ++++ resource_booking/i18n/fr.po | 23 ++++ resource_booking/i18n/fr_FR.po | 23 ++++ resource_booking/i18n/resource_booking.pot | 23 ++++ resource_booking/models/__init__.py | 1 + resource_booking/models/mail_activity.py | 58 +++++++++ resource_booking/models/resource_booking.py | 15 +++ .../static/description/index.html | 3 +- resource_booking/tests/test_backend.py | 112 +++++++++++++++++- .../views/mail_activity_views.xml | 45 +++++++ 14 files changed, 361 insertions(+), 4 deletions(-) create mode 100644 resource_booking/data/mail_data.xml create mode 100644 resource_booking/models/mail_activity.py create mode 100644 resource_booking/views/mail_activity_views.xml diff --git a/resource_booking/README.rst b/resource_booking/README.rst index 01881ec2..e112e8f2 100644 --- a/resource_booking/README.rst +++ b/resource_booking/README.rst @@ -7,7 +7,7 @@ Resource booking !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:1b5ee844dde4d92ddebc83454b46b058b45fddf1013e7ee6d17c187c15b74318 + !! source digest: sha256:8e2f6eac36cdf41491fa095fba459dcbfcb8d523de9740ae5158a171d5a9351d !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png diff --git a/resource_booking/__manifest__.py b/resource_booking/__manifest__.py index 830817fc..fea573cc 100644 --- a/resource_booking/__manifest__.py +++ b/resource_booking/__manifest__.py @@ -6,7 +6,7 @@ { "name": "Resource booking", "summary": "Manage appointments and resource booking", - "version": "15.0.1.4.2", + "version": "15.0.1.5.2", "development_status": "Production/Stable", "category": "Appointments", "website": "https://github.com/OCA/calendar", @@ -30,10 +30,12 @@ ], "data": [ "data/mail.xml", + "data/mail_data.xml", "security/resource_booking_security.xml", "security/ir.model.access.csv", "templates/portal.xml", "views/calendar_event_views.xml", + "views/mail_activity_views.xml", "views/resource_booking_combination_views.xml", "views/resource_booking_type_views.xml", "views/resource_booking_views.xml", diff --git a/resource_booking/data/mail_data.xml b/resource_booking/data/mail_data.xml new file mode 100644 index 00000000..ce9d01c5 --- /dev/null +++ b/resource_booking/data/mail_data.xml @@ -0,0 +1,10 @@ + + + + resource_booking + Resource Booking + fa-users + 11 + 1000 + + diff --git a/resource_booking/i18n/ca.po b/resource_booking/i18n/ca.po index ca776fd7..45701366 100644 --- a/resource_booking/i18n/ca.po +++ b/resource_booking/i18n/ca.po @@ -499,6 +499,12 @@ msgstr "" msgid "Duration:" msgstr "" +#. module: resource_booking +#: code:addons/resource_booking/models/mail_activity.py:0 +#, python-format +msgid "Feedback: %(feedback)s" +msgstr "" + #. module: resource_booking #: model:ir.model.fields,field_description:resource_booking.field_resource_booking__message_follower_ids #: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__message_follower_ids @@ -762,6 +768,17 @@ msgstr "" msgid "Next Activity Deadline" msgstr "" +#. module: resource_booking +#: model:ir.model.fields,field_description:resource_booking.field_mail_activity_mixin__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_product_product__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_product_template__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_res_partner__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_res_users__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_resource_booking__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__activity_booking_id +msgid "Next Activity Resource Booking" +msgstr "" + #. module: resource_booking #: model:ir.model.fields,field_description:resource_booking.field_resource_booking__activity_summary #: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__activity_summary @@ -825,6 +842,11 @@ msgstr "" msgid "Only one event per resource booking can exist." msgstr "" +#. module: resource_booking +#: model_terms:ir.ui.view,arch_db:resource_booking.mail_activity_view_form_popup +msgid "Open Resource Booking" +msgstr "" + #. module: resource_booking #: model_terms:ir.ui.view,arch_db:resource_booking.resource_booking_form msgid "Open a calendar to schedule a meeting for this booking request." @@ -884,6 +906,7 @@ msgstr "" #. module: resource_booking #: model:ir.model,name:resource_booking.model_resource_booking #: model:ir.module.category,name:resource_booking.category_resource_booking +#: model:mail.activity.type,name:resource_booking.mail_activity_data_resource_booking msgid "Resource Booking" msgstr "" diff --git a/resource_booking/i18n/es.po b/resource_booking/i18n/es.po index a07281bc..852b0173 100644 --- a/resource_booking/i18n/es.po +++ b/resource_booking/i18n/es.po @@ -517,6 +517,12 @@ msgstr "La duración debe ser positiva." msgid "Duration:" msgstr "Duración:" +#. module: resource_booking +#: code:addons/resource_booking/models/mail_activity.py:0 +#, python-format +msgid "Feedback: %(feedback)s" +msgstr "Retroalimentación: %(feedback)s" + #. module: resource_booking #: model:ir.model.fields,field_description:resource_booking.field_resource_booking__message_follower_ids #: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__message_follower_ids @@ -781,6 +787,17 @@ msgstr "" msgid "Next Activity Deadline" msgstr "Fecha límite de siguiente actividad" +#. module: resource_booking +#: model:ir.model.fields,field_description:resource_booking.field_mail_activity_mixin__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_product_product__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_product_template__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_res_partner__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_res_users__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_resource_booking__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__activity_booking_id +msgid "Next Activity Resource Booking" +msgstr "Siguiente actividad de reserva de recursos" + #. module: resource_booking #: model:ir.model.fields,field_description:resource_booking.field_resource_booking__activity_summary #: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__activity_summary @@ -844,6 +861,11 @@ msgstr "Número de mensajes no leídos" msgid "Only one event per resource booking can exist." msgstr "Solo puede existir un evento por reserva de recursos." +#. module: resource_booking +#: model_terms:ir.ui.view,arch_db:resource_booking.mail_activity_view_form_popup +msgid "Open Resource Booking" +msgstr "Abrir una reserva de recursos" + #. module: resource_booking #: model_terms:ir.ui.view,arch_db:resource_booking.resource_booking_form msgid "Open a calendar to schedule a meeting for this booking request." @@ -910,6 +932,7 @@ msgstr "Aviso al solicitante" #. module: resource_booking #: model:ir.model,name:resource_booking.model_resource_booking #: model:ir.module.category,name:resource_booking.category_resource_booking +#: model:mail.activity.type,name:resource_booking.mail_activity_data_resource_booking msgid "Resource Booking" msgstr "Reserva de recursos" diff --git a/resource_booking/i18n/fr.po b/resource_booking/i18n/fr.po index 072fdab5..14848dc7 100644 --- a/resource_booking/i18n/fr.po +++ b/resource_booking/i18n/fr.po @@ -493,6 +493,12 @@ msgstr "" msgid "Duration:" msgstr "" +#. module: resource_booking +#: code:addons/resource_booking/models/mail_activity.py:0 +#, python-format +msgid "Feedback: %(feedback)s" +msgstr "" + #. module: resource_booking #: model:ir.model.fields,field_description:resource_booking.field_resource_booking__message_follower_ids #: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__message_follower_ids @@ -756,6 +762,17 @@ msgstr "" msgid "Next Activity Deadline" msgstr "" +#. module: resource_booking +#: model:ir.model.fields,field_description:resource_booking.field_mail_activity_mixin__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_product_product__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_product_template__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_res_partner__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_res_users__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_resource_booking__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__activity_booking_id +msgid "Next Activity Resource Booking" +msgstr "" + #. module: resource_booking #: model:ir.model.fields,field_description:resource_booking.field_resource_booking__activity_summary #: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__activity_summary @@ -819,6 +836,11 @@ msgstr "" msgid "Only one event per resource booking can exist." msgstr "" +#. module: resource_booking +#: model_terms:ir.ui.view,arch_db:resource_booking.mail_activity_view_form_popup +msgid "Open Resource Booking" +msgstr "" + #. module: resource_booking #: model_terms:ir.ui.view,arch_db:resource_booking.resource_booking_form msgid "Open a calendar to schedule a meeting for this booking request." @@ -878,6 +900,7 @@ msgstr "" #. module: resource_booking #: model:ir.model,name:resource_booking.model_resource_booking #: model:ir.module.category,name:resource_booking.category_resource_booking +#: model:mail.activity.type,name:resource_booking.mail_activity_data_resource_booking msgid "Resource Booking" msgstr "" diff --git a/resource_booking/i18n/fr_FR.po b/resource_booking/i18n/fr_FR.po index c3065d35..c2abd67f 100644 --- a/resource_booking/i18n/fr_FR.po +++ b/resource_booking/i18n/fr_FR.po @@ -520,6 +520,12 @@ msgstr "La durée doit être positive." msgid "Duration:" msgstr "Durée:" +#. module: resource_booking +#: code:addons/resource_booking/models/mail_activity.py:0 +#, python-format +msgid "Feedback: %(feedback)s" +msgstr "" + #. module: resource_booking #: model:ir.model.fields,field_description:resource_booking.field_resource_booking__message_follower_ids #: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__message_follower_ids @@ -785,6 +791,17 @@ msgstr "" msgid "Next Activity Deadline" msgstr "Date limite de la prochaine activité" +#. module: resource_booking +#: model:ir.model.fields,field_description:resource_booking.field_mail_activity_mixin__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_product_product__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_product_template__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_res_partner__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_res_users__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_resource_booking__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__activity_booking_id +msgid "Next Activity Resource Booking" +msgstr "" + #. module: resource_booking #: model:ir.model.fields,field_description:resource_booking.field_resource_booking__activity_summary #: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__activity_summary @@ -848,6 +865,11 @@ msgstr "Nombre de messages non lus" msgid "Only one event per resource booking can exist." msgstr "Un seul événement par réservation de ressource peut exister." +#. module: resource_booking +#: model_terms:ir.ui.view,arch_db:resource_booking.mail_activity_view_form_popup +msgid "Open Resource Booking" +msgstr "" + #. module: resource_booking #: model_terms:ir.ui.view,arch_db:resource_booking.resource_booking_form msgid "Open a calendar to schedule a meeting for this booking request." @@ -913,6 +935,7 @@ msgstr "Avis au demandeur" #. module: resource_booking #: model:ir.model,name:resource_booking.model_resource_booking #: model:ir.module.category,name:resource_booking.category_resource_booking +#: model:mail.activity.type,name:resource_booking.mail_activity_data_resource_booking msgid "Resource Booking" msgstr "Réservation de ressources" diff --git a/resource_booking/i18n/resource_booking.pot b/resource_booking/i18n/resource_booking.pot index 6dd1c61c..e49025a6 100644 --- a/resource_booking/i18n/resource_booking.pot +++ b/resource_booking/i18n/resource_booking.pot @@ -489,6 +489,12 @@ msgstr "" msgid "Duration:" msgstr "" +#. module: resource_booking +#: code:addons/resource_booking/models/mail_activity.py:0 +#, python-format +msgid "Feedback: %(feedback)s" +msgstr "" + #. module: resource_booking #: model:ir.model.fields,field_description:resource_booking.field_resource_booking__message_follower_ids #: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__message_follower_ids @@ -752,6 +758,17 @@ msgstr "" msgid "Next Activity Deadline" msgstr "" +#. module: resource_booking +#: model:ir.model.fields,field_description:resource_booking.field_mail_activity_mixin__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_product_product__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_product_template__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_res_partner__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_res_users__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_resource_booking__activity_booking_id +#: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__activity_booking_id +msgid "Next Activity Resource Booking" +msgstr "" + #. module: resource_booking #: model:ir.model.fields,field_description:resource_booking.field_resource_booking__activity_summary #: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__activity_summary @@ -815,6 +832,11 @@ msgstr "" msgid "Only one event per resource booking can exist." msgstr "" +#. module: resource_booking +#: model_terms:ir.ui.view,arch_db:resource_booking.mail_activity_view_form_popup +msgid "Open Resource Booking" +msgstr "" + #. module: resource_booking #: model_terms:ir.ui.view,arch_db:resource_booking.resource_booking_form msgid "Open a calendar to schedule a meeting for this booking request." @@ -874,6 +896,7 @@ msgstr "" #. module: resource_booking #: model:ir.model,name:resource_booking.model_resource_booking #: model:ir.module.category,name:resource_booking.category_resource_booking +#: model:mail.activity.type,name:resource_booking.mail_activity_data_resource_booking msgid "Resource Booking" msgstr "" diff --git a/resource_booking/models/__init__.py b/resource_booking/models/__init__.py index 38ad3480..158a4b48 100644 --- a/resource_booking/models/__init__.py +++ b/resource_booking/models/__init__.py @@ -5,3 +5,4 @@ from . import resource_booking_type_combination_rel from . import resource_calendar from . import resource_resource +from . import mail_activity diff --git a/resource_booking/models/mail_activity.py b/resource_booking/models/mail_activity.py new file mode 100644 index 00000000..45fddefb --- /dev/null +++ b/resource_booking/models/mail_activity.py @@ -0,0 +1,58 @@ +# Copyright 2024 Tecnativa - Carolina Fernandez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import _, fields, models, tools +from odoo.tools import is_html_empty + + +class MailActivityType(models.Model): + _inherit = "mail.activity.type" + + category = fields.Selection( + selection_add=[("resource_booking", "Resource booking")] + ) + + +class MailActivity(models.Model): + _inherit = "mail.activity" + + booking_id = fields.Many2one( + "resource.booking", string="Resource booking", ondelete="cascade" + ) + + def action_create_resource_booking(self): + self.ensure_one() + action = self.env["ir.actions.actions"]._for_xml_id( + "resource_booking.resource_booking_action" + ) + if self.booking_id: + action["domain"] = [("id", "=", self.booking_id.id)] + else: + action["context"] = { + "default_activity_type_id": self.activity_type_id.id, + "default_res_id": self.env.context.get("default_res_id"), + "default_res_model": self.env.context.get("default_res_model"), + "default_name": self.summary or self.res_name, + "default_description": self.note + if not is_html_empty(self.note) + else "", + "default_booking_activity_ids": [(6, 0, self.ids)], + } + return action + + def _action_done(self, feedback=False, attachment_ids=False): + bookings = self.mapped("booking_id") + messages, activities = super(MailActivity, self)._action_done( + feedback=feedback, attachment_ids=attachment_ids + ) + if feedback: + for booking in bookings: + description = booking.description + description = "%s
%s" % ( + description if not tools.is_html_empty(description) else "", + _("Feedback: %(feedback)s", feedback=tools.plaintext2html(feedback)) + if feedback + else "", + ) + booking.write({"description": description}) + return messages, activities diff --git a/resource_booking/models/resource_booking.py b/resource_booking/models/resource_booking.py index 77fb74c2..0804db3b 100644 --- a/resource_booking/models/resource_booking.py +++ b/resource_booking/models/resource_booking.py @@ -215,6 +215,9 @@ class ResourceBooking(models.Model): required=True, tracking=True, ) + booking_activity_ids = fields.One2many( + "mail.activity", "booking_id", string="Activities" + ) @api.depends("partner_ids") def _compute_partner_id(self): @@ -584,22 +587,33 @@ def _get_intervals(self, start_dt, end_dt, combination=None): result &= combinations._get_intervals(start_dt, end_dt) return result + def _sync_booking_activities(self): + if self.booking_activity_ids and self.start: + self.booking_activity_ids.date_deadline = self.start + @api.model_create_multi def create(self, vals_list): """Sync booking with meeting if needed.""" result = super().create(vals_list) result._sync_meeting() + result._sync_booking_activities() return result def write(self, vals): """Sync booking with meeting if needed.""" result = super().write(vals) self._sync_meeting() + if vals.get("start"): + self._sync_booking_activities() return result + def _unlink_resource_booking_activities(self): + self.booking_activity_ids.unlink() + def unlink(self): """Unlink meeting if needed.""" self.meeting_id.unlink() + self._unlink_resource_booking_activities() return super().unlink() def name_get(self): @@ -707,6 +721,7 @@ def action_confirm(self): def action_unschedule(self): """Remove associated meetings.""" self.mapped("meeting_id").unlink() + self._unlink_resource_booking_activities() # Force recomputing, in case meeting_id is not visible in the form self.write({"meeting_id": False}) diff --git a/resource_booking/static/description/index.html b/resource_booking/static/description/index.html index 16aa8a9d..7a27354a 100644 --- a/resource_booking/static/description/index.html +++ b/resource_booking/static/description/index.html @@ -1,3 +1,4 @@ + @@ -366,7 +367,7 @@

Resource booking

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:1b5ee844dde4d92ddebc83454b46b058b45fddf1013e7ee6d17c187c15b74318 +!! source digest: sha256:8e2f6eac36cdf41491fa095fba459dcbfcb8d523de9740ae5158a171d5a9351d !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Production/Stable License: AGPL-3 OCA/calendar Translate me on Weblate Try me on Runboat

This module adds a new app to allow you to book resource combinations in given diff --git a/resource_booking/tests/test_backend.py b/resource_booking/tests/test_backend.py index 5cbdbe6c..6d34e590 100644 --- a/resource_booking/tests/test_backend.py +++ b/resource_booking/tests/test_backend.py @@ -1,10 +1,11 @@ # Copyright 2021 Tecnativa - Jairo Llopis # Copyright 2022 Tecnativa - Pedro M. Baeza -# Copyright 2023 Tecnativa - Carolina Fernandezs +# Copyright 2023 Tecnativa - Carolina Fernandez # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from datetime import date, datetime from unittest.mock import patch +from dateutil.relativedelta import relativedelta from freezegun import freeze_time from pytz import utc @@ -906,3 +907,112 @@ def test_resource_is_available_span_days(self): utc.localize(datetime(2021, 3, 14, 2, 0)), ) ) + + +class TestMailActivity(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.activity_type = cls.env.ref( + "resource_booking.mail_activity_data_resource_booking" + ) + cls.partner = cls.env["res.partner"].create({"name": "T Partner"}) + create_test_data(cls) + + def test_action_create_resource_booking(self): + mail_activity = self.env["mail.activity"].create( + { + "activity_type_id": self.activity_type.id, + "summary": "Test Summary", + "note": "Test Note", + "res_model_id": self.env["ir.model"]._get_id("res.partner"), + "res_id": self.partner.id, + } + ) + action = mail_activity.action_create_resource_booking() + self.assertEqual( + action["context"]["default_activity_type_id"], self.activity_type.id + ) + self.assertEqual(action["context"]["default_name"], "Test Summary") + self.assertEqual(action["context"]["default_description"], "

Test Note

") + self.assertEqual( + action["context"]["default_booking_activity_ids"], + [(6, 0, [mail_activity.id])], + ) + + def _create_resource_booking_activity(self): + mail_activity = self.env["mail.activity"].create( + { + "activity_type_id": self.activity_type.id, + "summary": "Test Summary", + "note": "Test Note", + "res_model_id": self.env["ir.model"]._get_id("res.partner"), + "res_id": self.partner.id, + } + ) + booking = self.env["resource.booking"].create( + { + "name": "Test Booking", + "description": "Booking Description", + "start": "2024-03-01 08:00:00", + "type_id": self.rbt.id, + "combination_auto_assign": False, + "combination_id": self.rbcs[1].id, + } + ) + mail_activity.write({"booking_id": booking.id}) + return mail_activity, booking + + def test_action_done_with_feedback(self): + mail_activity, booking = self._create_resource_booking_activity() + feedback = "Test Feedback" + messages, activities = mail_activity._action_done(feedback=feedback) + self.assertEqual( + booking.description, + "

Booking Description


Feedback:

Test Feedback

", + ) + self.assertNotEqual(messages, []) + self.assertNotEqual(activities, []) + + def test_action_done_without_feedback(self): + mail_activity, booking = self._create_resource_booking_activity() + messages, activities = mail_activity._action_done() + self.assertEqual(booking.description, "

Booking Description

") + self.assertNotEqual(messages, []) + self.assertNotEqual(activities, []) + + def test_sync_booking_activities(self): + mail_activity, booking = self._create_resource_booking_activity() + self.assertEqual(mail_activity.date_deadline, booking.start.date()) + booking.start = "2024-02-13 08:00:00" + self.assertEqual(mail_activity.date_deadline, "2024-02-13") + + def test_resource_booking_activity_without_date(self): + mail_activity = self.env["mail.activity"].create( + { + "activity_type_id": self.activity_type.id, + "summary": "Test Summary", + "note": "Test Note", + "res_model_id": self.env["ir.model"]._get_id("res.partner"), + "res_id": self.partner.id, + } + ) + booking = self.env["resource.booking"].create( + { + "name": "Test Booking", + "description": "Booking Description", + "type_id": self.rbt.id, + } + ) + mail_activity.write({"booking_id": booking.id}) + future_date = datetime.now() + relativedelta(years=1000) + self.assertEqual(mail_activity.date_deadline, future_date.date()) + booking.combination_id = self.rbcs[1].id + booking.combination_auto_assign = False + booking.start = "2024-02-13 08:00:00" + self.assertEqual(mail_activity.date_deadline, "2024-02-13") + + def test_unlink_resource_booking_activity(self): + mail_activity, booking = self._create_resource_booking_activity() + booking.action_cancel() + self.assertEqual(booking.booking_activity_ids, []) diff --git a/resource_booking/views/mail_activity_views.xml b/resource_booking/views/mail_activity_views.xml new file mode 100644 index 00000000..e76c4550 --- /dev/null +++ b/resource_booking/views/mail_activity_views.xml @@ -0,0 +1,45 @@ + + + + mail.activity.form.inherit.booking + mail.activity + + + + {'invisible': [('activity_category', 'in', ['resource_booking','meeting'])]} + + + {'invisible': [('activity_category', 'in', ['resource_booking','meeting'])]} + + + {'invisible': ['|', ('activity_category', 'in', ['resource_booking','meeting', 'phonecall']), ('id', '!=', False)]} + + + {'invisible': ['|', ('activity_category', 'in', ['resource_booking','meeting']), ('chaining_type', '=', 'trigger')]} + + + {'invisible': [('activity_category', 'in', ['resource_booking','meeting'])]} + + + +