Skip to content
Permalink
Browse files

🔥 - In finalized order, When re-selected customer, it didn't

disable button
  • Loading branch information...
fedoranvar committed Aug 23, 2019
1 parent 9b6c3fd commit 595576f6b0e8ba5512f7a3b9ac02ddf7baf66b03
Showing with 18 additions and 11 deletions.
  1. +18 −11 pos_mail/static/src/js/pos.js
@@ -1,4 +1,5 @@
/* 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). */
odoo.define('pos_mail.pos', function (require) {

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

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

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

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

mail_receipt_action: function() {
mail_receipt_action: function(new_client = false) {
var self = this;
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){
console.log("Mail's sent");
}).fail(function(error){
@@ -48,6 +58,10 @@ odoo.define('pos_mail.pos', function (require) {
self.able_mail_button();
});
} 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.$el.zIndex(-6);
this.pos.gui.screen_instances.clientlist.show();
@@ -90,17 +104,10 @@ odoo.define('pos_mail.pos', function (require) {
this.pos.config.send_receipt_by_mail &&
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;
receipt_screen.send_mail_receipt(this.new_client.id);
receipt_screen.$el.zIndex(0);
this.$el.zIndex(-1);
receipt_screen.mail_receipt_action(this.new_client);
} else {
this._super();
}

0 comments on commit 595576f

Please sign in to comment.
You can’t perform that action at this time.