Debian Codegraph @

addons/pos_sale/static/tests/tours/utils/pos_sale_utils.js

raw symbols SCIP
1 import * as ProductScreen from "@point_of_sale/../tests/pos/tours/utils/product_screen_util";
2 import * as Dialog from "@point_of_sale/../tests/generic_helpers/dialog_util";
3 import * as Numpad from "@point_of_sale/../tests/generic_helpers/numpad_util";
4
5 export function selectNthOrder(n) {
6 return [
7 ...ProductScreen.clickControlButton("Quotation/Order"),
8 {
9 content: `select nth order`,
10 trigger: `.modal:not(.o_inactive_modal) table.o_list_table tbody tr.o_data_row:nth-child(${n}) td`,
11 run: "click",
12 },
13 ];
14 }
15
16 export function settleSaleOrderByPrice(price) {
17 return [
18 ...ProductScreen.clickControlButton("Quotation/Order"),
19 {
20 content: `select sale order with price ${price}`,
21 trigger: `.modal:not(.o_inactive_modal) table.o_list_table tbody tr.o_data_row td:contains('${price}')`,
22 run: "click",
23 },
24 {
25 content: `Choose to settle the order`,
26 trigger: `.modal:not(.o_inactive_modal) .selection-item:contains('Settle the order')`,
27 run: "click",
28 },
29 ];
30 }
31
32 export function settleNthOrder(n, options = {}) {
33 const { loadSN } = options;
34 const step = [
35 ...selectNthOrder(n),
36 {
37 content: `Choose to settle the order`,
38 trigger: `.modal:not(.o_inactive_modal) .selection-item:contains('Settle the order')`,
39 run: "click",
40 },
41 ];
42 if (loadSN !== undefined) {
43 step.push({
44 content: `Choose to auto link the lot number to the order line`,
45 trigger: `.modal-content:contains('Do you want to load the SN/Lots linked to the Sales Order?') button:contains('${
46 loadSN ? "Ok" : "Cancel"
47 }')`,
48 run: "click",
49 });
50 }
51 step.push({
52 trigger: "body:not(:has(.modal))",
53 });
54 return step;
55 }
56
57 export function downPaymentFirstOrder(amount) {
58 return [
59 ...selectNthOrder(1),
60 {
61 content: `click on select the order`,
62 trigger: `.selection-item:contains('Apply a down payment')`,
63 run: "click",
64 },
65 Numpad.click(amount),
66 Dialog.confirm("Apply"),
67 ];
68 }
69
70 export function checkOrdersListEmpty() {
71 return [
72 ...ProductScreen.clickControlButton("Quotation/Order"),
73 {
74 content: "Check that the orders list is empty",
75 trigger: "p:contains(No record found)",
76 },
77 ];
78 }
79
80 export function selectedOrderLinesHasLots(productName, lots) {
81 const getSerialStep = (index, serialNumber) => ({
82 content: `check lot${index} is linked`,
83 trigger: `.info-list li:contains(${serialNumber})`,
84 });
85 const lotSteps = lots.reduce((acc, serial, i) => acc.concat(getSerialStep(i, serial)), []);
86 return [...ProductScreen.selectedOrderlineHas(productName), ...lotSteps];
87 }
88
89 export function checkOrdersListNotEmpty() {
90 return [
91 ...ProductScreen.clickControlButton("Quotation/Order"),
92 {
93 content: "Check that the orders list is not empty",
94 trigger: ".o_data_row",
95 },
96 ];
97 }