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.

91 lines
3.4 KiB

  1. /* Copyright 2019 Kolushov Alexandr <https://it-projects.info/team/kolushovalexandr>
  2. License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). */
  3. odoo.define('pos_keyboard.tour', function (require) {
  4. "use strict";
  5. var tour = require("web_tour.tour");
  6. var core = require('web.core');
  7. var _t = core._t;
  8. function open_pos_neworder() {
  9. return [{
  10. trigger: '.o_app[data-menu-xmlid="point_of_sale.menu_point_root"], .oe_menu_toggler[data-menu-xmlid="point_of_sale.menu_point_root"]',
  11. content: _t("Ready to launch your <b>point of sale</b>? <i>Click here</i>."),
  12. position: 'bottom',
  13. }, {
  14. trigger: ".o_pos_kanban button.oe_kanban_action_button",
  15. 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>"),
  16. position: "bottom"
  17. }, {
  18. content: "Switch to table or make dummy action",
  19. trigger: '.table:not(.oe_invisible .neworder-button), .order-button.selected',
  20. position: "bottom",
  21. timeout: 20000,
  22. }, {
  23. content: 'waiting for loading to finish',
  24. trigger: '.order-button.neworder-button',
  25. }];
  26. }
  27. function add_product_to_order(product_name) {
  28. return [{
  29. content: 'buy ' + product_name,
  30. trigger: '.product-list .product-name:contains("' + product_name + '")',
  31. }, {
  32. content: 'the ' + product_name + ' have been added to the order',
  33. trigger: '.order .product-name:contains("' + product_name + '")',
  34. }];
  35. }
  36. function simulate_keyup_event(number) {
  37. var event = $.Event('keyup');
  38. event.which = number;
  39. event.keyCode = number;
  40. $('body').trigger(event);
  41. }
  42. function update_qty_for_product(qty) {
  43. return [{
  44. content: "Make dummy action and update product qty",
  45. trigger: '.order-button.selected',
  46. run: function(){
  47. simulate_keyup_event(96 + qty);
  48. },
  49. }, {
  50. content: 'Check the qty',
  51. trigger: '.orderline.selected .info em:contains(' + qty + ')',
  52. }];
  53. }
  54. function open_cashier_popup_and_close_it() {
  55. return [{
  56. content: "Open cashier selection popup",
  57. trigger: '.username',
  58. }, {
  59. content: "Make dummy action and simulate escape button clicking",
  60. trigger: '.modal-dialog:not(".oe_hidden") p.title',
  61. run: function(){
  62. simulate_keyup_event(27);
  63. setTimeout(function () {
  64. if ($('.modal-dialog:not(".oe_hidden")').length) {
  65. console.log('error');
  66. } else {
  67. console.log('ok');
  68. }
  69. }, 50);
  70. },
  71. }, {
  72. content: "Make dummy action in order to properly pass the check for closed popups",
  73. trigger: '.order-button.selected',
  74. }];
  75. }
  76. var steps = [];
  77. steps = steps.concat(open_pos_neworder());
  78. steps = steps.concat(add_product_to_order('Miscellaneous'));
  79. steps = steps.concat(update_qty_for_product(3));
  80. steps = steps.concat(open_cashier_popup_and_close_it());
  81. tour.register('pos_keyboard_tour', { test: true, url: '/web' }, steps);
  82. });