diff --git a/cr_m2o_faster/__init__.py b/cr_m2o_faster/__init__.py new file mode 100644 index 000000000..40a96afc6 --- /dev/null +++ b/cr_m2o_faster/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/cr_m2o_faster/__manifest__.py b/cr_m2o_faster/__manifest__.py new file mode 100644 index 000000000..c353e0614 --- /dev/null +++ b/cr_m2o_faster/__manifest__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +{ + 'name': 'Faster Many2one', + 'summary': 'Faster Many2one', + 'description': """ + """, + "version": "17.0", + "author": "Croissant", + "license": "OPL-1", + 'depends': ['web'], + 'images': [ + 'static/description/banner.png', + ], + 'assets': { + 'web.assets_backend': [ + 'cr_m2o_faster/static/src/views/fields/many2one/*', + # 'cr_m2o_faster/static/src/views/fields/many2many/*', + ], + }, + 'installable': True, +} diff --git a/cr_m2o_faster/static/description/1.png b/cr_m2o_faster/static/description/1.png new file mode 100644 index 000000000..f872b6918 Binary files /dev/null and b/cr_m2o_faster/static/description/1.png differ diff --git a/cr_m2o_faster/static/description/banner.png b/cr_m2o_faster/static/description/banner.png new file mode 100644 index 000000000..70fa07b2c Binary files /dev/null and b/cr_m2o_faster/static/description/banner.png differ diff --git a/cr_m2o_faster/static/description/icon.png b/cr_m2o_faster/static/description/icon.png new file mode 100644 index 000000000..2daa800a7 Binary files /dev/null and b/cr_m2o_faster/static/description/icon.png differ diff --git a/cr_m2o_faster/static/description/index.html b/cr_m2o_faster/static/description/index.html new file mode 100644 index 000000000..e56881f32 --- /dev/null +++ b/cr_m2o_faster/static/description/index.html @@ -0,0 +1,66 @@ + + +
+
+
+ +
+
+
+

+ Many2one Show More +

+
+

Many2one字段一键直达更多。

+
+
+
+
+ + +
+
+
+

+ Description +

+
+
+
+ +
+
+

It provides a convenient way to quickly click on show more .

+
+

它提供了一种便捷的方式,快速点击更多。

+ +
+
+ +
+ + +
+
+
+

+ Support +

+
+ If there are any errors or issues, you will receive 60 days of free support. +
如果出现任何错误或问题,您将获得60天的免费支持。
+
+ If you have any questions or need support, please contact me +
如有任何问题或需要支持,请联系我
+ croissant_cr@163.com +
+
+
+
+
+
+ +
+
+
+ \ No newline at end of file diff --git a/cr_m2o_faster/static/src/views/fields/many2many/many2many_field.js b/cr_m2o_faster/static/src/views/fields/many2many/many2many_field.js new file mode 100644 index 000000000..d6d96f2ef --- /dev/null +++ b/cr_m2o_faster/static/src/views/fields/many2many/many2many_field.js @@ -0,0 +1,36 @@ +/** @odoo-module **/ +import {patch} from "@web/core/utils/patch"; +import {Many2manyField} from "@web/views/fields/many2one/many2one_field"; +import {useSelectCreate} from "@web/views/fields/relational_utils"; + +import { _t } from "@web/core/l10n/translation"; +import { sprintf } from "@web/core/utils/strings"; + +patch(Many2manyField.prototype, { + setup(...args) { + super.setup(...args) + let self = this; + this.selectCreate = useSelectCreate({ + resModel:this.relation, + activeActions: this.state.activeActions, + onSelected: (resId) => { + const resIds = Array.isArray(resId) ? resId : [resId]; + const values = resIds.map((id) => ({id})); + return self.update(values); + }, + onCreateEdit: ({context}) => this.openMany2X({context}), + onUnselect: this.update, + }); + }, + onMoreBtnClick() { + const domain = this.getDomain(); + let dynamicFilters = []; + const title = sprintf(_t("Search: %s"), this.props.string); + this.selectCreate({ + domain, + context: this.context, + filters: dynamicFilters, + title, + }); + } +}); diff --git a/cr_m2o_faster/static/src/views/fields/many2many/many2many_field.xml b/cr_m2o_faster/static/src/views/fields/many2many/many2many_field.xml new file mode 100644 index 000000000..e3b555dce --- /dev/null +++ b/cr_m2o_faster/static/src/views/fields/many2many/many2many_field.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + +