From 888a29b10f71e0fe39af1d2a168f30bbe4afd97b Mon Sep 17 00:00:00 2001 From: Adrien Widart Date: Wed, 9 Jun 2021 14:55:33 +0000 Subject: [PATCH] [FIX] point_of_sale: delete cash statement if no sale Suppose a POS with setting 'Advanced Cash Control' enabled. The user starts/closes a POS session (no sale, no cash difference). In Accounting > Cash, a bank statement exists, has no line and its starting balance is equal to its ending balance. The user has then to add a zero line, post an validate the bank statement. In such situation, the bank statement should be automatically deleted when closing the session OPW-2507394 closes odoo/odoo#71987 X-original-commit: 760c1b19229e2971ada911cd5607ceaea36e982f Signed-off-by: Adrien Widart Signed-off-by: pimodoo --- addons/point_of_sale/models/pos_session.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/models/pos_session.py b/addons/point_of_sale/models/pos_session.py index cd3bfe33640..2e2efc37d43 100644 --- a/addons/point_of_sale/models/pos_session.py +++ b/addons/point_of_sale/models/pos_session.py @@ -333,7 +333,10 @@ class PosSession(models.Model): self.env['pos.order'].search([('session_id', '=', self.id), ('state', '=', 'paid')]).write({'state': 'done'}) else: self.move_id.unlink() - + elif not self.cash_register_id.difference: + cash_register = self.cash_register_id + cash_register.pos_session_id = False + cash_register.unlink() self.write({'state': 'closed'}) return { 'type': 'ir.actions.client',