odoo-addon-web-m2x-options-manager 16.0.1.0.0.3__py3-none-any.whl → 17.0.1.0.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- odoo/addons/web_m2x_options_manager/README.rst +29 -18
- odoo/addons/web_m2x_options_manager/__init__.py +1 -3
- odoo/addons/web_m2x_options_manager/__manifest__.py +9 -2
- odoo/addons/web_m2x_options_manager/demo/res_partner_demo_view.xml +11 -10
- odoo/addons/web_m2x_options_manager/hooks.py +11 -0
- odoo/addons/web_m2x_options_manager/i18n/it.po +1 -16
- odoo/addons/web_m2x_options_manager/i18n/web_m2x_options_manager.pot +81 -33
- odoo/addons/web_m2x_options_manager/models/__init__.py +1 -3
- odoo/addons/web_m2x_options_manager/models/ir_model.py +46 -21
- odoo/addons/web_m2x_options_manager/models/ir_model_fields.py +53 -0
- odoo/addons/web_m2x_options_manager/models/ir_ui_view.py +9 -7
- odoo/addons/web_m2x_options_manager/models/m2x_create_edit_option.py +133 -76
- odoo/addons/web_m2x_options_manager/readme/CONTRIBUTORS.md +2 -0
- odoo/addons/web_m2x_options_manager/readme/USAGE.md +12 -0
- odoo/addons/web_m2x_options_manager/static/description/index.html +49 -32
- odoo/addons/web_m2x_options_manager/tests/__init__.py +2 -3
- odoo/addons/web_m2x_options_manager/tests/common.py +42 -0
- odoo/addons/web_m2x_options_manager/tests/test_ir_model.py +37 -0
- odoo/addons/web_m2x_options_manager/tests/test_ir_model_fields.py +99 -0
- odoo/addons/web_m2x_options_manager/tests/test_m2x_create_edit_option.py +67 -92
- odoo/addons/web_m2x_options_manager/tools.py +34 -0
- odoo/addons/web_m2x_options_manager/views/ir_model.xml +38 -18
- odoo/addons/web_m2x_options_manager/views/m2x_create_edit_option.xml +157 -0
- {odoo_addon_web_m2x_options_manager-16.0.1.0.0.3.dist-info → odoo_addon_web_m2x_options_manager-17.0.1.0.0.2.dist-info}/METADATA +37 -24
- odoo_addon_web_m2x_options_manager-17.0.1.0.0.2.dist-info/RECORD +30 -0
- {odoo_addon_web_m2x_options_manager-16.0.1.0.0.3.dist-info → odoo_addon_web_m2x_options_manager-17.0.1.0.0.2.dist-info}/WHEEL +1 -1
- odoo_addon_web_m2x_options_manager-17.0.1.0.0.2.dist-info/top_level.txt +1 -0
- odoo/addons/web_m2x_options_manager/readme/CONTRIBUTORS.rst +0 -4
- odoo/addons/web_m2x_options_manager/readme/USAGE.rst +0 -7
- odoo_addon_web_m2x_options_manager-16.0.1.0.0.3.dist-info/RECORD +0 -23
- odoo_addon_web_m2x_options_manager-16.0.1.0.0.3.dist-info/top_level.txt +0 -1
- /odoo/addons/web_m2x_options_manager/readme/{DESCRIPTION.rst → DESCRIPTION.md} +0 -0
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
.. image:: https://odoo-community.org/readme-banner-image
|
|
2
|
+
:target: https://odoo-community.org/get-involved?utm_source=readme
|
|
3
|
+
:alt: Odoo Community Association
|
|
4
|
+
|
|
1
5
|
=======================
|
|
2
6
|
Web M2X Options Manager
|
|
3
7
|
=======================
|
|
@@ -7,29 +11,30 @@ Web M2X Options Manager
|
|
|
7
11
|
!! This file is generated by oca-gen-addon-readme !!
|
|
8
12
|
!! changes will be overwritten. !!
|
|
9
13
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
10
|
-
!! source digest: sha256:
|
|
14
|
+
!! source digest: sha256:496ff9c028368302f839913a2c4c825d59aa913df9048705ab11ce524d388144
|
|
11
15
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
12
16
|
|
|
13
17
|
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
|
|
14
18
|
:target: https://odoo-community.org/page/development-status
|
|
15
19
|
:alt: Beta
|
|
16
|
-
.. |badge2| image:: https://img.shields.io/badge/
|
|
20
|
+
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
|
|
17
21
|
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
|
18
22
|
:alt: License: AGPL-3
|
|
19
23
|
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
|
|
20
|
-
:target: https://github.com/OCA/web/tree/
|
|
24
|
+
:target: https://github.com/OCA/web/tree/17.0/web_m2x_options_manager
|
|
21
25
|
:alt: OCA/web
|
|
22
26
|
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
|
23
|
-
:target: https://translation.odoo-community.org/projects/web-
|
|
27
|
+
:target: https://translation.odoo-community.org/projects/web-17-0/web-17-0-web_m2x_options_manager
|
|
24
28
|
:alt: Translate me on Weblate
|
|
25
29
|
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
|
|
26
|
-
:target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=
|
|
30
|
+
:target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=17.0
|
|
27
31
|
:alt: Try me on Runboat
|
|
28
32
|
|
|
29
33
|
|badge1| |badge2| |badge3| |badge4| |badge5|
|
|
30
34
|
|
|
31
|
-
Allows managing the "Create..." and "Create and Edit..." options for
|
|
32
|
-
and
|
|
35
|
+
Allows managing the "Create..." and "Create and Edit..." options for
|
|
36
|
+
``Many2one`` and ``Many2many`` fields directly from the ``ir.model``
|
|
37
|
+
form view.
|
|
33
38
|
|
|
34
39
|
**Table of contents**
|
|
35
40
|
|
|
@@ -42,10 +47,17 @@ Usage
|
|
|
42
47
|
Go to Settings > Technical > Models.
|
|
43
48
|
|
|
44
49
|
Choose the model you wish to edit, and open its form view. Go to the
|
|
45
|
-
"Create/Edit Options" tab, and add the fields you want to manage
|
|
50
|
+
"Create/Edit Options" tab, and add the fields you want to manage in 2
|
|
51
|
+
different sections:
|
|
52
|
+
|
|
53
|
+
- the first list view allows you to handle fields for the selected model
|
|
54
|
+
- the second list view allows you to handle fields where the selected
|
|
55
|
+
model is the comodel
|
|
56
|
+
|
|
57
|
+
For both sections:
|
|
46
58
|
|
|
47
|
-
|
|
48
|
-
|
|
59
|
+
- button "Fill" will add every missing field to the options
|
|
60
|
+
- button "Empty" will remove every option
|
|
49
61
|
|
|
50
62
|
Bug Tracker
|
|
51
63
|
===========
|
|
@@ -53,7 +65,7 @@ Bug Tracker
|
|
|
53
65
|
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
|
|
54
66
|
In case of trouble, please check there if your issue has already been reported.
|
|
55
67
|
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
|
56
|
-
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_m2x_options_manager%0Aversion:%
|
|
68
|
+
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_m2x_options_manager%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
|
57
69
|
|
|
58
70
|
Do not contact contributors directly about support or help with technical issues.
|
|
59
71
|
|
|
@@ -61,20 +73,19 @@ Credits
|
|
|
61
73
|
=======
|
|
62
74
|
|
|
63
75
|
Authors
|
|
64
|
-
|
|
76
|
+
-------
|
|
65
77
|
|
|
66
78
|
* Camptocamp
|
|
67
79
|
|
|
68
80
|
Contributors
|
|
69
|
-
|
|
81
|
+
------------
|
|
70
82
|
|
|
71
|
-
|
|
83
|
+
- `Camptocamp <https://www.camptocamp.com>`__:
|
|
72
84
|
|
|
73
|
-
|
|
74
|
-
* Duong (Tran Quoc) <duongtq@trobz.com>
|
|
85
|
+
- Silvio Gregorini
|
|
75
86
|
|
|
76
87
|
Maintainers
|
|
77
|
-
|
|
88
|
+
-----------
|
|
78
89
|
|
|
79
90
|
This module is maintained by the OCA.
|
|
80
91
|
|
|
@@ -86,6 +97,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
|
|
|
86
97
|
mission is to support the collaborative development of Odoo features and
|
|
87
98
|
promote its widespread use.
|
|
88
99
|
|
|
89
|
-
This module is part of the `OCA/web <https://github.com/OCA/web/tree/
|
|
100
|
+
This module is part of the `OCA/web <https://github.com/OCA/web/tree/17.0/web_m2x_options_manager>`_ project on GitHub.
|
|
90
101
|
|
|
91
102
|
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
|
@@ -6,18 +6,25 @@
|
|
|
6
6
|
"summary": 'Adds an interface to manage the "Create" and'
|
|
7
7
|
' "Create and Edit" options for specific models and'
|
|
8
8
|
" fields.",
|
|
9
|
-
"version": "
|
|
9
|
+
"version": "17.0.1.0.0",
|
|
10
10
|
"author": "Camptocamp, Odoo Community Association (OCA)",
|
|
11
11
|
"license": "AGPL-3",
|
|
12
12
|
"category": "Web",
|
|
13
13
|
"data": [
|
|
14
14
|
"security/ir.model.access.csv",
|
|
15
15
|
"views/ir_model.xml",
|
|
16
|
+
"views/m2x_create_edit_option.xml",
|
|
16
17
|
],
|
|
17
18
|
"demo": [
|
|
18
19
|
"demo/res_partner_demo_view.xml",
|
|
19
20
|
],
|
|
20
|
-
"depends": [
|
|
21
|
+
"depends": [
|
|
22
|
+
# OCA/server-tools
|
|
23
|
+
"base_view_inheritance_extension",
|
|
24
|
+
# OCA/web
|
|
25
|
+
"web_m2x_options",
|
|
26
|
+
],
|
|
21
27
|
"website": "https://github.com/OCA/web",
|
|
22
28
|
"installable": True,
|
|
29
|
+
"pre_init_hook": "pre_init_hook",
|
|
23
30
|
}
|
|
@@ -9,17 +9,18 @@
|
|
|
9
9
|
<form>
|
|
10
10
|
<sheet>
|
|
11
11
|
<group>
|
|
12
|
-
<!-- Many2one -->
|
|
12
|
+
<!-- Many2one w/o options -->
|
|
13
13
|
<field name="title" />
|
|
14
|
-
<!--
|
|
15
|
-
<field
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
<!-- Many2one w/ options -->
|
|
15
|
+
<field
|
|
16
|
+
name="parent_id"
|
|
17
|
+
options="{'create': False, 'create_edit': False}"
|
|
18
|
+
/>
|
|
19
|
+
<!-- Many2many w/ options -->
|
|
20
|
+
<field
|
|
21
|
+
name="category_id"
|
|
22
|
+
options="{'create': False, 'create_edit': False}"
|
|
23
|
+
/>
|
|
23
24
|
</group>
|
|
24
25
|
</sheet>
|
|
25
26
|
</form>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Copyright 2025 Camptocamp SA
|
|
2
|
+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
3
|
+
|
|
4
|
+
from .tools import prepare_column_can_have_options, prepare_column_comodel_id
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def pre_init_hook(env):
|
|
8
|
+
# Pre-create and pre-fill these columns for perf reasons (might take a while to
|
|
9
|
+
# let Odoo do it via the ORM for huge DBs)
|
|
10
|
+
prepare_column_can_have_options(env.cr)
|
|
11
|
+
prepare_column_comodel_id(env.cr)
|
|
@@ -34,11 +34,6 @@ msgstr "Aggiungi"
|
|
|
34
34
|
msgid "Create & Edit Option"
|
|
35
35
|
msgstr "Opzione crea & modifica"
|
|
36
36
|
|
|
37
|
-
#. module: web_m2x_options_manager
|
|
38
|
-
#: model:ir.model.fields,field_description:web_m2x_options_manager.field_m2x_create_edit_option__option_create_edit_wizard
|
|
39
|
-
msgid "Create & Edit Wizard"
|
|
40
|
-
msgstr "Procedura guidata crea & modifica"
|
|
41
|
-
|
|
42
37
|
#. module: web_m2x_options_manager
|
|
43
38
|
#: model:ir.model.fields,field_description:web_m2x_options_manager.field_m2x_create_edit_option__option_create
|
|
44
39
|
msgid "Create Option"
|
|
@@ -59,16 +54,6 @@ msgstr "Creato da"
|
|
|
59
54
|
msgid "Created on"
|
|
60
55
|
msgstr "Creato il"
|
|
61
56
|
|
|
62
|
-
#. module: web_m2x_options_manager
|
|
63
|
-
#: model:ir.model.fields,help:web_m2x_options_manager.field_m2x_create_edit_option__option_create_edit_wizard
|
|
64
|
-
msgid ""
|
|
65
|
-
"Defines behaviour for 'Create & Edit' Wizard\n"
|
|
66
|
-
"Set to False to prevent 'Create & Edit' Wizard to pop up"
|
|
67
|
-
msgstr ""
|
|
68
|
-
"Definisce il comportamento per la procedura guidata 'crea & modifica'\n"
|
|
69
|
-
"Imposta a Falso per impedire il pop up della procedura guidata 'crea & "
|
|
70
|
-
"modifica'"
|
|
71
|
-
|
|
72
57
|
#. module: web_m2x_options_manager
|
|
73
58
|
#: model:ir.model.fields,help:web_m2x_options_manager.field_m2x_create_edit_option__option_create_edit
|
|
74
59
|
msgid ""
|
|
@@ -168,7 +153,7 @@ msgid "Last Updated on"
|
|
|
168
153
|
msgstr "Ultimo aggiornamento il"
|
|
169
154
|
|
|
170
155
|
#. module: web_m2x_options_manager
|
|
171
|
-
#: model:ir.model.fields,field_description:web_m2x_options_manager.
|
|
156
|
+
#: model:ir.model.fields,field_description:web_m2x_options_manager.field_ir_model__m2x_option_ids
|
|
172
157
|
msgid "M2X Create Edit Option"
|
|
173
158
|
msgstr "Crea opzione modifica M2X"
|
|
174
159
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
#
|
|
5
5
|
msgid ""
|
|
6
6
|
msgstr ""
|
|
7
|
-
"Project-Id-Version: Odoo Server
|
|
7
|
+
"Project-Id-Version: Odoo Server 17.0\n"
|
|
8
8
|
"Report-Msgid-Bugs-To: \n"
|
|
9
9
|
"Last-Translator: \n"
|
|
10
10
|
"Language-Team: \n"
|
|
@@ -13,13 +13,6 @@ msgstr ""
|
|
|
13
13
|
"Content-Transfer-Encoding: \n"
|
|
14
14
|
"Plural-Forms: \n"
|
|
15
15
|
|
|
16
|
-
#. module: web_m2x_options_manager
|
|
17
|
-
#. odoo-python
|
|
18
|
-
#: code:addons/web_m2x_options_manager/models/m2x_create_edit_option.py:0
|
|
19
|
-
#, python-format
|
|
20
|
-
msgid "'%(field_name)s' is not a valid field for model '%(model_name)s'!"
|
|
21
|
-
msgstr ""
|
|
22
|
-
|
|
23
16
|
#. module: web_m2x_options_manager
|
|
24
17
|
#: model:ir.model.fields.selection,name:web_m2x_options_manager.selection__m2x_create_edit_option__option_create__set_true
|
|
25
18
|
#: model:ir.model.fields.selection,name:web_m2x_options_manager.selection__m2x_create_edit_option__option_create_edit__set_true
|
|
@@ -27,17 +20,36 @@ msgid "Add"
|
|
|
27
20
|
msgstr ""
|
|
28
21
|
|
|
29
22
|
#. module: web_m2x_options_manager
|
|
30
|
-
#: model:ir.model.fields,field_description:web_m2x_options_manager.
|
|
31
|
-
msgid "
|
|
23
|
+
#: model:ir.model.fields,field_description:web_m2x_options_manager.field_ir_model_fields__can_have_options
|
|
24
|
+
msgid "Can Have Options"
|
|
32
25
|
msgstr ""
|
|
33
26
|
|
|
34
27
|
#. module: web_m2x_options_manager
|
|
35
|
-
#: model:ir.model.fields,field_description:web_m2x_options_manager.
|
|
36
|
-
|
|
28
|
+
#: model:ir.model.fields,field_description:web_m2x_options_manager.field_ir_model_fields__comodel_id
|
|
29
|
+
#: model:ir.model.fields,field_description:web_m2x_options_manager.field_m2x_create_edit_option__comodel_id
|
|
30
|
+
#: model_terms:ir.ui.view,arch_db:web_m2x_options_manager.m2x_create_edit_option_search
|
|
31
|
+
msgid "Comodel"
|
|
32
|
+
msgstr ""
|
|
33
|
+
|
|
34
|
+
#. module: web_m2x_options_manager
|
|
35
|
+
#: model:ir.model.fields,field_description:web_m2x_options_manager.field_ir_model__comodel_field_ids
|
|
36
|
+
msgid "Comodel Field"
|
|
37
|
+
msgstr ""
|
|
38
|
+
|
|
39
|
+
#. module: web_m2x_options_manager
|
|
40
|
+
#: model:ir.model.fields,field_description:web_m2x_options_manager.field_m2x_create_edit_option__comodel_name
|
|
41
|
+
msgid "Comodel Name"
|
|
42
|
+
msgstr ""
|
|
43
|
+
|
|
44
|
+
#. module: web_m2x_options_manager
|
|
45
|
+
#: model:ir.model.fields,field_description:web_m2x_options_manager.field_m2x_create_edit_option__option_create_edit
|
|
46
|
+
#: model_terms:ir.ui.view,arch_db:web_m2x_options_manager.m2x_create_edit_option_search
|
|
47
|
+
msgid "Create & Edit Option"
|
|
37
48
|
msgstr ""
|
|
38
49
|
|
|
39
50
|
#. module: web_m2x_options_manager
|
|
40
51
|
#: model:ir.model.fields,field_description:web_m2x_options_manager.field_m2x_create_edit_option__option_create
|
|
52
|
+
#: model_terms:ir.ui.view,arch_db:web_m2x_options_manager.m2x_create_edit_option_search
|
|
41
53
|
msgid "Create Option"
|
|
42
54
|
msgstr ""
|
|
43
55
|
|
|
@@ -56,13 +68,6 @@ msgstr ""
|
|
|
56
68
|
msgid "Created on"
|
|
57
69
|
msgstr ""
|
|
58
70
|
|
|
59
|
-
#. module: web_m2x_options_manager
|
|
60
|
-
#: model:ir.model.fields,help:web_m2x_options_manager.field_m2x_create_edit_option__option_create_edit_wizard
|
|
61
|
-
msgid ""
|
|
62
|
-
"Defines behaviour for 'Create & Edit' Wizard\n"
|
|
63
|
-
"Set to False to prevent 'Create & Edit' Wizard to pop up"
|
|
64
|
-
msgstr ""
|
|
65
|
-
|
|
66
71
|
#. module: web_m2x_options_manager
|
|
67
72
|
#: model:ir.model.fields,help:web_m2x_options_manager.field_m2x_create_edit_option__option_create_edit
|
|
68
73
|
msgid ""
|
|
@@ -102,6 +107,18 @@ msgstr ""
|
|
|
102
107
|
msgid "Field"
|
|
103
108
|
msgstr ""
|
|
104
109
|
|
|
110
|
+
#. module: web_m2x_options_manager
|
|
111
|
+
#. odoo-python
|
|
112
|
+
#: code:addons/web_m2x_options_manager/models/m2x_create_edit_option.py:0
|
|
113
|
+
#, python-format
|
|
114
|
+
msgid "Field %(field)s cannot have M2X options"
|
|
115
|
+
msgstr ""
|
|
116
|
+
|
|
117
|
+
#. module: web_m2x_options_manager
|
|
118
|
+
#: model:ir.model,name:web_m2x_options_manager.model_m2x_create_edit_option
|
|
119
|
+
msgid "Field 'Create & Edit' Options"
|
|
120
|
+
msgstr ""
|
|
121
|
+
|
|
105
122
|
#. module: web_m2x_options_manager
|
|
106
123
|
#: model:ir.model.fields,field_description:web_m2x_options_manager.field_m2x_create_edit_option__field_name
|
|
107
124
|
msgid "Field Name"
|
|
@@ -112,11 +129,22 @@ msgstr ""
|
|
|
112
129
|
msgid "Fields"
|
|
113
130
|
msgstr ""
|
|
114
131
|
|
|
132
|
+
#. module: web_m2x_options_manager
|
|
133
|
+
#: model:ir.actions.act_window,name:web_m2x_options_manager.m2x_create_edit_option_action
|
|
134
|
+
#: model:ir.ui.menu,name:web_m2x_options_manager.m2x_create_edit_option_menu
|
|
135
|
+
msgid "Fields' Create & Edit Options"
|
|
136
|
+
msgstr ""
|
|
137
|
+
|
|
115
138
|
#. module: web_m2x_options_manager
|
|
116
139
|
#: model_terms:ir.ui.view,arch_db:web_m2x_options_manager.view_model_form_inherit
|
|
117
140
|
msgid "Fill"
|
|
118
141
|
msgstr ""
|
|
119
142
|
|
|
143
|
+
#. module: web_m2x_options_manager
|
|
144
|
+
#: model:ir.model.fields,help:web_m2x_options_manager.field_m2x_create_edit_option__comodel_name
|
|
145
|
+
msgid "For relationship fields, the technical name of the target model"
|
|
146
|
+
msgstr ""
|
|
147
|
+
|
|
120
148
|
#. module: web_m2x_options_manager
|
|
121
149
|
#: model:ir.model.fields.selection,name:web_m2x_options_manager.selection__m2x_create_edit_option__option_create__force_true
|
|
122
150
|
#: model:ir.model.fields.selection,name:web_m2x_options_manager.selection__m2x_create_edit_option__option_create_edit__force_true
|
|
@@ -130,13 +158,24 @@ msgid "Force Remove"
|
|
|
130
158
|
msgstr ""
|
|
131
159
|
|
|
132
160
|
#. module: web_m2x_options_manager
|
|
133
|
-
#:
|
|
134
|
-
msgid "
|
|
161
|
+
#: model_terms:ir.ui.view,arch_db:web_m2x_options_manager.m2x_create_edit_option_search
|
|
162
|
+
msgid "Group By"
|
|
163
|
+
msgstr ""
|
|
164
|
+
|
|
165
|
+
#. module: web_m2x_options_manager
|
|
166
|
+
#: model_terms:ir.ui.view,arch_db:web_m2x_options_manager.view_model_form_inherit
|
|
167
|
+
msgid ""
|
|
168
|
+
"Here are displayed options for other models' fields related to this model"
|
|
135
169
|
msgstr ""
|
|
136
170
|
|
|
137
171
|
#. module: web_m2x_options_manager
|
|
138
|
-
#:
|
|
139
|
-
msgid "
|
|
172
|
+
#: model_terms:ir.ui.view,arch_db:web_m2x_options_manager.view_model_form_inherit
|
|
173
|
+
msgid "Here are displayed options for this model's fields"
|
|
174
|
+
msgstr ""
|
|
175
|
+
|
|
176
|
+
#. module: web_m2x_options_manager
|
|
177
|
+
#: model:ir.model.fields,field_description:web_m2x_options_manager.field_m2x_create_edit_option__id
|
|
178
|
+
msgid "ID"
|
|
140
179
|
msgstr ""
|
|
141
180
|
|
|
142
181
|
#. module: web_m2x_options_manager
|
|
@@ -150,17 +189,18 @@ msgid "Last Updated on"
|
|
|
150
189
|
msgstr ""
|
|
151
190
|
|
|
152
191
|
#. module: web_m2x_options_manager
|
|
153
|
-
#: model:ir.model.fields,field_description:web_m2x_options_manager.
|
|
154
|
-
msgid "M2X
|
|
192
|
+
#: model:ir.model.fields,field_description:web_m2x_options_manager.field_ir_model__m2x_comodels_option_ids
|
|
193
|
+
msgid "M2X Comodels Option"
|
|
155
194
|
msgstr ""
|
|
156
195
|
|
|
157
196
|
#. module: web_m2x_options_manager
|
|
158
|
-
#: model:ir.model,
|
|
159
|
-
msgid "
|
|
197
|
+
#: model:ir.model.fields,field_description:web_m2x_options_manager.field_ir_model__m2x_option_ids
|
|
198
|
+
msgid "M2X Option"
|
|
160
199
|
msgstr ""
|
|
161
200
|
|
|
162
201
|
#. module: web_m2x_options_manager
|
|
163
202
|
#: model:ir.model.fields,field_description:web_m2x_options_manager.field_m2x_create_edit_option__model_id
|
|
203
|
+
#: model_terms:ir.ui.view,arch_db:web_m2x_options_manager.m2x_create_edit_option_search
|
|
164
204
|
msgid "Model"
|
|
165
205
|
msgstr ""
|
|
166
206
|
|
|
@@ -175,15 +215,13 @@ msgid "Models"
|
|
|
175
215
|
msgstr ""
|
|
176
216
|
|
|
177
217
|
#. module: web_m2x_options_manager
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
#, python-format
|
|
181
|
-
msgid "Only Many2many and Many2one fields can be chosen!"
|
|
218
|
+
#: model:ir.model.fields,field_description:web_m2x_options_manager.field_m2x_create_edit_option__name
|
|
219
|
+
msgid "Name"
|
|
182
220
|
msgstr ""
|
|
183
221
|
|
|
184
222
|
#. module: web_m2x_options_manager
|
|
185
|
-
#: model:ir.model.constraint,message:web_m2x_options_manager.
|
|
186
|
-
msgid "Options must be unique for each
|
|
223
|
+
#: model:ir.model.constraint,message:web_m2x_options_manager.constraint_m2x_create_edit_option_field_uniqueness
|
|
224
|
+
msgid "Options must be unique for each field!"
|
|
187
225
|
msgstr ""
|
|
188
226
|
|
|
189
227
|
#. module: web_m2x_options_manager
|
|
@@ -192,6 +230,16 @@ msgstr ""
|
|
|
192
230
|
msgid "Remove"
|
|
193
231
|
msgstr ""
|
|
194
232
|
|
|
233
|
+
#. module: web_m2x_options_manager
|
|
234
|
+
#: model:ir.model.fields,help:web_m2x_options_manager.field_m2x_create_edit_option__model_id
|
|
235
|
+
msgid "The model this field belongs to"
|
|
236
|
+
msgstr ""
|
|
237
|
+
|
|
238
|
+
#. module: web_m2x_options_manager
|
|
239
|
+
#: model:ir.model.fields,help:web_m2x_options_manager.field_m2x_create_edit_option__model_name
|
|
240
|
+
msgid "The technical name of the model this field belongs to"
|
|
241
|
+
msgstr ""
|
|
242
|
+
|
|
195
243
|
#. module: web_m2x_options_manager
|
|
196
244
|
#: model:ir.model,name:web_m2x_options_manager.model_ir_ui_view
|
|
197
245
|
msgid "View"
|
|
@@ -7,33 +7,58 @@ from odoo import fields, models
|
|
|
7
7
|
class IrModel(models.Model):
|
|
8
8
|
_inherit = "ir.model"
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
m2x_option_ids = fields.One2many(
|
|
11
11
|
"m2x.create.edit.option",
|
|
12
12
|
"model_id",
|
|
13
13
|
)
|
|
14
|
+
m2x_comodels_option_ids = fields.One2many(
|
|
15
|
+
"m2x.create.edit.option",
|
|
16
|
+
"comodel_id",
|
|
17
|
+
)
|
|
18
|
+
comodel_field_ids = fields.One2many("ir.model.fields", "comodel_id")
|
|
19
|
+
|
|
20
|
+
def button_empty_m2x_options(self):
|
|
21
|
+
self._empty_m2x_options(own=True)
|
|
22
|
+
|
|
23
|
+
def button_fill_m2x_options(self):
|
|
24
|
+
self._fill_m2x_options(own=True)
|
|
14
25
|
|
|
15
|
-
def
|
|
16
|
-
|
|
17
|
-
ir_model._empty_m2x_create_edit_option()
|
|
26
|
+
def button_empty_m2x_comodels_options(self):
|
|
27
|
+
self._empty_m2x_options(comodels=True)
|
|
18
28
|
|
|
19
|
-
def
|
|
20
|
-
|
|
21
|
-
ir_model._fill_m2x_create_edit_option()
|
|
29
|
+
def button_fill_m2x_comodels_options(self):
|
|
30
|
+
self._fill_m2x_options(comodels=True)
|
|
22
31
|
|
|
23
|
-
def
|
|
24
|
-
"""Removes every option for model ``self``
|
|
25
|
-
self.ensure_one()
|
|
26
|
-
self.m2x_create_edit_option_ids.unlink()
|
|
32
|
+
def _empty_m2x_options(self, own=False, comodels=False):
|
|
33
|
+
"""Removes every option for model ``self``'s fields
|
|
27
34
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
:param bool own: if True, deletes options for model's fields
|
|
36
|
+
:param bool comodels: if True, deletes options for fields where ``self`` is
|
|
37
|
+
the field's comodel
|
|
38
|
+
"""
|
|
39
|
+
to_delete = self.env["m2x.create.edit.option"]
|
|
40
|
+
if own:
|
|
41
|
+
to_delete += self.m2x_option_ids
|
|
42
|
+
if comodels:
|
|
43
|
+
to_delete += self.m2x_comodels_option_ids
|
|
44
|
+
if to_delete:
|
|
45
|
+
to_delete.unlink()
|
|
35
46
|
|
|
47
|
+
def _fill_m2x_options(self, own=False, comodels=False):
|
|
48
|
+
"""Adds every missing field option for model ``self`` (with default values)
|
|
36
49
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
50
|
+
:param bool own: if True, creates options for model's fields
|
|
51
|
+
:param bool comodels: if True, creates options for fields where ``self`` is
|
|
52
|
+
the field's comodel
|
|
53
|
+
"""
|
|
54
|
+
todo = set()
|
|
55
|
+
if own:
|
|
56
|
+
exist = self.m2x_option_ids.field_id
|
|
57
|
+
valid = self.field_id.filtered("can_have_options")
|
|
58
|
+
todo.update((valid - exist).ids)
|
|
59
|
+
if comodels:
|
|
60
|
+
exist = self.m2x_comodels_option_ids.field_id
|
|
61
|
+
valid = self.comodel_field_ids.filtered("can_have_options")
|
|
62
|
+
todo.update((valid - exist).ids)
|
|
63
|
+
if todo:
|
|
64
|
+
self.env["m2x.create.edit.option"].create([{"field_id": i} for i in todo])
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Copyright 2025 Camptocamp SA
|
|
2
|
+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
3
|
+
|
|
4
|
+
from odoo import api, fields, models
|
|
5
|
+
from odoo.osv.expression import AND
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class IrModelFields(models.Model):
|
|
9
|
+
_inherit = "ir.model.fields"
|
|
10
|
+
|
|
11
|
+
can_have_options = fields.Boolean(compute="_compute_can_have_options", store=True)
|
|
12
|
+
comodel_id = fields.Many2one(
|
|
13
|
+
"ir.model", compute="_compute_comodel_id", store=True, index=True
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
@api.depends("ttype")
|
|
17
|
+
def _compute_can_have_options(self):
|
|
18
|
+
for field in self:
|
|
19
|
+
field.can_have_options = field.ttype in ("many2many", "many2one")
|
|
20
|
+
|
|
21
|
+
@api.depends("relation")
|
|
22
|
+
def _compute_comodel_id(self):
|
|
23
|
+
empty = self.env["ir.model"]
|
|
24
|
+
getter = self.env["ir.model"]._get
|
|
25
|
+
for field in self:
|
|
26
|
+
if field.relation:
|
|
27
|
+
field.comodel_id = getter(field.relation)
|
|
28
|
+
else:
|
|
29
|
+
field.comodel_id = empty
|
|
30
|
+
|
|
31
|
+
@api.model
|
|
32
|
+
def name_search(self, name="", args=None, operator="ilike", limit=100):
|
|
33
|
+
# OVERRIDE: allow searching by field tech name if the correct context key is
|
|
34
|
+
# used; in this case, fields fetched by tech name are prepended to other fields
|
|
35
|
+
result = super().name_search(name, args, operator, limit)
|
|
36
|
+
if not (name and self.env.context.get("search_by_technical_name")):
|
|
37
|
+
return result
|
|
38
|
+
domain = AND([args or [], [("name", operator, name)]])
|
|
39
|
+
new_fields = self.search_read(domain, fields=["display_name"], limit=limit)
|
|
40
|
+
new_result = {f["id"]: f["display_name"] for f in new_fields}
|
|
41
|
+
while result and not (limit and 0 < limit <= len(new_result)):
|
|
42
|
+
field_id, field_display_name = result.pop(0)
|
|
43
|
+
if field_id not in new_result:
|
|
44
|
+
new_result[field_id] = field_display_name
|
|
45
|
+
return list(new_result.items())
|
|
46
|
+
|
|
47
|
+
@api.model
|
|
48
|
+
def _search(self, args, **kwargs):
|
|
49
|
+
# OVERRIDE: allow defining filtering custom domain on model/comodel when
|
|
50
|
+
# searching fields for O2M list views on ``m2x.create.edit.option``
|
|
51
|
+
if self.env.context.get("o2m_list_view_m2x_domain"):
|
|
52
|
+
args = AND([list(args or []), self.env.context["o2m_list_view_m2x_domain"]])
|
|
53
|
+
return super()._search(args, **kwargs)
|
|
@@ -8,12 +8,14 @@ class IrUiView(models.Model):
|
|
|
8
8
|
_inherit = "ir.ui.view"
|
|
9
9
|
|
|
10
10
|
def _postprocess_tag_field(self, node, name_manager, node_info):
|
|
11
|
+
# OVERRIDE: check ``m2x.create.edit.option`` config when processing a ``field``
|
|
12
|
+
# node in views
|
|
11
13
|
res = super()._postprocess_tag_field(node, name_manager, node_info)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
field
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
m2x_option = self.env["m2x.create.edit.option"].get(
|
|
15
|
+
name_manager.model._name,
|
|
16
|
+
# ``name`` is required in ``<field/>`` items
|
|
17
|
+
node.attrib["name"],
|
|
18
|
+
)
|
|
19
|
+
if m2x_option:
|
|
20
|
+
m2x_option._apply_options(node)
|
|
19
21
|
return res
|