Ivan Yelizariev
5 years ago
committed by
Vincent Van Rossem
3 changed files with 116 additions and 81 deletions
-
12pos_keyboard/data.xml
-
3pos_keyboard/static/src/js/pos.js
-
144pos_keyboard/static/src/js/test_pos_keyboard.js
@ -1,119 +1,147 @@ |
|||||
/* Copyright 2019 Kolushov Alexandr <https://it-projects.info/team/kolushovalexandr> |
/* Copyright 2019 Kolushov Alexandr <https://it-projects.info/team/kolushovalexandr> |
||||
Copyright 2019 Anvar Kildebekov <https://it-projects.info/team/fedoranvar>
|
Copyright 2019 Anvar Kildebekov <https://it-projects.info/team/fedoranvar>
|
||||
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). */
|
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). */
|
||||
odoo.define('pos_keyboard.tour', function (require) { |
|
||||
|
odoo.define("pos_keyboard.tour", function(require) { |
||||
"use strict"; |
"use strict"; |
||||
|
|
||||
var tour = require("web_tour.tour"); |
var tour = require("web_tour.tour"); |
||||
var core = require('web.core'); |
|
||||
|
var core = require("web.core"); |
||||
var _t = core._t; |
var _t = core._t; |
||||
|
|
||||
function open_pos_neworder() { |
function open_pos_neworder() { |
||||
return [{ |
|
||||
trigger: 'ul.o_menu_apps li.dropdown a.full', |
|
||||
|
return [ |
||||
|
{ |
||||
|
trigger: "ul.o_menu_apps li.dropdown a.full", |
||||
content: _t("Show Apps Menu"), |
content: _t("Show Apps Menu"), |
||||
position: 'bottom', |
|
||||
}, { |
|
||||
trigger: '.o_app[data-menu-xmlid="point_of_sale.menu_point_root"], .oe_menu_toggler[data-menu-xmlid="point_of_sale.menu_point_root"]', |
|
||||
content: _t("Ready to launch your <b>point of sale</b>? <i>Click here</i>."), |
|
||||
position: 'bottom', |
|
||||
}, { |
|
||||
|
position: "bottom", |
||||
|
}, |
||||
|
{ |
||||
|
trigger: |
||||
|
'.o_app[data-menu-xmlid="point_of_sale.menu_point_root"], .oe_menu_toggler[data-menu-xmlid="point_of_sale.menu_point_root"]', |
||||
|
content: _t( |
||||
|
"Ready to launch your <b>point of sale</b>? <i>Click here</i>." |
||||
|
), |
||||
|
position: "bottom", |
||||
|
}, |
||||
|
{ |
||||
trigger: ".o_pos_kanban button.oe_kanban_action_button", |
trigger: ".o_pos_kanban button.oe_kanban_action_button", |
||||
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>"), |
|
||||
position: "bottom" |
|
||||
}, { |
|
||||
|
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>" |
||||
|
), |
||||
|
position: "bottom", |
||||
|
}, |
||||
|
{ |
||||
content: "Switch to table or make dummy action", |
content: "Switch to table or make dummy action", |
||||
trigger: '.table:not(.oe_invisible .neworder-button), .order-button.selected', |
|
||||
|
trigger: |
||||
|
".table:not(.oe_invisible .neworder-button), .order-button.selected", |
||||
position: "bottom", |
position: "bottom", |
||||
timeout: 30000, |
timeout: 30000, |
||||
}, { |
|
||||
content: 'waiting for loading to finish', |
|
||||
trigger: '.order-button.neworder-button', |
|
||||
}]; |
|
||||
|
}, |
||||
|
{ |
||||
|
content: "waiting for loading to finish", |
||||
|
trigger: ".order-button.neworder-button", |
||||
|
}, |
||||
|
]; |
||||
} |
} |
||||
|
|
||||
function add_product_to_order(product_name) { |
function add_product_to_order(product_name) { |
||||
return [{ |
|
||||
content: 'buy ' + product_name, |
|
||||
|
return [ |
||||
|
{ |
||||
|
content: "buy " + product_name, |
||||
trigger: '.product-list .product-name:contains("' + product_name + '")', |
trigger: '.product-list .product-name:contains("' + product_name + '")', |
||||
}, { |
|
||||
content: 'the ' + product_name + ' have been added to the order', |
|
||||
|
}, |
||||
|
{ |
||||
|
content: "the " + product_name + " have been added to the order", |
||||
trigger: '.order .product-name:contains("' + product_name + '")', |
trigger: '.order .product-name:contains("' + product_name + '")', |
||||
}]; |
|
||||
|
}, |
||||
|
]; |
||||
} |
} |
||||
|
|
||||
function simulate_keyup_event(number) { |
function simulate_keyup_event(number) { |
||||
var event = $.Event('keyup'); |
|
||||
|
var event = $.Event("keyup"); |
||||
event.which = number; |
event.which = number; |
||||
event.keyCode = number; |
event.keyCode = number; |
||||
$('body').trigger(event); |
|
||||
|
$("body").trigger(event); |
||||
} |
} |
||||
|
|
||||
function update_qty_for_product(qty) { |
function update_qty_for_product(qty) { |
||||
return [{ |
|
||||
|
return [ |
||||
|
{ |
||||
content: "Make dummy action and update product qty", |
content: "Make dummy action and update product qty", |
||||
trigger: '.order-button.selected', |
|
||||
run: function(){ |
|
||||
|
trigger: ".order-button.selected", |
||||
|
run: function() { |
||||
simulate_keyup_event(96 + qty); |
simulate_keyup_event(96 + qty); |
||||
}, |
}, |
||||
}, { |
|
||||
content: 'Check the qty', |
|
||||
trigger: '.orderline.selected .info em:contains(' + qty + ')', |
|
||||
}]; |
|
||||
|
}, |
||||
|
{ |
||||
|
content: "Check the qty", |
||||
|
trigger: ".orderline.selected .info em:contains(" + qty + ")", |
||||
|
}, |
||||
|
]; |
||||
} |
} |
||||
|
|
||||
function connect_disconnect_keyboard() { |
function connect_disconnect_keyboard() { |
||||
var stps = [{ |
|
||||
|
var stps = [ |
||||
|
{ |
||||
content: "Open Payment-Screen", |
content: "Open Payment-Screen", |
||||
trigger: '.pay-circle', |
|
||||
}]; |
|
||||
|
trigger: ".pay-circle", |
||||
|
}, |
||||
|
]; |
||||
|
|
||||
if (odoo._modules.indexOf('pos_cashier_select') !== -1) { |
|
||||
stps = stps.concat([{ |
|
||||
|
if (odoo._modules.indexOf("pos_cashier_select") !== -1) { |
||||
|
stps = stps.concat([ |
||||
|
{ |
||||
trigger: '.modal-dialog.cashier .selection-item:contains("Admin")', |
trigger: '.modal-dialog.cashier .selection-item:contains("Admin")', |
||||
content: 'select first cashier', |
|
||||
}]); |
|
||||
|
content: "select first cashier", |
||||
|
}, |
||||
|
]); |
||||
} |
} |
||||
|
|
||||
stps = stps.concat([{ |
|
||||
content: 'Close Payment-Screen', |
|
||||
trigger: '.button:contains(Back)', |
|
||||
}]); |
|
||||
|
stps = stps.concat([ |
||||
|
{ |
||||
|
content: "Close Payment-Screen", |
||||
|
trigger: ".button:contains(Back)", |
||||
|
}, |
||||
|
]); |
||||
return stps; |
return stps; |
||||
} |
} |
||||
|
|
||||
function open_cashier_popup_and_close_it() { |
function open_cashier_popup_and_close_it() { |
||||
return [{ |
|
||||
|
return [ |
||||
|
{ |
||||
content: "Open cashier selection popup", |
content: "Open cashier selection popup", |
||||
trigger: '.username', |
|
||||
}, { |
|
||||
|
trigger: ".username", |
||||
|
}, |
||||
|
{ |
||||
content: "Make dummy action and simulate escape button clicking", |
content: "Make dummy action and simulate escape button clicking", |
||||
trigger: '.modal-dialog:not(".oe_hidden")', |
trigger: '.modal-dialog:not(".oe_hidden")', |
||||
run: function(){ |
|
||||
|
run: function() { |
||||
simulate_keyup_event(27); |
simulate_keyup_event(27); |
||||
setTimeout(function () { |
|
||||
|
setTimeout(function() { |
||||
if ($('.modal-dialog:not(".oe_hidden")').length) { |
if ($('.modal-dialog:not(".oe_hidden")').length) { |
||||
console.log('error'); |
|
||||
|
console.log("error"); |
||||
} else { |
} else { |
||||
console.log('ok'); |
|
||||
|
console.log("ok"); |
||||
} |
} |
||||
}, 50); |
}, 50); |
||||
}, |
}, |
||||
}, { |
|
||||
content: "Make dummy action in order to properly pass the check for closed popups", |
|
||||
trigger: '.order-button.selected', |
|
||||
}]; |
|
||||
|
}, |
||||
|
{ |
||||
|
content: |
||||
|
"Make dummy action in order to properly pass the check for closed popups", |
||||
|
trigger: ".order-button.selected", |
||||
|
}, |
||||
|
]; |
||||
} |
} |
||||
|
|
||||
var steps = []; |
var steps = []; |
||||
var quantity = 3; |
var quantity = 3; |
||||
steps = steps.concat(open_pos_neworder()); |
steps = steps.concat(open_pos_neworder()); |
||||
steps = steps.concat(add_product_to_order('Miscellaneous')); |
|
||||
|
steps = steps.concat(add_product_to_order("Miscellaneous")); |
||||
steps = steps.concat(update_qty_for_product(quantity)); |
steps = steps.concat(update_qty_for_product(quantity)); |
||||
steps = steps.concat(connect_disconnect_keyboard()); |
steps = steps.concat(connect_disconnect_keyboard()); |
||||
steps = steps.concat(update_qty_for_product(quantity+1)); |
|
||||
|
steps = steps.concat(update_qty_for_product(quantity + 1)); |
||||
steps = steps.concat(open_cashier_popup_and_close_it()); |
steps = steps.concat(open_cashier_popup_and_close_it()); |
||||
|
|
||||
tour.register('pos_keyboard_tour', { test: true, url: '/web' }, steps); |
|
||||
|
|
||||
|
tour.register("pos_keyboard_tour", {test: true, url: "/web"}, steps); |
||||
}); |
}); |
Write
Preview
Loading…
Cancel
Save
Reference in new issue