This commit is contained in:
李鹏宇
2025-04-06 19:51:04 +08:00
parent 5bd7ba9f07
commit ef2dd110f1
10 changed files with 174 additions and 1 deletions
+1 -1
View File
@@ -13,7 +13,7 @@
],
'assets': {
'web.assets_backend': [
# 'cr_m2o_faster/static/src/views/fields/many2one/*',
'cr_m2o_faster/static/src/views/fields/many2one/*',
'cr_m2o_faster/static/src/views/fields/many2many/*',
],
},
+4
View File
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# from . import controllers
# from . import models
+26
View File
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
{
"name": "Web List Number",
"summary": "列表序号 List Number, Row Number, Record Number",
"version": "17.0.0.1",
"category": "clearzZ/clearzZ",
"website": "mailto:1801226631@qq.com",
"author": "clearzZ",
"license": "AGPL-3",
"depends": ["base", "web"],
"sequence": 4,
"installable": True,
"application": True,
"auto_install": False,
'data': [
# 'security/ir.model.access.csv',
# 'views/views.xml',
# 'views/templates.xml',
],
'assets': {
'web.assets_backend': [
'web_list_number/static/src/views/list/*.*',
]
},
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

@@ -0,0 +1 @@
<svg class="icon" style="width: 1em;height: 1em;vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="12552"><path d="M917.333333 277.333333H277.333333V192h640v85.333333z m0 277.333334H277.333333v-85.333334h640v85.333334z m0 277.333333H277.333333v-85.333333h640v85.333333zM118.997333 278.613333v36.138667h107.541334V278.613333H195.498667V161.173333H165.290667L112.128 191.296l16.256 32.298667 23.765333-13.589334v68.586667H118.997333zM114.56 559.018667v31.808h108.181333V554.666667H169.877333l20.053334-20.053334c9.685333-9.386667 16.725333-18.346667 20.949333-26.837333 4.245333-8.618667 6.378667-17.621333 6.378667-27.008 0-14.634667-4.8-26.133333-14.592-34.133333-9.6-7.936-23.296-11.733333-40.768-11.733334-10.090667 0-19.925333 1.536-29.44 4.565334a77.44 77.44 0 0 0-24.170667 12.416l-1.429333 1.109333 13.930666 32.725333 2.389334-1.813333c5.610667-4.245333 11.178667-7.36 16.704-9.386667 5.696-2.026667 11.2-3.008 16.512-3.008 6.613333 0 11.093333 1.28 13.930666 3.498667 2.709333 2.133333 4.224 5.376 4.224 10.197333 0 3.754667-1.066667 7.594667-3.285333 11.52l-0.042667 0.042667c-2.112 3.968-5.824 8.874667-11.264 14.72L114.56 559.04zM221.482667 818.005333c0-9.450667-2.517333-17.642667-7.658667-24.426666a36.309333 36.309333 0 0 0-15.189333-11.946667 35.328 35.328 0 0 0 12.501333-11.093333 36.906667 36.906667 0 0 0 6.528-21.824c0-8.597333-2.304-16.256-6.954667-22.890667a44.288 44.288 0 0 0-19.584-15.146667c-8.234667-3.541333-17.792-5.269333-28.586666-5.269333-10.24 0-20.330667 1.493333-30.250667 4.522667-9.770667 2.88-17.813333 6.805333-24.042667 11.84l-1.386666 1.130666 13.909333 31.701334 2.346667-1.642667c5.888-4.096 12.010667-7.232 18.410666-9.386667l0.042667-0.042666c6.4-2.304 12.416-3.434667 18.005333-3.434667 5.696 0 9.685333 1.386667 12.373334 3.818667l0.064 0.064c2.752 2.282667 4.224 5.589333 4.224 10.24 0 4.288-1.493333 7.04-4.202667 8.789333-2.944 1.877333-8 3.008-15.637333 3.008h-21.546667v34.688H160.213333c7.893333 0 13.077333 1.194667 16 3.2 2.688 1.813333 4.245333 4.906667 4.245334 9.877333 0 5.418667-1.642667 8.768-4.48 10.730667l-0.042667 0.021333c-2.88 2.090667-8.234667 3.370667-16.576 3.370667-12.672 0-25.472-4.266667-38.4-12.906667l-2.346667-1.557333-13.866666 31.637333 1.365333 1.130667c6.08 5.034667 14.144 9.024 24.042667 12.053333h0.042666c9.941333 2.88 20.288 4.330667 31.061334 4.330667 18.176 0 32.810667-3.797333 43.626666-11.648 11.029333-8.064 16.597333-19.114667 16.597334-32.938667z" p-id="12553"></path></svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

@@ -0,0 +1,42 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div class="d-flex p-3 justify-content-center align-items-center flex-column flex-nowrap">
<div class="d-flex justify-content-center w-100" style="border-bottom:solid 1px #dedede;">
<h1>Web List Number</h1>
</div>
<div class="d-flex w-100 justify-content-center" style="color: white;padding: 20px;font-size: 20px">
<div style="background-color: #7C7BAD;padding: 10px;border-radius: 0.25rem;margin: 0 20px 0 20px;">
<i class="fa fa-check"/>Community
</div>
<div style="background-color: #875A7B;padding: 10px;border-radius: 0.25rem;margin: 0 20px 0 20px;">
<i class="fa fa-check"/>Enterprise
</div>
</div>
<div>
<h1 style="margin: 10px;padding: 10px">List View</h1>
<img class="img-fluid img-thumbnail mb16" src="img2.png" alt="">
</div>
<div>
<h1 style="margin: 10px;padding: 10px">Form View X2many Field List</h1>
<img class="img-fluid img-thumbnail mb16" src="img1.png" alt="">
</div>
<div class="img-fluid img-thumbnail mb16 d-flex flex-column" style="width: 100%;text-align: center;padding: 20px">
<h1 style="margin: 10px">If you encounter custom views causing the serial number to not appear.</h1>
<h1 style="margin: 10px">
<a class="btn btn-outline-info btn-info" style="color: white;padding: 10px;font-size: 20px" href="mailto:1801226631@qq.com">
<i class="fa fa-envelope"/>
1801226631@qq.com
</a>
</h1>
</div>
</div>
</body>
</html>
@@ -0,0 +1,52 @@
/** @odoo-module **/
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';
},
// The following code manipulates the DOM directly to avoid having to wait for a
// render + patch which would occur on the next frame and cause flickering.
freezeColumnWidths() {
if (!this.keepColumnWidths) {
this.columnWidths = null;
}
const table = this.tableRef.el;
const headers = [...table.querySelectorAll("thead th:not(.o_list_actions_header)")];
if (!this.columnWidths || !this.columnWidths.length) {
// no column widths to restore
table.style.tableLayout = "fixed";
const allowedWidth = table.parentNode.getBoundingClientRect().width;
// Set table layout auto and remove inline style to make sure that css
// rules apply (e.g. fixed width of record selector)
table.style.tableLayout = "auto";
headers.forEach((th) => {
th.style.width = null;
th.style.maxWidth = null;
});
this.setDefaultColumnWidths();
// Squeeze the table by applying a max-width on largest columns to
// ensure that it doesn't overflow
this.columnWidths = this.computeColumnWidthsFromContent(allowedWidth);
table.style.tableLayout = "fixed";
}
headers.forEach((th, index) => {
if (!th.style.width) {
th.style.width = `${Math.floor(this.columnWidths[index])}px`;
}
if (Array.from(th.classList).includes('list-number')){
th.style.width = `${String(this.props.list.offset || this.props.list.limit).length * 20}px`;
}
});
}
})
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-inherit="web.ListRenderer" t-inherit-mode="extension">
<xpath expr="//thead//th[@t-if='hasSelectors']" position="before">
<t t-if="numSwitch">
<th class="o_list_record_selector list-number">#</th>
</t>
</xpath>
<xpath expr="//tfoot//td[@t-if='hasSelectors']" position="before">
<t t-if="numSwitch">
<td class="o_list_record_selector"/>
</t>
</xpath>
</t>
<t t-inherit="web.ListRenderer.RecordRow" t-inherit-mode="extension">
<xpath expr="//td[@t-if='hasSelectors']" position="before">
<t t-if="numSwitch">
<t t-set="num" t-value="(record_index + 1) + list.offset"/>
<td t-esc="num" t-att-data-tooltip="num" class="cursor-pointer"/>
</t>
</xpath>
</t>
<t t-inherit="web.ListRenderer.Rows" t-inherit-mode="extension">
<xpath expr="//tr[@t-foreach='getEmptyRowIds']/td" position="before">
<t t-if="numSwitch">
<td/>
</t>
</xpath>
<xpath expr="//td[@t-if='withHandleColumn']" position="before">
<t t-if="numSwitch">
<td/>
</t>
</xpath>
</t>
<t t-inherit="web.ListRenderer.GroupRow" t-inherit-mode="extension">
<xpath expr="//th[@tabindex='-1']" position="before">
<t t-if="numSwitch">
<t t-set="num" t-value="(group_index + 1) + list.offset"/>
<td t-esc="num" t-att-data-tooltip="num" class="cursor-pointer"/>
</t>
</xpath>
</t>
</templates>