Skip to content
Permalink
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 changed to 'default_cashbox_id' with 'Many2one' (with 'account.bank.statement.cashbox').
 - '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 0730464 commit 3bf1d9c6c1280b8cdf92719d368f0202a03a720c
@@ -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 = 'account.bank.statement.cashbox'

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

class AccountBankStmtCashWizard(models.Model):
_inherit = 'account.bank.statement.cashbox'
@api.multi
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['account.bank.statement'].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': self.id})
return {'type': 'ir.actions.act_window_close'}


@api.model
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]
else:
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('account.bank.statement.cashbox', 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,15 @@ 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.session_ids:
balance_start = pos_config.last_session_closing_cash
else:
balance_start = total

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

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

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

cashbox_id = None
if balance_type == 'start':
cashbox_id = self.cash_register_id.cashbox_start_id.id
else:
cashbox_id = self.cash_register_id.cashbox_end_id.id
cashbox_id = self.cash_register_id.cashbox_end_id.id
if cashbox_id:
action['res_id'] = cashbox_id

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

<!--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"/>
</tree>
</field>
</record>
<record id="view_account_bnk_stmt_cashbox" model="ir.ui.view">
<field name="name">account.bnk_stmt_cashbox.form</field>
<field name="model">account.bank.statement.cashbox</field>
<field name="arch" type="xml">
<form>
<group>
<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"/>
</tree>
</field>
</group>
<footer>
<button string="Confirm" name="validate" type="object" class="btn-primary"/>
<button string="Cancel" class="btn-secondary" special="cancel"/>
</footer>
</form>
</field>
</record>

<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>
<record id="action_view_account_bnk_stmt_cashbox" model="ir.actions.act_window">
<field name="name">Cash Control</field>
<field name="res_model">account.bank.statement.cashbox</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>

<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>
<div class="row">
<label for="amount_authorized_diff" class="col-lg-4 o_light_label" />
<field name="amount_authorized_diff"/>
</div>
<div>
<button type="action" name="%(account_cashbox_line_action)d" string="Opening/Closing Values" class="btn-link" icon="fa-arrow-right"/>
</div>
</div>
</div>
</div>
@@ -48,13 +48,6 @@
<span class="o_stat_text">Money Out</span>
</div>
</button>
<button name="open_cashbox"
class="oe_stat_button"
attrs="{'invisible':['|', ('cash_control', '=', False), ('state', '!=', 'opening_control')]}"
icon="fa-money"
type="object" context="{'balance': 'start'}">
<span class="o_stat_text">Set Opening Balance</span>
</button>
<button name="open_cashbox"
class="oe_stat_button"
attrs="{'invisible':['|', '|', ('cash_control', '=', False), ('state', '=', 'opening_control'), ('state', '=', 'closed')]}"

0 comments on commit 3bf1d9c

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