[WIP] point_of_sale: disable validation button when order not fully paid
bzr revid: fva@openerp.com-20120831143159-a64527c3a1a8chk0
This commit is contained in:
parent
93395ac1ec
commit
846ec67adc
|
@ -735,6 +735,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
|
|||
|
||||
this.validate_button = this.add_action_button({
|
||||
label: 'Validate',
|
||||
name: 'validation',
|
||||
icon: '/point_of_sale/static/src/img/icons/png48/validate.png',
|
||||
click: function(){
|
||||
self.validateCurrentOrder();
|
||||
|
@ -806,6 +807,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
|
|||
this.$('#payment-paid-total').html(paidTotal.toFixed(2));
|
||||
this.$('#payment-remaining').html(remaining.toFixed(2));
|
||||
this.$('#payment-change').html(change.toFixed(2));
|
||||
this.pos_widget.action_bar.set_button_disabled('validation', remaining > 0);
|
||||
},
|
||||
set_numpad_state: function(numpadState) {
|
||||
if (this.numpadState) {
|
||||
|
|
|
@ -370,14 +370,21 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
this.label = options.label || 'button';
|
||||
this.rightalign = options.rightalign || false;
|
||||
this.click_action = options.click;
|
||||
this.disabled = options.disabled || false;
|
||||
if(options.icon){
|
||||
this.icon = options.icon;
|
||||
this.template = this.icon_template;
|
||||
}
|
||||
},
|
||||
set_disabled: function(disabled){
|
||||
if(this.disabled != disabled){
|
||||
this.disabled = !!disabled;
|
||||
this.renderElement();
|
||||
}
|
||||
},
|
||||
renderElement: function(){
|
||||
this._super();
|
||||
if(this.click_action){
|
||||
if(this.click_action && !this.disabled){
|
||||
this.$el.click(_.bind(this.click_action, this));
|
||||
}
|
||||
},
|
||||
|
@ -388,12 +395,12 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
init: function(parent, options){
|
||||
this._super(parent,options);
|
||||
this.button_list = [];
|
||||
this.fake_buttons = {};
|
||||
this.buttons = {};
|
||||
this.visibility = {};
|
||||
},
|
||||
set_element_visible: function(element, visible, action){
|
||||
if(visible != this.visibility[element]){
|
||||
this.visibility[element] = visible;
|
||||
this.visibility[element] = !!visible;
|
||||
if(visible){
|
||||
this.$('.'+element).show();
|
||||
}else{
|
||||
|
@ -401,14 +408,22 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
}
|
||||
}
|
||||
if(visible && action){
|
||||
this.action[element] = action;
|
||||
this.$('.'+element).off('click').click(action);
|
||||
}
|
||||
},
|
||||
set_button_disabled: function(name, disabled){
|
||||
var b = this.buttons[name];
|
||||
if(b){
|
||||
b.set_disabled(disabled);
|
||||
}
|
||||
},
|
||||
destroy_buttons:function(){
|
||||
for(var i = 0; i < this.button_list.length; i++){
|
||||
this.button_list[i].destroy();
|
||||
}
|
||||
this.button_list = [];
|
||||
this.buttons = {};
|
||||
return this;
|
||||
},
|
||||
get_button_count: function(){
|
||||
|
@ -417,6 +432,9 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
add_new_button: function(button_options){
|
||||
var button = new module.ActionButtonWidget(this,button_options);
|
||||
this.button_list.push(button);
|
||||
if(button_options.name){
|
||||
this.buttons[name] = button;
|
||||
}
|
||||
button.appendTo(this.$('.pos-actionbar-button-list'));
|
||||
return button;
|
||||
},
|
||||
|
|
|
@ -540,7 +540,7 @@
|
|||
</t>
|
||||
|
||||
<t t-name="ActionButtonWidget">
|
||||
<li t-att-class=" 'button '+ (widget.rightalign ? 'rightalign ' : '')">
|
||||
<li t-att-class=" 'button '+ (widget.rightalign ? 'rightalign ' : '') + (widget.disabled ? 'disabled ' : '')">
|
||||
<div class='label'>
|
||||
<t t-esc="widget.label" />
|
||||
</div>
|
||||
|
@ -548,7 +548,7 @@
|
|||
</t>
|
||||
|
||||
<t t-name="ActionButtonWidgetWithIcon">
|
||||
<li t-att-class=" 'button '+ (widget.rightalign ? 'rightalign ' : '')">
|
||||
<li t-att-class=" 'button '+ (widget.rightalign ? 'rightalign ' : '') + (widget.disabled ? 'disabled ' : '')">
|
||||
<div class='icon'>
|
||||
<img t-att-src="widget.icon" />
|
||||
<div class='iconlabel'><t t-esc="widget.label" /></div>
|
||||
|
|
Loading…
Reference in New Issue