Skip to content

[16.0][FIX] pms: pair folio sale lines by shared nights and order them by date - #465

Merged
OCA-git-bot merged 1 commit into
OCA:16.0from
DarioLodeiros:16.0-fix-sale-line-pairing-by-price
Oct 17, 2026
Merged

OCA-git-bot merged 1 commit into
OCA:16.0from
DarioLodeiros:16.0-fix-sale-line-pairing-by-price

Conversation

@DarioLodeiros

Copy link
Copy Markdown
Member

Problem

Extending an invoiced stay with nights cheaper than the invoiced ones fails with "It is forbidden to modify the following fields in a locked folio (fields already invoiced)".

_get_reservation_sale_lines groups the nights with read_group, which sorts the groups by price, and pairs them with the existing sale lines by position. The cheaper group sorts first and is handed the invoiced sale line, whose price is protected. Reservation services and folio services use the same pairing.

The same sort lists the room lines of the folio, and therefore of the invoice, by price instead of by date.

Fix

  • New helper _get_sale_line_groups: orders the groups by their first date and reuses each existing sale line for the group it shares most lines with. Groups sharing no line take the unused sale lines in order, as before.
  • Used for room nights, reservation services and folio services.
  • The sale lines to drop are accumulated across the services of a reservation; only those of the last service were kept.

On existing folios every group lands on its own sale line, so only sequence changes. Posted invoices are not touched.

Tests

  • extend an invoiced stay with cheaper nights
  • start an invoiced stay earlier with a cheaper night
  • add a cheaper day to an invoiced service
  • room lines ordered by their first night
  • a price change on one night keeps the sale line of the other nights

read_group returns the groups of nights sorted by price, and
_get_reservation_sale_lines paired them with the existing sale lines by
position. A new night cheaper than the invoiced ones sorted first and
took the invoiced sale line, so the locked folio check refused the
change: an invoiced stay could not be extended with cheaper nights.
Reservation and folio services used the same pairing.

Each existing sale line is now reused by the group it shares most lines
with; groups sharing none take the unused sale lines in order, as
before. Groups are ordered by their first date, so folio and invoice
lines follow the stay instead of the price. The sale lines to drop are
accumulated across the services of a reservation instead of keeping
only those of the last service.
@DarioLodeiros

Copy link
Copy Markdown
Member Author

/ocabot merge minor

@OCA-git-bot

Copy link
Copy Markdown
Contributor

On my way to merge this fine PR!
Prepared branch 16.0-ocabot-merge-pr-465-by-DarioLodeiros-bump-minor, awaiting test results.

@OCA-git-bot
OCA-git-bot merged commit eb00fc2 into OCA:16.0 Oct 17, 2026
5 of 7 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at 9f8d2ff. 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