[FIX] web: correct form style in x2ManyDialog

Since o_form_view class was not placed on the right element, as the
form is displayed in a dialog, some styles were not applied in x2Many
dialogs using a form view. Now, the selector matches all cases and
dialogs will be stylized as expected, since the class is placed on the
dialog container instead of the first div.

Now, we are consistent both for dialogs and standard form views.

Tests have been adapted to work as expected.

closes odoo/odoo#102953

X-original-commit: af67305b43d51e1669df19d376d9bda7418ba863
Signed-off-by: Michaël Mattiello <mcm@odoo.com>
Signed-off-by: Luca Vitali <luvi@odoo.com>
This commit is contained in:
luvi
2022-10-11 13:16:02 +02:00
parent 740dd7fb8a
commit e4ff2afaec
5 changed files with 13 additions and 10 deletions
@@ -2,8 +2,8 @@
<templates xml:space="preserve">
<t t-name="web.X2ManyFieldDialog" owl="1">
<Dialog title="title" withBodyPadding="false" modalRef="modalRef">
<FormRenderer class="'o_form_view'" record="record" fields="archInfo.fields" archInfo="archInfo"/>
<Dialog title="title" withBodyPadding="false" modalRef="modalRef" contentClass="'o_form_view'">
<FormRenderer record="record" fields="archInfo.fields" archInfo="archInfo"/>
<t t-set-slot="footer">
<t t-if="footerArchInfo">
<FormRenderer record="record" archInfo="footerArchInfo"/>
@@ -130,9 +130,6 @@
}
.o_row > div > .o_field_widget,
&.o_form_editable .oe_title .o_field_char {
width: 100%;
}
// Readonly specific rules
.o_form_readonly {
@@ -172,6 +169,10 @@
.oe_title {
max-width: 75%;
.o_field_char {
width: 100%;
}
}
.o_field_x2many .o_list_table .o_handle_cell .o_row_handle {
@@ -620,7 +621,7 @@
box-shadow: inset 0 1px 0 $border-color;
> td {
border:none;
&:empty {
padding: 0;
}
@@ -1021,6 +1022,8 @@
// Overridden style when form view in modal
.modal .modal-dialog {
.o_form_view {
min-height: auto;
.o_statusbar_buttons > .btn {
/**
* Override to prevent the status bar from increasing height when
@@ -380,7 +380,7 @@ QUnit.module("Fields", (hooks) => {
await click($(target).find(".o_field_many2many .o-kanban-button-new")[0]);
await click($(".modal .modal-footer .btn-primary:nth(1)")[0]);
assert.ok(
$(".modal .o_form_view.o_form_editable").length,
$(".modal .o_form_view .o_form_editable").length,
"should have opened a form view in edit mode, in a modal"
);
await editInput(target, ".modal .o_form_view input", "A new type");
@@ -9169,7 +9169,7 @@ QUnit.module("Fields", (hooks) => {
assert.containsNone(target, ".modal .o_form_view .o_data_row");
// click on the action button
await click(target.querySelector(".modal .o_form_view button"));
await click(target.querySelector(".modal .o_form_editable button"));
assert.containsOnce(target, ".modal .o_data_row");
assert.strictEqual(target.querySelector(".modal .o_data_cell").textContent, "gold");
@@ -828,7 +828,7 @@ tour.stepUtils.mobileModifier(tour.stepUtils.autoExpandMoreButtons('.o_control_p
run: 'text 10 hours',
}, {
mobile: true,
trigger: '.modal-body .o_form_view div[name="name"] input',
trigger: '.modal-content.o_form_view div[name="name"] input',
content: 'Enter a description this timesheet',
run: 'text 10 hours',
}, {
@@ -838,7 +838,7 @@ tour.stepUtils.mobileModifier(tour.stepUtils.autoExpandMoreButtons('.o_control_p
run: 'text 10',
}, {
mobile: true,
trigger: '.modal-body .o_form_view div[name="unit_amount"] input',
trigger: '.modal-content.o_form_view div[name="unit_amount"] input',
content: 'Enter one hour for this timesheet',
run: 'text 10',
}, {