Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions base_geoengine/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
"base_geoengine/static/src/css/style.css",
"base_geoengine/static/lib/geostats-2.1.0/geostats.css",
],
"web.assets_unit_tests": [
"base_geoengine/static/tests/**/*.test.js",
],
# Note: Third-party libraries (ol.js, chroma.js, geostats.js) are loaded
# dynamically via loadJS() in geoengine_libs.esm.js to avoid bundler issues
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,17 @@ export class GeoengineController extends Component {
*/
async openRecord(resModel, resId, viewId) {
const {views} = await this.view.loadViews({resModel, views: [[false, "form"]]});
this.actionService.doAction({
type: "ir.actions.act_window",
res_model: resModel,
views: viewId || [[views.form.id, "form"]],
res_id: resId,
target: "new",
context: {edit: false, create: false},
});
return this.actionService.doAction(
{
type: "ir.actions.act_window",
res_model: resModel,
views: viewId || [[views.form.id, "form"]],
res_id: resId,
target: "new",
context: {edit: this.editable, create: false},
},
{onClose: () => this.onSaveRecord()}
);
}

/**
Expand Down Expand Up @@ -208,6 +211,7 @@ GeoengineController.template = "base_geoengine.GeoengineController";
GeoengineController.components = {Layout, SearchBar};
GeoengineController.props = {
...standardViewProps,
env: {type: Object, optional: true},
Model: Function,
Renderer: Function,
archInfo: Object,
Expand Down
73 changes: 73 additions & 0 deletions base_geoengine/static/tests/geoengine_controller.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright 2026 Camptocamp SA
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

import {Component, xml} from "@odoo/owl";
import {
contains,
defineModels,
fields,
makeMockEnv,
models,
mountView,
mountWithCleanup,
onRpc,
patchWithCleanup,
} from "@web/../tests/web_test_helpers";
import {describe, expect, test} from "@odoo/hoot";
import {MainComponentsContainer} from "@web/core/main_components_container";
import {geoengineView} from "@base_geoengine/js/views/geoengine/geoengine_view.esm";

class GeoTest extends models.Model {
_name = "geo.test";

name = fields.Char();

_records = [{id: 1, name: "Test location"}];
}

class OpenRecordRenderer extends Component {
static props = ["*"];
static template = xml`
<button class="o_test_open_record" t-on-click="openRecord">Open record</button>
`;

openRecord() {
return this.props.openRecord("geo.test", 1);
}
}

defineModels([GeoTest]);
describe.current.tags("desktop");

test("editable GeoEngine view opens an editable form dialog and refreshes on close", async () => {
let loadCount = 0;
onRpc("geo.test", "web_search_read", () => {
loadCount++;
});
patchWithCleanup(geoengineView, {Renderer: OpenRecordRenderer});

const env = await makeMockEnv();
await mountWithCleanup(MainComponentsContainer, {env});
await mountView({
env,
type: "geoengine",
resModel: "geo.test",
arch: `
<geoengine editable="1">
<field name="name"/>
<templates>
<t t-name="info_box"><field name="name"/></t>
</templates>
</geoengine>`,
archs: {
"form,false": `<form><field name="name"/></form>`,
},
});
const initialLoadCount = loadCount;

await contains(".o_test_open_record").click();
expect(".modal .o_form_view .o_field_widget[name='name'] input").toHaveCount(1);

await contains(".modal .o_form_button_cancel").click();
expect(loadCount).toBeGreaterThan(initialLoadCount);
});
Loading