Skip to content

[16.0][FIX] pos_pms_link: offer reservations whose stay covers today - #446

Merged
OCA-git-bot merged 1 commit into
OCA:16.0from
DarioLodeiros:16.0-fix-pos_pms_link-reservations-by-date
Sep 7, 2026
Merged

[16.0][FIX] pos_pms_link: offer reservations whose stay covers today#446
OCA-git-bot merged 1 commit into
OCA:16.0from
DarioLodeiros:16.0-fix-pos_pms_link-reservations-by-date

Conversation

@DarioLodeiros

@DarioLodeiros DarioLodeiros commented Sep 4, 2026

Copy link
Copy Markdown
Member

Problem

pos.session._loader_params_pms_reservation() loads the reservations offered in the POS with this domain:

domain = [
    "|",
    ("state", "=", "onboard"),
    "&",
    ("checkout", "=", fields.Datetime.now().date()),
    ("state", "!=", "cancel"),
]

A reservation therefore reaches the POS only while it is onboard, or on its very last day. A stay that is confirmed but not yet checked in never appears, so the cashier cannot charge a consumption to it and the reservation-selection screen opens on an empty list.

That is reasonable for a hotel, where every guest is checked in on arrival. It makes the feature unusable for long stays: a reservation spanning weeks or months sits in confirm for its whole duration unless somebody performs a check-in, and a monthly-split stay gets a fresh segment whose checkout is weeks away. On a residence hall with ~250 rooms occupied for the whole academic year, the list was empty every single day.

Fix

Load every non-cancelled reservation whose stay covers today, which is the single question the POS needs answered: can I charge this consumption to somebody who is staying right now.

today = fields.Date.context_today(self)
domain = [
    ("state", "!=", "cancel"),
    ("checkin", "<=", today),
    ("checkout", ">=", today),
]

checkout >= today keeps the departure day included, which the old domain handled with its checkout == today branch, so a guest who checked out this morning can still be charged for breakfast.

This also replaces fields.Datetime.now().date() with fields.Date.context_today(). The former is UTC, so in a positive-offset timezone the date rolls over before local midnight and the evening shift loads the wrong day.

On dropping the explicit onboard branch

I did first keep onboard as an alternative, and then removed it because it earns nothing: the only reservations it adds are those that are onboard outside their own dates, and auto_departure_delayed() already moves those to departure_delayed on the checkout day and auto-checks them out afterwards.

So this is not a strict superset of the old behaviour, and it is worth being explicit about the one case that changes: on an instance whose nocheckout_reservations cron is disabled, an overstay left in onboard past its checkout is no longer offered in the POS, and its dates have to be corrected first. I think that is the right trade — charging a consumption to a stay that the system believes ended yesterday hides the real problem — but I am happy to put the branch back if maintainers prefer strict compatibility.

How to reproduce

  1. On a POS config, tick Pay on reservation, set a Pay on reservation method and allow the property.
  2. Create a reservation covering today that is confirm and not checked in.
  3. Open the POS and press the reservation-selection button.

Before: the list is empty. After: the reservation is listed with its guest name, rooms and services.

The POS reservation list was loaded with this domain:

    ["|", ("state", "=", "onboard"),
     "&", ("checkout", "=", now().date()), ("state", "!=", "cancel")]

so a reservation only reached the POS while it was onboard, or on its very
last day. A stay that is confirmed but not yet checked in was invisible, and
the cashier could not charge a consumption to it.

That is reasonable for a hotel, where every guest is checked in on arrival.
It makes the feature unusable for long stays: a reservation spanning weeks or
months sits in 'confirm' for its whole duration unless somebody performs a
check-in, and a monthly-split stay gets a fresh segment whose checkout is
weeks away. On a residence hall the list came up empty every single day.

Load instead every non-cancelled reservation whose stay covers today, which
is the single question the POS needs answered: can I charge this consumption
to somebody who is staying right now.

The explicit 'onboard' branch is dropped rather than kept as an alternative.
It only ever added reservations that are onboard outside their own dates, and
auto_departure_delayed() already moves those to 'departure_delayed' on the
checkout day and auto-checks them out afterwards. The one case that behaves
differently is an instance whose nocheckout_reservations cron is disabled: an
overstay left in 'onboard' past its checkout is no longer offered, and its
dates have to be corrected first.

Also use fields.Date.context_today() instead of fields.Datetime.now().date().
The latter is UTC, so in a positive-offset timezone the date rolls over before
local midnight and the evening shift loads the wrong day.
@DarioLodeiros
DarioLodeiros force-pushed the 16.0-fix-pos_pms_link-reservations-by-date branch from c055f1e to fc8f1b3 Compare September 4, 2026 10:13
@DarioLodeiros DarioLodeiros changed the title [16.0][FIX] pos_pms_link: load reservations covering today, not only onboard [16.0][FIX] pos_pms_link: offer reservations whose stay covers today Sep 4, 2026
@DarioLodeiros

Copy link
Copy Markdown
Member Author

/ocabot merge minor

@OCA-git-bot

Copy link
Copy Markdown
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 16.0-ocabot-merge-pr-446-by-DarioLodeiros-bump-minor, awaiting test results.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

@DarioLodeiros The merge process could not be finalized, because command git push origin 16.0-ocabot-merge-pr-446-by-DarioLodeiros-bump-minor:16.0 failed with output:

To https://github.com/OCA/pms
 ! [rejected]            16.0-ocabot-merge-pr-446-by-DarioLodeiros-bump-minor -> 16.0 (fetch first)
error: failed to push some refs to 'https://github.com/OCA/pms'
hint: Updates were rejected because the remote contains work that you do not
hint: have locally. This is usually caused by another repository pushing to
hint: the same ref. If you want to integrate the remote changes, use
hint: 'git pull' before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

@DarioLodeiros

Copy link
Copy Markdown
Member Author

/ocabot merge minor

@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 16.0-ocabot-merge-pr-446-by-DarioLodeiros-bump-minor, awaiting test results.

@OCA-git-bot
OCA-git-bot merged commit 8d4bc9f into OCA:16.0 Sep 7, 2026
5 of 7 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at 05bc0d2. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants