Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,47 @@
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */

import {ListRenderer} from "@web/views/list/list_renderer";
import {onWillRender} from "@odoo/owl";
import {patch} from "@web/core/utils/patch";
import {serializeDate, serializeDateTime} from "@web/core/l10n/dates";
import {exprToBoolean} from "@web/core/utils/strings";
import {browser} from "@web/core/browser/browser";

patch(ListRenderer.prototype, {
setup() {
super.setup(...arguments);
const parent = this.__owl__.parent.parent;
this.displayDuplicateLine =
const key = this.createViewKey();
this.keyDuplicateLineColumn = `duplicate_line_column,${key}`;
this.duplicateLineAllowed =
parent &&
parent.props &&
parent.props.fieldInfo &&
parent.props.fieldInfo.options &&
parent.props.fieldInfo.options.allow_clone;
this.displayDuplicateLine =
this.duplicateLineAllowed && this.duplicateLineColumn;
onWillRender(() => {
this.duplicateLineColumn = exprToBoolean(
browser.localStorage.getItem(this.keyDuplicateLineColumn),
false
);
this.displayDuplicateLine =
this.duplicateLineAllowed && this.duplicateLineColumn;
});
},
toggleDuplicateLineColumn() {
this.duplicateLineColumn = !this.duplicateLineColumn;
browser.localStorage.setItem(
this.keyDuplicateLineColumn,
this.duplicateLineColumn
);
this.displayDuplicateLine =
this.duplicateLineAllowed && this.duplicateLineColumn;
this.render();
},
get hasActionsColumn() {
return super.hasActionsColumn || Boolean(this.duplicateLineAllowed);
},
async onCloneIconClick(record) {
const toSkip = this.getFieldsToSkip();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,33 @@
style="width: 32px; min-width: 32px"
/>
</xpath>
<xpath
expr="//div[contains(@class, 'o_optional_columns_dropdown')]//t[@t-set-slot='content']"
position="inside"
>
<t t-set="hasX2ManyAction" t-value="isX2Many and activeActions.create" />
<t t-if="hasX2ManyAction and duplicateLineAllowed">
<div
t-if="!hasOptionalOpenFormViewColumn"
role="separator"
class="dropdown-divider"
/>
<DropdownItem
closingMode="'none'"
onSelected="() => this.toggleDuplicateLineColumn()"
>
<CheckBox
onChange="() => this.toggleDuplicateLineColumn()"
value="this.duplicateLineColumn"
name="'Duplicate Line'"
>
<span class="d-flex align-items-center">
<span class="text-truncate">Duplicate Line Button</span>
</span>
</CheckBox>
</DropdownItem>
</t>
</xpath>
</t>
<t
t-name="web_widget_one2many_tree_line_duplicate.ListRenderer.RecordRow"
Expand All @@ -39,5 +66,4 @@
</td>
</xpath>
</t>

</templates>