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.

119 lines
4.4 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. trigger: 'ul.o_menu_apps li.dropdown a.full',
  12. content: _t("Show Apps Menu"),
  13. position: 'bottom',
  14. }, {
  15. trigger: '.o_app[data-menu-xmlid="point_of_sale.menu_point_root"], .oe_menu_toggler[data-menu-xmlid="point_of_sale.menu_point_root"]',
  16. content: _t("Ready to launch your <b>point of sale</b>? <i>Click here</i>."),
  17. position: 'bottom',
  18. }, {
  19. trigger: ".o_pos_kanban button.oe_kanban_action_button",
  20. content: _t("<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>"),
  21. position: "bottom"
  22. }, {
  23. content: "Switch to table or make dummy action",
  24. trigger: '.table:not(.oe_invisible .neworder-button), .order-button.selected',
  25. position: "bottom",
  26. timeout: 30000,
  27. }, {
  28. content: 'waiting for loading to finish',
  29. trigger: '.order-button.neworder-button',
  30. }];
  31. }
  32. function add_product_to_order(product_name) {
  33. return [{
  34. content: 'buy ' + product_name,
  35. trigger: '.product-list .product-name:contains("' + product_name + '")',
  36. }, {
  37. content: 'the ' + product_name + ' have been added to the order',
  38. trigger: '.order .product-name:contains("' + product_name + '")',
  39. }];
  40. }
  41. function simulate_keyup_event(number) {
  42. var event = $.Event('keyup');
  43. event.which = number;
  44. event.keyCode = number;
  45. $('body').trigger(event);
  46. }
  47. function update_qty_for_product(qty) {
  48. return [{
  49. content: "Make dummy action and update product qty",
  50. trigger: '.order-button.selected',
  51. run: function(){
  52. simulate_keyup_event(96 + qty);
  53. },
  54. }, {
  55. content: 'Check the qty',
  56. trigger: '.orderline.selected .info em:contains(' + qty + ')',
  57. }];
  58. }
  59. function connect_disconnect_keyboard() {
  60. var stps = [{
  61. content: "Open Payment-Screen",
  62. trigger: '.pay-circle',
  63. }];
  64. if (odoo._modules.indexOf('pos_cashier_select') !== -1) {
  65. stps = stps.concat([{
  66. trigger: '.modal-dialog.cashier .selection-item:contains("Admin")',
  67. content: 'select first cashier',
  68. }]);
  69. }
  70. stps = stps.concat([{
  71. content: 'Close Payment-Screen',
  72. trigger: '.button:contains(Back)',
  73. }]);
  74. return stps;
  75. }
  76. function open_cashier_popup_and_close_it() {
  77. return [{
  78. content: "Open cashier selection popup",
  79. trigger: '.username',
  80. }, {
  81. content: "Make dummy action and simulate escape button clicking",
  82. trigger: '.modal-dialog:not(".oe_hidden")',
  83. run: function(){
  84. simulate_keyup_event(27);
  85. setTimeout(function () {
  86. if ($('.modal-dialog:not(".oe_hidden")').length) {
  87. console.log('error');
  88. } else {
  89. console.log('ok');
  90. }
  91. }, 50);
  92. },
  93. }, {
  94. content: "Make dummy action in order to properly pass the check for closed popups",
  95. trigger: '.order-button.selected',
  96. }];
  97. }
  98. var steps = [];
  99. var quantity = 3;
  100. steps = steps.concat(open_pos_neworder());
  101. steps = steps.concat(add_product_to_order('Miscellaneous'));
  102. steps = steps.concat(update_qty_for_product(quantity));
  103. steps = steps.concat(connect_disconnect_keyboard());
  104. steps = steps.concat(update_qty_for_product(quantity+1));
  105. steps = steps.concat(open_cashier_popup_and_close_it());
  106. tour.register('pos_keyboard_tour', { test: true, url: '/web' }, steps);
  107. });