diff --git a/addons/account/account_cash_statement.py b/addons/account/account_cash_statement.py index 2bb89a84cdc..9af0dcf60f4 100644 --- a/addons/account/account_cash_statement.py +++ b/addons/account/account_cash_statement.py @@ -169,7 +169,7 @@ class account_cash_statement(osv.osv): return result _columns = { - 'total_entry_encoding': fields.function(_get_sum_entry_encoding, string="Total Cash Transactions", + 'total_entry_encoding': fields.function(_get_sum_entry_encoding, string="Total Transactions", store = { 'account.bank.statement': (lambda self, cr, uid, ids, context=None: ids, ['line_ids','move_line_ids'], 10), 'account.bank.statement.line': (_get_statement_from_line, ['amount'], 10), diff --git a/addons/point_of_sale/__openerp__.py b/addons/point_of_sale/__openerp__.py index 9d985d40408..d08a8163be6 100644 --- a/addons/point_of_sale/__openerp__.py +++ b/addons/point_of_sale/__openerp__.py @@ -51,7 +51,6 @@ Main features: 'wizard/pos_confirm.xml', 'wizard/pos_discount.xml', 'wizard/pos_open_statement.xml', - 'wizard/pos_close_statement.xml', 'wizard/pos_payment_report_user_view.xml', 'wizard/pos_sales_user.xml', 'wizard/pos_receipt_view.xml', diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index c7d07b9eb5f..6d95b561fce 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -195,23 +195,17 @@ class pos_session(osv.osv): required=True, select=1, domain="[('state', '=', 'active')]", -# readonly=True, -# states={'draft' : [('readonly', False)]} ), - 'name' : fields.char('Session ID', size=32, - required=True, -# readonly=True, -# states={'draft' : [('readonly', False)]} - ), + 'name' : fields.char('Session ID', size=32, required=True, readonly=True), 'user_id' : fields.many2one('res.users', 'Responsible', required=True, select=1, -# readonly=True, -# states={'draft' : [('readonly', False)]} + readonly=True, + states={'opening_control' : [('readonly', False)]} ), - 'start_at' : fields.datetime('Opening Date'), - 'stop_at' : fields.datetime('Closing Date'), + 'start_at' : fields.datetime('Opening Date', readonly=True), + 'stop_at' : fields.datetime('Closing Date', readonly=True), 'state' : fields.selection(POS_SESSION_STATE, 'State', required=True, readonly=True, @@ -281,7 +275,7 @@ class pos_session(osv.osv): for session in self.browse(cr, uid, ids, context=None): # open if there is no session in 'opening_control', 'opened', 'closing_control' for one user domain = [ - ('state', '!=', 'closed'), + ('state', 'not in', ('closed','closing_control')), ('user_id', '=', uid) ] count = self.search_count(cr, uid, domain, context=context) @@ -344,7 +338,7 @@ class pos_session(osv.osv): record.write(values, context=context) for st in record.statement_ids: st.button_open(context=context) - return True + return self.open_frontend_cb(cr, uid, ids, context=context) def wkf_action_opening_control(self, cr, uid, ids, context=None): return self.write(cr, uid, ids, {'state' : 'opening_control'}, context=context) @@ -352,7 +346,7 @@ class pos_session(osv.osv): def wkf_action_closing_control(self, cr, uid, ids, context=None): for session in self.browse(cr, uid, ids, context=context): for statement in session.statement_ids: - if not statement.journal_id.closing_control: + if statement.id <> session.cash_register_id.id: if statement.balance_end<>statement.balance_end_real: self.pool.get('account.bank.statement').write(cr, uid, [statement.id], {'balance_end_real': statement.balance_end}) @@ -377,7 +371,7 @@ class pos_session(osv.osv): name= _('Point of Sale Loss') if not account_id: raise osv.except_osv( _('Error!'), - _("Please set your profit and loss accounts on your payment method '%s'.") % (st.journal_id.name,)) + _("Please set your profit and loss accounts on your payment method '%s'. This will allow OpenERP to post the difference of %.2f in your ending balance. To close this session, you can update the 'Closing Cash Control' to avoid any difference.") % (st.journal_id.name,st.difference)) bsl.create(cr, uid, { 'statement_id': st.id, 'amount': st.difference, @@ -388,7 +382,15 @@ class pos_session(osv.osv): getattr(st, 'button_confirm_%s' % st.journal_id.type)(context=context) self._confirm_orders(cr, uid, ids, context=context) - return self.write(cr, uid, ids, {'state' : 'closed'}, context=context) + self.write(cr, uid, ids, {'state' : 'closed'}, context=context) + + obj = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'point_of_sale', 'menu_point_root')[1] + return { + 'type' : 'ir.actions.client', + 'name' : 'Point of Sale Menu', + 'tag' : 'reload', + 'params' : {'menu_id': obj}, + } def _confirm_orders(self, cr, uid, ids, context=None): wf_service = netsvc.LocalService("workflow") @@ -413,10 +415,8 @@ class pos_session(osv.osv): def open_frontend_cb(self, cr, uid, ids, context=None): if not context: context = {} - if not ids: return {} - context.update({'session_id' : ids[0]}) return { 'type' : 'ir.actions.client', diff --git a/addons/point_of_sale/point_of_sale_data.xml b/addons/point_of_sale/point_of_sale_data.xml index 30fb98dc05f..108dd98c750 100644 --- a/addons/point_of_sale/point_of_sale_data.xml +++ b/addons/point_of_sale/point_of_sale_data.xml @@ -15,7 +15,7 @@ - Main PoS + Main diff --git a/addons/point_of_sale/point_of_sale_view.xml b/addons/point_of_sale/point_of_sale_view.xml index 0379d14e573..28407d0bcae 100644 --- a/addons/point_of_sale/point_of_sale_view.xml +++ b/addons/point_of_sale/point_of_sale_view.xml @@ -3,9 +3,9 @@ - @@ -156,7 +156,7 @@ - + @@ -764,18 +764,6 @@ - - - Point of Sale - - - 150 - - pos.config.form.view pos.config @@ -896,81 +884,93 @@ - - - - + + + + - - - + + + + + + Point of Sale Session: + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + You can define another list of available currencies on the + Cash Registers tab of the + payment method. + + + + + + + + + + + + + + + + + + + + + + + @@ -987,6 +987,7 @@ + @@ -1021,18 +1022,11 @@ - - @@ -1060,7 +1054,9 @@ - + diff --git a/addons/point_of_sale/static/src/js/pos_widgets.js b/addons/point_of_sale/static/src/js/pos_widgets.js index 8ec2d9c329c..bebbb3c1591 100644 --- a/addons/point_of_sale/static/src/js/pos_widgets.js +++ b/addons/point_of_sale/static/src/js/pos_widgets.js @@ -875,7 +875,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa }, close: function() { this.pos.barcode_reader.disconnect(); - return new instance.web.Model("ir.model.data").get_func("search_read")([['name', '=', 'action_pos_close_statement']], ['res_id']).pipe( + return new instance.web.Model("ir.model.data").get_func("search_read")([['name', '=', 'action_client_pos_menu']], ['res_id']).pipe( _.bind(function(res) { return this.rpc('/web/action/load', {'action_id': res[0]['res_id']}).pipe(_.bind(function(result) { var action = result.result; diff --git a/addons/point_of_sale/wizard/__init__.py b/addons/point_of_sale/wizard/__init__.py index cce0b46d6ff..0f97a054533 100644 --- a/addons/point_of_sale/wizard/__init__.py +++ b/addons/point_of_sale/wizard/__init__.py @@ -22,7 +22,6 @@ import pos_confirm import pos_discount import pos_open_statement -import pos_close_statement import pos_details import pos_sales_user import pos_sales_user_today diff --git a/addons/point_of_sale/wizard/pos_close_statement.py b/addons/point_of_sale/wizard/pos_close_statement.py deleted file mode 100644 index 336d9d51283..00000000000 --- a/addons/point_of_sale/wizard/pos_close_statement.py +++ /dev/null @@ -1,76 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 Tiny SPRL (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -from osv import osv -from tools.translate import _ - -class pos_close_statement(osv.osv_memory): - _name = 'pos.close.statement' - _description = 'Close Statements' - - def cancel_wizard(self, cr, uid, ids, context=None): - if context.get('cancel_action'): - return context['cancel_action'] - - def close_statement(self, cr, uid, ids, context=None): - """ - Close the statements - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param context: A standard dictionary - @return : Blank Dictionary - """ - context = context or {} - mod_obj = self.pool.get('ir.model.data') - statement_obj = self.pool.get('account.bank.statement') - journal_obj = self.pool.get('account.journal') - - j_ids = journal_obj.search(cr, uid, [('journal_user','=',1)], context=context) - ids = statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id', '=', uid), ('journal_id', 'in', j_ids)], context=context) - if not ids: - raise osv.except_osv(_('Message'), _('Cash registers are already closed.')) - for statement in statement_obj.browse(cr, uid, ids, context=context): - statement_obj.write(cr, uid, [statement.id], { - 'balance_end_real': statement.balance_end - }, context=context) - if not statement.journal_id.check_dtls: - statement_obj.button_confirm_cash(cr, uid, [statement.id], context=context) - - tree_res = mod_obj.get_object_reference(cr, uid, 'point_of_sale', 'view_cash_statement_pos_tree') - tree_id = tree_res and tree_res[1] or False - form_res = mod_obj.get_object_reference(cr, uid, 'account', 'view_bank_statement_form2') - form_id = form_res and form_res[1] or False - search_res = mod_obj.get_object_reference(cr, uid, 'account', 'view_account_bank_statement_filter') - - return { - 'domain': str([('id', 'in', ids)]), - 'name': _('Close Cash Registers'), - 'view_type': 'form', - 'view_mode': 'tree,form', - 'search_view_id': search_res and search_res[1] or False, - 'res_model': 'account.bank.statement', - 'views': [(tree_id, 'tree'), (form_id, 'form')], - 'type': 'ir.actions.act_window' - } -pos_close_statement() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/point_of_sale/wizard/pos_close_statement.xml b/addons/point_of_sale/wizard/pos_close_statement.xml deleted file mode 100644 index efc92f60e49..00000000000 --- a/addons/point_of_sale/wizard/pos_close_statement.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - Close Statements - pos.close.statement - form - - - - - - or - - - - - - - - - - - - Close Cash Register - ir.actions.act_window - pos.close.statement - form - form - new - - - diff --git a/addons/point_of_sale/wizard/pos_session_opening.py b/addons/point_of_sale/wizard/pos_session_opening.py index f62ab77966b..f7f231b3aa0 100644 --- a/addons/point_of_sale/wizard/pos_session_opening.py +++ b/addons/point_of_sale/wizard/pos_session_opening.py @@ -10,8 +10,26 @@ class pos_session_opening(osv.osv_memory): _columns = { 'pos_config_id' : fields.many2one('pos.config', 'Point of Sale', required=True), 'pos_session_id' : fields.many2one('pos.session', 'PoS Session'), + 'pos_state' : fields.char('Session State'), } + def open_ui(self, cr, uid, ids, context=None): + context = context or {} + data = self.browse(cr, uid, ids[0], context=context) + context['active_id'] = data.pos_session_id.id + return { + 'type' : 'ir.actions.client', + 'name' : 'Start Point Of Sale', + 'tag' : 'pos.ui', + 'context' : context + } + + def open_existing_session_cb_close(self, cr, uid, ids, context=None): + wf_service = netsvc.LocalService("workflow") + wizard = self.browse(cr, uid, ids[0], context=context) + wf_service.trg_validate(uid, 'pos.session', wizard.pos_session_id.id, 'cashbox_control', cr) + return self.open_session_cb(cr, uid, ids, context) + def open_session_cb(self, cr, uid, ids, context=None): assert len(ids) == 1, "you can open only one session at a time" proxy = self.pool.get('pos.session') @@ -42,18 +60,21 @@ class pos_session_opening(osv.osv_memory): } def on_change_config(self, cr, uid, ids, config_id, context=None): + result = { + 'pos_session_id': False, + 'pos_state': False + } if not config_id: - return {} + return {'value': result} proxy = self.pool.get('pos.session') session_ids = proxy.search(cr, uid, [ ('state', '<>', 'closed'), ('config_id', '=', config_id), ], context=context) - return { - 'value' : { - 'pos_session_id' : session_ids and session_ids[0] or False, - } - } + if session_ids: + result['pos_state'] = proxy.browse(cr, uid, session_ids[0], context=context).state + result['pos_session_id'] = session_ids[0] + return {'value' : result} def default_get(self, cr, uid, fieldnames, context=None): so = self.pool.get('pos.session') @@ -63,9 +84,10 @@ class pos_session_opening(osv.osv_memory): else: current_user = self.pool.get('res.users').browse(cr, uid, uid, context=context) result = current_user.pos_config and current_user.pos_config.id or False - + if not result: + r = self.pool.get('pos.config').search(cr, uid, [], context=context) + result = r and r[0] or False return { - 'pos_config_id' : result, - 'pos_session_id': session_ids and session_ids[0] or False + 'pos_config_id' : result } pos_session_opening() diff --git a/addons/point_of_sale/wizard/pos_session_opening.xml b/addons/point_of_sale/wizard/pos_session_opening.xml index 226edf70b62..38f8932bd56 100644 --- a/addons/point_of_sale/wizard/pos_session_opening.xml +++ b/addons/point_of_sale/wizard/pos_session_opening.xml @@ -7,28 +7,54 @@ - - - - - - + + + + + + + + + + + + + Click to start a session. + + You will first have to control your cash amount in your cash register. + Then you will be able to open the session and start selling with the touchscreen + interface. + + + - Open/Close a Session + Your Session ir.actions.act_window pos.session.opening form form - new + inline
+ You can define another list of available currencies on the + Cash Registers tab of the + payment method. +
+ Click to start a session. +
+ You will first have to control your cash amount in your cash register. + Then you will be able to open the session and start selling with the touchscreen + interface. +