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.

79 lines
2.8 KiB

  1. odoo.define('beesdoo_pos.screens', function (require) {
  2. "use strict";
  3. var screens = require("point_of_sale.screens");
  4. var set_customer_info = function(el_class, value, prefix) {
  5. var el = this.$(el_class);
  6. el.empty();
  7. if (prefix && value) {
  8. value = prefix + value
  9. }
  10. if (value) {
  11. el.append(value);
  12. }
  13. }
  14. screens.ActionpadWidget = screens.ActionpadWidget.include({
  15. renderElement : function() {
  16. var self = this;
  17. var loaded = new $.Deferred();
  18. this._super();
  19. if (!this.pos.get_client()) {
  20. return
  21. }
  22. var customer_id = this.pos.get_client().id;
  23. this._rpc({
  24. model: 'res.partner',
  25. method: 'get_eater',
  26. args: [customer_id],
  27. }, {
  28. shadow: true,
  29. }, {
  30. timeout: 1000,
  31. })
  32. .then(function (result) {
  33. set_customer_info.call(self, '.customer-delegate1', result[0], 'Eater 1: ');
  34. set_customer_info.call(self, '.customer-delegate2', result[1], 'Eater 2: ');
  35. set_customer_info.call(self, '.customer-delegate3', result[2], 'Eater 3: ');
  36. }).fail(function (type, error){
  37. loaded.reject(err);
  38. });
  39. },
  40. });
  41. screens.PaymentScreenWidget.include({
  42. render_customer_info : function() {
  43. var self = this;
  44. var loaded = new $.Deferred();
  45. if (!this.pos.get_client()) {
  46. return
  47. }
  48. var customer_id = this.pos.get_client().id;
  49. this._rpc({
  50. model: 'res.partner',
  51. method: 'get_eater',
  52. args: [customer_id],
  53. }, {
  54. shadow: true,
  55. }, {
  56. timeout: 1000,
  57. })
  58. .then(function (result) {
  59. set_customer_info.call(self, '.customer-name', self.pos.get_client().name);
  60. set_customer_info.call(self, '.customer-delegate1', result[0], 'Eater 1: ');
  61. set_customer_info.call(self, '.customer-delegate2', result[1], 'Eater 2: ');
  62. set_customer_info.call(self, '.customer-delegate3', result[2], 'Eater 3: ');
  63. }).fail(function (type, error){
  64. loaded.reject(err);
  65. });
  66. },
  67. renderElement : function() {
  68. this._super();
  69. this.render_customer_info();
  70. },
  71. customer_changed : function() {
  72. this._super();
  73. this.render_customer_info();
  74. },
  75. });
  76. });