[IMP] point_of_sale: The invoice button in the payment screen now sets the order to be invoiced instead of directly invoicing the order

This commit is contained in:
Frederic van der Essen
2014-08-25 15:36:30 +02:00
parent 7ce28ac75d
commit a1ed181c6d
4 changed files with 32 additions and 10 deletions
+5 -4
View File
@@ -496,10 +496,11 @@ td {
margin-right: 4px;
}
.pos .control-button.highlight{
background: #6EC89B;
border: solid 1px #6EC89B;
color: white;
.pos .control-button.highlight,
.pos .button.highlight {
background: #6EC89B !important;
border: solid 1px #6EC89B !important;
color: white !important;
}
.pos .control-button:active {
background: #7F82AC;
@@ -864,6 +864,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
this.receipt_type = 'receipt'; // 'receipt' || 'invoice'
this.temporary = attributes.temporary || false;
this.sequence_number = this.pos.pos_session.sequence_number++;
this.to_invoice = false;
return this;
},
is_empty: function(){
@@ -1068,6 +1069,12 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
}
}
},
set_to_invoice: function(to_invoice) {
this.to_invoice = to_invoice;
},
is_to_invoice: function(){
return this.to_invoice;
},
// remove all the paymentlines with zero money in it
clean_empty_paymentlines: function() {
var lines = this.get('paymentLines').models;
+19 -5
View File
@@ -1024,6 +1024,15 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
});
return methods;
},
click_invoice: function(){
var order = this.pos.get_order();
order.set_to_invoice(!order.is_to_invoice());
if (order.is_to_invoice()) {
this.$('.js_invoice').addClass('highlight');
} else {
this.$('.js_invoice').removeClass('highlight');
}
},
renderElement: function() {
var self = this;
this._super();
@@ -1045,7 +1054,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
});
this.$('.js_invoice').click(function(){
self.validate_order({invoice: true});
self.click_invoice();
});
},
@@ -1086,9 +1095,8 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
},
// Check if the order is paid, then sends it to the backend,
// and complete the sale process
validate_order: function(options) {
validate_order: function() {
var self = this;
options = options || {};
var order = this.pos.get_order();
@@ -1100,14 +1108,20 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
this.pos.proxy.open_cashbox();
}
if (options.invoice) {
if (order.is_to_invoice()) {
var invoiced = this.pos.push_and_invoice_order(order);
this.invoicing = true;
invoiced.fail(function(error){
self.invoicing = false;
if (error === 'error-no-client') {
self.pos_widget.screen_selector.set_current_screen('clientlist');
self.pos_widget.screen_selector.show_popup('confirm',{
message: _t('Please select the Customer'),
comment: _t('You need to select the customer before you can invoice an order.'),
confirm: function(){
self.pos_widget.screen_selector.set_current_screen('clientlist');
},
});
} else {
self.pos_widget.screen_selector.show_popup('error-invoice-transfer');
}
+1 -1
View File
@@ -528,7 +528,7 @@
<div class='payment-buttons'>
<t t-if='widget.pos.config.iface_invoicing'>
<div class='button js_invoice'>
<div t-attf-class='button js_invoice #{ widget.pos.get_order().is_to_invoice() ? "highlight" : ""} '>
<i class='fa fa-file-text-o' /> Invoice
</div>
</t>