Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions web_list_record_popup/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
=====================
Web List Record Popup
=====================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:98d747783d9eeaa78fab65334d871778a70c865edf1d26e076b9dbf3d179b1c5
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
:target: https://github.com/OCA/web/tree/18.0/web_list_record_popup
:alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/web-18-0/web-18-0-web_list_record_popup
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

**Features:**

- Adds a popup button to editable lists in form views
- Opens records in a form dialog instead of inline editing
- Works with both existing and new (NewID) records
- Optional activation via mixin - no hard dependencies

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`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**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Akretion

Contributors
------------

- Raphael Valyi <raphael.valyi@akretion.com>

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/web <https://github.com/OCA/web/tree/18.0/web_list_record_popup>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions web_list_record_popup/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
18 changes: 18 additions & 0 deletions web_list_record_popup/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "Web List Record Popup",
"version": "18.0.1.0.0",
"category": "Hidden",
"license": "LGPL-3",
"author": "Akretion, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
"depends": ["web"],
"data": [],
"assets": {
"web.assets_backend": [
"web_list_record_popup/static/src/js/list_renderer_with_button.esm.js",
],
"web.assets_unit_tests": [
"web_list_record_popup/static/tests/list_renderer_with_button.test.js",
],
},
}
1 change: 1 addition & 0 deletions web_list_record_popup/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import web_list_record_popup_mixin
66 changes: 66 additions & 0 deletions web_list_record_popup/models/web_list_record_popup_mixin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Copyright 2026-TODAY Akretion - Raphael Valyi <raphael.valyi@akretion.com>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.en.html).

from lxml import etree

from odoo import api, models


class WebListRecordPopupMixin(models.AbstractModel):
"""Mixin to inject popup button into form views.

Models inheriting from this mixin can define:
- _popup_button_xpaths: List of tuples (xpath, position) where to inject the button

Example:
_popup_button_xpaths = [
(
"//field[@name='invoice_line_ids']/list/field[@name='product_id']",
"before"
),
]
"""

_name = "web_list_record_popup.mixin"
_description = "Mixin to inject popup button into form views"

_popup_button_xpaths = []

@api.model
def _get_view(self, view_id=None, view_type="form", **options):
arch, view = super()._get_view(view_id, view_type, **options)

if view_type == "form" and self._popup_button_xpaths:
arch = self._inject_popup_buttons(arch)

return arch, view

def _inject_popup_buttons(self, arch):
"""Inject popup button before specified fields in list views inside forms."""
# Check if web_list_record_popup module is installed
if not self.env["ir.module.module"].search(
[("name", "=", "web_list_record_popup"), ("state", "=", "installed")]
):
return arch

for xpath_expr, position in self._popup_button_xpaths:
try:
nodes = arch.findall(xpath_expr)
for node in nodes:
button = etree.Element("button")
button.set("name", "dummy_button_for_js")
button.set("icon", "fa-external-link")
button.set("title", "Edit in Form")
button.set("class", "btn-sm btn-link p-0 edit-line-popup")

if position == "before":
node.addprevious(button)
elif position == "after":
node.addnext(button)
elif position == "inside":
node.insert(0, button)
except Exception:
# If xpath fails, skip this injection
continue

return arch
3 changes: 3 additions & 0 deletions web_list_record_popup/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
1 change: 1 addition & 0 deletions web_list_record_popup/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Raphael Valyi \<<raphael.valyi@akretion.com>\>
6 changes: 6 additions & 0 deletions web_list_record_popup/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
**Features:**

- Adds a popup button to editable lists in form views
- Opens records in a form dialog instead of inline editing
- Works with both existing and new (NewID) records
- Optional activation via mixin - no hard dependencies
74 changes: 74 additions & 0 deletions web_list_record_popup/readme/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
Web List Record Popup
=====================

This module provides a popup button for editable lists in Odoo forms.
When clicked, it opens the record in a form dialog instead of editing inline.

**Table of contents**

.. contents::
:local:

Usage
=====

This module provides a mixin that can be inherited by any model to add popup buttons
to x2many list fields in form views.

To use it:

1. Make your model inherit from ``web_list_record_popup.mixin``
2. Define ``_popup_button_xpaths`` class attribute with xpath expressions where buttons should be injected

Example::

class MyModel(models.Model):
_inherit = ["web_list_record_popup.mixin"]

_popup_button_xpaths = [
("//field[@name='line_ids']/list/field[@name='product_id']", "before"),
]

The button will only be injected if the ``web_list_record_popup`` module is installed.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
feedback.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Akretion
* Raphael Valyi
* Odoo Community Association (OCA)

Contributors
~~~~~~~~~~~~

* Raphael Valyi <raphael.valyi@akretion.com>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/web <https://github.com/OCA/web/tree/18.0/web_list_record_popup>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Loading
Loading