summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoren Van Onder <jov@odoo.com>2015-09-15 15:43:41 +0200
committerJoren Van Onder <jov@odoo.com>2015-09-16 14:09:41 +0200
commit94900dda501656300e183289d1dfa16dfd0ee5b8 (patch)
tree1f4cce0c14861844afd6e7bad7f6e589c1fcada8
parent5345961073b58f511e5a229b506bb1dbb071a619 (diff)
[IMP] point_of_sale: reimplement cash control support
Support for cash control was removed in c04065abd8f62c9a211c8fa824f5eecf68e61b73. 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.
-rw-r--r--addons/account/models/account_bank_statement.py2
-rw-r--r--addons/point_of_sale/point_of_sale.py25
-rw-r--r--addons/point_of_sale/point_of_sale_view.xml22
3 files changed, 40 insertions, 9 deletions
diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py
index 80e6cd59fd8..d315a12e6e9 100644
--- a/addons/account/models/account_bank_statement.py
+++ b/addons/account/models/account_bank_statement.py
@@ -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:
diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py
index bdf8e989fec..3ddcbb77d11 100644
--- a/addons/point_of_sale/point_of_sale.py
+++ b/addons/point_of_sale/point_of_sale.py
@@ -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):
diff --git a/addons/point_of_sale/point_of_sale_view.xml b/addons/point_of_sale/point_of_sale_view.xml
index e924e5126e8..6abcd323133 100644
--- a/addons/point_of_sale/point_of_sale_view.xml
+++ b/addons/point_of_sale/point_of_sale_view.xml
@@ -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: