初始提交

This commit is contained in:
2026-11-04 19:58:07 +08:00
commit 53b7d22429
829 changed files with 469986 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
import { describe, expect, test } from "@odoo/hoot";
import { click } from "@odoo/hoot-dom";
import { animationFrame } from "@odoo/hoot-mock";
import { mountWithCleanup, defineModels } from "@web/../tests/web_test_helpers";
import { mailModels } from "@mail/../tests/mail_test_helpers";
import { BankRecButton } from "@account_accountant/components/bank_reconciliation/button/button";
// Due to dependency with mail module, we have to define their models for our tests.
defineModels(mailModels);
describe.current.tags("desktop");
test("can display a button", async () => {
await mountWithCleanup(BankRecButton, {
props: {
label: "A label",
action: () => {},
count: null,
primary: false,
},
});
expect(".btn.btn-secondary").toHaveText("A label");
});
test("can display a button with a count", async () => {
await mountWithCleanup(BankRecButton, {
props: {
label: "Another label",
action: () => {},
count: 10,
primary: false,
},
});
expect(".btn span:first").toHaveText("Another label");
expect(".btn span:last").toHaveText("10");
});
test("can display a button with primary class", async () => {
await mountWithCleanup(BankRecButton, {
props: {
label: "A label with primary class",
action: () => {},
count: null,
primary: true,
},
});
expect(".btn.btn-primary").toHaveText("A label with primary class");
});
test("can call function when button is clicked", async () => {
let counter = 0;
await mountWithCleanup(BankRecButton, {
props: {
label: "A button with an action",
action: () => counter++,
count: null,
primary: false,
},
});
await click(".btn");
await animationFrame();
expect(counter).toBe(1);
});

View File

@@ -0,0 +1,289 @@
import { mailModels } from "@mail/../tests/mail_test_helpers";
import { beforeEach, describe, expect, test } from "@odoo/hoot";
import { click, queryAll, queryAllTexts, queryOne } from "@odoo/hoot-dom";
import { animationFrame, mockDate } from "@odoo/hoot-mock";
import {
contains,
defineModels,
fields,
getService,
models,
mountWithCleanup,
} from "@web/../tests/web_test_helpers";
import { WebClient } from "@web/webclient/webclient";
import { BankRecSelectCreateDialog } from "@account_accountant/components/bank_reconciliation/search_dialog/search_dialog";
class AccountMoveLine extends models.Model {
name = fields.Char({ string: "Name" });
date = fields.Date({ string: "Date" });
partner_id = fields.Many2one({ string: "Partner", relation: "partner" });
amount_residual = fields.Float({ string: "Amount Residual" });
amount_residual_currency = fields.Float({ string: "Amount Residual Currency" });
currency_id = fields.Many2one({ string: "Currency", relation: "res.currency" });
company_currency_id = fields.Many2one({ string: "Currency", relation: "res.currency" });
_records = [
{
id: 1,
name: "INV/2025/0001",
date: "2025-01-11",
partner_id: 1,
amount_residual: -230,
currency_id: 1,
},
{
id: 2,
name: "INV/2025/0002",
date: "2025-01-12",
partner_id: 1,
amount_residual: -150,
currency_id: 1,
},
{
id: 3,
name: "INV/2025/0003",
date: "2025-01-13",
partner_id: 1,
amount_residual: -50,
currency_id: 1,
},
{
id: 4,
name: "INV/2025/0004",
date: "2025-01-14",
partner_id: 2,
amount_residual: -100,
currency_id: 1,
},
{
id: 5,
name: "INV/2025/0005",
date: "2025-01-15",
partner_id: 3,
amount_residual: -125,
currency_id: 1,
},
];
_views = {
list: /* xml */ `
<list js_class="bank_rec_dialog_list" string="Journal Items">
<field name="date"/>
<field name="name"/>
<field name="partner_id"/>
<field name="amount_residual"/>
<field name="amount_residual_currency"/>
<field name="currency_id"/>
</list>
`,
search: /* xml */ `
<search>
<field name="partner_id"/>
</search>
`,
kanban: /* xml */ `
<kanban>
<field name="date"/>
<field name="name"/>
<templates>
<t t-name="card"/>
</templates>
</kanban>
`,
form: /* xml */ `
<form/>
`,
};
}
class Partner extends models.Model {
name = fields.Char({ string: "Name" });
_records = [
{ id: 1, name: "Jean Pierre" },
{ id: 2, name: "Pierre Jean" },
{ id: 3, name: "JB Pokie" },
];
}
// Due to dependency with mail module, we have to define their models for our tests.
defineModels({ ...mailModels, AccountMoveLine, Partner });
beforeEach(() => {
mockDate("2025-04-22 00:00:00");
});
describe.current.tags("desktop");
test("BankRecSelectCreateDialog footer with right information", async () => {
await mountWithCleanup(WebClient);
getService("dialog").add(BankRecSelectCreateDialog, {
noCreate: true,
resModel: "account.move.line",
suspenseAccountLine: {
amount_currency: 233.33,
currency_id: { id: 1 },
company_currency_id: { id: 1 },
},
date: luxon.DateTime.now(),
reference: "A cool reference to display",
context: { search_default_partner_id: 1 },
domain: [],
});
await animationFrame();
const bankReconciliationInfoNode = queryOne("div[name='bank_reconciliation_info']").children;
const bankReconciliationInfo = queryAllTexts(bankReconciliationInfoNode);
expect(bankReconciliationInfo[0]).toBe("Apr 22");
expect(bankReconciliationInfo[1]).toBe("A cool reference to display");
expect(bankReconciliationInfo[2]).toBe("Balance: $ 233.33");
});
test("BankRecSelectCreateDialog list view single currency", async () => {
await mountWithCleanup(WebClient);
getService("dialog").add(BankRecSelectCreateDialog, {
noCreate: true,
resModel: "account.move.line",
suspenseAccountLine: {
amount_currency: 100,
currency_id: { id: 1 },
company_currency_id: { id: 1 },
},
reference: "A useless reference",
date: luxon.DateTime.now(),
context: { search_default_partner_id: 1 },
domain: [],
});
await animationFrame();
expect("div[name='remaining_amount']").toHaveText("Balance: $ 100.00");
expect("div.o_facet_values > small.o_facet_value").toHaveText("Jean Pierre");
// Check that we have 4 checkboxes (Select all + 3 elements)
let checkboxes = queryAll(".form-check > .form-check-input[type='checkbox']");
expect(checkboxes.length).toBe(4);
// Select an element already fetch
await click(checkboxes[2]);
await animationFrame();
// Unselect this element
await click(checkboxes[2]);
await animationFrame();
await click("div.o_facet_values > button.o_facet_remove");
await animationFrame();
// Check that we have 6 checkboxes (Select all + 5 elements)
checkboxes = queryAll(".form-check > .form-check-input[type='checkbox']");
expect(checkboxes.length).toBe(6);
await click(checkboxes[4]);
await animationFrame();
await animationFrame();
// Check that the balance is correctly affected by the selection
expect("div[name='remaining_amount']").toHaveText("Balance: $ 0.00");
await click(checkboxes[4]);
await animationFrame();
await animationFrame();
expect("div[name='remaining_amount']").toHaveText("Balance: $ 100.00");
await click(".o_pager_value");
await animationFrame();
expect(".o_pager_counter .o_pager_value").toHaveValue("1-5");
await contains("input.o_pager_value").edit("1-2");
await click(document.body);
await animationFrame();
checkboxes = queryAll(".form-check > .form-check-input[type='checkbox']");
expect(checkboxes.length).toBe(3);
await click(checkboxes[0]);
await animationFrame();
await contains(`.o_select_domain`).click();
await animationFrame();
expect("div[name='remaining_amount']").toHaveText("Balance: $ -555.00");
});
test("BankRecSelectCreateDialog list view multi currencies", async () => {
AccountMoveLine._records.push({
id: 6,
name: "INV/2025/0006",
date: "2025-01-15",
partner_id: 3,
amount_residual: -100,
amount_residual_currency: -200,
currency_id: 2,
});
AccountMoveLine._records.push({
id: 7,
name: "INV/2025/0007",
date: "2025-01-15",
partner_id: 3,
amount_residual: -100,
amount_residual_currency: -150,
currency_id: 2,
});
AccountMoveLine._records.push({
id: 8,
name: "INV/2025/0008",
date: "2025-01-15",
partner_id: 3,
amount_residual: -100,
amount_residual_currency: -100,
currency_id: 1,
});
await mountWithCleanup(WebClient);
getService("dialog").add(BankRecSelectCreateDialog, {
noCreate: true,
resModel: "account.move.line",
suspenseAccountLine: {
amount_currency: 100,
currency_id: { id: 2 },
company_currency_id: { id: 1 },
},
reference: "A useless reference",
date: luxon.DateTime.now(),
context: { search_default_partner_id: 3 },
domain: [],
});
await animationFrame();
expect("div[name='remaining_amount']").toHaveText("Balance: 100.00 €");
const checkboxes = queryAll(".form-check > .form-check-input[type='checkbox']");
expect(checkboxes.length).toBe(5);
await click(checkboxes[2]);
await animationFrame();
await animationFrame();
expect("div[name='remaining_amount']").toHaveText("Balance: -100.00 €");
await click(checkboxes[3]);
await animationFrame();
await animationFrame();
expect("div[name='remaining_amount']").toHaveText("Balance: -250.00 €");
await click(checkboxes[2]);
await animationFrame();
await animationFrame();
expect("div[name='remaining_amount']").toHaveText("Balance: -50.00 €");
await click(checkboxes[3]);
await animationFrame();
await animationFrame();
expect("div[name='remaining_amount']").toHaveText("Balance: 100.00 €");
// Different currencies cannot be computed together
await click(checkboxes[4]);
await animationFrame();
await animationFrame();
expect("div[name='remaining_amount']").toHaveText("Balance: /");
await click(checkboxes[4]);
await animationFrame();
await animationFrame();
expect("div[name='remaining_amount']").toHaveText("Balance: 100.00 €");
});

View File

@@ -0,0 +1,258 @@
import { mailModels } from "@mail/../tests/mail_test_helpers";
import { beforeEach, describe, expect, test } from "@odoo/hoot";
import { click, keyDown, queryAll, queryAllTexts, queryOne } from "@odoo/hoot-dom";
import { animationFrame, mockDate } from "@odoo/hoot-mock";
import {
contains,
defineModels,
fields,
getService,
models,
mountWithCleanup,
} from "@web/../tests/web_test_helpers";
import { WebClient } from "@web/webclient/webclient";
import { BankRecSelectCreateDialog } from "@account_accountant/components/bank_reconciliation/search_dialog/search_dialog";
class AccountMoveLine extends models.Model {
move_name = fields.Char({ string: "Move Name" });
ref = fields.Char({ string: "Ref" });
date = fields.Date({ string: "Date" });
partner_id = fields.Many2one({ string: "Partner", relation: "partner" });
amount_residual = fields.Float({ string: "Amount Residual" });
amount_residual_currency = fields.Float({ string: "Amount Residual Currency" });
currency_id = fields.Many2one({ string: "Currency", relation: "res.currency" });
company_currency_id = fields.Many2one({ string: "Currency", relation: "res.currency" });
_records = [
{
id: 1,
move_name: "INV/2025/0001",
ref: "Customer Reference invoice 1",
date: "2025-01-11",
partner_id: 1,
amount_residual: -230,
currency_id: 1,
},
{
id: 2,
move_name: "INV/2025/0002",
ref: "Customer Reference invoice 2",
date: "2025-01-12",
partner_id: 1,
amount_residual: -150,
currency_id: 1,
},
{
id: 3,
move_name: "INV/2025/0003",
ref: "Customer Reference invoice 3",
date: "2025-01-13",
partner_id: 1,
amount_residual: -50,
currency_id: 1,
},
{
id: 4,
move_name: "INV/2025/0004",
ref: "Customer Reference invoice 4",
date: "2025-01-14",
partner_id: 2,
amount_residual: -100,
currency_id: 1,
},
{
id: 5,
move_name: "INV/2025/0005",
ref: "Customer Reference invoice 5",
date: "2025-01-15",
partner_id: 2,
amount_residual: 100,
currency_id: 1,
},
{
id: 6,
move_name: "INV/2025/0006",
ref: "Customer Reference invoice 6",
date: "2025-01-15",
partner_id: 3,
amount_residual: -125,
currency_id: 1,
},
];
_views = {
kanban: /* xml */ `
<kanban js_class="bank_rec_dialog_kanban">
<field name="currency_id"/>
<field name="company_currency_id"/>
<templates>
<t t-name="card">
<field name="move_name"/>
<field name="ref"/>
<field name="date"/>
<field name="partner_id"/>
<field name="amount_residual"/>
<field name="amount_residual_currency"/>
</t>
</templates>
</kanban>
`,
search: /* xml */ `
<search>
<field name="partner_id"/>
</search>
`,
};
}
class Partner extends models.Model {
name = fields.Char({ string: "Name" });
_records = [
{ id: 1, name: "Jean Pierre" },
{ id: 2, name: "Pierre Jean" },
{ id: 3, name: "JB Pokie" },
];
}
defineModels({ ...mailModels, AccountMoveLine, Partner });
beforeEach(() => {
mockDate("2025-04-22 00:00:00");
});
describe.current.tags("mobile");
test("BankRecSelectCreateDialog header with right information", async () => {
await mountWithCleanup(WebClient);
getService("dialog").add(BankRecSelectCreateDialog, {
noCreate: true,
resModel: "account.move.line",
suspenseAccountLine: {
amount_currency: 233.33,
currency_id: { id: 1 },
company_currency_id: { id: 1 },
},
date: luxon.DateTime.now(),
reference: "A cool reference to display",
context: {},
domain: [],
});
await animationFrame();
const bankReconciliationInfoNode = queryOne("div[name='bank_reconciliation_info']").children;
const bankReconciliationInfo = queryAllTexts(bankReconciliationInfoNode);
expect(bankReconciliationInfo[0]).toBe("Apr 22");
expect(bankReconciliationInfo[1]).toBe("A cool reference to display");
expect(bankReconciliationInfo[2]).toBe("Balance: $ 233.33");
});
test("BankRecSelectCreateDialog kanban view single currency", async () => {
await mountWithCleanup(WebClient);
getService("dialog").add(BankRecSelectCreateDialog, {
noCreate: true,
resModel: "account.move.line",
suspenseAccountLine: {
amount_currency: 100,
currency_id: { id: 1 },
company_currency_id: { id: 1 },
},
reference: "A useless reference",
date: luxon.DateTime.now(),
context: { search_default_partner_id: 1 },
domain: [],
});
await animationFrame();
expect("div[name='remaining_amount']").toHaveText("Balance: $ 100.00");
await click("div.o_control_panel_navigation > button > i[data-icon='search']");
await animationFrame();
expect("div.o_facet_values > small.o_facet_value").toHaveText("Jean Pierre");
let articles = queryAll("article.o_kanban_record");
expect(articles.length).toBe(3);
await click("button.o_facet_remove");
await animationFrame();
articles = queryAll("article.o_kanban_record");
expect(articles.length).toBe(6);
await keyDown("Alt");
await contains(articles[3]).click();
await animationFrame();
expect("div[name='remaining_amount']").toHaveText("Balance: $ 0.00");
await keyDown("Alt");
await contains(articles[3]).click();
await animationFrame();
expect("div[name='remaining_amount']").toHaveText("Balance: $ 100.00");
await keyDown("Alt");
await contains(articles[4]).click();
await animationFrame();
expect("div[name='remaining_amount']").toHaveText("Balance: $ 200.00");
await keyDown("Alt");
await contains(articles[4]).click();
await animationFrame();
expect("div[name='remaining_amount']").toHaveText("Balance: $ 100.00");
await keyDown("Alt");
await contains(articles[0]).click();
await animationFrame();
await contains(`.o_select_domain`).click();
await animationFrame();
expect("div.o_selection_box").toHaveText("All 6 selected");
expect("div[name='remaining_amount']").toHaveText("Balance: $ -455.00");
});
test("BankRecSelectCreateDialog kanban view multiple currencies", async () => {
AccountMoveLine._records.push({
id: 7,
move_name: "INV/2025/0007",
ref: "Customer Reference invoice 7",
date: "2025-01-17",
partner_id: 3,
amount_residual: -100,
amount_residual_currency: -200,
currency_id: 2,
company_currency_id: 1,
});
await mountWithCleanup(WebClient);
getService("dialog").add(BankRecSelectCreateDialog, {
noCreate: true,
resModel: "account.move.line",
suspenseAccountLine: {
amount_currency: 100,
currency_id: { id: 2 },
company_currency_id: { id: 1 },
},
reference: "A useless reference",
date: luxon.DateTime.now(),
context: {},
domain: [],
});
await animationFrame();
expect("div[name='remaining_amount']").toHaveText("Balance: 100.00 €");
const articles = queryAll("article.o_kanban_record");
expect(articles.length).toBe(7);
await keyDown("Alt");
await contains(articles[6]).click();
await animationFrame();
expect("div[name='remaining_amount']").toHaveText("Balance: -100.00 €");
await keyDown("Alt");
await contains(articles[6]).click();
await animationFrame();
expect("div[name='remaining_amount']").toHaveText("Balance: 100.00 €");
await keyDown("Alt");
await contains(articles[3]).click();
await animationFrame();
expect("div[name='remaining_amount']").toHaveText("Balance: /");
});

View File

@@ -0,0 +1,54 @@
import { describe, expect, test } from "@odoo/hoot";
import { click, queryOne } from "@odoo/hoot-dom";
import { animationFrame } from "@odoo/hoot-mock";
import { mountWithCleanup, defineModels } from "@web/../tests/web_test_helpers";
import { mailModels } from "@mail/../tests/mail_test_helpers";
import { BankRecStatementSummary } from "@account_accountant/components/bank_reconciliation/statement_summary/statement_summary";
// Due to dependency with mail module, we have to define their models for our tests.
defineModels(mailModels);
describe.current.tags("desktop");
test("can display a BankRecStatementSummary", async () => {
let counter = 0;
await mountWithCleanup(BankRecStatementSummary, {
props: {
label: "A label",
action: () => {
counter++;
},
amount: "$1,000.00",
},
});
const elements = queryOne("div.o_statement_summary").children;
await click(elements[1]);
await animationFrame();
expect(counter).toBe(1);
expect(elements[0]).toHaveText("A label");
expect(elements[1]).toHaveText("$1,000.00");
});
test("no amount displayed if no amount in props", async () => {
await mountWithCleanup(BankRecStatementSummary, {
props: {
label: "A label",
action: () => {},
},
});
const elements = queryOne("div.o_statement_summary").children;
expect(elements).toHaveCount(1);
});
test("label in text danger when isValid set to False", async () => {
await mountWithCleanup(BankRecStatementSummary, {
props: {
label: "A label",
isValid: false,
action: () => {},
amount: "$1,000.00",
},
});
expect("div.o_statement_summary > div > h4").toHaveClass("text-danger");
});

View File

@@ -0,0 +1,57 @@
import { expect, runAllTimers, test } from "@odoo/hoot";
import { clickFieldDropdownItem, contains, defineModels, fields, models, mountView, onRpc } from "@web/../tests/web_test_helpers";
import { mailModels } from "@mail/../tests/mail_test_helpers";
class AccountBankStatement extends models.Model {
name = fields.Char();
_records = [
{ id: 1, name: "Statement 1" },
{ id: 2, name: "Statement 2" },
];
}
class AccountBankStatementLine extends models.Model {
name = fields.Char();
statement_id = fields.Many2one({ relation: "account.bank.statement" });
attachment_ids = fields.Many2many({ relation: "ir.attachment" });
bank_statement_attachment_ids = fields.Many2many({ relation: "ir.attachment" });
partner_id = fields.Integer();
line_ids = fields.Integer();
journal_id = fields.Integer();
company_id = fields.Integer();
_records = [
{ id: 1, name: "Line 1", statement_id: 1 },
{ id: 2, name: "Line 2", statement_id: 1 },
];
}
defineModels({ ...mailModels, AccountBankStatement, AccountBankStatementLine });
test.tags("desktop");
test("bank_rec_list_many2one_multi_id widget works in multi-edit", async () => {
expect.assertions(1);
onRpc("web_save", ({ args }) => {
expect(args[1].statement_id).toBe(3);
});
await mountView({
resModel: "account.bank.statement.line",
type: "list",
arch: `
<list multi_edit="1" js_class="bank_rec_list">
<field name="name"/>
<field name="statement_id" widget="bank_rec_list_many2one_multi_id"/>
</list>
`,
});
await contains(".o_data_row:eq(0) .o_list_record_selector input").click();
await contains(".o_data_row:eq(1) .o_list_record_selector input").click();
await contains(".o_data_row:eq(0) [name='statement_id']").click();
await contains("[name='statement_id'] input").edit("New Statement", { confirm: false });
await runAllTimers();
await clickFieldDropdownItem("statement_id", 'Create "New Statement"');
// Confirm the multi-edit dialog
await contains(".modal .btn-primary").click();
});

View File

@@ -0,0 +1,331 @@
import { defineAccountModels } from "@account/../tests/account_test_helpers";
import {
click,
contains,
listenStoreFetch,
onRpcBefore,
openListView,
patchUiSize,
SIZES,
start,
startServer,
STORE_FETCH_ROUTES,
userContext,
waitStoreFetch,
} from "@mail/../tests/mail_test_helpers";
import { beforeEach, expect, test } from "@odoo/hoot";
import { onRpc } from "@web/../tests/web_test_helpers";
import { getOrigin } from "@web/core/utils/urls";
const ROUTES_TO_IGNORE = [
...STORE_FETCH_ROUTES,
"/bus/im_status",
"/hr_attendance/attendance_user_data",
"/web/dataset/call_kw/account.move.line/get_views",
"/web/dataset/call_kw/res.users/has_group",
"/web/dataset/call_kw/res.users/load_views",
"/web/webclient/load_menus",
];
const openPreparedView = async (size) => {
patchUiSize({ size: size });
onRpcBefore((route, args) => {
if (
ROUTES_TO_IGNORE.includes(route) ||
route.includes("/web/static/lib/pdfjs/web/viewer.html")
) {
return;
}
expect.step(`${route} - ${JSON.stringify(args)}`);
});
onRpc(({ kwargs, route }) => {
if (ROUTES_TO_IGNORE.includes(route)) {
return;
}
expect.step(`${route} - {"kwargs":${JSON.stringify(kwargs)}}`);
});
listenStoreFetch("init_messaging");
await start();
await waitStoreFetch("init_messaging");
await openListView("account.move.line", {
context: { group_by: ["move_id"] },
arch: `
<list editable='bottom' js_class='account_move_line_list'>
<field name='id'/>
<field name='name'/>
<field name='move_id'/>
</list>`,
});
};
defineAccountModels();
beforeEach(async () => {
const pyEnv = await startServer();
const accountMoveLineIds = pyEnv["account.move.line"].create([
{ name: "line0" },
{ name: "line1" },
{ name: "line2" },
{ name: "line3" },
{ name: "line4" },
{ name: "line5" },
]);
const accountMove = pyEnv["account.move"].create([
{ name: "move0", invoice_line_ids: [accountMoveLineIds[0], accountMoveLineIds[1]] },
{ name: "move1", invoice_line_ids: [accountMoveLineIds[2], accountMoveLineIds[3]] },
{ name: "move2", invoice_line_ids: [accountMoveLineIds[4], accountMoveLineIds[5]] },
]);
const attachmentIds = pyEnv["ir.attachment"].create([
{ res_id: accountMove[1], res_model: "account.move", mimetype: "application/pdf" },
{ res_id: accountMove[2], res_model: "account.move", mimetype: "application/pdf" },
]);
pyEnv["account.move"].write([accountMove[1]], { attachment_ids: [attachmentIds[0]] });
pyEnv["account.move.line"].write([accountMoveLineIds[0]], { move_id: accountMove[0] });
pyEnv["account.move.line"].write([accountMoveLineIds[1]], { move_id: accountMove[0] });
pyEnv["account.move.line"].write([accountMoveLineIds[2]], {
move_id: accountMove[1],
move_attachment_ids: [attachmentIds[0]],
});
pyEnv["account.move.line"].write([accountMoveLineIds[3]], {
move_id: accountMove[1],
move_attachment_ids: [attachmentIds[0]],
});
pyEnv["account.move.line"].write([accountMoveLineIds[4]], {
move_id: accountMove[2],
move_attachment_ids: [attachmentIds[1]],
});
pyEnv["account.move.line"].write([accountMoveLineIds[5]], {
move_id: accountMove[2],
move_attachment_ids: [attachmentIds[1]],
});
});
test("No preview on small devices", async () => {
await openPreparedView(SIZES.XL);
await contains(".o_move_line_list_view");
await expect.waitForSteps([
`/web/dataset/call_kw/account.move.line/web_read_group - ${JSON.stringify({
kwargs: {
domain: [],
groupby: ["move_id"],
aggregates: [],
limit: 80,
offset: 0,
order: "",
auto_unfold: false,
unfold_read_specification: {
id: {},
name: {},
move_id: { fields: { display_name: {} } },
move_attachment_ids: { fields: { mimetype: {} } },
},
unfold_read_default_limit: 80,
groupby_read_specification: {},
context: {
...userContext(),
bin_size: true,
read_group_expand: true,
group_by: ["move_id"],
},
},
})}`,
]);
// weak test, no guarantee to wait long enough for the potential attachment preview to show
await contains(".o_attachment_preview", { count: 0 }); // The preview component shouldn't be mounted for small screens
await click(":nth-child(1 of .o_group_header)");
await contains(".o_data_row", { count: 2 });
await expect.waitForSteps([
`/web/dataset/call_kw/account.move.line/web_search_read - ${JSON.stringify({
kwargs: {
specification: {
id: {},
name: {},
move_id: { fields: { display_name: {} } },
move_attachment_ids: { fields: { mimetype: {} } },
},
offset: 0,
order: "",
limit: 80,
context: {
...userContext(),
group_by: ["move_id"],
default_move_id: 1,
},
count_limit: 10001,
domain: [["move_id", "=", 1]],
},
})}`,
]);
await click(":nth-child(1 of .o_data_row) :nth-child(2 of .o_data_cell)");
await contains(":nth-child(1 of .o_data_row) :nth-child(2 of .o_data_cell) textarea");
// weak test, no guarantee to wait long enough for the potential attachment preview to show
await contains(".o_attachment_preview", { count: 0 }); // The preview component shouldn't be mounted for small screens even when clicking on a line without attachment
await click(":nth-child(2 of .o_group_header)");
await contains(".o_data_row", { count: 4 });
await expect.waitForSteps([
`/web/dataset/call_kw/account.move.line/web_search_read - ${JSON.stringify({
kwargs: {
specification: {
id: {},
name: {},
move_id: { fields: { display_name: {} } },
move_attachment_ids: { fields: { mimetype: {} } },
},
offset: 0,
order: "",
limit: 80,
context: {
...userContext(),
group_by: ["move_id"],
default_move_id: 2,
},
count_limit: 10001,
domain: [["move_id", "=", 2]],
},
})}`,
]);
await click(":nth-child(4 of .o_data_row) :nth-child(2 of .o_data_cell)");
await contains(":nth-child(4 of .o_data_row) :nth-child(2 of .o_data_cell) textarea");
// weak test, no guarantee to wait long enough for the potential attachment preview to show
await contains(".o_attachment_preview", { count: 0 }); // The preview component shouldn't be mounted for small screens even when clicking on a line with attachment
await expect.waitForSteps([], { message: "no extra rpc should be done" });
});
test("Fetch and preview of attachments on big devices", async () => {
await openPreparedView(SIZES.XXL);
await contains(".o_move_line_list_view");
await expect.waitForSteps([
`/web/dataset/call_kw/account.move.line/web_read_group - ${JSON.stringify({
kwargs: {
domain: [],
groupby: ["move_id"],
aggregates: [],
limit: 80,
offset: 0,
order: "",
auto_unfold: false,
unfold_read_specification: {
id: {},
name: {},
move_id: { fields: { display_name: {} } },
move_attachment_ids: { fields: { mimetype: {} } },
},
unfold_read_default_limit: 80,
groupby_read_specification: {},
context: {
...userContext(),
bin_size: true,
read_group_expand: true,
group_by: ["move_id"],
},
},
})}`,
]);
await contains(".o_attachment_preview");
await contains(".o_attachment_preview p", {
text: "Choose a line to preview its attachments.",
});
await contains(".o_attachment_preview iframe", { count: 0 });
await click(":nth-child(1 of .o_group_header)");
await contains(".o_data_row", { count: 2 });
await expect.waitForSteps([
`/web/dataset/call_kw/account.move.line/web_search_read - ${JSON.stringify({
kwargs: {
specification: {
id: {},
name: {},
move_id: { fields: { display_name: {} } },
move_attachment_ids: { fields: { mimetype: {} } },
},
offset: 0,
order: "",
limit: 80,
context: {
...userContext(),
group_by: ["move_id"],
default_move_id: 1,
},
count_limit: 10001,
domain: [["move_id", "=", 1]],
},
})}`,
]);
await click(":nth-child(1 of .o_data_row) :nth-child(2 of .o_data_cell)");
await contains(".o_attachment_preview iframe", { count: 0 });
await contains(".o_attachment_preview p", { text: "No attachments linked." });
await click(":nth-child(2 of .o_group_header)");
await contains(".o_data_row", { count: 4 });
await contains(".o_attachment_preview p", { text: "No attachments linked." });
await expect.waitForSteps([
`/web/dataset/call_kw/account.move.line/web_search_read - ${JSON.stringify({
kwargs: {
specification: {
id: {},
name: {},
move_id: { fields: { display_name: {} } },
move_attachment_ids: { fields: { mimetype: {} } },
},
offset: 0,
order: "",
limit: 80,
context: {
...userContext(),
group_by: ["move_id"],
default_move_id: 2,
},
count_limit: 10001,
domain: [["move_id", "=", 2]],
},
})}`,
]);
await click(":nth-child(4 of .o_data_row) :nth-child(2 of .o_data_cell)");
await contains(".o_attachment_preview p", { count: 0 });
await contains(
`.o_attachment_preview iframe[data-src='/web/static/lib/pdfjs/web/viewer.html?file=${encodeURIComponent(
getOrigin() + "/web/content/1"
)}#pagemode=none']`
);
await expect.waitForSteps([], { message: "no extra rpc should be done" });
await click(":nth-child(3 of .o_group_header)");
await contains(".o_data_row", { count: 6 });
// weak test, no guarantee to wait long enough for the potential attachment to change
await contains(
`.o_attachment_preview iframe[data-src='/web/static/lib/pdfjs/web/viewer.html?file=${encodeURIComponent(
getOrigin() + "/web/content/1"
)}#pagemode=none']`
); // The previewer content shouldn't change without clicking on another line from another account.move
await expect.waitForSteps([
`/web/dataset/call_kw/account.move.line/web_search_read - ${JSON.stringify({
kwargs: {
specification: {
id: {},
name: {},
move_id: { fields: { display_name: {} } },
move_attachment_ids: { fields: { mimetype: {} } },
},
offset: 0,
order: "",
limit: 80,
context: {
...userContext(),
group_by: ["move_id"],
default_move_id: 3,
},
count_limit: 10001,
domain: [["move_id", "=", 3]],
},
})}`,
]);
await click(":nth-child(5 of .o_data_row) :nth-child(2 of .o_data_cell)");
await contains(":nth-child(5 of .o_data_row) :nth-child(2 of .o_data_cell) textarea");
await contains(
`.o_attachment_preview iframe[data-src='/web/static/lib/pdfjs/web/viewer.html?file=${encodeURIComponent(
getOrigin() + "/web/content/2"
)}#pagemode=none']`
);
await expect.waitForSteps([]);
await click(":nth-child(1 of .o_data_row) :nth-child(2 of .o_data_cell)");
await contains(".o_attachment_preview iframe", { count: 0 });
await contains(".o_attachment_preview p");
await expect.waitForSteps([]);
});

View File

@@ -0,0 +1,66 @@
/** @odoo-module **/
import { registry } from "@web/core/registry";
import { stepUtils } from "@web_tour/tour_utils";
import { accountTourSteps } from "@account/js/tours/account";
registry.category("web_tour.tours").add('account_accountant_bank_rec_widget_save_analytic_distribution', {
steps: () => [
stepUtils.showAppsMenuItem(),
...accountTourSteps.goToAccountMenu("Open the accounting module"),
{
trigger: ".o_breadcrumb",
},
{
content: "Open the bank reconciliation widget",
trigger: "button.btn-secondary[name='action_open_reconcile']",
run: "click",
},
{
trigger: "div[name='line_ids']",
},
{
content: "The 'line1' should be selected by default",
trigger: "div[name='line_ids'] td[field='name']:contains('line1')",
},
{
content: "Click on first line",
trigger: "div[name='line_ids'] td[field='debit']:first",
run: "click",
},
{
content: "The 'manual_operations_tab' should be active now and the auto_balance line mounted in edit",
trigger: "a.active[name='manual_operations_tab']",
},
{
content: "Enter an analytic distribution",
trigger: "div[name='analytic_distribution'] .o_input_dropdown",
run: "click",
},
{
content: "Select analytic distribution",
trigger: "tr[name='line_0'] input",
run: "edit analytic_account",
},
{
trigger: ".ui-autocomplete",
},
{
content: "Select analytic distribution",
trigger: ".ui-autocomplete:visible li:contains('analytic_account')",
run: "click",
},
{
content: "Close the analytic distribution",
trigger: ".o_button",
run: "click",
},
...stepUtils.toggleHomeMenu(),
...accountTourSteps.goToAccountMenu("Reset back to accounting module"),
{
content: "check that we're back on the dashboard",
trigger: 'a:contains("Sales")',
},
]
});

View File

@@ -0,0 +1,58 @@
import { registry } from "@web/core/registry";
import { stepUtils } from "@web_tour/tour_utils";
import { accountTourSteps } from "@account/js/tours/account";
/**
* Verifies that when setting a partner on a statement line from a branch company,
* contacts owned by the parent company are visible in the lookup dialog.
*
* The partner lookup domain uses `parent_of` so that contacts belonging to any
* ancestor company of the statement line's company are included.
*/
registry.category("web_tour.tours").add("account_accountant_bank_rec_set_partner_branch_company", {
steps: () => [
stepUtils.showAppsMenuItem(),
...accountTourSteps.goToAccountMenu("Open the accounting module"),
{
content: "Open the branch bank reconciliation widget",
trigger: "a.oe_kanban_action span:contains('Branch Bank')",
run: "click",
},
{
trigger: "div.o_bank_reconciliation_kanban_renderer",
},
{
content: "Unfold the statement line",
trigger: "div[name='bank_statement_line']",
run: "click",
},
{
content: "Line is unfolded",
trigger: "div.o_button_line",
},
{
content: "Open the Set Partner dialog",
trigger: "button.set-partner-btn",
run: "click",
},
{
content: "Search dialog is open",
trigger: "div.modal-dialog",
},
{
// The parent company's contact must appear even though the statement line
// belongs to a branch company — this validates the `parent_of` domain fix.
content: "Parent company contact is visible in the results",
trigger: "tbody > tr > td[name='display_name']:contains('AAAA Parent Partner')",
},
{
content: "Select the parent company contact",
trigger: "tbody > tr > td[name='display_name']:contains('AAAA Parent Partner')",
run: "click",
},
{
content: "Partner is set on the statement line",
trigger: "span[name='statement_line_partner_name']:contains('AAAA Parent Partner')",
},
],
});

View File

@@ -0,0 +1,267 @@
import { registry } from "@web/core/registry";
import { stepUtils } from "@web_tour/tour_utils";
import { accountTourSteps } from "@account/js/tours/account";
registry.category("web_tour.tours").add("account_accountant_bank_rec_widget", {
steps: () => [
stepUtils.showAppsMenuItem(),
...accountTourSteps.goToAccountMenu("Open the accounting module"),
{
content: "Open the bank reconciliation widget",
trigger: "a.oe_kanban_action span:contains('Bank')",
run: "click",
},
{
trigger: "div.o_bank_reconciliation_kanban_renderer",
},
{
content: "Create New statement",
trigger: "button.o-kanban-button-new",
run: "click",
},
{
trigger: "div.o_bank_reconciliation_quick_create",
},
{
content: "Write Label",
trigger: "div[name='payment_ref'] input",
run: "edit test",
},
{
content: "Add a amount",
trigger: "div[name='amount'] input",
run: "edit 100",
},
{
content: "Save & close",
trigger: "div.button_group button.o_kanban_edit",
run: "click",
},
{
content: "Statement is created",
trigger: "div[name='bank_statement_line']",
},
{
content: "Unfold statement line",
trigger: "div[name='bank_statement_line']",
run: "click",
},
{
content: "line is unfolded",
trigger: "div.o_button_line",
},
{
content: "Set Partner",
trigger: "button.set-partner-btn",
run: "click",
},
{
content: "Search view is opened",
trigger: "div.modal-dialog",
},
{
content: "Select first partner",
trigger: "tbody > tr > td[name='display_name']",
run: "click",
},
{
content: "Partner is set",
trigger: "span[name='statement_line_partner_name']",
},
{
content: "Fold statement line",
trigger: "div[name='bank_statement_line']",
run: "click",
},
{
content: "Statement line is reconciled because move with same partner and amount",
trigger: "div[name='reconciled_line_name']",
},
{
content: "Create New statement",
trigger: "button.o-kanban-button-new",
run: "click",
},
{
trigger: "div.o_bank_reconciliation_quick_create",
},
{
content: "Write Label",
trigger: "div[name='payment_ref'] input",
run: "edit test",
},
{
content: "Add a amount",
trigger: "div[name='amount'] input",
run: "edit 150",
},
{
content: "Save & close",
trigger: "div.button_group button.o_kanban_edit",
run: "click",
},
{
content: "Open Ellipsis button",
trigger: "button.btn-secondary i[data-icon='more_vert']",
run: "click",
},
{
content: "Reconcile button",
trigger: "span.btn-link:contains('Reconcile')",
run: "click",
},
{
content: "Search view is opened",
trigger: "div.modal-dialog",
},
{
content: "Select first move line",
trigger: "tbody > tr > td[name='partner_id']",
run: "click",
},
{
content: "Statement line is reconciled",
trigger: "div[name='reconciled_line_name']",
},
// ensure statement can be added for multiple statement lines at once
{
content: "Switch to list view",
trigger: "button.o_switch_view.o_list",
run: "click",
},
{
content: "Select the statement lines",
trigger: "div.o-checkbox",
run: "click",
},
{
content: "Open the Many2One to set statement",
trigger: "td.o_bank_rec_list_many2one_multi_id_cell",
run: "click",
},
{
content: "Search for the created statement",
trigger: "input.o-autocomplete--input",
run: "click",
},
{
content: "Select the created statement",
trigger: "a.dropdown-item:contains('test')",
run: "click",
},
{
content: "Update setting statement on both lines",
trigger: "button.btn-primary:contains('Update')",
run: "click",
},
],
});
registry.category("web_tour.tours").add("account_accountant_set_partner_with_child_contact", {
steps: () => [
stepUtils.showAppsMenuItem(),
...accountTourSteps.goToAccountMenu("Open the accounting module"),
{
content: "Open the bank reconciliation widget",
trigger: "a.oe_kanban_action span:contains('Bank')",
run: "click",
},
{
trigger: "div.o_bank_reconciliation_kanban_renderer",
},
{
content: "Create New statement",
trigger: "button.o-kanban-button-new",
run: "click",
},
{
trigger: "div.o_bank_reconciliation_quick_create",
},
{
content: "Write Label",
trigger: "div[name='payment_ref'] input",
run: "edit test",
},
{
content: "Add a amount",
trigger: "div[name='amount'] input",
run: "edit 100",
},
{
content: "Save & close",
trigger: "div.button_group button.o_kanban_edit",
run: "click",
},
{
content: "Statement is created",
trigger: "div[name='bank_statement_line']",
},
{
content: "Set Partner",
trigger: "button.set-partner-btn",
run: "click",
},
{
content: "Search view is opened",
trigger: "div.modal-dialog",
},
{
content: "Select partner",
trigger: "body:not(:has(tbody > tr > td[name='display_name']:contains('test child contact')))",
},
]
});
registry.category("web_tour.tours").add("account_accountant_bank_reconciliation_ui_context_keys", {
steps: () => [
{
trigger: "div.o_bank_reconciliation_kanban_renderer",
},
{
content: "Create New statement",
trigger: "button.o-kanban-button-new",
run: "click",
},
{
trigger: "div.o_bank_reconciliation_quick_create",
},
{
content: "Write Label",
trigger: "div[name='payment_ref'] input",
run: "edit test",
},
{
content: "Add a amount",
trigger: "div[name='amount'] input",
run: "edit 100",
},
{
content: "Save & close",
trigger: "div.button_group button.o_kanban_edit",
run: "click",
},
{
content: "Statement is created",
trigger: "div[name='bank_statement_line']",
},
{
content: "Statement line is reconciled",
trigger: "div[name='reconciled_line_name']",
},
{
content: "Upload button is not shown for a synchronized journal (Kanban View)",
trigger: "div.o_control_panel_main_buttons:not(:has(.o_button_upload_bill))",
},
{
content: "Switch to List View",
trigger: "button.o_switch_view.o_list",
run: "click",
},
{
content: "Upload button is not shown for a synchronized journal (List View)",
trigger: "div.o_control_panel_main_buttons:not(:has(.o_button_upload_bill))",
},
]
});

View File

@@ -0,0 +1,53 @@
import { registry } from "@web/core/registry";
import { stepUtils } from "@web_tour/tour_utils";
import { accountTourSteps } from "@account/js/tours/account";
registry
.category("web_tour.tours")
.add("account_accountant_bank_reconciliation_widget_reload_activies_when_add_a_new_one", {
steps: () => [
stepUtils.showAppsMenuItem(),
...accountTourSteps.goToAccountMenu("Open the accounting module"),
{
content: "Open the bank reconciliation widget",
trigger: "a.oe_kanban_action span:contains('Bank')",
run: "click",
},
{
trigger: "div.o_bank_reconciliation_kanban_renderer",
},
{
content: "Select statement line",
trigger: "div[name='bank_statement_line']",
run: "click",
},
{
content: "Open chatter",
trigger: "i.oi.oi-lg[data-icon='forum']:not(:visible)",
run: "click",
},
{
content: "Chatter is opened",
trigger: "div.o_bank_rec_widget_chatter_container",
},
{
content: "Create an activity",
trigger: "button.o-mail-Chatter-activity",
run: "click",
},
{
content: "Dialog activity is opened",
trigger: "h4.modal-title:contains('Schedule Activity')",
},
{
content: "Validate default activity",
trigger: "button[name='action_schedule_activities']",
run: "click",
},
{
content: "Activity is reloaded in the widget",
trigger: "div.activity-container > i.oi.oi-lg[data-icon='schedule']",
},
],
});

View File

@@ -0,0 +1,50 @@
/** @odoo-module **/
import { registry } from "@web/core/registry";
import { stepUtils } from "@web_tour/tour_utils";
import { accountTourSteps } from "@account/js/tours/account";
registry.category("web_tour.tours").add("account_accountant_journal_items_export", {
steps: () => [
stepUtils.showAppsMenuItem(),
...accountTourSteps.goToAccountMenu("Open the accounting module"),
{
content: "Open journal items list view",
trigger: 'button[data-menu-xmlid="account.menu_finance_entries"]',
run: "click",
},
{
content: "Open journal items list view",
trigger: 'a[data-menu-xmlid="account.menu_action_account_moves_all"]',
run: "click",
},
{
content: "Select all items",
trigger: 'thead tr th.o_list_record_selector',
run: "click",
},
{
content: "Open export dialog",
trigger: 'i[data-icon="more_vert"]',
run: "click",
},
{
content: "Open export dialog",
trigger: 'i[data-icon="upload"]',
run: "click",
},
{
content: "Click on the cancel button",
trigger: 'button.o_form_button_cancel',
run: "click",
},
// End
...stepUtils.toggleHomeMenu(),
...accountTourSteps.goToAccountMenu("Reset back to accounting module"),
{
content: "check that we're back on the dashboard",
trigger: 'a:contains("Sales")',
},
],
});

View File

@@ -0,0 +1,66 @@
import { expect, test } from "@odoo/hoot";
import {
contains,
defineModels,
fields,
models,
mountView,
onRpc,
} from "@web/../tests/web_test_helpers";
import { mailModels } from "@mail/../tests/mail_test_helpers";
class AccountBankStatementLine extends models.Model {
transaction_details = fields.Json();
_records = [
{
id: 1,
transaction_details: {
name: "Downpayment for your services",
amount: 350,
status: "posted",
identifier: "cb38d10c-4c93-41c7-bbbb-e0f57745cf0a",
counter_part: { name: "Azure Interior" },
is_zero_balancing: false,
},
},
];
}
defineModels({ ...mailModels, AccountBankStatementLine });
test.tags("desktop");
test("Check Formatted Transactions Details Widget on Desktop", async () => {
onRpc(
"account.bank.statement.line",
"format_transaction_details",
() => {
return "<div><pre><b>name:</b> Downpayment for your services\n<b>amount:</b> 350.0\n<b>status:</b> posted\n<b>identifier:</b> cb38d10c-4c93-41c7-bbbb-e0f57745cf0a\n<b>counter_part:</b> \n <b>name:</b> Azure Interior\n<b>is_zero_balancing:</b> False\n</pre></div>";
}
);
await mountView({
type: "list",
resModel: "account.bank.statement.line",
arch: `
<list>
<field name="transaction_details" widget="formatted_transaction_details"/>
</list>`,
resId: 1,
});
// no popover by default
expect(".popover-content-wrapper").toHaveCount(0);
// hover over search icon to see if popover appears
await contains(".o_field_formatted_transaction_details [data-icon='search']").hover();
expect(".popover-content-wrapper").toHaveCount(1);
// the output should be expected markup formatted
expect(".popover-content-wrapper").toHaveText("name: Downpayment for your services\namount: 350.0\nstatus: posted\nidentifier: cb38d10c-4c93-41c7-bbbb-e0f57745cf0a\ncounter_part: \n name: Azure Interior\nis_zero_balancing: False");
// hover over popover to check that it still stays open
await contains(".popover-content-wrapper").hover();
expect(".popover-content-wrapper").toHaveCount(1);
});