Skip to content

[REF] pos: refactor pos accounting feature#5153

Draft
zepa-odoo wants to merge 3 commits into
master-pos_closing_accounting-modafrom
master-pos_accounting-zepa
Draft

[REF] pos: refactor pos accounting feature#5153
zepa-odoo wants to merge 3 commits into
master-pos_closing_accounting-modafrom
master-pos_accounting-zepa

Conversation

@zepa-odoo
Copy link
Copy Markdown

improve pos improve grouping and prepare vals for closing move

Refactor of the pos accounting and invoicing logic, now when closing
a session, it will create two moves if needed
- Sales move: containing all pos.order of type sale with aggregated
lines
- Refunds move: containing all pos.order of type refund with aggregated
lines

One of the major changes here is `pos_settle_due` in which is now only
possible to settle invoices and not pos order. That's because when
paying by customer account it will create an invoice each time.

Removed fields
- `invoice_journal_id` and `pos_invoice_journal_id` because now all
invoice are created with the same journal, the one defined on the pos
config.

- `split_transactions` because now, we don't allow to split payments
transactions on cash and bank, only when the type is pay_later

- `account_default_pos_receivable_account_id` because now the receivable
account is defined though a default partner on the pos.config

- `cash_real_transaction`, `cash_register_balance_start`,
`cash_register_balance_end_real`, `cash_journal_id`,
`cash_register_difference` and `cash_register_balance_end` all these
infos are now handled though the cash statement and its lines, so no
need to have them on the session

- `is_cash_count` because cash is now identified by type == 'cash'

- `is_invoiced` replaced by `is_singly_invoiced` and
`is_globally_invoiced`

- `session_move_id` because account_move is now used to link the order
to the session move if it was not invoiced

- `is_online_payment` because online payment method is now identified by
type == 'online' and not by a boolean field

- `settle_invoice_product_id`, `deposit_product_id` and
`settle_due_product_id` because we don't create a pos.order when
settling an invoice, so no need to have these products.

- `settled_invoice_id` and `settled_order_id` because we don't create a
pos.order when settling an invoice, so no need to link them anymore.

- `init_customer_due_total`, `customer_due_total`,
`settled_order_line_ids`, `settled_orders_count`, `commercial_partner_id`
because we don't settle pos.order anymore

- `pos_order_line_ids` and `pos_amount_unsettled` because we don't settle
pos.order anymore

- `pos_orders_amount_due` because we don't settle pos.order anymore

Test tracking
A lot of tests were replaced because all accounting entries for order
and session closing are now refactored.

Some tests were also removed because they were not relevant anymore with
the new way of handling payment and invoicing on pos.order.

Replaced tests
`test_classic_sale_order` replace:
- `test_state_when_closing_register`

`test_fifo_valuation_with_invoice` replace:
- `test_fifo_valuation_with_invoice_when_pos_customer_is_delivery_type`

`test_fixed_tax_negative_qty_should_be_negative` replace:
- `test_fixed_tax_negative_qty`
- `test_fixed_tax_positive_qty`

`test_user_right_on_statement_line_for_pos_user` replace:
- `test_pos_closing_cash_details`

`test_rounding_when_closing_session` replace:
- `test_invoice_rounding_overpaid_backend`
- `test_pos_create_account_move_round_globally`
- `test_rounding_method`

Moved in `test_pos_accounting.py`:
`test_journal_entries_category_without_account`
`test_tax_change_blocked_when_open_pos_session`
`test_order_partial_refund_rounding`

Test suite in `test_pos_accounting.py` replace:
- `test_pos_simple_invoiced_orders.py`
- `test_orders_no_invoiced`
- `test_orders_with_invoiced`
- `test_01_invoiced_order_from_other_customer`
- `test_02_all_orders_invoiced_mixed_customers`
- `test_total_due.py`
- `test_02_orders_without_invoice`
- `test_03_orders_with_invoice`

`test_invoice_a_negative_order_should_create_credit_note` replace:
- `test_manual_refund_negative_qty_invoice_creates_credit_note`

`test_invoice_an_order_from_closed_session` replace:
- `test_invoice_past_order_affecting_taxes`
- `test_invoice_past_refund`
- `test_invoice_past_order`
- `test_sale_order_postponed_invoicing`
- `test_order_invoiced_after_session_closed`
- `test_order_invoiced_customer_account_after_session_closed`
- `test_sale_order_postponed_invoicing`

`test_pos_order_sale_and_refund_with_taxes` replace:
- `test_orders_with_invoiced`
- `test_return_order`

`test_pos_order_sale_and_refund_with_taxes_invoiced` replace:
- `test_pos_create_correct_account_move`
- `test_return_order_invoiced`

`test_pos_order_sale_and_refund_with_taxes_not_invoiced` replace:
- `test_pos_create_correct_account_move`
- `test_return_order`

`test_invoiced_order_with_discount_sale_and_refund_with_tax` replace:
- `test_pos_create_correct_account_move_round_globally_discount`
- `test_pos_create_correct_account_move_round_globally_discount_real_use_case`

`test_tax_change_blocked_when_open_pos_session` replace:
- `test_tax_is_used_when_in_transactions`

`test_pos_payment_direction_and_account` replace:
- `test_pos_payment_direction_and_accounts`

`test_cash_statement_opening_and_closing_consistency` replace:
- `test_cash_register_if_no_order`
- `test_cash_payments_should_reflect_on_next_opening`

`test_invoicing_zero_amount_pos_order` replace:
- `test_orders_with_zero_valued_invoiced`

`test_order_partial_refund_rounding` replace:
- `test_refund_rounding_backend`
- `test_order_partial_refund`

`test_pos_config_with_other_currency_than_company` replace:
- `test_order_to_payment_currency`

`test_accounting_items_when_closing_with_bank_difference` replace:
- `test_payment_difference_accounting_items`
- `test_state_when_closing_register`

`test_pos_order_with_closing_storno` replace:
- `test_sale_order_postponed_invoicing_storno`

`test_various_orders` replace:
- `test_correct_partner_on_invoice_receivables`

`test_pos_order_session_closing_with_fp` replace:
- `test_01_no_invoice_fpos`
- `test_02_no_invoice_fpos_no_tax_dest`

`test_available_stock_order_no_invoice` replace:
- `test_orders_no_invoiced`
- `test_return_order`

`test_available_stock_order_with_invoice` replace:
- `test_orders_with_invoiced`
- `test_return_order`

`test_pos_order_with_company_branch` replace:
- `test_pos_branch_account`

Removed tests
`test_ZATCA_blocks_settle_due_and_sale_on_same_order` not usefull
settle due doesn't create pos.order anymore

`test_split_payment_linked_to_accounting_partner` split transaction is
now only available when using customer account (type == pay_layer)

`test_pos_hr_session_name_gap` removed not useful

`test_order_to_invoice_no_tax` not useful

`test_order_invoiced_customer_account_after_session_closed` not useful,
customer account payment are always invoiced but this test is almost
the same `test_invoice_an_order_from_closed_session`

`test_start_balance_with_two_pos` useless test, cash payment cannot be
shared.

`test_different_customer_invoices_settlement_same_session_reconciled_separately`
settling an invoice doesn't create `pos.order` anymore

`test_split_cash_payments` removed because split on customer account
is now available only when using `pay_later` payment method.

`test_receivable_account_reconciliation.py`, `test_pos_reconcile` no
more necessary, payment are now directly added to the account.move

`test_pos_settling_account_resets_on_payment_screen_unmount` removed
because now when leaving payment screen it will delete the order if its
a settling one.

`test_pos_settle_due_with_rounding` deleted, wtf we round on a money
deposit ?

`test_split_payment_linked_to_accounting_partner` split_transactions is
no more available with classic pm, only with pay_later.

`test_05_tax_base_amount` removed tax base amount are handled and tested
by accounting helpers

`test_no_kitchen_confirmation_for_deposit_money` removed because deposit
money doesn't create a pos.order anymore.

`test_order_with_deleted_tax` is now not possible to archive a tax used
by an open order.

`fastValidate` hoot deleted in pos_settle_due because isn't possible to
use fast validation with settle customer invoice anymore.

`test_double_syncing_same_order` removed, sync data with the same UUID
will update the same order, but since a payment_ids create command is in
the data, its normal that this payment is created two times.

`test_session_name_gap` removed, sequences are never rollbacked, so the
test is not correct.
@robodoo
Copy link
Copy Markdown

robodoo commented May 7, 2026

This PR targets the un-managed branch odoo-dev/odoo:master-pos_closing_accounting-moda, it needs to be retargeted before it can be merged.

@zepa-odoo zepa-odoo force-pushed the master-pos_accounting-zepa branch from 0d3781b to d07c2f7 Compare May 7, 2026 10:05
@davidmonnom davidmonnom force-pushed the master-pos_closing_accounting-moda branch 7 times, most recently from 72eea6d to df499b0 Compare May 12, 2026 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants