FixHighlight of Weekly #002

Paid POS orders no longer reopen after a server sync

With delivery platforms such as UrbanPiper, an incoming order could reload drafts just as a payment was validated. The next customer's products then landed on the order that had just been paid.

Versions18.019.020.0
ModulesPoint of Sale point_of_sale
AppPoint of Sale

Pull requests and commits

BranchPull requestCommit
18.0odoo/odoo#289249 ↗09af22f5ec ↗
19.0odoo/odoo#291573 ↗b7c58d1a8f ↗
20.0odoo/odoo#291986 ↗82e4c0720c ↗

Commit message

[FIX] point_of_sale: keep a paid order paid after a stale draft read

Steps to reproduce:
- Use a PoS that reloads its draft orders from the server on an
  external event, e.g. a PoS linked to a delivery platform
  (pos_urban_piper) which calls getServerOrders() on each incoming
  delivery order.
- Validate the payment of an order at the moment such an event arrives.
- The next customer's products are added to the order that was just
  paid, and the receipt shows both sales and both payments.

Issue:
The second sale is never recorded. The server logs "sync ignored for
existing PoS order (state: paid)" and no order, picking or journal
entry is created for it.

Cause:
getServerOrders() reads the orders in state draft. When that read
starts before the payment is committed, its answer still holds the
order as draft, and it can reach the PoS after the answer of the
payment sync. loadServerOrders() loads it over the local record, so
the order goes from paid back to draft in the PoS only. It is editable
again, later reads do not correct it as the server no longer returns it
as draft, and the server ignores any further sync of an order it
already has as paid.

Fix:
In loadServerOrders(), remember the state of the orders that are
already finalized locally before the read, and restore it when the
answer brings one of them back as draft. An order finalized in the PoS
is never legitimately draft again on the server, so such an answer is
always stale.

opw-6582460

My stack

Pick the versions and apps you run. Weekly digests, this week's table and All changes then show only what concerns you. Saved in this browser.

Versions
Apps
Modules