[FIX] point_of_sale: correct starting balance for rescue session

Current behavior:
The rescue session are created with a starting balance of 0.00. When the
starting balance should be the end balance of the previous session.

Steps to reproduce:
- Open a POS session on 2 different browsers
- Make an order on the first browser, and close the session
- Make an order on the second browser, and close the session
- The second browser's session will be in rescue mode and the starting
  balance will be 0.00 when it should be the end balance of the first
  session.

opw-3136236

closes odoo/odoo#115258

X-original-commit: 265817f7d7d096be4a84a7dd710c1dabb93fe402
Signed-off-by: Trinh Jacky (trj) <trj@odoo.com>
Signed-off-by: Engels Robin (roen) <roen@odoo.com>
This commit is contained in:
roen-odoo
2023-03-15 13:19:58 +01:00
parent 3a798039d6
commit bfe6f3e9b0
2 changed files with 4 additions and 0 deletions
+3
View File
@@ -105,6 +105,9 @@ class PosOrder(models.Model):
})
# bypass opening_control (necessary when using cash control)
new_session.action_pos_session_open()
if new_session.config_id.cash_control and new_session.rescue:
last_session = self.env['pos.session'].search([('config_id', '=', new_session.config_id.id), ('id', '!=', new_session.id)], limit=1)
new_session.cash_register_balance_start = last_session.cash_register_balance_end_real
return new_session
@@ -688,6 +688,7 @@ class TestPointOfSaleFlow(TestPointOfSaleCommon):
rescue_session.post_closing_cash_details(total_cash_payment)
rescue_session.close_session_from_ui()
self.assertEqual(rescue_session.state, 'closed', "Rescue session was not properly closed")
self.assertEqual(rescue_session.cash_register_balance_start, current_session.cash_register_balance_end_real, "Rescue session does not start with the same amount as the previous session")
def test_order_to_payment_currency(self):
"""