Skip to content
Browse files

[IMP] POS: usability improvements

 - 'Create: Default Balance' wizard has been removed from 'Cash Control' at pos.config form view.
 -  Now at 'Cash Control', creat and edit 'Default Opening' will open tree view (# of Coins/Bills | Value of Coins/Bills | Subtotal and at bottom shows 'total').
 - 'default_cashbox_lines_ids' field in 'pos.config' has been set 'Many2one' (with '').
 - 'Set Opening Balance' button at 'pos.session' has been discarded.
 - 'Opening/Closing Values' has been discarded from 'Cash Control' as it is not required anymore over there.

 This commit is related to task id : 1934784
  • Loading branch information...
sht-odoo committed Apr 12, 2019
1 parent 7c970af commit 1b2f2e5d908ed49ad473b5cee14d6dfd5da7d28e
@@ -8,32 +8,28 @@
from odoo.exceptions import ValidationError

class AccountCashboxLine(models.Model):
_inherit = 'account.cashbox.line'

default_pos_id = fields.Many2one('pos.config', string='This cashbox line is used by default when opening or closing a balance for this point of sale')
class AccountBankStmtCashWizard(models.Model):
_inherit = ''

def name_get(self):
result = []
for cashbox_line in self:
result.append((, "%s * %s"%(cashbox_line.coin_value, cashbox_line.number)))
for cashbox_lines in self:
result.append((, "Cashbox %s" % (
return result

class AccountBankStmtCashWizard(models.Model):
_inherit = ''
def validate(self):
bnk_stmt_id = self.env.context.get('bank_statement_id', False) or self.env.context.get('active_id', False)
bnk_stmt = self.env[''].browse(bnk_stmt_id)
total = 0.0
for lines in self.cashbox_lines_ids:
total += lines.subtotal
# closing balance
bnk_stmt.write({'balance_end_real': total, 'cashbox_end_id':})
return {'type': 'ir.actions.act_window_close'}

def default_get(self, fields):
vals = super(AccountBankStmtCashWizard, self).default_get(fields)
config_id = self.env.context.get('default_pos_id')
if config_id:
lines = self.env['account.cashbox.line'].search([('default_pos_id', '=', config_id)])
if self.env.context.get('balance', False) == 'start':
vals['cashbox_lines_ids'] = [[0, 0, {'coin_value': line.coin_value, 'number': line.number, 'subtotal': line.subtotal}] for line in lines]
vals['cashbox_lines_ids'] = [[0, 0, {'coin_value': line.coin_value, 'number': 0, 'subtotal': 0.0}] for line in lines]
return vals

class PosConfig(models.Model):
_name = 'pos.config'
@@ -150,7 +146,7 @@ def _compute_default_customer_html(self):
help="This product is used as reference on customer receipts.")
fiscal_position_ids = fields.Many2many('account.fiscal.position', string='Fiscal Positions', help='This is useful for restaurants with onsite and take-away services that imply specific tax rates.')
default_fiscal_position_id = fields.Many2one('account.fiscal.position', string='Default Fiscal Position')
default_cashbox_lines_ids = fields.One2many('account.cashbox.line', 'default_pos_id', string='Default Balance')
default_cashbox_id = fields.Many2one('', string='Default Balance')
customer_facing_display_html = fields.Html(string='Customer facing display content', translate=True, default=_compute_default_customer_html)
use_pricelist = fields.Boolean("Use a pricelist.")
tax_regime = fields.Boolean("Tax Regime")
@@ -203,6 +203,17 @@ def create(self, values):
if values.get('name'):
pos_name += ' ' + values['name']

total = 0.0
balance_start = None
for lines in pos_config.default_cashbox_id.cashbox_lines_ids:
total += lines.subtotal
if pos_config.last_session_closing_cash:
balance_start = pos_config.last_session_closing_cash
elif pos_config.default_cashbox_id:
balance_start = total
balance_start = 0.0

statements = []
ABS = self.env['']
uid = SUPERUSER_ID if self.env.user.has_group('point_of_sale.group_pos_user') else
@@ -212,6 +223,7 @@ def create(self, values):
# newly created bank statement
ctx['journal_id'] = if pos_config.cash_control and journal.type == 'cash' else False
st_values = {
'balance_start': balance_start,
'name': pos_name
@@ -222,7 +234,8 @@ def create(self, values):
'name': pos_name,
'statement_ids': [(6, 0, statements)],
'config_id': config_id
'config_id': config_id,
'balance_start': balance_start

res = super(PosSession, self.with_context(ctx).sudo(uid)).create(values)
@@ -318,10 +331,9 @@ def open_frontend_cb(self):
def open_cashbox(self):
context = dict(self._context)
balance_type = context.get('balance') or 'start'
balance_type = context.get('balance')
context['bank_statement_id'] =
context['balance'] = balance_type
context['default_pos_id'] =

action = {
'name': _('Cash Control'),
@@ -335,10 +347,7 @@ def open_cashbox(self):

cashbox_id = None
if balance_type == 'start':
cashbox_id =
cashbox_id =
cashbox_id =
if cashbox_id:
action['res_id'] = cashbox_id

@@ -1,28 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>

<!--Account cashbox line-->
<!--Account bank cashbox -->

<record id="account_cashbox_line_view_tree" model="ir.ui.view">
<field name="name">account.cashbox.line.tree</field>
<field name="model">account.cashbox.line</field>
<field name="arch" type="xml">
<tree string="Cashbox balance" editable="top">
<field name="coin_value"/>
<field name="number"/>
<field name="subtotal"/>
<record id="view_account_bnk_stmt_cashbox" model="ir.ui.view">
<field name="name">account.bnk_stmt_cashbox.form</field>
<field name="model"></field>
<field name="arch" type="xml">
<field name="cashbox_lines_ids" nolabel="1">
<tree editable="bottom">
<field name="currency_id" invisible="1"/>
<field name="coin_value" widget="monetary"/>
<field name="number"/>
<field name="subtotal" sum="Total" widget="monetary"/>
<button string="Confirm" name="validate" type="object" class="btn-primary"/>
<button string="Cancel" class="btn-secondary" special="cancel"/>

<record id="account_cashbox_line_action" model="ir.actions.act_window">
<field name="name">Opening/Closing Values</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.cashbox.line</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="account_cashbox_line_view_tree"/>
<record id="action_view_account_bnk_stmt_cashbox" model="ir.actions.act_window">
<field name="name">Cash Control</field>
<field name="res_model"></field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_account_bnk_stmt_cashbox"/>
<field name="target">new</field>

<record id="pos_config_view_form" model="ir.ui.view">
<field name="name">pos.config.form.view</field>
@@ -346,15 +357,12 @@
<div class="content-group mt16" attrs="{'invisible': [('cash_control', '=', False)]}">
<div class="row mt16">
<label string="Default Opening" for="proxy_ip" class="col-lg-4 o_light_label" />
<field name="default_cashbox_lines_ids" widget="many2many_tags" context="{'show_coin_and_value': True}"/>
<field name="default_cashbox_id"/>
<div class="row">
<label for="amount_authorized_diff" class="col-lg-4 o_light_label" />
<field name="amount_authorized_diff"/>
<button type="action" name="%(account_cashbox_line_action)d" string="Opening/Closing Values" class="btn-link" icon="fa-arrow-right"/>
@@ -48,13 +48,6 @@
<span class="o_stat_text">Money Out</span>
<button name="open_cashbox"
attrs="{'invisible':['|', ('cash_control', '=', False), ('state', '!=', 'opening_control')]}"
type="object" context="{'balance': 'start'}">
<span class="o_stat_text">Set Opening Balance</span>
<button name="open_cashbox"
attrs="{'invisible':['|', '|', ('cash_control', '=', False), ('state', '=', 'opening_control'), ('state', '=', 'closed')]}"

0 comments on commit 1b2f2e5

Please sign in to comment.
You can’t perform that action at this time.