diff --git a/mis_builder/__manifest__.py b/mis_builder/__manifest__.py
index d727bca72..25b856e7f 100644
--- a/mis_builder/__manifest__.py
+++ b/mis_builder/__manifest__.py
@@ -33,12 +33,17 @@
"mis_builder/static/src/components/mis_report_widget.esm.js",
"mis_builder/static/src/components/mis_report_widget.xml",
"mis_builder/static/src/components/mis_report_widget.css",
+ "mis_builder/static/src/views/field/field.esm.js",
+ "mis_builder/static/src/views/form/mis_report_form_compiler.esm.js",
+ "mis_builder/static/src/views/form/mis_report_form_controller.esm.js",
+ "mis_builder/static/src/views/form/mis_report_form_controller.xml",
+ "mis_builder/static/src/views/form/mis_report_form_renderer.esm.js",
+ "mis_builder/static/src/views/form/mis_report_form_view.esm.js",
],
"web.report_assets_common": [
"/mis_builder/static/src/css/report.css",
],
},
- "qweb": ["static/src/xml/mis_report_widget.xml"],
"installable": True,
"application": True,
"license": "AGPL-3",
diff --git a/mis_builder/static/src/components/mis_report_widget.esm.js b/mis_builder/static/src/components/mis_report_widget.esm.js
index 5b8db981f..1051b1786 100644
--- a/mis_builder/static/src/components/mis_report_widget.esm.js
+++ b/mis_builder/static/src/components/mis_report_widget.esm.js
@@ -9,6 +9,9 @@ import {SearchBar} from "@web/search/search_bar/search_bar";
import {parseDate} from "@web/core/l10n/dates";
import {registry} from "@web/core/registry";
import {standardFieldProps} from "@web/views/fields/standard_field_props";
+import {useSetupAction} from "@web/webclient/actions/action_hook";
+
+export const misReportWidgetClassName = "mis_report_widget";
export class MisReportWidget extends Component {
setup() {
@@ -33,6 +36,18 @@ export class MisReportWidget extends Component {
this.refresh();
});
onWillStart(this.willStart);
+ useSetupAction({
+ getGlobalState: () => {
+ if (!this.showSearchBar) {
+ return {};
+ }
+ return {
+ misReportSearchModelState: JSON.stringify(
+ this.searchModel.exportState()
+ ),
+ };
+ },
+ });
}
// Lifecycle
@@ -59,11 +74,15 @@ export class MisReportWidget extends Component {
this.widget_show_pivot_date = result.widget_show_pivot_date;
if (this.showSearchBar) {
// Initialize the search model
- await this.searchModel.load({
+ const config = {
resModel: this.source_aml_model_name,
searchViewId: this.widget_search_view_id,
analyticAccountId: this.analyticAccountId,
- });
+ };
+ if (this.props.misReportSearchModelState) {
+ config.state = JSON.parse(this.props.misReportSearchModelState);
+ }
+ await this.searchModel.load(config);
}
// Compute the report
@@ -232,9 +251,15 @@ MisReportWidget.props = {
type: String,
optional: true,
},
+ misReportSearchModelState: {
+ type: String,
+ optional: true,
+ },
+};
+MisReportWidget.extractProps = ({attrs}) => {
+ return {
+ analyticAccountIdField: attrs.analytic_account_id_field,
+ };
};
-MisReportWidget.extractProps = ({attrs}) => ({
- analyticAccountIdField: attrs.analytic_account_id_field,
-});
-registry.category("fields").add("mis_report_widget", MisReportWidget);
+registry.category("fields").add(misReportWidgetClassName, MisReportWidget);
diff --git a/mis_builder/static/src/views/field/field.esm.js b/mis_builder/static/src/views/field/field.esm.js
new file mode 100644
index 000000000..1513a5917
--- /dev/null
+++ b/mis_builder/static/src/views/field/field.esm.js
@@ -0,0 +1,23 @@
+/** @odoo-module **/
+
+import {Field} from "@web/views/fields/field";
+import {misReportWidgetClassName} from "@mis_builder/components/mis_report_widget.esm";
+
+export class MisReportField extends Field {
+ /**
+ * @override
+ */
+ get fieldComponentProps() {
+ const fieldComponentProps = super.fieldComponentProps;
+ // Ensures that misReportSearchModelState is passed to the props of the
+ // `mis_report_widget` widget that is mounted on the field.
+ if (
+ this.props.fieldInfo.widget &&
+ this.props.fieldInfo.widget === misReportWidgetClassName
+ ) {
+ fieldComponentProps.misReportSearchModelState =
+ this.props.misReportSearchModelState;
+ }
+ return fieldComponentProps;
+ }
+}
diff --git a/mis_builder/static/src/views/form/mis_report_form_compiler.esm.js b/mis_builder/static/src/views/form/mis_report_form_compiler.esm.js
new file mode 100644
index 000000000..bb342fbb6
--- /dev/null
+++ b/mis_builder/static/src/views/form/mis_report_form_compiler.esm.js
@@ -0,0 +1,25 @@
+/** @odoo-module **/
+
+import {FormCompiler} from "@web/views/form/form_compiler";
+import {misReportWidgetClassName} from "@mis_builder/components/mis_report_widget.esm";
+
+export class MisReportFormCompiler extends FormCompiler {
+ /**
+ * @override
+ */
+ compileField(el) {
+ // Passes misReportSearchModelState to the Field that is compiled in the
+ // view when the field has the `mis_report_widget` widget set.
+ const field = super.compileField(el);
+ if (
+ el.hasAttribute("widget") &&
+ el.getAttribute("widget") === misReportWidgetClassName
+ ) {
+ field.setAttribute(
+ "misReportSearchModelState",
+ "props.globalState && props.globalState.misReportSearchModelState"
+ );
+ }
+ return field;
+ }
+}
diff --git a/mis_builder/static/src/views/form/mis_report_form_controller.esm.js b/mis_builder/static/src/views/form/mis_report_form_controller.esm.js
new file mode 100644
index 000000000..22b9faf7a
--- /dev/null
+++ b/mis_builder/static/src/views/form/mis_report_form_controller.esm.js
@@ -0,0 +1,8 @@
+/** @odoo-module */
+
+import {FormController} from "@web/views/form/form_controller";
+
+export class MisReportFormController extends FormController {}
+
+// Ensures that globalState is passed to the renderer.
+MisReportFormController.template = "mis_builder.FormView";
diff --git a/mis_builder/static/src/views/form/mis_report_form_controller.xml b/mis_builder/static/src/views/form/mis_report_form_controller.xml
new file mode 100644
index 000000000..0e45f4da9
--- /dev/null
+++ b/mis_builder/static/src/views/form/mis_report_form_controller.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+ props.globalState
+
+
+ props.globalState
+
+
+
+
diff --git a/mis_builder/static/src/views/form/mis_report_form_renderer.esm.js b/mis_builder/static/src/views/form/mis_report_form_renderer.esm.js
new file mode 100644
index 000000000..38d4261bc
--- /dev/null
+++ b/mis_builder/static/src/views/form/mis_report_form_renderer.esm.js
@@ -0,0 +1,19 @@
+/** @odoo-module */
+
+import {FormRenderer} from "@web/views/form/form_renderer";
+import {MisReportField} from "@mis_builder/views/field/field.esm";
+
+export class MisReportFormRenderer extends FormRenderer {}
+
+// Gets the global state from the attributes that have been passed by the controller.
+MisReportFormRenderer.extractProps = ({attrs}) => {
+ return {
+ ...FormRenderer.extractProps({attrs}),
+ globalState: attrs.globalState || {},
+ };
+};
+
+MisReportFormRenderer.components = {
+ ...FormRenderer.components,
+ Field: MisReportField,
+};
diff --git a/mis_builder/static/src/views/form/mis_report_form_view.esm.js b/mis_builder/static/src/views/form/mis_report_form_view.esm.js
new file mode 100644
index 000000000..0da192eaa
--- /dev/null
+++ b/mis_builder/static/src/views/form/mis_report_form_view.esm.js
@@ -0,0 +1,18 @@
+/** @odoo-module **/
+
+import {MisReportFormCompiler} from "@mis_builder/views/form/mis_report_form_compiler.esm";
+import {MisReportFormController} from "@mis_builder/views/form/mis_report_form_controller.esm";
+import {MisReportFormRenderer} from "@mis_builder/views/form/mis_report_form_renderer.esm";
+import {formView} from "@web/views/form/form_view";
+import {registry} from "@web/core/registry";
+
+// The view to use when mounting `mis_report_widget` widget in order to preserve the
+// filters when returning from the drill-down views.
+export const misReportFormView = {
+ ...formView,
+ Compiler: MisReportFormCompiler,
+ Controller: MisReportFormController,
+ Renderer: MisReportFormRenderer,
+};
+
+registry.category("views").add("mis_report_form_view", misReportFormView);
diff --git a/mis_builder/views/mis_report_instance.xml b/mis_builder/views/mis_report_instance.xml
index f13fce50e..c4c07228b 100644
--- a/mis_builder/views/mis_report_instance.xml
+++ b/mis_builder/views/mis_report_instance.xml
@@ -10,13 +10,14 @@
edit="false"
create="false"
delete="false"
+ js_class="mis_report_form_view"
>