Skip to content

Commit 861c3e3

Browse files
committed
[ADD] web_m2m_inline
1 parent 0fe0548 commit 861c3e3

File tree

14 files changed

+428
-0
lines changed

14 files changed

+428
-0
lines changed

web_m2m_inline/README.rst

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
==============
2+
Web M2m Inline
3+
==============
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:2b35600f7a72d13ee75692f74827b74a0f0e057462a818e3e1eeb21d6851efff
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
20+
:target: https://github.com/OCA/web/tree/17.0/web_m2m_inline
21+
:alt: OCA/web
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/web-17-0/web-17-0-web_m2m_inline
24+
:alt: Translate me on Weblate
25+
.. |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=17.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module extends the functionality of the Many2Many field in Odoo to
32+
support inline adjustments. It allows users to directly add or edit
33+
Many2Many field values within the form view.
34+
35+
**Table of contents**
36+
37+
.. contents::
38+
:local:
39+
40+
Usage
41+
=====
42+
43+
To use this module, you need to add widget="m2m_inline":
44+
45+
.. code-block:: XML
46+
47+
::
48+
49+
<field name="my_m2m_field_ids" widget="m2m_inline">
50+
<tree editable="bottom">
51+
<field name="name"/>
52+
</tree>
53+
</field>
54+
55+
Bug Tracker
56+
===========
57+
58+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
59+
In case of trouble, please check there if your issue has already been reported.
60+
If you spotted it first, help us to smash it by providing a detailed and welcomed
61+
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_m2m_inline%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
62+
63+
Do not contact contributors directly about support or help with technical issues.
64+
65+
Credits
66+
=======
67+
68+
Authors
69+
-------
70+
71+
* Camptocamp
72+
73+
Contributors
74+
------------
75+
76+
- ``Trobz <https://www.trobz.com>``
77+
78+
- Tris Doan tridm@trobz.com
79+
80+
Other credits
81+
-------------
82+
83+
The development of this module has been financially supported by:
84+
85+
- Camptocamp
86+
87+
Maintainers
88+
-----------
89+
90+
This module is maintained by the OCA.
91+
92+
.. image:: https://odoo-community.org/logo.png
93+
:alt: Odoo Community Association
94+
:target: https://odoo-community.org
95+
96+
OCA, or the Odoo Community Association, is a nonprofit organization whose
97+
mission is to support the collaborative development of Odoo features and
98+
promote its widespread use.
99+
100+
This module is part of the `OCA/web <https://github.com/OCA/web/tree/17.0/web_m2m_inline>`_ project on GitHub.
101+
102+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

web_m2m_inline/__init__.py

Whitespace-only changes.

web_m2m_inline/__manifest__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2025 Camptocamp
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
{
5+
"name": "Web M2m Inline",
6+
"summary": """Inline creation/update for M2M field""",
7+
"version": "17.0.1.0.0",
8+
"license": "AGPL-3",
9+
"author": "Camptocamp,Odoo Community Association (OCA)",
10+
"website": "https://github.com/OCA/web",
11+
"depends": ["web"],
12+
"assets": {
13+
"web.assets_backend": [
14+
"web_m2m_inline/static/src/**/*",
15+
],
16+
},
17+
}

web_m2m_inline/pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* `Trobz <https://www.trobz.com>`
2+
3+
* Tris Doan <tridm@trobz.com>

web_m2m_inline/readme/CREDITS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The development of this module has been financially supported by:
2+
3+
- Camptocamp
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This module extends the functionality of the Many2Many field in Odoo to support inline adjustments. It allows users to directly add or edit Many2Many field values within the form view.

web_m2m_inline/readme/USAGE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
To use this module, you need to add widget="m2m_inline":
2+
3+
.. code-block:: XML
4+
5+
<field name="my_m2m_field_ids" widget="m2m_inline">
6+
<tree editable="bottom">
7+
<field name="name"/>
8+
</tree>
9+
</field>
9.23 KB
Loading
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/** @odoo-module **/
2+
3+
import {_t} from "@web/core/l10n/translation";
4+
import {Many2XAutocomplete} from "@web/views/fields/relational_utils";
5+
6+
export class CustomMany2XAutocomplete extends Many2XAutocomplete {
7+
async loadOptionsSource(request) {
8+
const res = await super.loadOptionsSource(request);
9+
if (this.props.value) {
10+
const inputVal = this.autoCompleteContainer.el.querySelector("input").value;
11+
const record = await this.orm.call(this.props.resModel, "name_search", [], {
12+
name: this.props.value,
13+
operator: "ilike",
14+
args: [],
15+
limit: 1,
16+
context: this.props.context,
17+
});
18+
res.push({
19+
label: _t(`Edit ${record[0][1]}`),
20+
classList: "o_m2o_dropdown_option o_m2o_dropdown_option_create_edit",
21+
action: () =>
22+
this._updateRecord(this.props.resModel, record[0], inputVal),
23+
});
24+
}
25+
return res;
26+
}
27+
async _updateRecord(model, record, changes) {
28+
return await this.orm.write(model, [record[0]], {name: changes});
29+
}
30+
}

0 commit comments

Comments
 (0)