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.6 KiB

  1. /* Copyright 2019 Kolushov Alexandr <https://it-projects.info/team/kolushovalexandr>
  2. Copyright 2019 Kildebekov Anvar <https://it-projects.info/team/kildebekov>
  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: 20000,
  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 open_cashier_popup_and_close_it() {
  60. return [{
  61. content: "Open cashier selection popup",
  62. trigger: '.username',
  63. }, {
  64. content: "Make dummy action and simulate escape button clicking",
  65. trigger: '.modal-dialog:not(".oe_hidden")',
  66. run: function(){
  67. simulate_keyup_event(27);
  68. setTimeout(function () {
  69. if ($('.modal-dialog:not(".oe_hidden")').length) {
  70. console.log('error');
  71. } else {
  72. console.log('ok');
  73. }
  74. }, 50);
  75. },
  76. }, {
  77. content: "Make dummy action in order to properly pass the check for closed popups",
  78. trigger: '.order-button.selected',
  79. }];
  80. }
  81. var steps = [];
  82. steps = steps.concat(open_pos_neworder());
  83. steps = steps.concat(add_product_to_order('Miscellaneous'));
  84. steps = steps.concat(update_qty_for_product(3));
  85. steps = steps.concat(open_cashier_popup_and_close_it());
  86. tour.register('pos_keyboard_tour', { test: true, url: '/web' }, steps);
  87. });