Skip to content

Commit

Permalink
[IMP] resource_booking: No create/unlink call if nothing to do
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pedrobaeza committed Jan 5, 2024
1 parent 969899c commit b616d24
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions resource_booking/models/resource_booking.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,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()

Check warning on line 421 in resource_booking/models/resource_booking.py

View check run for this annotation

Codecov / codecov/patch

resource_booking/models/resource_booking.py#L421

Added line #L421 was not covered by tests
if to_create:
_self.env["calendar.event"].create(to_create)

@api.constrains("combination_id", "meeting_id", "type_id")
def _check_scheduling(self):
Expand Down

0 comments on commit b616d24

Please sign in to comment.