odoo/odoo#285662
Created by fw-bot
Statuses:
- legal/cla: Contributor License Agreement check
- ci/runbot: Odoo Test Suite
- ci/upgrade_enterprise: Test upgrades for enterprise master
- ci/template: (runtime 938s)
- ci/style: Optional style check. Ignore it only if strictly necessary.
- ci/security: Required security check. Can only be ignored by security team.
- ci/l10n: (runtime 38s)
- ci/documentation: (runtime 990s)
- ci/design-theme: (runtime 0s)
- label
- odoo-dev:saas-18.4-18.0-pos-opw-6401146-2-pebr-562103-fw
- head
- a88dae2dd480c0ece277402d21f76375a507f6f6
- merged
- 1 day ago by Pedram Bi Ria (pebr)
| odoo/odoo | |
|---|---|
| 18.0 | #284695 |
| saas-18.3 | #285427 |
| saas-18.4 | #285662 |
| 19.0 | #285769 |
| saas-19.1 | #285793 |
| saas-19.2 | #285813 |
| saas-19.3 | #285827 |
| saas-19.4 | #285835 |
| master | #285848 |
[FIX] point_of_sale: do not unlink a reloaded orderline
Steps to reproduce:
- Restaurant config with two POS devices on the same session
- Device A: open a table, add two products, press Order (the order is synced as a draft, its lines get server ids)
- Device A: remove both lines, without syncing
- Device B: touch the same order, so device A re-reads it from the server through the synchronisation websocket
- Device A: pay and validate the order
Issue:
The order is saved as paid, with its total and its payment, but without any orderline. The lines are deleted on the server: odoo.models.unlink: deleted pos.order.line records with IDs: [...]
Cause:
Removing an orderline queues an unlink command in
models.commands['pos.order'].unlink['lines_<order id>'] (delete_ in related_models.js). That command is only discarded by clearCommands(), which syncAllOrders() calls after a successful sync, so it stays pending in between.
Any read of the order in that window puts the line back: a deleted record counts as missing in missingRecursive(), so it is fetched again and loadData() re-creates it with its server id.
serialize() then emits both the update of the live line and the still pending unlink, and sync_from_ui writes
lines: [[1, id, {...}], [3, id]]. The ORM applies commands in order, and pos.order.line.order_id is ondelete='cascade', so Command.UNLINK deletes the line right after writing it.
Fix:
Skip a removal command when the record is still linked to the parent at serialization time. A record cannot be both linked and removed in the same payload, so the pending command is stale and dropping it keeps the local state. Genuine removals, where the record is no longer linked, are still sent.
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr