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.

96 lines
3.5 KiB

  1. odoo.define('beescoop.pos', function (require) {
  2. "use strict";
  3. var module = require("point_of_sale.screens");
  4. var Model = require('web.DataModel');
  5. var set_customer_info = function(el_class, value, prefix) {
  6. var el = this.$(el_class);
  7. el.empty();
  8. if (prefix && value) {
  9. value = prefix + value
  10. }
  11. if (value) {
  12. el.append(value);
  13. }
  14. }
  15. // TODO: will be taken care of in separate 'pos_order_email' module
  16. /* module.ReceiptScreenWidget = module.ReceiptScreenWidget.include({
  17. send : function() {
  18. var self = this;
  19. var loaded = new $.Deferred();
  20. var order = this.pos.get_order().name;
  21. var records = new Model('pos.order').call('send_order', [order], {}, { shadow: false, timeout: 10000});
  22. records.then(function(result){
  23. var el = self.$('.message-send')
  24. el.empty();
  25. el.append('<h2>' + result + '</h2>');
  26. },function(err){
  27. loaded.reject(err);
  28. });
  29. },
  30. renderElement: function() {
  31. var self = this;
  32. this._super();
  33. this.$('.button.send').click(function(){
  34. if (!self._locked) {
  35. self.send();
  36. }
  37. });
  38. },
  39. show: function(){
  40. this._super();
  41. var self = this;
  42. this.$('.message-send').empty();
  43. },
  44. })*/
  45. module.ActionpadWidget = module.ActionpadWidget.include({
  46. renderElement : function() {
  47. var self = this;
  48. var loaded = new $.Deferred();
  49. this._super();
  50. if (!this.pos.get_client()) {
  51. return
  52. }
  53. var customer_id = this.pos.get_client().id;
  54. var res = new Model('res.partner').call('get_eater',
  55. [ customer_id ], undefined, { shadow: true, timeout: 1000});
  56. res.then(function(result) {
  57. set_customer_info.call(self, '.customer-delegate1', result[0], 'Eater 1: ');
  58. set_customer_info.call(self, '.customer-delegate2', result[1], 'Eater 2: ');
  59. set_customer_info.call(self, '.customer-delegate3', result[2], 'Eater 3: ');
  60. }, function(err) {
  61. loaded.reject(err);
  62. });
  63. },
  64. });
  65. module.PaymentScreenWidget.include({
  66. render_customer_info : function() {
  67. var self = this;
  68. var loaded = new $.Deferred();
  69. if (!this.pos.get_client()) {
  70. return
  71. }
  72. var customer_id = this.pos.get_client().id;
  73. var res = new Model('res.partner').call('get_eater', [ customer_id ], undefined, { shadow: true, timeout: 1000});
  74. res.then(function(result) {
  75. set_customer_info.call(self, '.customer-name', self.pos.get_client().name);
  76. set_customer_info.call(self, '.customer-delegate1', result[0], 'Eater 1: ');
  77. set_customer_info.call(self, '.customer-delegate2', result[1], 'Eater 2: ');
  78. set_customer_info.call(self, '.customer-delegate3', result[2], 'Eater 3: ');
  79. }, function(err) {
  80. loaded.reject(err);
  81. });
  82. },
  83. renderElement : function() {
  84. this._super();
  85. this.render_customer_info();
  86. },
  87. customer_changed : function() {
  88. this._super();
  89. this.render_customer_info();
  90. },
  91. });
  92. });