[FIX] point_of_sale: uninvoiced orders' state not set to 'done'
Prior to this commit: b234e97f87,
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#39735
X-original-commit: bb490301c22c84c86d2b1c2d27ecb96a4ff19ac5
Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user