From 819b9141eada3fb69e5662a324219799bb264268 Mon Sep 17 00:00:00 2001 From: rrebollo Date: Thu, 25 Jan 2024 11:31:04 -0500 Subject: [PATCH] [IMP] resource_booking: add freezegun as a python external dependency [IMP] resource_booking: fix failling BackendCase. test_booking_from_calendar_view [IMP] resource_booking: fix typo in help parameter for combination_assignment field from resource_booking_type [IMP] resource_booking: fix failing PortalCase.test_portal_no_bookings Test was failling cause there was no bookings link on portal home for external users, then no trigger. Also I had to tweak eslintrc config cause precommit was failling due to ECMA version. [IMP] resource_booking: No create/unlink call if nothing to do [FIX] resource_booking: error CalendarQuickCreate title is not a string when scheduling a booking [FIX] resource_booking: portal responsive booking calendar table going wider and no x scroll --- .eslintrc.yml | 3 +- resource_booking/README.rst | 20 +- resource_booking/__manifest__.py | 9 +- resource_booking/models/resource_booking.py | 8 +- .../models/resource_booking_type.py | 2 +- .../static/description/index.html | 13 +- .../static/src/js/booking_portal.js | 13 ++ .../js/{ => tours}/resource_booking_tour.js | 2 - resource_booking/templates/portal.xml | 209 +++++++++--------- resource_booking/tests/test_backend.py | 4 +- test_requirements.txt | 1 + 11 files changed, 160 insertions(+), 124 deletions(-) create mode 100644 resource_booking/static/src/js/booking_portal.js rename resource_booking/static/src/js/{ => tours}/resource_booking_tour.js (98%) create mode 100644 test_requirements.txt diff --git a/.eslintrc.yml b/.eslintrc.yml index fed88d70..3d63b68a 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -4,7 +4,8 @@ env: # See https://github.com/OCA/odoo-community.org/issues/37#issuecomment-470686449 parserOptions: - ecmaVersion: 2019 + ecmaVersion: 11 + sourceType: module overrides: - files: diff --git a/resource_booking/README.rst b/resource_booking/README.rst index f366a771..8d38c22e 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:17ca982be0206aaadf1595108e53e37b5812a0963b66d3debc7530a9798b5a95 + !! source digest: sha256:2a7f2a32fec85849182a06dcf2daaae0efca0d9e6eb26893dedc0ff2151c0333 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png @@ -17,13 +17,13 @@ Resource booking :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcalendar-lightgray.png?logo=github - :target: https://github.com/OCA/calendar/tree/15.0/resource_booking + :target: https://github.com/OCA/calendar/tree/16.0/resource_booking :alt: OCA/calendar .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/calendar-15-0/calendar-15-0-resource_booking + :target: https://translation.odoo-community.org/projects/calendar-16-0/calendar-16-0-resource_booking :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/calendar&target_branch=15.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/calendar&target_branch=16.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -170,7 +170,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. @@ -186,6 +186,7 @@ Contributors ~~~~~~~~~~~~ * Jairo Llopis (https://www.tecnativa.com/) +* Henrik Norlin (https://ows.cloud) Maintainers ~~~~~~~~~~~ @@ -203,11 +204,14 @@ promote its widespread use. .. |maintainer-pedrobaeza| image:: https://github.com/pedrobaeza.png?size=40px :target: https://github.com/pedrobaeza :alt: pedrobaeza +.. |maintainer-ows-cloud| image:: https://github.com/ows-cloud.png?size=40px + :target: https://github.com/ows-cloud + :alt: ows-cloud -Current `maintainer `__: +Current `maintainers `__: -|maintainer-pedrobaeza| +|maintainer-pedrobaeza| |maintainer-ows-cloud| -This module is part of the `OCA/calendar `_ project on GitHub. +This module is part of the `OCA/calendar `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/resource_booking/__manifest__.py b/resource_booking/__manifest__.py index bf49ba1b..e3c6125d 100644 --- a/resource_booking/__manifest__.py +++ b/resource_booking/__manifest__.py @@ -40,8 +40,13 @@ "views/menus.xml", ], "assets": { - "web.assets_frontend": ["resource_booking/static/src/scss/portal.scss"], - "web.assets_tests": ["resource_booking/static/src/js/resource_booking_tour.js"], + "web.assets_frontend": [ + "resource_booking/static/src/js/booking_portal.js", + "resource_booking/static/src/scss/portal.scss", + ], + "web.assets_tests": [ + "resource_booking/static/src/js/tours/resource_booking_tour.js" + ], }, "demo": ["demo/res_users_demo.xml"], } diff --git a/resource_booking/models/resource_booking.py b/resource_booking/models/resource_booking.py index a5e0a40b..c1177e4c 100644 --- a/resource_booking/models/resource_booking.py +++ b/resource_booking/models/resource_booking.py @@ -432,8 +432,10 @@ def _sync_meeting(self): to_create.append(meeting_vals) else: to_delete |= one.meeting_id - to_delete.unlink() - _self.env["calendar.event"].create(to_create) + if to_delete: + to_delete.unlink() + if to_create: + _self.env["calendar.event"].create(to_create) @api.constrains("combination_id", "meeting_id", "type_id") def _check_scheduling(self): @@ -697,7 +699,7 @@ def action_schedule(self): self.duration, False ), default_resource_booking_ids=[(6, 0, self.ids)], - default_name=self.name, + default_name=self.name or "", ), "name": _("Schedule booking"), "res_model": "calendar.event", diff --git a/resource_booking/models/resource_booking_type.py b/resource_booking/models/resource_booking_type.py index caad7631..a029d9c2 100644 --- a/resource_booking/models/resource_booking_type.py +++ b/resource_booking/models/resource_booking_type.py @@ -35,7 +35,7 @@ class ResourceBookingType(models.Model): default="random", help=( "Choose how to auto-assign resource combinations. " - "It has no effect if assiged manually." + "It has no effect if assigned manually." ), ) combination_rel_ids = fields.One2many( diff --git a/resource_booking/static/description/index.html b/resource_booking/static/description/index.html index da161a6f..91bc596d 100644 --- a/resource_booking/static/description/index.html +++ b/resource_booking/static/description/index.html @@ -367,9 +367,9 @@

Resource booking

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:17ca982be0206aaadf1595108e53e37b5812a0963b66d3debc7530a9798b5a95 +!! source digest: sha256:2a7f2a32fec85849182a06dcf2daaae0efca0d9e6eb26893dedc0ff2151c0333 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

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

+

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 schedules.

Example use cases:

@@ -521,7 +521,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.

@@ -536,6 +536,7 @@

Authors

Contributors

@@ -545,9 +546,9 @@

Maintainers

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

-

Current maintainer:

-

pedrobaeza

-

This module is part of the OCA/calendar project on GitHub.

+

Current maintainers:

+

pedrobaeza ows-cloud

+

This module is part of the OCA/calendar project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/resource_booking/static/src/js/booking_portal.js b/resource_booking/static/src/js/booking_portal.js new file mode 100644 index 00000000..31213f9b --- /dev/null +++ b/resource_booking/static/src/js/booking_portal.js @@ -0,0 +1,13 @@ +/** @odoo-module */ + +import publicWidget from "web.public.widget"; +import "portal.portal"; // Force dependencies + +publicWidget.registry.PortalHomeCounters.include({ + /** + * @override + */ + _getCountersAlwaysDisplayed() { + return this._super(...arguments).concat(["booking_count"]); + }, +}); diff --git a/resource_booking/static/src/js/resource_booking_tour.js b/resource_booking/static/src/js/tours/resource_booking_tour.js similarity index 98% rename from resource_booking/static/src/js/resource_booking_tour.js rename to resource_booking/static/src/js/tours/resource_booking_tour.js index 8b1a9fba..972c54a9 100644 --- a/resource_booking/static/src/js/resource_booking_tour.js +++ b/resource_booking/static/src/js/tours/resource_booking_tour.js @@ -1,6 +1,4 @@ odoo.define("resource_booking.tour", function (require) { - "use strict"; - var tour = require("web_tour.tour"); tour.register( diff --git a/resource_booking/templates/portal.xml b/resource_booking/templates/portal.xml index 91f576cc..1b8e2fe1 100644 --- a/resource_booking/templates/portal.xml +++ b/resource_booking/templates/portal.xml @@ -32,110 +32,117 @@ - - - - - - - - - - - - - - - +
+
-
-
- - - - - - - - -
+ + + + + + + + - - - - - - + + + + + + + + + + + - + + + + + + + + + + + + - - - - - - - -
+
+
+ + + + - -
+ - + + +
+ +
- - - - - - - -
All times are displayed using this timezone: +
- All times are displayed using this timezone: - -
+ + + -