diff options
| author | Joseph Caburnay <jcb@odoo.com> | 2019-09-11 09:51:52 +0000 |
|---|---|---|
| committer | Joseph Caburnay <jcb@odoo.com> | 2019-09-12 08:21:44 +0000 |
| commit | 25b7494e776c3675554ce9bd0d4f133e1ceeae4b (patch) | |
| tree | 64bd9946fe2317df54a1062b96a65979dbc42417 /addons | |
| parent | 7965c890c4e6f6562d265e1605fef3384b00316e (diff) | |
[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>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/point_of_sale/static/src/js/screens.js | 18 | ||||
| -rw-r--r-- | addons/point_of_sale/static/src/xml/pos.xml | 2 | ||||
| -rw-r--r-- | addons/point_of_sale/static/tests/tours/point_of_sale.js | 29 | ||||
| -rw-r--r-- | addons/point_of_sale/tests/test_frontend.py | 5 |
4 files changed, 45 insertions, 9 deletions
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 @@ </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'> 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 |
