[imp] added wizard when there is no cash registers
bzr revid: nicolas.vanhoren@openerp.com-20111214170658-y3eao3448ocy84rf
This commit is contained in:
@@ -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));
|
||||
},
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
<group col="4" colspan="4">
|
||||
<group col="2" colspan="2"/>
|
||||
<button icon='gtk-stop' special="cancel"
|
||||
string="No" />
|
||||
string="No" invisible="context.get('cancel_action')"/>
|
||||
<button icon='gtk-stop' type="object" name="cancel_wizard"
|
||||
string="No" invisible="not context.get('cancel_action')"/>
|
||||
<button name="close_statement" string="Yes"
|
||||
type="object" icon="gtk-ok"/>
|
||||
</group>
|
||||
|
||||
@@ -75,16 +75,9 @@ class pos_open_statement(osv.osv_memory):
|
||||
form_id = form_res and form_res[1] or False
|
||||
search_id = mod_obj.get_object_reference(cr, uid, 'point_of_sale', 'view_pos_open_cash_statement_filter')
|
||||
|
||||
return {
|
||||
'domain': "[('id', 'in',[ "+','.join(map(str,st_ids))+"])]",
|
||||
'name': _('Open Cash Registers'),
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree, form',
|
||||
'search_view_id': search_id and search_id[1] or False ,
|
||||
'res_model': 'account.bank.statement',
|
||||
'views': [(tree_id, 'tree'), (form_id, 'form')],
|
||||
'context': {},
|
||||
'type': 'ir.actions.act_window'
|
||||
return {
|
||||
'type': 'ir.actions.client',
|
||||
'tag': 'pos.ui',
|
||||
}
|
||||
pos_open_statement()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user