bemade_full_formview_from_modal: fixed for 17.0 with a test tour as well.

This commit is contained in:
Marc Durepos 2024-05-02 15:00:17 -04:00
parent dc04ab952b
commit 716f153c91
6 changed files with 85 additions and 17 deletions

View file

@ -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

View file

@ -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,
})
}
});
})

View file

@ -1,13 +1,18 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-inherit="web.FormViewDialog.ToMany.buttons" t-inherit-mode="extension" owl="1">
<xpath expr="//button[hasclass('o_form_button_save_new')]" position="after">
<button class="btn btn-secondary o_form_button_open" t-on-click="_onOpen">Open</button>
</xpath>
</t>
<t t-inherit="web.FormViewDialog.ToOne.buttons" t-inherit-mode="extension" owl="1">
<xpath expr="//button[hasclass('o_form_button_save')]" position="after">
<button class="btn btn-secondary o_form_button_open" t-on-click="onOpenButtonClicked">Open</button>
<t t-inherit="web.X2ManyFieldDialog" t-inherit-mode="extension">
<xpath expr="//t[@t-set-slot='footer']" position="inside">
<button class="btn btn-primary" t-on-click="onOpenButtonClicked">Open</button>
</xpath>
</t>
<!-- <t t-inherit="web.FormViewDialog.ToMany.buttons" t-inherit-mode="extension">-->
<!-- <xpath expr="//button[hasclass('o_form_button_save_new')]" position="after">-->
<!-- <button class="btn btn-secondary o_form_button_open" t-on-click="_onOpen">Open</button>-->
<!-- </xpath>-->
<!-- </t>-->
<!-- <t t-inherit="web.FormViewDialog.ToOne.buttons" t-inherit-mode="extension">-->
<!-- <xpath expr="//button[hasclass('o_form_button_save')]" position="after">-->
<!-- <button class="btn btn-secondary o_form_button_open" t-on-click="onOpenButtonClicked">Open</button>-->
<!-- </xpath>-->
<!-- </t>-->
</templates>

View file

@ -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")',
}
]
});

View file

@ -0,0 +1 @@
from . import test_full_formview_from_modal

View file

@ -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")