odoo/odoo#197715

Created by Aditi Patel (adip)
Merged at 4605e94960dd6737532878717c3167bb658ffa4a

Statuses:

label
odoo-dev:saas-18.1-sentry-6276299189-pos-undefined-function-error-adip
head
703d00b5d99815ff44b084fff6feb7cc6fbc865f
merged
5 months ago by POS IoT, Adrien Guilliams (adgu)
odoo/odoo
saas-18.1 #197715
saas-18.2 #209256
saas-18.3 #209278
saas-18.4
19.0
master #209420

[FIX] point_of_sale: prevent error when reopening a POS session

Currently, an error occurs on reopening a POS session if its 'Login Number Sequence' record has been deleted. This results in preventing the user from accessing the session.

Steps to produce:
- Install the point_of_sale module (with demo data).
- Open the register of the Furniture Shop from the POS dashboard.
- Now, without closing the register of shop, Navigate to:
Settings > Technical > Sequences & Identifiers > Sequences (list).
- Delete the Login Number Sequence of Session 3 sequence record.
- Reopen that shop session again.
- Observe the error at the backend.

Error:

UndefinedFunction
operator does not exist: integer = boolean
LINE 1: SELECT number_next FROM ir_sequence WHERE id=false FOR UPDAT...
                                                    ^
HINT:  No operator matches the given name and argument types. You might need
to add explicit type casts.

The error occurs because the system attempts to access the login_number_seq_id of the POS session at [1], but it is unavailable as the user has already deleted it.

This commit adds validation to prevent deletion of the 'Login Number Sequence' if the associated POS session is not closed.

[1] - https://github.com/odoo/odoo/blob/948f6c5afdf76b9a25daa120fec1edd21c5c08d6/addons/point_of_sale/models/pos_session.py#L404-L406

Sentry-6276299189


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr