Search code examples
pythonsessionodoopoint-of-sale

Odoo POS - Closing session gives bad query SQL error


I am trying to close a session in Odoo 13 but I am getting the following error:

Model: Payments (account.payment), Field: Payment Method (payment_method_id)', None)

I checked the log file and found this:

2023-05-16 14:11:39,382 1484292 ERROR Gofresh_Live odoo.sql_db: bad query: INSERT INTO "account_payment" ("id", "create_uid", "create_date", "write_uid", "write_date", "amount", "communication", "currency_id", "journal_id", "move_name", "name", "partner_id", "partner_type", "payment_date", "payment_difference_handling", "payment_method_id", "payment_type", "state", "writeoff_label") VALUES (nextval('account_payment_id_seq'), 2, (now() at time zone 'UTC'), 2, (now() at time zone 'UTC'), '2.300', 'POS/06001', 96, 7, NULL, 'POS/06001', NULL, 'supplier', '2023-05-16', 'open', NULL, 'outbound', 'reconciled', 'Write-Off') RETURNING id
ERROR: null value in column "payment_method_id" violates not-null constraint
DETAIL:  Failing row contains (3325, POS/06001, null, null, null, reconciled, outbound, null, supplier, null, 2.300, 96, 2023-05-16, POS/06001, 7, open, null, Write-Off, null, null, 2, 2023-05-16 14:11:35.362199, 2, 2023-05-16 14:11:35.362199, null, null).
 
2023-05-16 14:11:39,386 1484292 WARNING Gofresh_Live odoo.http: ('The operation cannot be completed:\n- Create/update: a mandatory field is not set.\n- Delete: another model requires the record being deleted. If possible, archive it instead.\n\nModel: Payments (account.payment), Field: Payment Method (payment_method_id)', None) 

Can anyone tell me how to resolve this?


Solution

  • Let's try these steps:

    1. Identify the payment methods available in your Odoo instance. Go to the "Accounting" module and navigate to "Configuration" -> "Payment Methods".

    2. Check that there is a valid payment method configured for the Point of Sale transactions.

    3. Check that the payment method assigned to the session is correct. Go to the Point of Sale module and open the session that you are trying to close.

    4. Check the "Payment Methods" tab of the session and ensure that a valid payment method is selected.

    5. If the payment method is missing or incorrect, edit the session and assign the appropriate payment method.

    6. Try to close the session again.

    With those steps, you should be able to resolve the "null value in column 'payment_method_id' violates not-null constraint" error during the session closure process.