diff --git a/cr_m2o_faster/__manifest__.py b/cr_m2o_faster/__manifest__.py index 6ddcd257f..986366374 100644 --- a/cr_m2o_faster/__manifest__.py +++ b/cr_m2o_faster/__manifest__.py @@ -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/*', ], }, diff --git a/web_list_number/__init__.py b/web_list_number/__init__.py new file mode 100644 index 000000000..73dad77a4 --- /dev/null +++ b/web_list_number/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +# from . import controllers +# from . import models diff --git a/web_list_number/__manifest__.py b/web_list_number/__manifest__.py new file mode 100644 index 000000000..61f3f3b74 --- /dev/null +++ b/web_list_number/__manifest__.py @@ -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/*.*', + ] + }, +} + diff --git a/web_list_number/static/description/icon.png b/web_list_number/static/description/icon.png new file mode 100644 index 000000000..91be2272c Binary files /dev/null and b/web_list_number/static/description/icon.png differ diff --git a/web_list_number/static/description/icon.svg b/web_list_number/static/description/icon.svg new file mode 100644 index 000000000..b4c91e1bf --- /dev/null +++ b/web_list_number/static/description/icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/web_list_number/static/description/img1.png b/web_list_number/static/description/img1.png new file mode 100644 index 000000000..9e1fde37a Binary files /dev/null and b/web_list_number/static/description/img1.png differ diff --git a/web_list_number/static/description/img2.png b/web_list_number/static/description/img2.png new file mode 100644 index 000000000..26d6b511b Binary files /dev/null and b/web_list_number/static/description/img2.png differ diff --git a/web_list_number/static/description/index.html b/web_list_number/static/description/index.html new file mode 100644 index 000000000..2cea25c8b --- /dev/null +++ b/web_list_number/static/description/index.html @@ -0,0 +1,42 @@ + + + + + + + Document + + +
+
+

Web List Number

+
+
+
+ Community +
+
+ Enterprise +
+
+
+

List View

+ +
+
+

Form View X2many Field List

+ +
+
+

If you encounter custom views causing the serial number to not appear.

+

+ + + 1801226631@qq.com + +

+
+
+ + \ No newline at end of file diff --git a/web_list_number/static/src/views/list/list_renderer.js b/web_list_number/static/src/views/list/list_renderer.js new file mode 100644 index 000000000..88b335904 --- /dev/null +++ b/web_list_number/static/src/views/list/list_renderer.js @@ -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`; + } + }); + } + +}) \ No newline at end of file diff --git a/web_list_number/static/src/views/list/list_renderer.xml b/web_list_number/static/src/views/list/list_renderer.xml new file mode 100644 index 000000000..c7532ba9f --- /dev/null +++ b/web_list_number/static/src/views/list/list_renderer.xml @@ -0,0 +1,48 @@ + + + + + + + # + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file