Skip to content

Commit bf720d7

Browse files
committed
[ADD] web_list_record_popup: new module
1 parent 175beb6 commit bf720d7

12 files changed

Lines changed: 858 additions & 0 deletions

File tree

web_list_record_popup/README.rst

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
=====================
2+
Web List Record Popup
3+
=====================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:98d747783d9eeaa78fab65334d871778a70c865edf1d26e076b9dbf3d179b1c5
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-LGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
18+
:alt: License: LGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
20+
:target: https://github.com/OCA/web/tree/18.0/web_list_record_popup
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-18-0/web-18-0-web_list_record_popup
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=18.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
**Features:**
32+
33+
- Adds a popup button to editable lists in form views
34+
- Opens records in a form dialog instead of inline editing
35+
- Works with both existing and new (NewID) records
36+
- Optional activation via mixin - no hard dependencies
37+
38+
**Table of contents**
39+
40+
.. contents::
41+
:local:
42+
43+
Bug Tracker
44+
===========
45+
46+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
47+
In case of trouble, please check there if your issue has already been reported.
48+
If you spotted it first, help us to smash it by providing a detailed and welcomed
49+
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_list_record_popup%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
50+
51+
Do not contact contributors directly about support or help with technical issues.
52+
53+
Credits
54+
=======
55+
56+
Authors
57+
-------
58+
59+
* Akretion
60+
61+
Contributors
62+
------------
63+
64+
- Raphael Valyi <raphael.valyi@akretion.com>
65+
66+
Maintainers
67+
-----------
68+
69+
This module is maintained by the OCA.
70+
71+
.. image:: https://odoo-community.org/logo.png
72+
:alt: Odoo Community Association
73+
:target: https://odoo-community.org
74+
75+
OCA, or the Odoo Community Association, is a nonprofit organization whose
76+
mission is to support the collaborative development of Odoo features and
77+
promote its widespread use.
78+
79+
This module is part of the `OCA/web <https://github.com/OCA/web/tree/18.0/web_list_record_popup>`_ project on GitHub.
80+
81+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

web_list_record_popup/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "Web List Record Popup",
3+
"version": "18.0.1.0.0",
4+
"category": "Hidden",
5+
"license": "LGPL-3",
6+
"author": "Akretion, Odoo Community Association (OCA)",
7+
"website": "https://github.com/OCA/web",
8+
"depends": ["web"],
9+
"data": [],
10+
"assets": {
11+
"web.assets_backend": [
12+
"web_list_record_popup/static/src/js/list_renderer_with_button.esm.js",
13+
],
14+
"web.assets_unit_tests": [
15+
"web_list_record_popup/static/tests/list_renderer_with_button.test.js",
16+
],
17+
},
18+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import web_list_record_popup_mixin
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Copyright 2026-TODAY Akretion - Raphael Valyi <raphael.valyi@akretion.com>
2+
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.en.html).
3+
4+
from lxml import etree
5+
6+
from odoo import api, models
7+
8+
9+
class WebListRecordPopupMixin(models.AbstractModel):
10+
"""Mixin to inject popup button into form views.
11+
12+
Models inheriting from this mixin can define:
13+
- _popup_button_xpaths: List of tuples (xpath, position) where to inject the button
14+
15+
Example:
16+
_popup_button_xpaths = [
17+
(
18+
"//field[@name='invoice_line_ids']/list/field[@name='product_id']",
19+
"before"
20+
),
21+
]
22+
"""
23+
24+
_name = "web_list_record_popup.mixin"
25+
_description = "Mixin to inject popup button into form views"
26+
27+
_popup_button_xpaths = []
28+
29+
@api.model
30+
def _get_view(self, view_id=None, view_type="form", **options):
31+
arch, view = super()._get_view(view_id, view_type, **options)
32+
33+
if view_type == "form" and self._popup_button_xpaths:
34+
arch = self._inject_popup_buttons(arch)
35+
36+
return arch, view
37+
38+
def _inject_popup_buttons(self, arch):
39+
"""Inject popup button before specified fields in list views inside forms."""
40+
# Check if web_list_record_popup module is installed
41+
if not self.env["ir.module.module"].search(
42+
[("name", "=", "web_list_record_popup"), ("state", "=", "installed")]
43+
):
44+
return arch
45+
46+
for xpath_expr, position in self._popup_button_xpaths:
47+
try:
48+
nodes = arch.findall(xpath_expr)
49+
for node in nodes:
50+
button = etree.Element("button")
51+
button.set("name", "dummy_button_for_js")
52+
button.set("icon", "fa-external-link")
53+
button.set("title", "Edit in Form")
54+
button.set("class", "btn-sm btn-link p-0 edit-line-popup")
55+
56+
if position == "before":
57+
node.addprevious(button)
58+
elif position == "after":
59+
node.addnext(button)
60+
elif position == "inside":
61+
node.insert(0, button)
62+
except Exception:
63+
# If xpath fails, skip this injection
64+
continue
65+
66+
return arch
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Raphael Valyi \<<raphael.valyi@akretion.com>\>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
**Features:**
2+
3+
- Adds a popup button to editable lists in form views
4+
- Opens records in a form dialog instead of inline editing
5+
- Works with both existing and new (NewID) records
6+
- Optional activation via mixin - no hard dependencies
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
Web List Record Popup
2+
=====================
3+
4+
This module provides a popup button for editable lists in Odoo forms.
5+
When clicked, it opens the record in a form dialog instead of editing inline.
6+
7+
**Table of contents**
8+
9+
.. contents::
10+
:local:
11+
12+
Usage
13+
=====
14+
15+
This module provides a mixin that can be inherited by any model to add popup buttons
16+
to x2many list fields in form views.
17+
18+
To use it:
19+
20+
1. Make your model inherit from ``web_list_record_popup.mixin``
21+
2. Define ``_popup_button_xpaths`` class attribute with xpath expressions where buttons should be injected
22+
23+
Example::
24+
25+
class MyModel(models.Model):
26+
_inherit = ["web_list_record_popup.mixin"]
27+
28+
_popup_button_xpaths = [
29+
("//field[@name='line_ids']/list/field[@name='product_id']", "before"),
30+
]
31+
32+
The button will only be injected if the ``web_list_record_popup`` module is installed.
33+
34+
Bug Tracker
35+
===========
36+
37+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
38+
In case of trouble, please check there if your issue has already been reported.
39+
If you spotted it first, help us to smash it by providing a detailed and welcomed
40+
feedback.
41+
42+
Do not contact contributors directly about support or help with technical issues.
43+
44+
Credits
45+
=======
46+
47+
Authors
48+
~~~~~~~
49+
50+
* Akretion
51+
* Raphael Valyi
52+
* Odoo Community Association (OCA)
53+
54+
Contributors
55+
~~~~~~~~~~~~
56+
57+
* Raphael Valyi <raphael.valyi@akretion.com>
58+
59+
Maintainers
60+
~~~~~~~~~~~
61+
62+
This module is maintained by the OCA.
63+
64+
.. image:: https://odoo-community.org/logo.png
65+
:alt: Odoo Community Association
66+
:target: https://odoo-community.org
67+
68+
OCA, or the Odoo Community Association, is a nonprofit organization whose
69+
mission is to support the collaborative development of Odoo features and
70+
promote its widespread use.
71+
72+
This module is part of the `OCA/web <https://github.com/OCA/web/tree/18.0/web_list_record_popup>`_ project on GitHub.
73+
74+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

0 commit comments

Comments
 (0)