You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.9 KiB

  1. /* Copyright 2019 Druidoo - Iván Todorovich
  2. License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). */
  3. odoo.define('pos_invoice_send_mail.screens', function (require) {
  4. "use strict";
  5. var core = require('web.core');
  6. var screens = require('point_of_sale.screens');
  7. var _t = core._t;
  8. screens.PaymentScreenWidget.include({
  9. renderElement: function() {
  10. var self = this;
  11. this._super();
  12. this.$('.js_send_mail').click(function(){
  13. self.click_send_mail();
  14. });
  15. },
  16. click_send_mail: function() {
  17. var order = this.pos.get_order();
  18. order.set_to_send_mail(!order.is_to_send_mail());
  19. if (order.is_to_send_mail()) {
  20. this.$('.js_send_mail').addClass('highlight');
  21. } else {
  22. this.$('.js_send_mail').removeClass('highlight');
  23. }
  24. if (order.is_to_send_mail() && !order.is_to_invoice()) {
  25. this.click_invoice();
  26. }
  27. },
  28. click_invoice: function() {
  29. this._super();
  30. var order = this.pos.get_order();
  31. if (!order.is_to_invoice() && order.is_to_send_mail()) {
  32. this.click_send_mail();
  33. }
  34. },
  35. });
  36. screens.ScreenWidget.include({
  37. _handleFailedPushForInvoice: function(order, refresh_screen, error) {
  38. var self = this;
  39. order = order || this.pos.get_order();
  40. this.invoicing = false;
  41. order.finalized = false;
  42. if (error.message === 'Missing Customer Email') {
  43. this.gui.show_popup('confirm', {
  44. 'title': _t('Please fill the customer email'),
  45. 'body': _t('You need to complete the customer email in order to send it.'),
  46. confirm: function(){
  47. self.gui.show_screen('clientlist', null, refresh_screen);
  48. },
  49. });
  50. } else {
  51. return this._super(order, refresh_screen, error);
  52. }
  53. },
  54. });
  55. });