odoo/industry#2014

Created by fw-bot
Merged at 74464671fc224030b42cedc4a9d18d546f718d7e

Statuses:

label
odoo-dev:saas-19.1-19.0-hotel-occupancy-availability-trcaz-512453-fw
head
27a874a2d8bfa0211df30a3fdfd324e70477ba1a
merged
1 day ago by Tristan Cazier (trcaz)
odoo/industry
19.0 #1912
saas-19.1 #2014
saas-19.2 #2018
master #2019

[IMP] booking_engine: add availabilities

Adds a new feature for the booking engine: availability & occupancy, which allow the user to monitor the occupancy of their planning resources for each day using pills in a color-coded Gantt chart heatmap.

This is done with automations on create & update of several models tied to the computation of an availability, namely resource.calendar.leaves, planning.slot, product.template & resource.resource. A CRON is also scheduled at night to create the availability records for the next 500 days in prospect of the channex integration.

In more detail, a single update server action is used across all the automations' server actions to recompute all the availabilities flagged with a x_to_recompute boolean to minimize faulty states due to race conditions. This way, each automation only has to flag the current (and new availabilites in the case of on create or edit) availabilities tied to records being updated or unlinked with that boolean, then trigger the recomputation in a separate server action that will fetch all the availabilities that have to be recomputed instead of each automation recomputing it separately with its own state.
A CRON is used for the unlinks instead of just a server action because calling the server action directly does not have the desired behavior since the server action is triggered before the records are actually deleted. Therefore, the records to be deleted are still taken into account for the recomputation. Using a CRON fixes this because the computation happens after the records are removed from the DB. Unlinks of these 4 models are rare cases, and therefore less likely to cause a problem than running the CRON for every little change, hence why we still use the server action for those, in addition to it working properly unlike the unlink.

Also adds more demo data for each of the industries using booking_engine.

task-5913061

Forward-Port-Of: #1912