From 5ee1007bf2483cb8b1d8ebfd1daa49973ec2648b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Tue, 22 May 2012 14:53:32 +0200 Subject: [PATCH] [FIX] point_of_sale: retrieve bank_statements associated to current session only bzr revid: fva@openerp.com-20120522125332-t6epspfeqxknjypo --- .../point_of_sale/static/src/js/pos_models.js | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/addons/point_of_sale/static/src/js/pos_models.js b/addons/point_of_sale/static/src/js/pos_models.js index db799b0f1d2..749b863d93e 100644 --- a/addons/point_of_sale/static/src/js/pos_models.js +++ b/addons/point_of_sale/static/src/js/pos_models.js @@ -107,13 +107,6 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal self.set({'product_list': result}); }); - var bank_def = fetch( - 'account.bank.statement', - ['account_id','currency','journal_id','state','name'], - [['state','=','open'], ['user_id', '=', this.session.uid]] - ).then(function(result){ - self.set({'bank_statements':result}); - }); var tax_def = fetch('account.tax', ['amount','price_include','type']) .then(function(result){ @@ -122,21 +115,21 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal var session_def = fetch( // loading the PoS Session. 'pos.session', - ['id', 'journal_ids','name','config_id','start_at','stop_at'], + ['id', 'journal_ids','name','user_id','config_id','start_at','stop_at'], [['state', '=', 'opened'], ['user_id', '=', this.session.uid]] ).pipe(function(result) { - // some data are associated with the pos session, like the pos config. + // some data are associated with the pos session, like the pos config and bank statements. // we must have a valid session before we can read those. - var pos_config_def = new $.Deferred(); + var session_data_def = new $.Deferred(); if( result.length !== 0 ) { var pos_session = result[0]; self.set({'pos_session': pos_session}); - pos_config_def = fetch( + var pos_config_def = fetch( 'pos.config', ['name','journal_ids','shop_id','journal_id', 'iface_self_checkout', 'iface_websql', 'iface_led', 'iface_cashdrawer', @@ -146,14 +139,25 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal ).then(function(result){ self.set({'pos_config': result[0]}); }); + + var bank_def = fetch( + 'account.bank.statement', + ['account_id','currency','journal_id','state','name','user_id'], + [['state','=','open'],['user_id', '=', pos_session.user_id[0]]] + ).then(function(result){ + self.set({'bank_statements':result}); + }); + + session_data_def = $.when(pos_config_def,bank_def); + }else{ - pos_config_def.reject(); + session_data_def.reject(); } - return pos_config_def; + return session_data_def; }); // when all the data has loaded, we compute some stuff, and declare the Pos ready to be used. - $.when(cat_def, prod_def, bank_def, session_def, tax_def, this.get_app_data(), this.flush()) + $.when(cat_def, prod_def, session_def, tax_def, this.get_app_data(), this.flush()) .then(function(){ self.build_tree(); self.set({'cashRegisters' : new module.CashRegisterCollection(self.get('bank_statements'))});