import { click, insertText, openFormView, start, startServer, triggerHotkey } from "@mail/../tests/mail_test_helpers"; import { expect, test } from "@odoo/hoot"; import { asyncStep, contains, defineModels, fields, onRpc, models, waitForSteps} from "@web/../tests/web_test_helpers"; import { defineAccountModels } from "./account_test_helpers"; defineAccountModels(); test("When I switch tabs, it saves", async () => { const pyEnv = await startServer(); const accountMove = pyEnv["account.move"].create({ name: "move0" }); await start(); onRpc("account.move", "web_save", () => { asyncStep("tab saved"); }); await openFormView("account.move", accountMove, { arch: `
`, }); await insertText("[name='name'] input", "somebody save me!"); triggerHotkey("Enter"); await click('a[name="aml_tab"]'); await waitForSteps(["tab saved"]); }); test("Confirmation dialog on delete contains a warning", async () => { const pyEnv = await startServer(); const accountMove = pyEnv["account.move"].create({ name: "move0" }); await start(); onRpc("account.move", "check_move_sequence_chain", () => { return false; }); await openFormView("account.move", accountMove, { arch: `
`, }); await contains(".o_cp_action_menus button").click(); await contains(".o_menu_item:contains(Delete)").click(); expect(".o_dialog div.text-danger").toHaveText("This operation will create a gap in the sequence.", { message: "warning message has been added in the dialog" }); }); class AccountMove extends models.Model { line_ids = fields.One2many({ string: "Invoice Lines", relation: "account.move.line", }) _records = [{ id: 1, name: "account.move" }] } class AccountMoveLine extends models.Model { name = fields.Char(); product_id = fields.Many2one({ string:"Product", relation:"product", }); move_id = fields.Many2one({ string: "Account Move", relation: "account.move", }) } class Product extends models.Model { name = fields.Char(); _records = [{ id: 1, name: "testProduct" }]; } defineModels({ Product, AccountMoveLine, AccountMove }); test("Update description on product line", async() => { const pyEnv = await startServer(); const productId = pyEnv["product"].browse([1]); const accountMove = pyEnv["account.move"].browse([1]); pyEnv["account.move"].write([accountMove[0].id], { invoice_line_ids: [[0, 0, { name: productId[0].name, product_id: productId[0].id }]], }); await start(); onRpc("account.move", "web_save", () => { asyncStep("save")}); await openFormView("account.move", accountMove[0].id, { arch: `
`, }); await click(".o_many2one"); await contains("#labelVisibilityButtonId").click() await insertText("textarea[placeholder='Enter a description']", "testDescription"); await click(".o_form_button_save"); await waitForSteps(["save"]); const line = pyEnv["account.move.line"].browse([1])[0]; expect(line.name).toBe("testProduct\ntestDescription"); });