[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
This commit is contained in:
Jacky (trj)
2021-08-05 10:52:09 +00:00
parent c41ab54ed1
commit eb3e866b2e
2 changed files with 17 additions and 0 deletions
+11
View File
@@ -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
@@ -60,6 +60,7 @@
<field name="pos_session_state"/>
<field name="pos_session_duration"/>
<field name="currency_id"/>
<field name="number_of_opened_session"/>
<templates>
<t t-name="kanban-box">
<div>
@@ -119,11 +120,16 @@
<span><field name="last_session_closing_cash" widget="monetary"/></span>
</div>
</div>
<button t-if="record.number_of_opened_session.value &gt; 1" class="btn btn-link" style="padding-left:0; text-decoration: underline" name="open_opened_session_list" type="object">
There are <t t-esc="record.number_of_opened_session.value"/> open sessions
</button>
</div>
</div>
<div style="text-align:right;">
<field name="current_user_id" widget="many2one_avatar_user"/>
</div>
</div><div class="container o_kanban_card_manage_pane dropdown-menu" role="menu">
<div class="row">
<div class="col-6 o_kanban_card_manage_section o_kanban_manage_view">