diff --git a/bemade_full_formview_from_modal/__manifest__.py b/bemade_full_formview_from_modal/__manifest__.py index 2a37f2f..ad1be08 100644 --- a/bemade_full_formview_from_modal/__manifest__.py +++ b/bemade_full_formview_from_modal/__manifest__.py @@ -25,12 +25,15 @@ 'author': 'Bemade Inc.', 'website': 'http://www.bemade.org', 'license': 'OPL-1', - 'depends': [], + 'depends': ['base'], # For testing, install contacts module as well. 'data': [], 'assets': { 'web.assets_backend': [ - # 'bemade_full_formview_from_modal/static/src/**/*', + 'bemade_full_formview_from_modal/static/src/**/*', ], + 'web.assets_tests': [ + 'bemade_full_formview_from_modal/static/tests/**/*', + ] }, 'installable': True, 'auto_install': False diff --git a/bemade_full_formview_from_modal/static/src/view_dialogs/form_view_dialog.js b/bemade_full_formview_from_modal/static/src/view_dialogs/form_view_dialog.js index 06e1418..177353f 100644 --- a/bemade_full_formview_from_modal/static/src/view_dialogs/form_view_dialog.js +++ b/bemade_full_formview_from_modal/static/src/view_dialogs/form_view_dialog.js @@ -1,22 +1,23 @@ /** @odoo-module **/ import { patch } from "@web/core/utils/patch"; -import { FormController } from "@web/views/form/form_controller"; import { useService } from "@web/core/utils/hooks"; +import { X2ManyFieldDialog } from "@web/views/fields/relational_utils" -patch(FormController.prototype, "bemade_full_formview_from_modal.FormController", { +patch(X2ManyFieldDialog.prototype, { setup () { - this._super(); - this.action = useService("action") + super.setup(); + this.action = useService('action') + this.env.dialogData.onOpenButtonClicked = this.onOpenButtonClicked.bind(this); }, onOpenButtonClicked: function () { this.action.doAction({ type: "ir.actions.act_window", - res_model: this.props.resModel, - res_id: this.props.resId, + res_model: this.record.resModel, + res_id: this.record.resId, views: [[false, "form"]], target: "current", context: this.props.context, }) } -}); +}) diff --git a/bemade_full_formview_from_modal/static/src/view_dialogs/form_view_dialog.xml b/bemade_full_formview_from_modal/static/src/view_dialogs/form_view_dialog.xml index 65aefe9..2e4e55d 100644 --- a/bemade_full_formview_from_modal/static/src/view_dialogs/form_view_dialog.xml +++ b/bemade_full_formview_from_modal/static/src/view_dialogs/form_view_dialog.xml @@ -1,13 +1,18 @@ - - - - - - - - + + + + + + + + + + + + + \ No newline at end of file diff --git a/bemade_full_formview_from_modal/static/tests/test_full_formview_from_modal.js b/bemade_full_formview_from_modal/static/tests/test_full_formview_from_modal.js new file mode 100644 index 0000000..8fe7427 --- /dev/null +++ b/bemade_full_formview_from_modal/static/tests/test_full_formview_from_modal.js @@ -0,0 +1,45 @@ +/** @odoo-module **/ + +import { registry } from "@web/core/registry"; +import { stepUtils } from "@web_tour/tour_service/tour_utils"; + +registry.category("web_tour.tours").add("full_formview_from_modal_tour", { + test: true, + url: '/web', + steps: () => [stepUtils.showAppsMenuItem(), + { + content: 'Go to contacts', + trigger: '.o_app[data-menu-xmlid="contacts.menu_contacts"]', + }, + { + content: 'Click search', + trigger: '.o_searchview_input', + }, + { + content: 'insert text in the search bar', + trigger: '.o_searchview_input', + run: 'text Test parent', + }, + { + content: 'Validate search', + trigger: '.o_searchview_autocomplete .o_menu_item:contains("Name")', + }, + { + content: 'Open the contact', + trigger: '.o_kanban_record .o_kanban_record_title span:contains("Test parent")', + }, + { + content: 'Open the child', + trigger: 'div[name="child_ids"] .o_kanban_record:first-child', + }, + { + "trigger": "button:contains('Open')", + "content": "Click the open button on the modal", + "run": "click", + }, + { + content: 'Make sure the form view opens to Test Child', + trigger: 'div.o_last_breadcrumb_item span:contains("Test Child")', + } + ] +}); diff --git a/bemade_full_formview_from_modal/tests/__init__.py b/bemade_full_formview_from_modal/tests/__init__.py new file mode 100644 index 0000000..5aca76f --- /dev/null +++ b/bemade_full_formview_from_modal/tests/__init__.py @@ -0,0 +1 @@ +from . import test_full_formview_from_modal diff --git a/bemade_full_formview_from_modal/tests/test_full_formview_from_modal.py b/bemade_full_formview_from_modal/tests/test_full_formview_from_modal.py new file mode 100644 index 0000000..c7f801f --- /dev/null +++ b/bemade_full_formview_from_modal/tests/test_full_formview_from_modal.py @@ -0,0 +1,13 @@ +from odoo.tests import HttpCase, tagged + + +@tagged('post_install', '-at_install') +class TestFullFormviewFromModal(HttpCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.parent = cls.env['res.partner'].create({'name': 'Test parent', }) + cls.child = cls.env['res.partner'].create({'name': 'Test Child', 'parent_id': cls.parent.id}) + + def test_tour(self): + self.start_tour("/web", 'full_formview_from_modal_tour', login="demo")