|
@ -6,6 +6,8 @@ odoo.define("pos_mail_receipt.screens", function (require) { |
|
|
|
|
|
|
|
|
var screens = require('point_of_sale.screens'); |
|
|
var screens = require('point_of_sale.screens'); |
|
|
var rpc = require('web.rpc'); |
|
|
var rpc = require('web.rpc'); |
|
|
|
|
|
var core = require('web.core'); |
|
|
|
|
|
var QWeb = core.qweb; |
|
|
|
|
|
|
|
|
var ReceiptScreenWidget = screens.ReceiptScreenWidget.include({ |
|
|
var ReceiptScreenWidget = screens.ReceiptScreenWidget.include({ |
|
|
renderElement: function() { |
|
|
renderElement: function() { |
|
@ -24,15 +26,14 @@ odoo.define("pos_mail_receipt.screens", function (require) { |
|
|
email: function() { |
|
|
email: function() { |
|
|
var self = this; |
|
|
var self = this; |
|
|
var email = false; |
|
|
var email = false; |
|
|
var body_from_ui = this.$('.pos-sale-ticket').html() |
|
|
|
|
|
if( this.pos.get_order().get_client() && this.pos.get_order().get_client().email ) { |
|
|
if( this.pos.get_order().get_client() && this.pos.get_order().get_client().email ) { |
|
|
self._send_email_server(this.pos.get_order().name, {"email": this.pos.get_order().get_client().email, "body_from_ui": body_from_ui}); |
|
|
|
|
|
|
|
|
self._send_email_server(this.pos.get_order(), {"email": this.pos.get_order().get_client().email}); |
|
|
} else { |
|
|
} else { |
|
|
this.gui.show_popup('textarea', { |
|
|
this.gui.show_popup('textarea', { |
|
|
'title':_t('E-mail address to use'), |
|
|
'title':_t('E-mail address to use'), |
|
|
'value': '', |
|
|
'value': '', |
|
|
'confirm': function(value) { |
|
|
'confirm': function(value) { |
|
|
self._send_email_server(self.pos.get_order().name, {"email": value, "body_from_ui": body_from_ui}); |
|
|
|
|
|
|
|
|
self._send_email_server(self.pos.get_order(), {"email": value}); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
@ -50,11 +51,12 @@ odoo.define("pos_mail_receipt.screens", function (require) { |
|
|
while (self.pos.get("synch").state == "connecting") { |
|
|
while (self.pos.get("synch").state == "connecting") { |
|
|
await sleep(1000); |
|
|
await sleep(1000); |
|
|
} |
|
|
} |
|
|
|
|
|
var receipt = QWeb.render('XmlReceipt', this.get_receipt_render_env()); |
|
|
|
|
|
|
|
|
return rpc.query({ |
|
|
return rpc.query({ |
|
|
model: 'pos.order', |
|
|
model: 'pos.order', |
|
|
method: 'send_mail_receipt', |
|
|
method: 'send_mail_receipt', |
|
|
args: [order, options["email"], options["body_from_ui"]], |
|
|
|
|
|
|
|
|
args: [order.name, options["email"], receipt], |
|
|
}, { |
|
|
}, { |
|
|
timeout: timeout, |
|
|
timeout: timeout, |
|
|
}) |
|
|
}) |
|
@ -79,12 +81,14 @@ odoo.define("pos_mail_receipt.screens", function (require) { |
|
|
'title': error.data.message, |
|
|
'title': error.data.message, |
|
|
'body': error.data.debug |
|
|
'body': error.data.debug |
|
|
}); |
|
|
}); |
|
|
|
|
|
this.$('.button.email').removeClass("highlight"); |
|
|
} |
|
|
} |
|
|
if(connection_problem){ |
|
|
if(connection_problem){ |
|
|
self.gui.show_popup('error',{ |
|
|
self.gui.show_popup('error',{ |
|
|
'title': _t('The e-mail could not be sent'), |
|
|
'title': _t('The e-mail could not be sent'), |
|
|
'body': _t('Check your internet connection and try again.'), |
|
|
'body': _t('Check your internet connection and try again.'), |
|
|
}); |
|
|
}); |
|
|
|
|
|
this.$('.button.email').removeClass("highlight"); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|