Skip to content

Commit

Permalink
🔥 - In finalized order, When re-selected customer, it didn't
Browse files Browse the repository at this point in the history
disable button
  • Loading branch information
fedoranvar committed Aug 23, 2019
1 parent 9b6c3fd commit 595576f
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions pos_mail/static/src/js/pos.js
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,5 @@
/* Copyright 2019 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr> /* Copyright 2019 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
* Copyright 2019 Anvar Kildebekov <https://it-projects.info/team/fedoranvar2>
* License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). */ * License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). */
odoo.define('pos_mail.pos', function (require) { odoo.define('pos_mail.pos', function (require) {


Expand All @@ -9,10 +10,16 @@ odoo.define('pos_mail.pos', function (require) {
var QWeb = core.qweb; var QWeb = core.qweb;
var _t = core._t; var _t = core._t;


screens.PaymentScreenWidget.include({
show: function() {
this._super();
this.gui.screen_instances.receipt.able_mail_button();
},
});

screens.ReceiptScreenWidget.include({ screens.ReceiptScreenWidget.include({
show: function() { show: function() {
this._super(); this._super();
this.able_mail_button();
}, },


renderElement: function() { renderElement: function() {
Expand All @@ -34,10 +41,13 @@ odoo.define('pos_mail.pos', function (require) {
return this.able_mail_button().addClass('disable'); return this.able_mail_button().addClass('disable');
}, },


mail_receipt_action: function() { mail_receipt_action: function(new_client = false) {
var self = this; var self = this;
var partner = this.pos.get_order().get_client(); var partner = this.pos.get_order().get_client();
if (partner) { if (new_client) {
partner = new_client
}
if (partner && partner.email) {
return this.send_mail_receipt(partner.id).done(function(res){ return this.send_mail_receipt(partner.id).done(function(res){
console.log("Mail's sent"); console.log("Mail's sent");
}).fail(function(error){ }).fail(function(error){
Expand All @@ -48,6 +58,10 @@ odoo.define('pos_mail.pos', function (require) {
self.able_mail_button(); self.able_mail_button();
}); });
} else { } else {
this.gui.show_popup('error',{
'title': _t('Customer has no email address'),
'body': _t('Please add customer email or select another one'),
});
this.set_mail_customer = true; this.set_mail_customer = true;
this.$el.zIndex(-6); this.$el.zIndex(-6);
this.pos.gui.screen_instances.clientlist.show(); this.pos.gui.screen_instances.clientlist.show();
Expand Down Expand Up @@ -90,17 +104,10 @@ odoo.define('pos_mail.pos', function (require) {
this.pos.config.send_receipt_by_mail && this.pos.config.send_receipt_by_mail &&
this.gui.current_screen.set_mail_customer) { this.gui.current_screen.set_mail_customer) {


if (!this.new_client.email) {
this.gui.show_popup('error',{
'title': _t('Customer has no email address'),
'body': _t('Please add customer email or select another one'),
});
return;
}
var receipt_screen = this.gui.screen_instances.receipt; var receipt_screen = this.gui.screen_instances.receipt;
receipt_screen.send_mail_receipt(this.new_client.id);
receipt_screen.$el.zIndex(0); receipt_screen.$el.zIndex(0);
this.$el.zIndex(-1); this.$el.zIndex(-1);
receipt_screen.mail_receipt_action(this.new_client);
} else { } else {
this._super(); this._super();
} }
Expand Down

0 comments on commit 595576f

Please sign in to comment.