From b16eb923f0a3b15bb76381dbf957aa1a8f0f61b4 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Wed, 14 Dec 2011 18:06:58 +0100 Subject: [PATCH] [imp] added wizard when there is no cash registers bzr revid: nicolas.vanhoren@openerp.com-20111214170658-y3eao3448ocy84rf --- addons/point_of_sale/static/src/js/pos.js | 19 ++++++++++++++----- .../wizard/pos_close_statement.py | 5 +++++ .../wizard/pos_close_statement.xml | 4 +++- .../wizard/pos_open_statement.py | 13 +++---------- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/addons/point_of_sale/static/src/js/pos.js b/addons/point_of_sale/static/src/js/pos.js index 7add23bb73a..0b76097d177 100644 --- a/addons/point_of_sale/static/src/js/pos.js +++ b/addons/point_of_sale/static/src/js/pos.js @@ -80,7 +80,7 @@ openerp.point_of_sale = function(db) { }, this)); $.when(this.fetch('pos.category', ['name', 'parent_id', 'child_id']), this.fetch('product.product', ['name', 'list_price', 'pos_categ_id', 'taxes_id', 'img'], [['pos_categ_id', '!=', 'false']]), - this.fetch('account.bank.statement', ['account_id', 'currency', 'journal_id', 'state', 'name']), + this.fetch('account.bank.statement', ['account_id', 'currency', 'journal_id', 'state', 'name'], [['state', '=', 'open']]), this.fetch('account.journal', ['auto_cash', 'check_dtls', 'currency', 'name', 'type']), this.get_currency()) .then(this.build_tree); @@ -1226,6 +1226,15 @@ openerp.point_of_sale = function(db) { pos.app = new App(self.$element); $('.oe_toggle_secondary_menu').hide(); $('.oe_footer').hide(); + + if (pos.store.get('account.bank.statement').length === 0) + return new db.web.Model("ir.model.data").get_func("search_read")([['name', '=', 'action_pos_open_statement']], ['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; + this.do_action(action); + }, this)); + }, this)); }, this)); }, render: function() { @@ -1264,12 +1273,12 @@ openerp.point_of_sale = function(db) { }, this)); }, close: function() { - new db.web.Model("ir.model.data").get_func("search_read")([['name', '=', 'action_pos_close_statement']], ['res_id']).pipe( + return new db.web.Model("ir.model.data").get_func("search_read")([['name', '=', 'action_pos_close_statement']], ['res_id']).pipe( _.bind(function(res) { - this.rpc('/web/action/load', {'action_id': res[0]['res_id']}).pipe(_.bind(function(result) { + return this.rpc('/web/action/load', {'action_id': res[0]['res_id']}).pipe(_.bind(function(result) { var action = result.result; - this.do_action(action) - this.do_action({type: 'ir.actions.client', tag: 'default_home'}); + action.context = _.extend(action.context || {}, {'cancel_action': {type: 'ir.actions.client', tag: 'default_home'}}); + this.do_action(action); }, this)); }, this)); }, diff --git a/addons/point_of_sale/wizard/pos_close_statement.py b/addons/point_of_sale/wizard/pos_close_statement.py index 92dee2f8e4c..08f51113d8d 100644 --- a/addons/point_of_sale/wizard/pos_close_statement.py +++ b/addons/point_of_sale/wizard/pos_close_statement.py @@ -25,6 +25,10 @@ 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): """ @@ -35,6 +39,7 @@ class pos_close_statement(osv.osv_memory): @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') diff --git a/addons/point_of_sale/wizard/pos_close_statement.xml b/addons/point_of_sale/wizard/pos_close_statement.xml index 61c984c873e..9c11ad02e39 100644 --- a/addons/point_of_sale/wizard/pos_close_statement.xml +++ b/addons/point_of_sale/wizard/pos_close_statement.xml @@ -15,7 +15,9 @@