From eb3e866b2e367449c43077c28da15132bec1c2a7 Mon Sep 17 00:00:00 2001 From: "Jacky (trj)" Date: Fri, 25 Jun 2021 12:27:26 +0000 Subject: [PATCH] [IMP] point_of_sale: opened sessions list In order to avoid a rescue session opened for ages, the point of sale dashboard also shows if there are more than one opened session at the same time. task-2492631 --- addons/point_of_sale/models/pos_config.py | 11 +++++++++++ .../point_of_sale/views/point_of_sale_dashboard.xml | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/addons/point_of_sale/models/pos_config.py b/addons/point_of_sale/models/pos_config.py index df3310851ef..7f2a55ee76e 100644 --- a/addons/point_of_sale/models/pos_config.py +++ b/addons/point_of_sale/models/pos_config.py @@ -162,6 +162,7 @@ class PosConfig(models.Model): session_ids = fields.One2many('pos.session', 'config_id', string='Sessions') current_session_id = fields.Many2one('pos.session', compute='_compute_current_session', string="Current Session") current_session_state = fields.Char(compute='_compute_current_session') + number_of_opened_session = fields.Integer(string="Number of Opened Session", compute='_compute_current_session') last_session_closing_cash = fields.Float(compute='_compute_last_session') last_session_closing_date = fields.Date(compute='_compute_last_session') last_session_closing_cashbox = fields.Many2one('account.bank.statement.cashbox', compute='_compute_last_session') @@ -268,6 +269,7 @@ class PosConfig(models.Model): opened_sessions = pos_config.session_ids.filtered(lambda s: not s.state == 'closed') session = pos_config.session_ids.filtered(lambda s: not s.state == 'closed' and not s.rescue) # sessions ordered by id desc + pos_config.number_of_opened_session = len(opened_sessions) pos_config.has_active_session = opened_sessions and True or False pos_config.current_session_id = session and session[0].id or False pos_config.current_session_state = session and session[0].state or False @@ -665,6 +667,15 @@ class PosConfig(models.Model): 'type': 'ir.actions.act_window', } + def open_opened_session_list(self): + return { + 'name': _('Opened Sessions'), + 'res_model': 'pos.session', + 'view_mode': 'tree,kanban,form', + 'type': 'ir.actions.act_window', + 'domain': [('state', '!=', 'closed'), ('config_id', '=', self.id)] + } + # All following methods are made to create data needed in POS, when a localisation # is installed, or if POS is installed on database having companies that already have # a localisation installed diff --git a/addons/point_of_sale/views/point_of_sale_dashboard.xml b/addons/point_of_sale/views/point_of_sale_dashboard.xml index faf333e61c7..a25867a8ea5 100644 --- a/addons/point_of_sale/views/point_of_sale_dashboard.xml +++ b/addons/point_of_sale/views/point_of_sale_dashboard.xml @@ -60,6 +60,7 @@ +
@@ -119,11 +120,16 @@
+ +
+