[IMP] point_of_sale: Cash Control Default Opening/Closing Balance

========
Purpose
========

POS : It is annoying process to put coin/bill value repeatedly in the cash register.
If user select cash control check box it should add default values.

In pos configuration the option cash control checkbox move to a new category
called Cash Control.

-When opening a POS session, when doing the cash control, it should already prefill
 the modal with the defaults cash control values (Coin/Bill Value, Number of
 Coins/Bills, Subtotal).
-When closing the POS session, the closing balance should just take the Coin/Bill
 Value defaults values. The user has to type in the number of Coins/Bills manually).
This commit is contained in:
Srushti Patel
2016-05-12 14:38:32 +02:00
committed by Yannick Tivisse
parent 3c14eee441
commit 58ffd9fc02
3 changed files with 34 additions and 3 deletions
+22
View File
@@ -5,6 +5,27 @@ import uuid
from odoo import api, fields, models, _
from odoo.exceptions import UserError
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.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'
@@ -92,6 +113,7 @@ class PosConfig(models.Model):
help="The product used to encode the customer tip. Leave empty if you do not accept tips.")
fiscal_position_ids = fields.Many2many('account.fiscal.position', string='Fiscal Positions')
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')
@api.depends('journal_id.currency_id', 'journal_id.company_id.currency_id')
def _compute_currency(self):
+10 -1
View File
@@ -44,7 +44,6 @@
<field name="iface_print_auto" />
<field name="iface_display_categ_images" />
<field name="iface_print_skip_screen" attrs="{'invisible' : [('iface_print_auto', '=', False)]}" />
<field name="cash_control" />
</group>
</group>
<group string="Hardware Proxy / PosBox" >
@@ -54,6 +53,16 @@
<field name="iface_electronic_scale" />
<field name="iface_cashdrawer" />
</group>
<group string="Cash Control">
<field name="cash_control"/>
<field name="default_cashbox_lines_ids" attrs="{'invisible': [('cash_control', '=', False)]}">
<tree string="Cashbox" editable="bottom">
<field name="coin_value"/>
<field name="number"/>
<field name="subtotal"/>
</tree>
</field>
</group>
<group name="receipt" string="Receipt" >
<field name="receipt_header" string="Header" placeholder="A custom receipt header message"/>
<field name="receipt_footer" string="Footer" placeholder="A custom receipt footer message"/>
@@ -52,14 +52,14 @@
class="oe_stat_button"
attrs="{'invisible':['|', ('cash_control', '=', False), ('state', '!=', 'opening_control')]}"
icon="fa-money"
type="action" context="{'balance': 'start', 'bank_statement_id': cash_register_id}">
type="action" context="{'balance': 'start', 'bank_statement_id': cash_register_id, 'default_pos_id': config_id}">
<span class="o_stat_text">Set Opening Balance</span>
</button>
<button name="%(account.action_view_account_bnk_stmt_cashbox)d"
class="oe_stat_button"
attrs="{'invisible':['|', '|', ('cash_control', '=', False), ('state', '=', 'opening_control'), ('state', '=', 'closed')]}"
icon="fa-money"
type="action" context="{'balance': 'end', 'bank_statement_id': cash_register_id}">
type="action" context="{'balance': 'end', 'bank_statement_id': cash_register_id, 'default_pos_id': config_id}">
<span class="o_stat_text">Set Closing Balance</span>
</button>
</div>