bemade_full_formview_from_modal: fixed for 17.0 with a test tour as well.
This commit is contained in:
parent
dc04ab952b
commit
716f153c91
6 changed files with 85 additions and 17 deletions
|
|
@ -25,12 +25,15 @@
|
||||||
'author': 'Bemade Inc.',
|
'author': 'Bemade Inc.',
|
||||||
'website': 'http://www.bemade.org',
|
'website': 'http://www.bemade.org',
|
||||||
'license': 'OPL-1',
|
'license': 'OPL-1',
|
||||||
'depends': [],
|
'depends': ['base'], # For testing, install contacts module as well.
|
||||||
'data': [],
|
'data': [],
|
||||||
'assets': {
|
'assets': {
|
||||||
'web.assets_backend': [
|
'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,
|
'installable': True,
|
||||||
'auto_install': False
|
'auto_install': False
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,23 @@
|
||||||
/** @odoo-module **/
|
/** @odoo-module **/
|
||||||
|
|
||||||
import { patch } from "@web/core/utils/patch";
|
import { patch } from "@web/core/utils/patch";
|
||||||
import { FormController } from "@web/views/form/form_controller";
|
|
||||||
import { useService } from "@web/core/utils/hooks";
|
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 () {
|
setup () {
|
||||||
this._super();
|
super.setup();
|
||||||
this.action = useService("action")
|
this.action = useService('action')
|
||||||
|
this.env.dialogData.onOpenButtonClicked = this.onOpenButtonClicked.bind(this);
|
||||||
},
|
},
|
||||||
onOpenButtonClicked: function () {
|
onOpenButtonClicked: function () {
|
||||||
this.action.doAction({
|
this.action.doAction({
|
||||||
type: "ir.actions.act_window",
|
type: "ir.actions.act_window",
|
||||||
res_model: this.props.resModel,
|
res_model: this.record.resModel,
|
||||||
res_id: this.props.resId,
|
res_id: this.record.resId,
|
||||||
views: [[false, "form"]],
|
views: [[false, "form"]],
|
||||||
target: "current",
|
target: "current",
|
||||||
context: this.props.context,
|
context: this.props.context,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,18 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<templates xml:space="preserve">
|
<templates xml:space="preserve">
|
||||||
<t t-inherit="web.FormViewDialog.ToMany.buttons" t-inherit-mode="extension" owl="1">
|
<t t-inherit="web.X2ManyFieldDialog" t-inherit-mode="extension">
|
||||||
<xpath expr="//button[hasclass('o_form_button_save_new')]" position="after">
|
<xpath expr="//t[@t-set-slot='footer']" position="inside">
|
||||||
<button class="btn btn-secondary o_form_button_open" t-on-click="_onOpen">Open</button>
|
<button class="btn btn-primary" t-on-click="onOpenButtonClicked">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>
|
|
||||||
</xpath>
|
</xpath>
|
||||||
</t>
|
</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>
|
</templates>
|
||||||
|
|
@ -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")',
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
1
bemade_full_formview_from_modal/tests/__init__.py
Normal file
1
bemade_full_formview_from_modal/tests/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
from . import test_full_formview_from_modal
|
||||||
|
|
@ -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")
|
||||||
Loading…
Reference in a new issue