This commit is contained in:
李鹏宇
2025-07-03 00:13:53 +08:00
parent 0767df8158
commit b7e54d8dd8
4 changed files with 35 additions and 56 deletions
+2 -1
View File
@@ -67,9 +67,10 @@
"tree_view_advanced_filter/static/src/web_list_num/**/*",
"tree_view_advanced_filter/static/src/list_view_sticky_header_and_column/js/*",
"tree_view_advanced_filter/static/src/list_view_sticky_header_and_column/xml/*",
"tree_view_advanced_filter/static/src/list_view_sticky_header_and_column/scss/*",
"tree_view_advanced_filter/static/src/list_view_sticky_header_and_column/scss/*"
]
},
"images": ["static/description/banner.jpg"],
"installable": True,
"auto_install": False,
@@ -2,12 +2,11 @@
/** This file will used to stick the selected header and column in the list view **/
import { patch } from "@web/core/utils/patch";
import { ListRenderer } from "@web/views/list/list_renderer";
import { useService } from "@web/core/utils/hooks";
patch(ListRenderer.prototype, {
/** super the setup function **/
setup() {
super.setup();
this.orm = useService('orm');
},
/**
* function defining the button having t-on-click _onClick
@@ -52,9 +51,6 @@ patch(ListRenderer.prototype, {
}
}
});
// debugger
// this.props.updateForzenColumns(columnIndex);
this.saveManagerData(columnIndex);
},
/**
* super onClickSortColumn function and remove the icon and element having the class sticky-column
@@ -65,20 +61,5 @@ patch(ListRenderer.prototype, {
$(this.__owl__.bdom.parentEl.querySelectorAll('.clicked-header')).removeClass('clicked-header');
const $tableHeaders = $(this.__owl__.bdom.parentEl.querySelectorAll('.o_list_table th'));
$tableHeaders.removeClass('sticky-column').css('left', '');
},
saveManagerData(num) {
return this.env.model.orm.call(
'ir.ui.view',
'save_manager_data',
[
this.env.config.viewId,
{
columns: this.props.ooManagerColumns,
filter: this.props.ooManagerFilter,
serial_num: this.props.ooManagerSerialNum,
frozen_columns: num, // 加入保存
}
]
);
}
});
@@ -1,52 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<!--Adding the
icon in purchase -->
<t t-name="sticky_header_and_column_in_list_view.PurchaseListRender"
<!--Adding the icon in purchase -->
<t t-name="sticky_header_and_column_in_list_view.PurchaseListRender"
t-inherit="purchase.PurchaseListView"
t-inherit-mode="extension" owl="1">
<xpath expr="//div[hasclass('o_list_renderer')]/table/thead/tr/t/th/t/div/span"
<xpath expr="//div[hasclass('o_list_renderer')]/table/thead/tr/t/th/t/div/span"
position="after">
<i class="fa fa-thumb-tack"
<i class="fa fa-thumb-tack"
style="color: #27ae60; font-size: 16px; margin-right: 5px;"
t-on-click="(ev) => this._onClickIcon(ev,record)"/>
</xpath>
</t>
<!--Adding
the icon in account -->
<t t-name="sticky_header_ and_column_in_list_view.AccountListRender"
</xpath>
</t>
<!--Adding the icon in account -->
<t t-name="sticky_header_ and_column_in_list_view.AccountListRender"
t-inherit="account.ListRenderer" t-inherit-mode="extension"
owl="1">
<xpath expr="//div[hasclass('o_list_renderer')]/table/thead/tr/t/th/t/div/span"
<xpath expr="//div[hasclass('o_list_renderer')]/table/thead/tr/t/th/t/div/span"
position="after">
<i class="fa fa-thumb-tack"
<i class="fa fa-thumb-tack"
style="color: #27ae60; font-size: 16px; margin-right: 5px;"
t-on-click="(ev) => this._onClickIcon(ev,record)"/>
</xpath>
</t>
<!--Adding
the icon in Hr Expense -->
<t t-name="sticky_header_and_column_in_list_view.HrExpenseListRender"
</xpath>
</t>
<!--Adding the icon in Hr Expense -->
<t t-name="sticky_header_and_column_in_list_view.HrExpenseListRender"
t-inherit="hr_expense.DashboardListRenderer"
t-inherit-mode="extension" owl="1">
<xpath expr="//div[hasclass('o_list_renderer')]/table/thead/tr/t/th/t/div/span"
<xpath expr="//div[hasclass('o_list_renderer')]/table/thead/tr/t/th/t/div/span"
position="after">
<i class="fa fa-thumb-tack"
<i class="fa fa-thumb-tack"
style="color: #27ae60; font-size: 16px; margin-right: 5px;"
t-on-click="(ev) => this._onClickIcon(ev,record)"/>
</xpath>
</t>
<!--Adding
the icon in All-->
<t t-name="sticky_header_and_column_in_list_view.RowListView"
</xpath>
</t>
<!--Adding the icon in All-->
<t t-name="sticky_header_and_column_in_list_view.RowListView"
t-inherit="web.ListRenderer" t-inherit-mode="extension"
owl="1">
<xpath expr="//div[hasclass('o_list_renderer')]/table/thead/tr/t/th/t/div/span"
<xpath expr="//div[hasclass('o_list_renderer')]/table/thead/tr/t/th/t/div/span"
position="after">
<i class="fa fa-thumb-tack"
<i class="fa fa-thumb-tack"
style="color: #27ae60; font-size: 16px; margin-right: 5px;"
t-on-click="(ev) => this._onClickIcon(ev,record)"
/>
</xpath>
</t>
</templates>
</xpath>
</t>
</templates>
@@ -1,12 +1,12 @@
/** @odoo-module **/
import { patch } from "@web/core/utils/patch";
import { ListRenderer } from "@web/views/list/list_renderer";
import {patch} from "@web/core/utils/patch";
import {ListRenderer} from "@web/views/list/list_renderer";
patch(ListRenderer.prototype, {
setup() {
super.setup();
this.numSwitch = this.constructor.name === 'ListRenderer';
setup(){
super.setup();
this.numSwitch = this.constructor.name === 'ListRenderer';
},
// The following code manipulates the DOM directly to avoid having to wait for a
@@ -43,7 +43,7 @@ patch(ListRenderer.prototype, {
if (!th.style.width) {
th.style.width = `${Math.floor(this.columnWidths[index])}px`;
}
if (Array.from(th.classList).includes('list-number')) {
if (Array.from(th.classList).includes('list-number')){
th.style.width = `${String(this.props.list.offset || this.props.list.limit).length * 20}px`;
}
});