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.

58 lines
2.0 KiB

  1. /*
  2. Copyright (C) 2004-Today Apertoso NV (<http://www.apertoso.be>)
  3. Copyright (C) 2016-Today La Louve (<http://www.lalouve.net/>)
  4. @author: Jos DE GRAEVE (<Jos.DeGraeve@apertoso.be>)
  5. @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
  6. The licence is in the file __manifest__.py
  7. */
  8. odoo.define('pos_customer_required.pos_customer_required', function (require) {
  9. "use strict";
  10. var screens = require('point_of_sale.screens');
  11. var gui = require('point_of_sale.gui');
  12. var core = require('web.core');
  13. var _t = core._t;
  14. screens.PaymentScreenWidget.include({
  15. validate_order: function(options) {
  16. if(this.pos.config.require_customer != 'no'
  17. && !this.pos.get_order().get_client()){
  18. this.gui.show_popup('error',{
  19. 'title': _t('An anonymous order cannot be confirmed'),
  20. 'body': _t('Please select a customer for this order.'),
  21. });
  22. return;
  23. }
  24. return this._super(options);
  25. }
  26. });
  27. /*
  28. Because of clientlist screen behaviour, it is not possible to simply
  29. use: set_default_screen('clientlist') + remove cancel button on
  30. customer screen.
  31. Instead of,
  32. - we overload the function : show_screen(screen_name,params,refresh),
  33. - and we replace the required screen by the 'clientlist' screen if the
  34. current PoS Order has no Customer.
  35. */
  36. var _show_screen_ = gui.Gui.prototype.show_screen;
  37. gui.Gui.prototype.show_screen = function(screen_name, params, refresh){
  38. if(this.pos.config.require_customer == 'order'
  39. && !this.pos.get_order().get_client()
  40. && screen_name != 'clientlist'){
  41. // We call first the original screen, to avoid to break the
  42. // 'previous screen' mecanism
  43. _show_screen_.call(this, screen_name, params, refresh);
  44. screen_name = 'clientlist';
  45. }
  46. _show_screen_.call(this, screen_name, params, refresh);
  47. };
  48. });