Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][MIG] resource_booking: Migration to 17.0 #140

Open
wants to merge 82 commits into
base: 17.0
Choose a base branch
from

Conversation

victoralmau
Copy link
Member

@victoralmau victoralmau commented Nov 11, 2024

Migration to 17.0

Please @pedrobaeza can you review it?

@Tecnativa TT51647

Jairo Llopis and others added 30 commits November 11, 2024 12:03
This module adds a new app to allow you to book resource combinations in given
schedules.

Example use cases:

* Management of consultations in a clinic.
* Salesman appointments.
* Classroom and projector reservations.
* Hotel room booking.

Among the things you can do:

* Specify the type of booking, which includes a calendar of availability.
* Specify which resources can be booked together. All of them must be free to be booked.
* Place pending bookings, effectively giving permissions to someone to see the availability calendar and choose one slot.
* Partners can do that from their portals.
* If a partner has no user, he can still do the same via a tokenized URL.
* Backend users can also do that from the backend.
* Booking lifecycle with computed states.
* Automatic meeting creation and deletion.
* Automatic conflict detection.
* Deadline to block modifications.

@Tecnativa TT28201
Currently translated at 100.0% (190 of 190 strings)

Translation: calendar-12.0/calendar-12.0-resource_booking
Translate-URL: https://translation.odoo-community.org/projects/calendar-12-0/calendar-12-0-resource_booking/es/
…ating calendars

Without this patch, users couldn't change a calendar schedule if there were past or unconfirmed bookings that wouldn't fit in it.

Excluding those bookings from the check fixes the situation.

We also check that, to confirm a booking, it must fit in the calendar (because now it can happen that, in the time that has passed since the booking was scheduled until it is confirmed, the calendar changes).

@Tecnativa TT29509
The notifications emitted to the resource booking requester must always be in the same TZ as the resource booking itself.

For example, if you book one hotel room in the other side of the world, a notification in your own TZ is confusing.

Besides, res.partner created from website_sale are created with `tz=False`, making it even more confusing.

@Tecnativa TT30331
The constraint that checks the schedule of a resource booking is currently being applied to all the bookings, including past ones.
As the resource combination or associated calendars might change regularly and trigger a recomputation of this, such change might take a very long time.
Plus, the calendar restrictions might change, trigger a recompute of the constraint and detect bookings that can't be assigned, which makes no sense when they already happened.

This applies it only to future bookings, ignoring past ones.

TT30478
It's very unlikely that you need to book resources in a seconds-based precision.

This simplifies portal UI. Still, declared as a variable in case you need some customizations downstream.

@Tecnativa TT31063
- Standard v13 changes.
- Some onchanges removed in favor of computes.

@Tecnativa TT30987
From now on, `resource.booking.type` duration represents the default duration that will be applied to new `resource.booking` of that type, instead of the hardcoded duration for every new booking.

This means that you can create a new booking in pending state and define a custom duration before sending the portal link to customer.

Thus, the available schedule slots in portal will be based on the type duration, whereas only those that have enough time left to complete the booking duration will be displayed.

@Tecnativa TT30987
…cation

Thanks to this patch, you will be able to more predictably block the chosen resource combination, with the added checkbox.

Also, the location field is propagated to `resource.booking` records, and synced from there to `calendar.event` if needed. This way, you can alter the location before sending the portal invitation.

@Tecnativa TT30987
The filter wasn't working fine due to the `auto_join=True` set in `meeting_id`. It was never displaying pending bookings.

Besides, it wasn't necessary to keep it as a field because it was displayed nowhere and the search could be done directly in the view. This way, there's less python code to maintain and we disable the possibility of having a negative domain, which enters doomed scenarios when x2many fields are involved (see odoo/odoo#43957).

@Tecnativa TT30987
Adding `.with_context(exclude_public_holidays=True)` in needed places to let `hr_holidays_public` do its magic and never allow allocating a booking during a public holidays when that module is properly installed and configured.

@Tecnativa TT30987
- Allow users to optionally define a name for the resource booking.
- Display that name in portal if set.
- Sync it with meeting name when creating it.

@Tecnativa TT30987
Without this patch, when entering the Resource Bookings menu, if the current user attended any recurrent meeting, it failed with this error:

```
Server application error
 Error code: 200
 Error message: Odoo Server Error
 Error data message:
 invalid input syntax for integer: "82-20210726143000"
LINE 1: ... AND  ("resource_booking"."meeting_id" in (3,5,81,'82-202107...
                                                             ^

 Error data debug:
 Traceback (most recent call last):
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 624, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 310, in _handle_exception
    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
  File "/opt/odoo/custom/src/odoo/odoo/tools/pycompat.py", line 14, in reraise
    raise value
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 669, in dispatch
    result = self._call_function(**self.params)
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 350, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/service/model.py", line 94, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 339, in checked_call
    result = self.endpoint(*a, **kw)
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 915, in __call__
    return self.method(*args, **kw)
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 515, in response_wrap
    response = f(*args, **kw)
  File "/opt/odoo/auto/addons/web/controllers/main.py", line 1339, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/opt/odoo/auto/addons/web/controllers/main.py", line 1331, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/api.py", line 383, in call_kw
    result = _call_kw_model(method, model, args, kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/api.py", line 356, in _call_kw_model
    result = method(recs, *args, **kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/models.py", line 4936, in search_read
    records = self.search(domain or [], offset=offset, limit=limit, order=order)
  File "/opt/odoo/custom/src/odoo/odoo/models.py", line 1648, in search
    res = self._search(args, offset=offset, limit=limit, order=order, count=count)
  File "/opt/odoo/custom/src/odoo/odoo/models.py", line 4499, in _search
    self._cr.execute(query_str, where_clause_params)
  File "/opt/odoo/custom/src/odoo/odoo/sql_db.py", line 173, in wrapper
    return f(self, *args, **kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/sql_db.py", line 250, in execute
    res = self._obj.execute(query, params)
psycopg2.DataError: invalid input syntax for integer: "82-20210726143000"
LINE 1: ... AND  ("resource_booking"."meeting_id" in (3,5,81,'82-202107...
                                                             ^
```

@Tecnativa TT30987
Upstream ``unlink`` method in calendar.event adds this keyword argument.
When a user had no resource_booking permissions and opened a calendar event linked to a resource booking, he got an unnecessary access error.

@Tecnativa TT31238
When `_leave_intervals_batch()` in `resource.calendar` is extended by other modules that add more leaves for any reason, the returned recordset must be of the `resource.calendar.leaves` model. Otherwise, Odoo fails with:

    TypeError: '<' not supported between instances of 'resource.resource' and 'resource.calendar.leaves'

The resource didn't have a meaning here, so changing it to avoid bug.

@Tecnativa TT31249
Missing part from OCA#34:

- Display booking duration and location on portal, even on pending state.
- Improve portal test to contemplate new behaviors.

@Tecnativa TT31250
- If RBC (resource.booking.combination) was auto-assigned, attendees generated from RBC human resources are expected to confirm attendance manually.
- If RBC was handpicked, those attendees are auto-confirmed.
- All those confirmations are done before sending invitations, so invitations contain the correct attendance status.
- If requester books from portal view, he's also confirmed before sending invitation, for the same reason.

@Tecnativa TT31239
This allows better filtering while in the normal calendar view.

By default, the organizer will be whoever created the booking. Calendar invitations will go out in his name.

Also, avoid sending calendar event modification notifications if the modification isn't the schedule.

@Tecnativa TT31240

resource_booking 13.0.2.3.0
Includes those coming from requester and from resource combination.

@Tecnativa TT31901
Currently translated at 97.0% (196 of 202 strings)

Translation: calendar-13.0/calendar-13.0-resource_booking
Translate-URL: https://translation.odoo-community.org/projects/calendar-13-0/calendar-13-0-resource_booking/fr_FR/
Currently translated at 1.4% (3 of 202 strings)

Translation: calendar-13.0/calendar-13.0-resource_booking
Translate-URL: https://translation.odoo-community.org/projects/calendar-13-0/calendar-13-0-resource_booking/fr/
When some partner is a resource assigned to a booking, he should get auto-subscribed.

Inspired in OCA#42, but I'm changing that behavior.

@Tecnativa TT32148
By using the upstream `mail.message_user_assigned` template, we were getting this exception:

```
odoo.addons.base.models.qweb.QWebException: 'resource.booking' object has no attribute 'user_id'
Traceback (most recent call last):
  File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/qweb.py", line 348, in _compiled_fn
    return compiled(self, append, new, options, log)
  File "<template>", line 1, in template_2601_10519
AttributeError: 'resource.booking' object has no attribute 'user_id'
```

So I provide a specific template for this kind of subscription notification, which doesn't use that `user_id` field. Besides, it explains better why you're getting it.

@Tecnativa TT32190
Forward-port of OCA#51.

Includes a modification for the migration script of 13.0.1.0.0 (if you migrate from v12, you'll need it; if you migrate from v13, it will be automatic).

@Tecnativa TT31901
Without this patch, if you create a resource booking for a type that has categories (tags), it will fail with `CacheMiss` error.

@Tecnativa TT32552
If I'm creating bookings for my colleagues, I'll be the owner of all of the meetings. But that doesn't mean I'll be busy.

With this patch, only when I'm a booked resource will the event be set as busy.

@Tecnativa TT32666
[UPD] Update resource_booking.pot

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: calendar-15.0/calendar-15.0-resource_booking
Translate-URL: https://translation.odoo-community.org/projects/calendar-15-0/calendar-15-0-resource_booking/
Set the inverse for partner_id so modules can adapt seamlessly to the
changes in OCA#110

TT45338

[BOT] post-merge updates
Depending on how the create/unlink overrides are programmed, there can
be overheads or blocking things when calling unconditionally these
methods, even with an empty list, so let's only call them when there
is really something to delete or to create.

This has been discovered as `google_calendar` module is calling Google
API on calendar event create (although vals_list being empty), and due
to an error with Google API right now, I was not able to create a
draft resource booking.

[BOT] post-merge updates
TT47152

[UPD] Update resource_booking.pot

[BOT] post-merge updates

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: calendar-15.0/calendar-15.0-resource_booking
Translate-URL: https://translation.odoo-community.org/projects/calendar-15-0/calendar-15-0-resource_booking/
Changes done:
- [FIX] _get_available_slots
- [IMP] new field slot_duration
- [IMP] Button (partner -> booking)
- [IMP] combination -> bookings -> create: default combination
- [FIX] _get_intervals() when type_id is missing
- [IMP] booking: search on combination
- [FIX] _availability_is_fitting()
- [IMP] booking list view with hidden partner_ids
- [FIX] attendance hour_to 23:59 -> 24:00
- [FIX] pre-commit
- [FIX] calendar_slot_duration format
- [FIX] _get_calendar_context() with correct start / timezone

Co-authored-by: Henrik Norlin
Changes done:
- Add freezegun to test_requirements.txt
- Fix failling BackendCase. test_booking_from_calendar_view
- Fix typo in help parameter for combination_assignment field from resource_booking_type
- Error CalendarQuickCreate title is not a string when scheduling a booking
- Portal responsive booking calendar table going wider and no x scroll
- 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.

Co-authored-by: Rolando Pérez Rebollo
Changes done:
- Squash administrative commits.
- Purge translations.
- Fix tests and/or remove warnings.
- Remove migration scripts from 15.0
- Change resource_booking_ids field from partner to many2many field

TT45643

[UPD] Update resource_booking.pot

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: calendar-16.0/calendar-16.0-resource_booking
Translate-URL: https://translation.odoo-community.org/projects/calendar-16-0/calendar-16-0-resource_booking/
Translated using Weblate (Portuguese (Brazil))

Currently translated at 36.5% (80 of 219 strings)

Translation: calendar-16.0/calendar-16.0-resource_booking
Translate-URL: https://translation.odoo-community.org/projects/calendar-16-0/calendar-16-0-resource_booking/pt_BR/

Translated using Weblate (Portuguese (Brazil))

Currently translated at 47.0% (103 of 219 strings)

Translation: calendar-16.0/calendar-16.0-resource_booking
Translate-URL: https://translation.odoo-community.org/projects/calendar-16-0/calendar-16-0-resource_booking/pt_BR/
Currently translated at 100.0% (219 of 219 strings)

Translation: calendar-16.0/calendar-16.0-resource_booking
Translate-URL: https://translation.odoo-community.org/projects/calendar-16-0/calendar-16-0-resource_booking/es/
…quested

The _prepare_home_portal_values() method sometimes requests booking_count
and only then should we return the value.
[BOT] post-merge updates

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: calendar-16.0/calendar-16.0-resource_booking
Translate-URL: https://translation.odoo-community.org/projects/calendar-16-0/calendar-16-0-resource_booking/

[BOT] post-merge updates
…t side effects in some cases

[BOT] post-merge updates
…portal.

Related to OCA@8528dc7

Example use case:

- Create a resource booking with several Attendees
- Use the Share link
- Write a message

TT41745

[BOT] post-merge updates
If the default mail_note subtype is defined, when generating the calendar.event
is generated and emails are sent to attendees, the mail_notify_author
because each email would also be sent to the author (the event organizer).

Now it is changed to use a specific context and only send the email to the author if
it is the the recipient of the email (the email of their attendance to the event).

Related to OCA@575d2aa

TT49045

[BOT] post-merge updates
If we are creating the calendar event from resource booking, we want to
notify only the partner_ids and not all followers (to avoid that each email is
sent to all followers). Example: Resource booking with combination of several users.
This happens only when the the subtype not is enabled by default in the instance.

Related to OCA@a3cd5a8

TT49045

[BOT] post-merge updates
…ong" results

TT50035

[BOT] post-merge updates
Currently translated at 100.0% (220 of 220 strings)

Translation: calendar-16.0/calendar-16.0-resource_booking
Translate-URL: https://translation.odoo-community.org/projects/calendar-16-0/calendar-16-0-resource_booking/it/

[BOT] post-merge updates
d7bbcef

The changes added at OCA@851dc9a and OCA@a3cd5a8 are unnecessary according to the approach added at odoo/odoo@d7bbcef.
We maintain the tests to confirm that the expected behavior is maintained.

[BOT] post-merge updates
Currently translated at 100.0% (220 of 220 strings)

Translation: calendar-16.0/calendar-16.0-resource_booking
Translate-URL: https://translation.odoo-community.org/projects/calendar-16-0/calendar-16-0-resource_booking/it/
Currently translated at 100.0% (220 of 220 strings)

Translation: calendar-16.0/calendar-16.0-resource_booking
Translate-URL: https://translation.odoo-community.org/projects/calendar-16-0/calendar-16-0-resource_booking/it/

Translated using Weblate (Italian)

Currently translated at 100.0% (220 of 220 strings)

Translation: calendar-16.0/calendar-16.0-resource_booking
Translate-URL: https://translation.odoo-community.org/projects/calendar-16-0/calendar-16-0-resource_booking/it/

Translated using Weblate (Italian)

Currently translated at 100.0% (220 of 220 strings)

Translation: calendar-16.0/calendar-16.0-resource_booking
Translate-URL: https://translation.odoo-community.org/projects/calendar-16-0/calendar-16-0-resource_booking/it/

Translated using Weblate (Italian)

Currently translated at 100.0% (220 of 220 strings)

Translation: calendar-16.0/calendar-16.0-resource_booking
Translate-URL: https://translation.odoo-community.org/projects/calendar-16-0/calendar-16-0-resource_booking/it/
Currently translated at 100.0% (220 of 220 strings)

Translation: calendar-16.0/calendar-16.0-resource_booking
Translate-URL: https://translation.odoo-community.org/projects/calendar-16-0/calendar-16-0-resource_booking/it/
@victoralmau victoralmau force-pushed the 17.0-mig-resource_booking branch from 45fb003 to fbfe75a Compare November 11, 2024 13:05
Copy link

@lauradiaz22 lauradiaz22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good morning,
I have tested this PR at a functional level, and this LGTM👍.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.