[IMP] point_of_sale: new state on session

To have a better flow when a session needs to be cash controled and
really opened, we've added a state on the session which is 'new_session'
to identify the new sessions that have not been cash controled yet.

TASK-ID: 1934784

closes odoo/odoo#33948

Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
This commit is contained in:
Robin Heinz
2019-07-23 07:41:21 +00:00
committed by Pierre Masereel
parent 91532b7b13
commit 76fc5b772d
4 changed files with 15 additions and 9 deletions
+1 -1
View File
@@ -250,7 +250,7 @@ class PosConfig(models.Model):
@api.depends('session_ids')
def _compute_current_session_user(self):
for pos_config in self:
session = pos_config.session_ids.filtered(lambda s: s.state in ['opening_control', 'opened', 'closing_control'] and not s.rescue)
session = pos_config.session_ids.filtered(lambda s: s.state in ['new_session', 'opening_control', 'opened', 'closing_control'] and not s.rescue)
if session:
pos_config.pos_session_username = session[0].user_id.name
pos_config.pos_session_state = session[0].state
+4 -3
View File
@@ -13,6 +13,7 @@ class PosSession(models.Model):
_inherit = ['mail.thread', 'mail.activity.mixin']
POS_SESSION_STATE = [
('new_session', 'New Session'),
('opening_control', 'Opening Control'), # method action_pos_session_open
('opened', 'In Progress'), # method action_pos_session_closing_control
('closing_control', 'Closing Control'), # method action_pos_session_close
@@ -41,7 +42,7 @@ class PosSession(models.Model):
orders_to_reconcile.sudo()._reconcile_payments()
company_id = fields.Many2one('res.company', related='config_id.company_id', string="Company", readonly=True)
config_id = fields.Many2one(
'pos.config', string='Point of Sale',
help="The physical point of sale you will use.",
@@ -62,7 +63,7 @@ class PosSession(models.Model):
state = fields.Selection(
POS_SESSION_STATE, string='Status',
required=True, readonly=True,
index=True, copy=False, default='opening_control')
index=True, copy=False, default='new_session')
sequence_number = fields.Integer(string='Order Sequence Number', help='A sequence number that is incremented with each order', default=1)
login_number = fields.Integer(string='Login Sequence Number', help='A sequence number that is incremented each time a user resumes the pos session', default=0)
@@ -253,7 +254,7 @@ class PosSession(models.Model):
def action_pos_session_open(self):
# second browse because we need to refetch the data from the DB for cash_register_id
# we only open sessions that haven't already been opened
for session in self.filtered(lambda session: session.state == 'opening_control'):
for session in self.filtered(lambda session: session.state in ('new_session', 'opening_control')):
values = {}
if not session.start_at:
values['start_at'] = fields.Datetime.now()
@@ -59,6 +59,9 @@
<div class="o_primary">
<t t-esc="record.name.value"/>
</div>
<t t-if="record.pos_session_state.raw_value == 'new_session'">
<div class="badge badge-info o_kanban_inline_block">New session</div>
</t>
<t t-if="record.pos_session_state.raw_value == 'opening_control'">
<div class="badge badge-info o_kanban_inline_block">Opening Control</div>
</t>
@@ -81,7 +84,7 @@
<div class="col-6 o_kanban_primary_left">
<button t-if="record.current_session_state.raw_value === 'opened'" class="btn btn-primary" name="open_ui" type="object">Resume</button>
<button t-if="record.current_session_state.raw_value === 'opening_control'" class="btn btn-primary" name="open_existing_session_cb" type="object">Open Session</button>
<button t-if="record.current_session_state.raw_value === 'new_session' || record.current_session_state.raw_value === 'opening_control'" class="btn btn-primary" name="open_existing_session_cb" type="object">Open Session</button>
<button t-if="_.contains(['opened', 'closing_control'], record.current_session_state.raw_value)" class="btn btn-secondary" name="open_existing_session_cb" type="object">Close</button>
@@ -6,7 +6,10 @@
<field name="arch" type="xml">
<form string="Point of Sale Session" create="0">
<header>
<button name="action_pos_session_open" type="object" string="Open Session"
<button name="open_cashbox_pos" type="object" string="Open Session"
attrs="{'invisible' : ['|', ('cash_control', '=', False), ('state', '!=', 'new_session')]}" class="oe_highlight"
context="{'balance': 'start'}"/>
<button name="action_pos_session_open" type="object" string="Start Session"
attrs="{'invisible' : ['|', ('cash_control', '=', False), ('state', '!=', 'opening_control')]}" class="oe_highlight"/>
<button name="open_frontend_cb" type="object" string="Continue Selling" states="opened"
class="oe_highlight"/>
@@ -19,8 +22,7 @@
<button name="action_pos_session_validate" type="object" string="Validate Closing &amp; Post Entries" states="closing_control"
class="oe_highlight"/>
<field name="state" widget="statusbar" statusbar_visible="opening_control,opened,closing_control,closed" nolabel="1" />
<field name="state" widget="statusbar" statusbar_visible="new_session,opening_control,opened,closing_control,closed" nolabel="1" />
</header>
<sheet>
<field name="cash_register_id" invisible="1"/>
@@ -81,7 +83,7 @@
</group>
</div>
</page>
<page string="Payments" attrs="{'invisible' : [('state', '=', 'opening_control')]}">
<page string="Payments" attrs="{'invisible' : [('state', 'in', ('new_session', 'opening_control'))]}">
<field name="statement_ids">
<tree string="Statements">
<field name="name" />