[FIX] point_of_sale: make the email button behave as the invoice
This commit makes the email button to behave consistently with the invoice button. Basically, if there is no selected customer when invoicing, the UI should direct the user to select a customer. This behaviour is implemented with the email button with special check on the validity of the customer email. closes odoo/odoo#36681 Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
This commit is contained in:
@@ -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');
|
||||
},
|
||||
|
||||
@@ -824,7 +824,7 @@
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
<div t-attf-class='button js_email #{widget.pos.get_client() ? "" : "oe_hidden"}'>
|
||||
<div class='button js_email'>
|
||||
<i class='fa fa-inbox' /> Email
|
||||
</div>
|
||||
<t t-if='widget.pos.config.tip_product_id'>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user