From 3db4e744fca6f7eed8b2c023cd97cc0a9f80e07b Mon Sep 17 00:00:00 2001 From: Aungkokolin1997 Date: Wed, 26 Jul 2023 12:10:56 +0630 Subject: [PATCH] [IMP] web_widget_open_tab --- web_widget_open_tab/README.rst | 7 +++ web_widget_open_tab/__init__.py | 1 + web_widget_open_tab/__manifest__.py | 3 ++ web_widget_open_tab/i18n/ja.po | 50 +++++++++++++++++++ web_widget_open_tab/models/__init__.py | 2 + web_widget_open_tab/models/ir_model.py | 10 ++++ web_widget_open_tab/models/ir_ui_view.py | 25 ++++++++++ web_widget_open_tab/readme/CONTRIBUTORS.rst | 3 ++ web_widget_open_tab/readme/USAGE.rst | 4 ++ .../static/description/index.html | 7 +++ web_widget_open_tab/views/ir_model_views.xml | 13 +++++ 11 files changed, 125 insertions(+) create mode 100644 web_widget_open_tab/i18n/ja.po create mode 100644 web_widget_open_tab/models/__init__.py create mode 100644 web_widget_open_tab/models/ir_model.py create mode 100644 web_widget_open_tab/models/ir_ui_view.py create mode 100644 web_widget_open_tab/views/ir_model_views.xml diff --git a/web_widget_open_tab/README.rst b/web_widget_open_tab/README.rst index bd92d9063..759af03c8 100644 --- a/web_widget_open_tab/README.rst +++ b/web_widget_open_tab/README.rst @@ -48,6 +48,10 @@ Edit the tree view and add the widget as the first field, usually, we should use You can open the record in a new tab when clicking with the mouse wheel on the external link icon. On a usual click the record will be opened without changes (keeping the breadcrumbs). +You can also add open-tab field in tree views by selecting "Add Open Tab Field" field in +the ir.model record. When you do this, the open-tab field is added right after the name +field in the tree if the field exists, otherwise at the beginning of the tree. + Known issues / Roadmap ====================== @@ -77,6 +81,9 @@ Contributors * Enric Tobella * Raf Ven * Dhara Solanki +* `Quartile `__: + + * Aung Ko Ko Lin Maintainers ~~~~~~~~~~~ diff --git a/web_widget_open_tab/__init__.py b/web_widget_open_tab/__init__.py index e69de29bb..0650744f6 100644 --- a/web_widget_open_tab/__init__.py +++ b/web_widget_open_tab/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/web_widget_open_tab/__manifest__.py b/web_widget_open_tab/__manifest__.py index 8ad5863f6..64048bc2a 100644 --- a/web_widget_open_tab/__manifest__.py +++ b/web_widget_open_tab/__manifest__.py @@ -11,6 +11,9 @@ "website": "https://github.com/OCA/web", "depends": ["web"], "demo": ["demo/res_users_view.xml"], + "data": [ + "views/ir_model_views.xml", + ], "assets": { "web.assets_backend": [ "web_widget_open_tab/static/src/xml/open_tab_widget.xml", diff --git a/web_widget_open_tab/i18n/ja.po b/web_widget_open_tab/i18n/ja.po new file mode 100644 index 000000000..cf0c15bfd --- /dev/null +++ b/web_widget_open_tab/i18n/ja.po @@ -0,0 +1,50 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_widget_open_tab +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-05-27 08:24+0000\n" +"PO-Revision-Date: 2023-05-27 08:24+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: web_widget_open_tab +#: model:ir.model.fields,field_description:web_widget_open_tab.field_ir_model__add_open_tab_field +msgid "Add Open Tab Field" +msgstr "別タブ表示ボタン追加" + +#. module: web_widget_open_tab +#: model:ir.model.fields,help:web_widget_open_tab.field_ir_model__add_open_tab_field +msgid "Adds open-tab field in list views." +msgstr "リストビューに別タブ表示ボタンを追加。" + +#. module: web_widget_open_tab +#: model:ir.model,name:web_widget_open_tab.model_base +msgid "Base" +msgstr "ベース" + +#. module: web_widget_open_tab +#. odoo-javascript +#: code:addons/web_widget_open_tab/static/src/js/open_tab_widget.esm.js:0 +#, python-format +msgid "Click to open on new tab" +msgstr "クリックして別タブを開く" + +#. module: web_widget_open_tab +#: model:ir.model,name:web_widget_open_tab.model_ir_model +msgid "Models" +msgstr "モデル" + +#. module: web_widget_open_tab +#. odoo-javascript +#: code:addons/web_widget_open_tab/static/src/js/open_tab_widget.esm.js:0 +#, python-format +msgid "Open Tab" +msgstr "別タブを開く" diff --git a/web_widget_open_tab/models/__init__.py b/web_widget_open_tab/models/__init__.py new file mode 100644 index 000000000..9368777a0 --- /dev/null +++ b/web_widget_open_tab/models/__init__.py @@ -0,0 +1,2 @@ +from . import ir_model +from . import ir_ui_view diff --git a/web_widget_open_tab/models/ir_model.py b/web_widget_open_tab/models/ir_model.py new file mode 100644 index 000000000..667576758 --- /dev/null +++ b/web_widget_open_tab/models/ir_model.py @@ -0,0 +1,10 @@ +# Copyright 2023 Quartile Limited +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class IrModel(models.Model): + _inherit = "ir.model" + + add_open_tab_field = fields.Boolean(help="Adds open-tab field in list views.") diff --git a/web_widget_open_tab/models/ir_ui_view.py b/web_widget_open_tab/models/ir_ui_view.py new file mode 100644 index 000000000..4004fe8dd --- /dev/null +++ b/web_widget_open_tab/models/ir_ui_view.py @@ -0,0 +1,25 @@ +# Copyright 2023 Quartile Limited +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from lxml import etree + +from odoo import api, models + + +class Base(models.AbstractModel): + _inherit = "base" + + @api.model + def _get_view(self, view_id=None, view_type="form", **options): + arch, view = super()._get_view(view_id, view_type, **options) + model = self.env["ir.model"]._get(self._name) + if view_type == "tree" and model.add_open_tab_field: + id_elem = """""" + id_elem = etree.fromstring(id_elem) + tree = arch.xpath("//tree")[0] + name_field = tree.xpath('./field[@name="name"]') + if name_field: + tree.insert(name_field[0].getparent().index(name_field[0]) + 1, id_elem) + else: + tree.insert(0, id_elem) + return arch, view diff --git a/web_widget_open_tab/readme/CONTRIBUTORS.rst b/web_widget_open_tab/readme/CONTRIBUTORS.rst index fa8a6cdea..84b084275 100644 --- a/web_widget_open_tab/readme/CONTRIBUTORS.rst +++ b/web_widget_open_tab/readme/CONTRIBUTORS.rst @@ -1,3 +1,6 @@ * Enric Tobella * Raf Ven * Dhara Solanki +* `Quartile `__: + + * Aung Ko Ko Lin diff --git a/web_widget_open_tab/readme/USAGE.rst b/web_widget_open_tab/readme/USAGE.rst index a47bb4fd0..3e4bb3c66 100644 --- a/web_widget_open_tab/readme/USAGE.rst +++ b/web_widget_open_tab/readme/USAGE.rst @@ -5,3 +5,7 @@ Edit the tree view and add the widget as the first field, usually, we should use You can open the record in a new tab when clicking with the mouse wheel on the external link icon. On a usual click the record will be opened without changes (keeping the breadcrumbs). + +You can also add open-tab field in tree views by selecting "Add Open Tab Field" field in +the ir.model record. When you do this, the open-tab field is added right after the name +field in the tree if the field exists, otherwise at the beginning of the tree. diff --git a/web_widget_open_tab/static/description/index.html b/web_widget_open_tab/static/description/index.html index c52e8a9e3..8a4473136 100644 --- a/web_widget_open_tab/static/description/index.html +++ b/web_widget_open_tab/static/description/index.html @@ -395,6 +395,9 @@ When clicking on the line (but not on the button), the record is opened in the s <field name=”id” widget=”open_tab”/>

You can open the record in a new tab when clicking with the mouse wheel on the external link icon. On a usual click the record will be opened without changes (keeping the breadcrumbs).

+

You can also add open-tab field in tree views by selecting “Add Open Tab Field” field in +the ir.model record. When you do this, the open-tab field is added right after the name +field in the tree if the field exists, otherwise at the beginning of the tree.

Known issues / Roadmap

@@ -424,6 +427,10 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
  • Enric Tobella <etobella@creublanca.es>
  • Raf Ven <raf.ven@dynapps.be>
  • Dhara Solanki <dhara.solanki@initos.com>
  • +
  • Quartile:
      +
    • Aung Ko Ko Lin
    • +
    +
  • diff --git a/web_widget_open_tab/views/ir_model_views.xml b/web_widget_open_tab/views/ir_model_views.xml new file mode 100644 index 000000000..78acc1178 --- /dev/null +++ b/web_widget_open_tab/views/ir_model_views.xml @@ -0,0 +1,13 @@ + + + + ir.model.view.form + ir.model + + + + + + + +