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.

147 lines
5.0 KiB

  1. /* Copyright 2019 Kolushov Alexandr <https://it-projects.info/team/kolushovalexandr>
  2. Copyright 2019 Anvar Kildebekov <https://it-projects.info/team/fedoranvar>
  3. License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). */
  4. odoo.define("pos_keyboard.tour", function(require) {
  5. "use strict";
  6. var tour = require("web_tour.tour");
  7. var core = require("web.core");
  8. var _t = core._t;
  9. function open_pos_neworder() {
  10. return [
  11. {
  12. trigger: "ul.o_menu_apps li.dropdown a.full",
  13. content: _t("Show Apps Menu"),
  14. position: "bottom",
  15. },
  16. {
  17. trigger:
  18. '.o_app[data-menu-xmlid="point_of_sale.menu_point_root"], .oe_menu_toggler[data-menu-xmlid="point_of_sale.menu_point_root"]',
  19. content: _t(
  20. "Ready to launch your <b>point of sale</b>? <i>Click here</i>."
  21. ),
  22. position: "bottom",
  23. },
  24. {
  25. trigger: ".o_pos_kanban button.oe_kanban_action_button",
  26. content: _t(
  27. "<p>Click to start the point of sale interface. It <b>runs on tablets</b>, laptops, or industrial hardware.</p><p>Once the session launched, the system continues to run without an internet connection.</p>"
  28. ),
  29. position: "bottom",
  30. },
  31. {
  32. content: "Switch to table or make dummy action",
  33. trigger:
  34. ".table:not(.oe_invisible .neworder-button), .order-button.selected",
  35. position: "bottom",
  36. timeout: 30000,
  37. },
  38. {
  39. content: "waiting for loading to finish",
  40. trigger: ".order-button.neworder-button",
  41. },
  42. ];
  43. }
  44. function add_product_to_order(product_name) {
  45. return [
  46. {
  47. content: "buy " + product_name,
  48. trigger: '.product-list .product-name:contains("' + product_name + '")',
  49. },
  50. {
  51. content: "the " + product_name + " have been added to the order",
  52. trigger: '.order .product-name:contains("' + product_name + '")',
  53. },
  54. ];
  55. }
  56. function simulate_keyup_event(number) {
  57. var event = $.Event("keyup");
  58. event.which = number;
  59. event.keyCode = number;
  60. $("body").trigger(event);
  61. }
  62. function update_qty_for_product(qty) {
  63. return [
  64. {
  65. content: "Make dummy action and update product qty",
  66. trigger: ".order-button.selected",
  67. run: function() {
  68. simulate_keyup_event(96 + qty);
  69. },
  70. },
  71. {
  72. content: "Check the qty",
  73. trigger: ".orderline.selected .info em:contains(" + qty + ")",
  74. },
  75. ];
  76. }
  77. function connect_disconnect_keyboard() {
  78. var stps = [
  79. {
  80. content: "Open Payment-Screen",
  81. trigger: ".pay-circle",
  82. },
  83. ];
  84. if (odoo._modules.indexOf("pos_cashier_select") !== -1) {
  85. stps = stps.concat([
  86. {
  87. trigger: '.modal-dialog.cashier .selection-item:contains("Admin")',
  88. content: "select first cashier",
  89. },
  90. ]);
  91. }
  92. stps = stps.concat([
  93. {
  94. content: "Close Payment-Screen",
  95. trigger: ".button:contains(Back)",
  96. },
  97. ]);
  98. return stps;
  99. }
  100. function open_cashier_popup_and_close_it() {
  101. return [
  102. {
  103. content: "Open cashier selection popup",
  104. trigger: ".username",
  105. },
  106. {
  107. content: "Make dummy action and simulate escape button clicking",
  108. trigger: '.modal-dialog:not(".oe_hidden")',
  109. run: function() {
  110. simulate_keyup_event(27);
  111. setTimeout(function() {
  112. if ($('.modal-dialog:not(".oe_hidden")').length) {
  113. console.log("error");
  114. } else {
  115. console.log("ok");
  116. }
  117. }, 50);
  118. },
  119. },
  120. {
  121. content:
  122. "Make dummy action in order to properly pass the check for closed popups",
  123. trigger: ".order-button.selected",
  124. },
  125. ];
  126. }
  127. var steps = [];
  128. var quantity = 3;
  129. steps = steps.concat(open_pos_neworder());
  130. steps = steps.concat(add_product_to_order("Miscellaneous"));
  131. steps = steps.concat(update_qty_for_product(quantity));
  132. steps = steps.concat(connect_disconnect_keyboard());
  133. steps = steps.concat(update_qty_for_product(quantity + 1));
  134. steps = steps.concat(open_cashier_popup_and_close_it());
  135. tour.register("pos_keyboard_tour", {test: true, url: "/web"}, steps);
  136. });