[FIX] web: prevent selection while record in edit mode from editable list view
If applied, this commit will solve the issue of the list view selection when the record is not actually created but it can be selected and can able to perform the action. Steps to produce: - Open Accounting > Configurations > Chart of Accounts. - Click on the 'New' button. - Select the new line which has been added. - Perform the 'Duplicate' action for that record. This commit will fix the generic issue by preventing the record selection while the record is in 'Edit' mode. sentry - 4191036697 closes odoo/odoo#129000 X-original-commit: 5570216c8c852b5851526217858b5b7515309444 Signed-off-by: Mathieu Duckerts-Antoine (dam) <dam@odoo.com> Signed-off-by: Parth Solanki (paso) <paso@odoo.com>
This commit is contained in:
@@ -1732,8 +1732,15 @@ export class ListRenderer extends Component {
|
||||
group.toggle();
|
||||
}
|
||||
|
||||
get canSelectRecord() {
|
||||
return !this.props.list.editedRecord && !this.props.list.model.useSampleModel;
|
||||
}
|
||||
|
||||
toggleSelection() {
|
||||
const list = this.props.list;
|
||||
if (!this.canSelectRecord) {
|
||||
return;
|
||||
}
|
||||
if (list.selection.length === list.records.length) {
|
||||
list.records.forEach((record) => {
|
||||
record.toggleSelection(false);
|
||||
@@ -1747,6 +1754,9 @@ export class ListRenderer extends Component {
|
||||
}
|
||||
|
||||
toggleRecordSelection(record) {
|
||||
if (!this.canSelectRecord) {
|
||||
return;
|
||||
}
|
||||
if (this.shiftKeyMode && this.lastCheckedRecord) {
|
||||
this.toggleRecordShiftSelection(record);
|
||||
} else {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th t-if="hasSelectors" class="o_list_record_selector o_list_controller align-middle pe-1 cursor-pointer" tabindex="-1" t-on-keydown.synthetic="(ev) => this.onCellKeydown(ev)" t-on-click.stop="toggleSelection">
|
||||
<CheckBox disabled="!!props.list.editedRecord or props.list.model.useSampleModel" value="selectAll" className="'d-flex m-0'" onChange.bind="toggleSelection"/>
|
||||
<CheckBox disabled="!canSelectRecord" value="selectAll" className="'d-flex m-0'" onChange.bind="toggleSelection"/>
|
||||
</th>
|
||||
<t t-foreach="state.columns" t-as="column" t-key="column.id">
|
||||
<th t-if="column.type === 'field'"
|
||||
@@ -222,7 +222,7 @@
|
||||
t-on-touchmove="() => this.onRowTouchMove(record)"
|
||||
>
|
||||
<td t-on-keydown.synthetic="(ev) => this.onCellKeydown(ev, group, record)" t-if="hasSelectors" class="o_list_record_selector user-select-none" t-on-click.stop="() => this.toggleRecordSelection(record)" tabindex="-1">
|
||||
<CheckBox disabled="!!props.list.editedRecord or props.list.model.useSampleModel" value="record.selected" onChange.alike="() => this.toggleRecordSelection(record)" />
|
||||
<CheckBox disabled="!canSelectRecord" value="record.selected" onChange.alike="() => this.toggleRecordSelection(record)" />
|
||||
</td>
|
||||
<t t-foreach="getColumns(record)" t-as="column" t-key="column.id">
|
||||
<t t-if="column.type === 'field'">
|
||||
|
||||
@@ -19044,6 +19044,33 @@ QUnit.module("Views", (hooks) => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("list view: prevent record selection when editable list in edit mode", async function (assert) {
|
||||
await makeView({
|
||||
type: "list",
|
||||
resModel: "foo",
|
||||
serverData,
|
||||
arch: `
|
||||
<tree editable="top">
|
||||
<field name="foo" />
|
||||
</tree>`,
|
||||
});
|
||||
|
||||
// When we try to select new record in edit mode
|
||||
await click(target.querySelector(".o_control_panel_main_buttons .d-none.d-xl-inline-flex .o_list_button_add"));
|
||||
await click(target.querySelector('.o_data_row .o_list_record_selector'));
|
||||
assert.strictEqual(
|
||||
target.querySelector('.o_data_row .o_list_record_selector input[type="checkbox"]').checked,
|
||||
false
|
||||
);
|
||||
|
||||
// When we try to select all records in edit mode
|
||||
await click(target.querySelector('th.o_list_record_selector.o_list_controller'));
|
||||
assert.strictEqual(
|
||||
target.querySelector('.o_list_controller input[type="checkbox"]').checked,
|
||||
false
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("context keys not passed down the stack and not to fields", async (assert) => {
|
||||
patchWithCleanup(AutoComplete, {
|
||||
timeout: 0,
|
||||
|
||||
Reference in New Issue
Block a user