diff --git a/addons/survey/__manifest__.py b/addons/survey/__manifest__.py
index 72370816acb..0f093e65438 100644
--- a/addons/survey/__manifest__.py
+++ b/addons/survey/__manifest__.py
@@ -105,7 +105,10 @@ sent mails with personal token for the invitation of the survey.
],
'web.assets_common': [
'survey/static/src/js/tours/survey_tour.js',
- ]
+ ],
+ 'web.assets_qweb': [
+ 'survey/static/src/question_page/*.xml',
+ ],
},
'license': 'LGPL-3',
}
diff --git a/addons/survey/static/src/question_page/description_page_field.js b/addons/survey/static/src/question_page/description_page_field.js
new file mode 100644
index 00000000000..d3cd74d1609
--- /dev/null
+++ b/addons/survey/static/src/question_page/description_page_field.js
@@ -0,0 +1,27 @@
+/** @odoo-module */
+
+import { CharField } from "@web/views/fields/char/char_field";
+import { registry } from "@web/core/registry";
+
+const { useEffect, useRef } = owl;
+
+class DescriptionPageField extends CharField {
+ setup() {
+ super.setup();
+ const inputRef = useRef("input");
+ useEffect(
+ (input) => {
+ if (input) {
+ input.classList.add("col");
+ }
+ },
+ () => [inputRef.el]
+ );
+ }
+ onExternalBtnClick() {
+ this.env.openRecord(this.props.record);
+ }
+}
+DescriptionPageField.template = "survey.DescriptionPageField";
+
+registry.category("fields").add("survey_description_page", DescriptionPageField);
diff --git a/addons/survey/static/src/question_page/description_page_field.xml b/addons/survey/static/src/question_page/description_page_field.xml
new file mode 100644
index 00000000000..94d09ca4bf2
--- /dev/null
+++ b/addons/survey/static/src/question_page/description_page_field.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/survey/static/src/question_page/question_page_one2many_field.js b/addons/survey/static/src/question_page/question_page_one2many_field.js
index 11f54bba9dd..cbe0b7ee5dc 100644
--- a/addons/survey/static/src/question_page/question_page_one2many_field.js
+++ b/addons/survey/static/src/question_page/question_page_one2many_field.js
@@ -4,7 +4,16 @@ import { QuestionPageListRenderer } from "./question_page_list_renderer";
import { registry } from "@web/core/registry";
import { X2ManyField } from "@web/views/fields/x2many/x2many_field";
-class QuestionPageOneToManyField extends X2ManyField {}
+const { useSubEnv } = owl;
+
+class QuestionPageOneToManyField extends X2ManyField {
+ setup() {
+ super.setup();
+ useSubEnv({
+ openRecord: (record) => this.openRecord(record),
+ });
+ }
+}
QuestionPageOneToManyField.components = {
...X2ManyField.components,
ListRenderer: QuestionPageListRenderer,
diff --git a/addons/survey/static/tests/components/description_page_field_tests.js b/addons/survey/static/tests/components/description_page_field_tests.js
new file mode 100644
index 00000000000..710947d91c5
--- /dev/null
+++ b/addons/survey/static/tests/components/description_page_field_tests.js
@@ -0,0 +1,90 @@
+/** @odoo-module */
+
+import { click, clickEdit, getFixture } from "@web/../tests/helpers/utils";
+import { makeView, setupViewRegistries } from "@web/../tests/views/helpers";
+
+QUnit.module("DescriptionPageField", (hooks) => {
+ let serverData;
+ let target;
+
+ hooks.beforeEach(() => {
+ target = getFixture();
+
+ serverData = {
+ models: {
+ partner: {
+ fields: { lines: { type: "one2many", relation: "lines_sections" } },
+ records: [
+ {
+ id: 1,
+ lines: [1, 2],
+ },
+ ],
+ },
+ lines_sections: {
+ fields: {
+ is_page: { type: "boolean" },
+ title: { type: "char", string: "Title" },
+ random_questions_count: { type: "number", string: "Question Count" },
+ },
+ records: [
+ {
+ id: 1,
+ is_page: true,
+ title: "firstSectionTitle",
+ random_questions_count: 4,
+ },
+ {
+ id: 2,
+ is_page: false,
+ title: "recordTitle",
+ random_questions_count: 5,
+ },
+ ],
+ },
+ },
+ views: {
+ "lines_sections,false,form": `
+
+ `,
+ },
+ };
+
+ setupViewRegistries();
+ });
+
+ QUnit.test(
+ "button is visible in the edited record and allows to open that record",
+ async (assert) => {
+ await makeView({
+ type: "form",
+ resModel: "partner",
+ resId: 1,
+ serverData,
+ arch: `
+
+ `,
+ });
+ assert.containsN(target, "td.o_survey_description_page_cell", 2);
+ assert.containsNone(target, "button.o_icon_button");
+
+ await clickEdit(target);
+ await click(target.querySelector(".o_data_cell"));
+ assert.containsOnce(target.querySelector(".o_data_row"), "button.o_icon_button");
+ assert.containsNone(target, ".modal .o_form_view_dialog");
+
+ await click(target, "button.o_icon_button");
+ assert.containsOnce(target, ".modal .o_form_view_dialog");
+ }
+ );
+});