[IMP] point_of_sale: reimplement cash control support
Support for cash control was removed in
c04065abd8. Because the cash_control field
on account.journal was removed, we now define a cash_control preference
on pos.config. In order to set the opening and closing balances the new
AccountBankStmtCashWizard is used.
This commit is contained in:
@@ -40,7 +40,7 @@ class AccountBankStmtCashWizard(models.Model):
|
||||
|
||||
@api.multi
|
||||
def validate(self):
|
||||
bnk_stmt_id = self.env.context.get('active_id', False)
|
||||
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:
|
||||
|
||||
@@ -105,6 +105,7 @@ class pos_config(osv.osv):
|
||||
'iface_tax_included': fields.boolean('Include Taxes in Prices', help='The displayed prices will always include all taxes, even if the taxes have been setup differently'),
|
||||
'iface_start_categ_id': fields.many2one('pos.category','Start Category', help='The point of sale will display this product category by default. If no category is specified, all available products will be shown'),
|
||||
'iface_display_categ_images': fields.boolean('Display Category Pictures', help="The product categories will be displayed with pictures."),
|
||||
'cash_control': fields.boolean('Cash Control', help="Check the amount of the cashbox at opening and closing."),
|
||||
'receipt_header': fields.text('Receipt Header',help="A short text that will be inserted as a header in the printed receipt"),
|
||||
'receipt_footer': fields.text('Receipt Footer',help="A short text that will be inserted as a footer in the printed receipt"),
|
||||
'proxy_ip': fields.char('IP Address', help='The hostname or ip address of the hardware proxy, Will be autodetected if left empty', size=45),
|
||||
@@ -351,12 +352,16 @@ class pos_session(osv.osv):
|
||||
'cash_register_id' : False,
|
||||
'cash_control' : False,
|
||||
}
|
||||
# TODO: cash_control field is removed.
|
||||
# for st in record.statement_ids:
|
||||
# if st.journal_id.cash_control == True:
|
||||
# result[record.id]['cash_control'] = True
|
||||
# result[record.id]['cash_journal_id'] = st.journal_id.id
|
||||
# result[record.id]['cash_register_id'] = st.id
|
||||
|
||||
if record.config_id.cash_control:
|
||||
for st in record.statement_ids:
|
||||
if st.journal_id.type == 'cash':
|
||||
result[record.id]['cash_control'] = True
|
||||
result[record.id]['cash_journal_id'] = st.journal_id.id
|
||||
result[record.id]['cash_register_id'] = st.id
|
||||
|
||||
if not result[record.id]['cash_control']:
|
||||
raise UserError(_("Cash control can only be applied to cash journals."))
|
||||
|
||||
return result
|
||||
|
||||
@@ -526,6 +531,14 @@ class pos_session(osv.osv):
|
||||
'config_id': config_id
|
||||
})
|
||||
|
||||
# set the journal_id which should be used by
|
||||
# account.bank.statement to set the opening balance of the
|
||||
# newly created bank statement
|
||||
if pos_config.cash_control:
|
||||
for journal in pos_config.journal_ids:
|
||||
if journal.type == 'cash':
|
||||
context.update({'journal_id': journal.id})
|
||||
|
||||
return super(pos_session, self).create(cr, uid, values, context=context)
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
|
||||
@@ -686,6 +686,7 @@
|
||||
<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" >
|
||||
@@ -785,21 +786,38 @@
|
||||
|
||||
</header>
|
||||
<sheet>
|
||||
<field name="cash_register_id" invisible="1"/>
|
||||
<div class="oe_button_box" name="button_box">
|
||||
<button class="oe_stat_button" name="%(action_pos_box_in)d"
|
||||
type="action" states="opened,closing_control" icon="fa-level-down">
|
||||
type="action" icon="fa-level-down"
|
||||
attrs="{'invisible': ['|', ('cash_control', '=', False), ('state', 'not in', ['opened', 'closing_control'])]}">
|
||||
<div class="o_form_field o_stat_info">
|
||||
<span class="o_stat_text">Put</span>
|
||||
<span class="o_stat_text">Money In</span>
|
||||
</div>
|
||||
</button>
|
||||
<button class="oe_stat_button" name="%(action_pos_box_out)d"
|
||||
type="action" states="opened,closing_control" icon="fa-level-up">
|
||||
type="action" icon="fa-level-up"
|
||||
attrs="{'invisible': ['|', ('cash_control', '=', False), ('state', 'not in', ['opened', 'closing_control'])]}">
|
||||
<div class="o_form_field o_stat_info">
|
||||
<span class="o_stat_text">Take</span>
|
||||
<span class="o_stat_text">Money Out</span>
|
||||
</div>
|
||||
</button>
|
||||
<button name="%(account.action_view_account_bnk_stmt_cashbox)d"
|
||||
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}">
|
||||
<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}">
|
||||
<span class="o_stat_text">Set Closing Balance</span>
|
||||
</button>
|
||||
</div>
|
||||
<h1 class="oe_title">
|
||||
Session:
|
||||
|
||||
Reference in New Issue
Block a user