diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js
index 80ddbde9191..d8424baca6d 100644
--- a/addons/point_of_sale/static/src/js/screens.js
+++ b/addons/point_of_sale/static/src/js/screens.js
@@ -2146,14 +2146,9 @@ var PaymentScreenWidget = ScreenWidget.extend({
}
});
},
- toggle_email_button: function() {
- var client = this.pos.get_client();
- this.$('.js_email').removeClass('oe_hidden', client);
- },
customer_changed: function() {
var client = this.pos.get_client();
this.$('.js_customer_name').text( client ? client.name : _t('Customer') );
- this.toggle_email_button();
},
click_set_customer: function(){
this.gui.show_screen('clientlist');
@@ -2283,10 +2278,17 @@ var PaymentScreenWidget = ScreenWidget.extend({
}
}
- if (order.get_client && order.is_to_email() && !order.get_client().email) {
+ var client = order.get_client();
+ if (order.is_to_email() && (!client || client && !utils.is_email(client.email))) {
+ var title = !client
+ ? 'Please select the customer'
+ : 'Please provide valid email';
+ var body = !client
+ ? 'You need to select the customer before you can send the receipt via email.'
+ : 'This customer does not have a valid email address, define one or do not send an email.';
this.gui.show_popup('confirm', {
- 'title': _t('Please fill the Customer Email'),
- 'body': _t('This customer does not have an email address, define one or do not send an email'),
+ 'title': _t(title),
+ 'body': _t(body),
confirm: function () {
this.gui.show_screen('clientlist');
},
diff --git a/addons/point_of_sale/static/src/xml/pos.xml b/addons/point_of_sale/static/src/xml/pos.xml
index 96529b384d5..eec6e286fb6 100644
--- a/addons/point_of_sale/static/src/xml/pos.xml
+++ b/addons/point_of_sale/static/src/xml/pos.xml
@@ -824,7 +824,7 @@
-
+
Email
diff --git a/addons/point_of_sale/static/tests/tours/point_of_sale.js b/addons/point_of_sale/static/tests/tours/point_of_sale.js
index 352624a61c3..4f0a774ff09 100644
--- a/addons/point_of_sale/static/tests/tours/point_of_sale.js
+++ b/addons/point_of_sale/static/tests/tours/point_of_sale.js
@@ -288,6 +288,34 @@ odoo.define('point_of_sale.tour.acceptance', function (require) {
}];
}
+ function activate_email_and_select_a_customer_then_deactivate_email() {
+ // Check if the flow to select customer with email activated is working.
+ return [{
+ content: "activate email",
+ trigger: '.button.js_email',
+ }, {
+ content: "validate the order",
+ trigger: '.button.next.highlight:visible',
+ }, {
+ content: "verify dialog box to select customer",
+ trigger: ".button.confirm:visible",
+ }, {
+ content: "select a customer",
+ trigger: 'tr.client-line:contains("TEST PARTNER")',
+ }, {
+ content: "verify the selected customer",
+ trigger: '.button.next.highlight:visible',
+ }, {
+ content: "check if customer is set",
+ trigger: 'span.js_customer_name:contains("TEST PARTNER")',
+ run: function () {}, // it's a check
+ }, {
+ // sending email should be checked in different test
+ content: "deactivate email",
+ trigger: '.button.js_email',
+ }];
+ }
+
function finish_order() {
return [{
content: "validate the order",
@@ -338,6 +366,7 @@ odoo.define('point_of_sale.tour.acceptance', function (require) {
run: function () {}, // it's a check
}]);
+ steps = steps.concat(activate_email_and_select_a_customer_then_deactivate_email());
steps = steps.concat(finish_order());
// test opw-672118 orderline subtotal rounding
diff --git a/addons/point_of_sale/tests/test_frontend.py b/addons/point_of_sale/tests/test_frontend.py
index da6dcd43515..0961acadeab 100644
--- a/addons/point_of_sale/tests/test_frontend.py
+++ b/addons/point_of_sale/tests/test_frontend.py
@@ -265,6 +265,11 @@ class TestUi(odoo.tests.HttpCase):
})
env.ref('base.res_partner_18').property_product_pricelist = excluded_pricelist
+ partner = self.env['res.partner'].create({
+ 'name': 'TEST PARTNER',
+ 'email': 'test@partner.com',
+ })
+
# set the company currency to USD, otherwise it will assume
# euro's. this will cause issues as the sales journal is in
# USD, because of this all products would have a different