From d915a99c19b11ed5ae4503bfa7bf032de35e728d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Mon, 11 Mar 2024 14:15:07 +0100 Subject: [PATCH] [MIG] resource_booking: Finish migration Changes done: - Squash administrative commits. - Purge translations. - Fix tests and/or remove warnings. - Remove migration scripts from 15.0 TT45643 --- resource_booking/i18n/es.po | 6 --- resource_booking/i18n/fr_FR.po | 9 ----- .../migrations/15.0.1.4.0/post-migration.py | 19 ---------- .../migrations/15.0.1.4.0/pre-migration.py | 10 ----- resource_booking/models/resource_booking.py | 10 +++-- resource_booking/tests/test_backend.py | 27 +++++++------- resource_booking/tests/test_portal.py | 37 ++++++++----------- 7 files changed, 37 insertions(+), 81 deletions(-) delete mode 100644 resource_booking/migrations/15.0.1.4.0/post-migration.py delete mode 100644 resource_booking/migrations/15.0.1.4.0/pre-migration.py diff --git a/resource_booking/i18n/es.po b/resource_booking/i18n/es.po index cc2e3b06..0acd71f6 100644 --- a/resource_booking/i18n/es.po +++ b/resource_booking/i18n/es.po @@ -1349,9 +1349,3 @@ msgstr "" #: model_terms:ir.ui.view,arch_db:resource_booking.message_combination_assigned msgid "because you belong to the chosen resource combination:" msgstr "" - -#~ msgid "Next Activity Resource Booking" -#~ msgstr "Siguiente actividad de reserva de recursos" - -#~ msgid "Who requested this booking?" -#~ msgstr "¿Quién solicitó esta reserva/cita?" diff --git a/resource_booking/i18n/fr_FR.po b/resource_booking/i18n/fr_FR.po index ef223482..d1986ac7 100644 --- a/resource_booking/i18n/fr_FR.po +++ b/resource_booking/i18n/fr_FR.po @@ -1360,12 +1360,3 @@ msgstr "" #: model_terms:ir.ui.view,arch_db:resource_booking.message_combination_assigned msgid "because you belong to the chosen resource combination:" msgstr "" - -#~ msgid "Who requested this booking?" -#~ msgstr "Qui a demandé cette réservation ?" - -#~ msgid "SMS Delivery error" -#~ msgstr "Erreur de livraison SMS" - -#~ msgid "Followers (Channels)" -#~ msgstr "Abonnés (Chaînes)" diff --git a/resource_booking/migrations/15.0.1.4.0/post-migration.py b/resource_booking/migrations/15.0.1.4.0/post-migration.py deleted file mode 100644 index 27678d64..00000000 --- a/resource_booking/migrations/15.0.1.4.0/post-migration.py +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2023 Tecnativa - Carolina Fernandez -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openupgradelib import openupgrade - - -def convert_resource_booking_partners(env): - openupgrade.m2o_to_x2m( - env.cr, - env["resource.booking"], - "resource_booking", - "partner_ids", - "old_partner_id", - ) - - -@openupgrade.migrate() -def migrate(env, version): - """Put partner_id in partner_ids""" - convert_resource_booking_partners(env) diff --git a/resource_booking/migrations/15.0.1.4.0/pre-migration.py b/resource_booking/migrations/15.0.1.4.0/pre-migration.py deleted file mode 100644 index 50dd4a68..00000000 --- a/resource_booking/migrations/15.0.1.4.0/pre-migration.py +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright 2023 Tecnativa - Carolina Fernandez -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - - -def migrate(env): - env.cr.execute( - """ - ALTER TABLE resource_booking RENAME partner_id TO old_partner_id - """, - ) diff --git a/resource_booking/models/resource_booking.py b/resource_booking/models/resource_booking.py index 06400c9d..d26822d6 100644 --- a/resource_booking/models/resource_booking.py +++ b/resource_booking/models/resource_booking.py @@ -724,7 +724,7 @@ def _message_get_suggested_recipients(self): def action_schedule(self): """Redirect user to a simpler way to schedule this booking.""" - FloatTimeParser = self.env["ir.qweb.field.float_time"] + DurationParser = self.env["ir.qweb.field.duration"] return { "context": dict( self.env.context, @@ -732,8 +732,12 @@ def action_schedule(self): default_res_model_id=False, default_res_id=False, # Context used by web_calendar_slot_duration module - calendar_slot_duration=FloatTimeParser.value_to_html( - self.duration, False + calendar_slot_duration=DurationParser.value_to_html( + self.duration, + { + "unit": "hour", + "digital": True, + }, ), default_resource_booking_ids=[(6, 0, self.ids)], default_name=self.name or "", diff --git a/resource_booking/tests/test_backend.py b/resource_booking/tests/test_backend.py index da1acda0..595db4aa 100644 --- a/resource_booking/tests/test_backend.py +++ b/resource_booking/tests/test_backend.py @@ -618,7 +618,9 @@ def test_location(self): self.assertEqual(rb.location, "Office 3") def test_videocall_location(self): - """Videocall location across records works as expected.""" + """Videocall location across records works as expected. + We need to set dummy urls to prevent the _set_videocall_location() method + of calendar from doing so.""" rbt2 = self.rbt.copy({"videocall_location": "Videocall Office 2"}) rb_f = Form(self.env["resource.booking"]) rb_f.partner_ids.add(self.partner) @@ -638,29 +640,28 @@ def test_videocall_location(self): self.assertEqual(rb.videocall_location, "Videocall Office 2") # Still can change it independently with Form(rb) as rb_f: - rb_f.videocall_location = "Videocall Office 1" - self.assertEqual(rb.videocall_location, "Videocall Office 1") + rb_f.videocall_location = "https://Videocall Office 1" + self.assertEqual(rb.videocall_location, "https://Videocall Office 1") self.assertEqual(rbt2.videocall_location, "Videocall Office 2") # Schedule the booking, meeting inherits videocall location from it with Form(rb) as rb_f: rb_f.start = "2021-03-01 08:00:00" self.assertEqual(rb.state, "scheduled") - self.assertEqual(rb.videocall_location, "Videocall Office 1") - self.assertEqual(rb.meeting_id.videocall_location, "Videocall Office 1") - # Changing meeting videocall location changes videocall location of booking + self.assertEqual(rb.videocall_location, "https://Videocall Office 1") + self.assertEqual(rb.meeting_id.videocall_location, "https://Videocall Office 1") with Form(rb.meeting_id) as meeting_f: - meeting_f.videocall_location = "Videocall Office 2" - self.assertEqual(rb.videocall_location, "Videocall Office 2") - self.assertEqual(rb.meeting_id.videocall_location, "Videocall Office 2") + meeting_f.videocall_location = "https://Videocall Office 2" + self.assertEqual(rb.videocall_location, "https://Videocall Office 2") + self.assertEqual(rb.meeting_id.videocall_location, "https://Videocall Office 2") # Changing booking videocall location changes meeting location with Form(rb) as rb_f: - rb_f.videocall_location = "Videocall Office 3" - self.assertEqual(rb.meeting_id.videocall_location, "Videocall Office 3") - self.assertEqual(rb.videocall_location, "Videocall Office 3") + rb_f.videocall_location = "https://Videocall Office 3" + self.assertEqual(rb.videocall_location, "https://Videocall Office 3") + self.assertEqual(rb.meeting_id.videocall_location, "https://Videocall Office 3") # When unscheduled, it keeps videocall location untouched rb.action_unschedule() self.assertFalse(rb.meeting_id) - self.assertEqual(rb.videocall_location, "Videocall Office 3") + self.assertEqual(rb.videocall_location, "https://Videocall Office 3") def test_organizer_sync(self): """Resource booking and meeting organizers are properly synced.""" diff --git a/resource_booking/tests/test_portal.py b/resource_booking/tests/test_portal.py index 5c7939fe..273e4d02 100644 --- a/resource_booking/tests/test_portal.py +++ b/resource_booking/tests/test_portal.py @@ -7,33 +7,28 @@ from freezegun import freeze_time from lxml.html import fromstring +from odoo.tests import new_test_user, tagged from odoo.tests.common import HttpCase from .common import create_test_data @freeze_time("2021-02-26 09:00:00", tick=True) +@tagged("post_install", "-at_install") class PortalCase(HttpCase): - def setUp(self): - super().setUp() - create_test_data(self) - self.user_portal, self.user_manager = self.env["res.users"].create( - [ - { - "name": "portal", - "login": "ptl", - "password": "ptl", - "groups_id": [(4, self.env.ref("base.group_portal").id, 0)], - }, - { - "name": "manager", - "login": "mgr", - "password": "mgr", - "groups_id": [ - (4, self.env.ref("resource_booking.group_manager").id, 0) - ], - }, - ] + @classmethod + def setUpClass(cls): + super().setUpClass() + create_test_data(cls) + + cls.user_portal = new_test_user( + cls.env, login="ptl", password="ptl", groups="base.group_portal" + ) + cls.user_manager = new_test_user( + cls.env, + login="mgr", + password="mgr", + groups="resource_booking.group_manager", ) def _url_xml(self, url, data=None, timeout=10): @@ -195,7 +190,7 @@ def test_portal_scheduling_conflict(self): ) ) # Public guy's booking and related meeting are OK in backend - booking_public.invalidate_cache(ids=booking_public.ids) + booking_public.invalidate_model() self.assertEqual(booking_public.state, "confirmed") self.assertEqual(len(booking_public.meeting_id.attendee_ids), 2) for attendee in booking_public.meeting_id.attendee_ids: