Skip to content
Snippets Groups Projects
Commit bb490301 authored by Joseph Caburnay's avatar Joseph Caburnay
Browse files

[FIX] point_of_sale: uninvoiced orders' state not set to 'done'


Prior to this commit: b234e97f,
uninvoiced orders' state is set to 'done' when the session is validated.
However, this was not taken into consideration in the said commit such
that even if the session is already validated, the uninvoiced orders'
state remains 'paid'.

Setting the orders state to 'done' is the correct behavior and is
implemented in this commit.

closes odoo/odoo#39720

Signed-off-by: default avatarpimodoo <pimodoo@users.noreply.github.com>
parent 01b143b9
Branches
Tags
No related merge requests found
......@@ -286,6 +286,8 @@ class PosSession(models.Model):
self._create_account_move()
if self.move_id.line_ids:
self.move_id.post()
# Set the uninvoiced orders' state to 'done'
self.env['pos.order'].search([('session_id', '=', self.id), ('state', '=', 'paid')]).write({'state': 'done'})
else:
# The cash register needs to be confirmed for cash diffs
# made thru cash in/out when sesion is in cash_control.
......
......@@ -228,9 +228,23 @@ class TestPoSBasicConfig(TestPoSCommon):
self.assertAlmostEqual(invoice.amount_total, 130, msg='Amount total should be 130. Product is untaxed.')
invoice_receivable_line = invoice.line_ids.filtered(lambda line: line.account_id == self.receivable_account)
# check state of orders before validating the session.
self.assertEqual('invoiced', invoiced_order.state, msg="state should be 'invoiced' for invoiced orders.")
uninvoiced_orders = self.pos_session.order_ids - invoiced_order
self.assertTrue(
all([order.state == 'paid' for order in uninvoiced_orders]),
msg="state should be 'paid' for uninvoiced orders before validating the session."
)
# close the session
self.pos_session.action_pos_session_validate()
# check state of orders after validating the session.
self.assertTrue(
all([order.state == 'done' for order in uninvoiced_orders]),
msg="State should be 'done' for uninvoiced orders after validating the session."
)
# check values after the session is closed
session_move = self.pos_session.move_id
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment