3
0
Fork 0

[MIG] web_tree_duplicate to v16

16.0
Holger Brunn 2023-07-05 11:55:32 +02:00
parent c0c2cc6e0d
commit b53521ca67
14 changed files with 154 additions and 194 deletions

View File

@ -0,0 +1 @@
../../../../web_tree_duplicate

View File

@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

View File

@ -2,10 +2,13 @@
Tree View Duplicate Records Tree View Duplicate Records
=========================== ===========================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f76ad85d67cf363cb525bf60998a317d0f9a114ebe4ecc6685dae79cc5b0465e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status :target: https://odoo-community.org/page/development-status
@ -14,14 +17,14 @@ Tree View Duplicate Records
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
:target: https://github.com/OCA/web/tree/12.0/web_tree_duplicate :target: https://github.com/OCA/web/tree/16.0/web_tree_duplicate
:alt: OCA/web :alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_tree_duplicate :target: https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_tree_duplicate
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/162/12.0 :target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=16.0
:alt: Try me on Runbot :alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@ -35,9 +38,9 @@ With this module you can duplicate records directly from the tree view.
Configuration Configuration
============= =============
The duplicate option is disabled by default. The duplicate option is enabled by default.
To enable it you have to add attribute `duplicate` to the tree view. To disable it you have to add attribute `duplicate` to the tree view.
Set `duplicate` to `true` to enable it or `false` to (explicitly) disable it. Set `duplicate` to `false` to enable it or `true` to (explicitly) disable it.
Example: Example:
@ -50,7 +53,7 @@ Example:
<field name="inherit_id" ref="base.view_users_tree"/> <field name="inherit_id" ref="base.view_users_tree"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//tree" position="attributes"> <xpath expr="//tree" position="attributes">
<attribute name="duplicate">true</attribute> <attribute name="duplicate">false</attribute>
</xpath> </xpath>
</field> </field>
</record> </record>
@ -72,8 +75,8 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_. 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. In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed 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_tree_duplicate%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. `feedback <https://github.com/OCA/web/issues/new?body=module:%20web_tree_duplicate%0Aversion:%2016.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. Do not contact contributors directly about support or help with technical issues.
@ -83,12 +86,14 @@ Credits
Authors Authors
~~~~~~~ ~~~~~~~
* Hunki Enterprises BV
* Onestein * Onestein
Contributors Contributors
~~~~~~~~~~~~ ~~~~~~~~~~~~
* Dennis Sluijk <d.sluijk@onestein.nl> * Dennis Sluijk <d.sluijk@onestein.nl>
* Holger Brunn <mail@hunki-enterprises.com> (https://hunki-enterprises.com)
Maintainers Maintainers
~~~~~~~~~~~ ~~~~~~~~~~~
@ -111,6 +116,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-tarteo| |maintainer-tarteo|
This module is part of the `OCA/web <https://github.com/OCA/web/tree/12.0/web_tree_duplicate>`_ project on GitHub. This module is part of the `OCA/web <https://github.com/OCA/web/tree/16.0/web_tree_duplicate>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -2,22 +2,19 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{ {
'name': 'Tree View Duplicate Records', "name": "Tree View Duplicate Records",
'summary': 'Duplicate records directly from the tree view.', "summary": "Duplicate records directly from the tree view.",
'development_status': 'Beta', "development_status": "Beta",
'category': 'Extra Tools', "category": "Extra Tools",
'version': '12.0.1.0.0', "version": "16.0.1.0.0",
'author': 'Onestein, Odoo Community Association (OCA)', "author": "Hunki Enterprises BV, Onestein, Odoo Community Association (OCA)",
'license': 'AGPL-3', "license": "AGPL-3",
'website': 'https://github.com/OCA/web', "website": "https://github.com/OCA/web",
'depends': [ "depends": ["web"],
'web' "maintainers": ["tarteo"],
], "assets": {
'data': [ "web.assets_backend": [
'templates/assets.xml' "web_tree_duplicate/static/src/web_tree_duplicate.esm.js",
], ],
'demo': [ },
'demo/res_users_view.xml'
],
'maintainers': ['tarteo']
} }

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright 2019 Onestein
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="view_users_tree" model="ir.ui.view">
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_tree"/>
<field name="arch" type="xml">
<xpath expr="//tree" position="attributes">
<attribute name="duplicate">true</attribute>
</xpath>
</field>
</record>
</odoo>

View File

@ -0,0 +1,30 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_tree_duplicate
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-07-05 08:47+0000\n"
"PO-Revision-Date: 2023-07-05 08:47+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_tree_duplicate
#. odoo-javascript
#: code:addons/web_tree_duplicate/static/src/web_tree_duplicate.esm.js:0
#, python-format
msgid "Duplicate"
msgstr "שכפול"
#. module: web_tree_duplicate
#. odoo-javascript
#: code:addons/web_tree_duplicate/static/src/web_tree_duplicate.esm.js:0
#, python-format
msgid "Duplicated Records"
msgstr "רשומות משוכפלות"

View File

@ -1,12 +1,14 @@
# Translation of Odoo Server. # Translation of Odoo Server.
# This file contains the translation of the following modules: # This file contains the translation of the following modules:
# * web_tree_duplicate # * web_tree_duplicate
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 12.0\n" "Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n" "POT-Creation-Date: 2023-07-05 08:47+0000\n"
"PO-Revision-Date: 2023-07-05 08:47+0000\n"
"Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
@ -14,16 +16,15 @@ msgstr ""
"Plural-Forms: \n" "Plural-Forms: \n"
#. module: web_tree_duplicate #. module: web_tree_duplicate
#. openerp-web #. odoo-javascript
#: code:addons/web_tree_duplicate/static/src/js/backend.js:47 #: code:addons/web_tree_duplicate/static/src/web_tree_duplicate.esm.js:0
#, python-format #, python-format
msgid "Duplicate" msgid "Duplicate"
msgstr "" msgstr ""
#. module: web_tree_duplicate #. module: web_tree_duplicate
#. openerp-web #. odoo-javascript
#: code:addons/web_tree_duplicate/static/src/js/backend.js:84 #: code:addons/web_tree_duplicate/static/src/web_tree_duplicate.esm.js:0
#, python-format #, python-format
msgid "Duplicated Records" msgid "Duplicated Records"
msgstr "" msgstr ""

View File

@ -1,6 +1,6 @@
The duplicate option is disabled by default. The duplicate option is enabled by default.
To enable it you have to add attribute `duplicate` to the tree view. To disable it you have to add attribute `duplicate` to the tree view.
Set `duplicate` to `true` to enable it or `false` to (explicitly) disable it. Set `duplicate` to `false` to enable it or `true` to (explicitly) disable it.
Example: Example:
@ -13,7 +13,7 @@ Example:
<field name="inherit_id" ref="base.view_users_tree"/> <field name="inherit_id" ref="base.view_users_tree"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//tree" position="attributes"> <xpath expr="//tree" position="attributes">
<attribute name="duplicate">true</attribute> <attribute name="duplicate">false</attribute>
</xpath> </xpath>
</field> </field>
</record> </record>

View File

@ -1 +1,2 @@
* Dennis Sluijk <d.sluijk@onestein.nl> * Dennis Sluijk <d.sluijk@onestein.nl>
* Holger Brunn <mail@hunki-enterprises.com> (https://hunki-enterprises.com)

View File

@ -1,7 +1,9 @@
To use this module, you need to: To use this module, you need to:
#. Go to any tree view; #. Go to any tree view
#. select some records; #. select some records
#. open the sidebar menu and click 'Duplicate'. #. open the sidebar menu and click 'Duplicate'
Note that even when selecting all records via the top checkbox on a list, this will only duplicate the currently visible items. If you really need to duplicate all records, you need to adjust the list view limit accordingly.
.. image:: /web_tree_duplicate/static/description/screenshot-duplicate.png .. image:: /web_tree_duplicate/static/description/screenshot-duplicate.png

View File

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" /> <meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Tree View Duplicate Records</title> <title>Tree View Duplicate Records</title>
<style type="text/css"> <style type="text/css">
@ -366,8 +366,10 @@ ul.auto-toc {
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! <!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f76ad85d67cf363cb525bf60998a317d0f9a114ebe4ecc6685dae79cc5b0465e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/web/tree/12.0/web_tree_duplicate"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_tree_duplicate"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/162/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p> <p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/web/tree/16.0/web_tree_duplicate"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_tree_duplicate"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>With this module you can duplicate records directly from the tree view.</p> <p>With this module you can duplicate records directly from the tree view.</p>
<p><strong>Table of contents</strong></p> <p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents"> <div class="contents local topic" id="contents">
@ -385,23 +387,23 @@ ul.auto-toc {
</div> </div>
<div class="section" id="configuration"> <div class="section" id="configuration">
<h1><a class="toc-backref" href="#id1">Configuration</a></h1> <h1><a class="toc-backref" href="#id1">Configuration</a></h1>
<p>The duplicate option is disabled by default. <p>The duplicate option is enabled by default.
To enable it you have to add attribute <cite>duplicate</cite> to the tree view. To disable it you have to add attribute <cite>duplicate</cite> to the tree view.
Set <cite>duplicate</cite> to <cite>true</cite> to enable it or <cite>false</cite> to (explicitly) disable it.</p> Set <cite>duplicate</cite> to <cite>false</cite> to enable it or <cite>true</cite> to (explicitly) disable it.</p>
<p>Example:</p> <p>Example:</p>
<pre class="code xml literal-block"> <pre class="code xml literal-block">
<span class="cp">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;</span> <span class="cp">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;</span><span class="w">
<span class="nt">&lt;odoo&gt;</span> </span><span class="nt">&lt;odoo&gt;</span><span class="w">
<span class="nt">&lt;record</span> <span class="na">id=</span><span class="s">&quot;view_users_tree&quot;</span> <span class="na">model=</span><span class="s">&quot;ir.ui.view&quot;</span><span class="nt">&gt;</span> </span><span class="nt">&lt;record</span><span class="w"> </span><span class="na">id=</span><span class="s">&quot;view_users_tree&quot;</span><span class="w"> </span><span class="na">model=</span><span class="s">&quot;ir.ui.view&quot;</span><span class="nt">&gt;</span><span class="w">
<span class="nt">&lt;field</span> <span class="na">name=</span><span class="s">&quot;model&quot;</span><span class="nt">&gt;</span>res.users<span class="nt">&lt;/field&gt;</span> </span><span class="nt">&lt;field</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;model&quot;</span><span class="nt">&gt;</span>res.users<span class="nt">&lt;/field&gt;</span><span class="w">
<span class="nt">&lt;field</span> <span class="na">name=</span><span class="s">&quot;inherit_id&quot;</span> <span class="na">ref=</span><span class="s">&quot;base.view_users_tree&quot;</span><span class="nt">/&gt;</span> </span><span class="nt">&lt;field</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;inherit_id&quot;</span><span class="w"> </span><span class="na">ref=</span><span class="s">&quot;base.view_users_tree&quot;</span><span class="nt">/&gt;</span><span class="w">
<span class="nt">&lt;field</span> <span class="na">name=</span><span class="s">&quot;arch&quot;</span> <span class="na">type=</span><span class="s">&quot;xml&quot;</span><span class="nt">&gt;</span> </span><span class="nt">&lt;field</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;arch&quot;</span><span class="w"> </span><span class="na">type=</span><span class="s">&quot;xml&quot;</span><span class="nt">&gt;</span><span class="w">
<span class="nt">&lt;xpath</span> <span class="na">expr=</span><span class="s">&quot;//tree&quot;</span> <span class="na">position=</span><span class="s">&quot;attributes&quot;</span><span class="nt">&gt;</span> </span><span class="nt">&lt;xpath</span><span class="w"> </span><span class="na">expr=</span><span class="s">&quot;//tree&quot;</span><span class="w"> </span><span class="na">position=</span><span class="s">&quot;attributes&quot;</span><span class="nt">&gt;</span><span class="w">
<span class="nt">&lt;attribute</span> <span class="na">name=</span><span class="s">&quot;duplicate&quot;</span><span class="nt">&gt;</span>true<span class="nt">&lt;/attribute&gt;</span> </span><span class="nt">&lt;attribute</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;duplicate&quot;</span><span class="nt">&gt;</span>false<span class="nt">&lt;/attribute&gt;</span><span class="w">
<span class="nt">&lt;/xpath&gt;</span> </span><span class="nt">&lt;/xpath&gt;</span><span class="w">
<span class="nt">&lt;/field&gt;</span> </span><span class="nt">&lt;/field&gt;</span><span class="w">
<span class="nt">&lt;/record&gt;</span> </span><span class="nt">&lt;/record&gt;</span><span class="w">
<span class="nt">&lt;/odoo&gt;</span> </span><span class="nt">&lt;/odoo&gt;</span>
</pre> </pre>
</div> </div>
<div class="section" id="usage"> <div class="section" id="usage">
@ -418,8 +420,8 @@ Set <cite>duplicate</cite> to <cite>true</cite> to enable it or <cite>false</cit
<h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1> <h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_tree_duplicate%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_tree_duplicate%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@ -427,6 +429,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<div class="section" id="authors"> <div class="section" id="authors">
<h2><a class="toc-backref" href="#id5">Authors</a></h2> <h2><a class="toc-backref" href="#id5">Authors</a></h2>
<ul class="simple"> <ul class="simple">
<li>Hunki Enterprises BV</li>
<li>Onestein</li> <li>Onestein</li>
</ul> </ul>
</div> </div>
@ -434,6 +437,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<h2><a class="toc-backref" href="#id6">Contributors</a></h2> <h2><a class="toc-backref" href="#id6">Contributors</a></h2>
<ul class="simple"> <ul class="simple">
<li>Dennis Sluijk &lt;<a class="reference external" href="mailto:d.sluijk&#64;onestein.nl">d.sluijk&#64;onestein.nl</a>&gt;</li> <li>Dennis Sluijk &lt;<a class="reference external" href="mailto:d.sluijk&#64;onestein.nl">d.sluijk&#64;onestein.nl</a>&gt;</li>
<li>Holger Brunn &lt;<a class="reference external" href="mailto:mail&#64;hunki-enterprises.com">mail&#64;hunki-enterprises.com</a>&gt; (<a class="reference external" href="https://hunki-enterprises.com">https://hunki-enterprises.com</a>)</li>
</ul> </ul>
</div> </div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
@ -445,7 +449,7 @@ mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p> <p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external" href="https://github.com/tarteo"><img alt="tarteo" src="https://github.com/tarteo.png?size=40px" /></a></p> <p><a class="reference external" href="https://github.com/tarteo"><img alt="tarteo" src="https://github.com/tarteo.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/12.0/web_tree_duplicate">OCA/web</a> project on GitHub.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/16.0/web_tree_duplicate">OCA/web</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div> </div>
</div> </div>

View File

@ -1,101 +0,0 @@
/* Copyright 2019 Onestein
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */
odoo.define('web_tree_duplicate', function (require) {
"use strict";
var core = require('web.core');
var _t = core._t;
var ListController = require('web.ListController');
var ListView = require('web.ListView');
var search_inputs = require('web.search_inputs');
ListView.include({
/**
* @override
*/
init: function () {
this._super.apply(this, arguments);
var sidebarDuplicate = false;
if ('duplicate' in this.arch.attrs) {
sidebarDuplicate = _.str.toBool(this.arch.attrs.duplicate);
}
this.controllerParams.sidebarDuplicate = sidebarDuplicate;
},
});
ListController.include({
/**
* @override
*/
init: function (parent, model, renderer, params) {
this._super.apply(this, arguments);
this.sidebarDuplicate = params.sidebarDuplicate;
},
/**
* Add the Duplicate button to the sidebar.
*
* @override
*/
renderSidebar: function () {
var res = this._super.apply(this, arguments);
if (this.hasSidebar && this.sidebarDuplicate) {
this.sidebar._addItems('other', [{
label: _t('Duplicate'),
callback: this._onDuplicateSelectedRecords.bind(this),
}]);
}
return res;
},
/**
* This function is triggered when the Duplicate button is clicked.
*
* @private
*/
_onDuplicateSelectedRecords: function () {
this._duplicateRecords(this.selectedRecords);
},
/**
* Duplicate records.
*
* @param {Array} ids Ids of records to duplicate
* @private
* @returns {jQuery.Deferred}
*/
_duplicateRecords: function (ids) {
var self = this;
var done = [];
_.each(ids, function (id) {
done.push(self.model.duplicateRecord(id));
});
return $.when.apply($, done).done(function () {
var dataPoints = arguments;
var ids = _.map(dataPoints, function (dataPoint) {
return self.model.localData[dataPoint].res_id;
});
var filter = {
attrs: {
domain: JSON.stringify([['id', 'in', ids]]),
string: _t('Duplicated Records')
}
}
var filterWidget = new search_inputs.Filter(filter);
var filterGroup = new search_inputs.FilterGroup(
[filterWidget],
self.searchView,
self.searchView.intervalMapping,
self.searchView.periodMapping
);
var facet = filterGroup.make_facet([filterGroup.make_value(filter)]);
self.searchView.query.add([facet]);
});
},
});
});

View File

@ -0,0 +1,40 @@
/** @odoo-module **/
// (c) 2023 Hunki Enterprises BV (<https://hunki-enterprises.com>)
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
import {Domain} from "@web/core/domain";
import {ListController} from "@web/views/list/list_controller";
import {patch} from "@web/core/utils/patch";
patch(ListController.prototype, "add duplicate action", {
getActionMenuItems() {
const result = this._super();
if (
this.archInfo.activeActions.create &&
this.archInfo.activeActions.duplicate
) {
result.other.push({
key: "duplicate",
description: this.env._t("Duplicate"),
callback: () => this.duplicateRecords(),
});
}
return result;
},
async duplicateRecords() {
const ids = await Promise.all(
this.model.root.selection.map(async (record) => {
return await record.model.orm.call(record.resModel, "copy", [
record.resId,
]);
})
);
this.env.searchModel.createNewFilters([
{
description: this.env._t("Duplicated Records"),
domain: new Domain([["id", "in", ids]]).toString(),
type: "filter",
},
]);
},
});

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2019 Onestein
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<template id="assets_backend" inherit_id="web.assets_backend">
<xpath expr=".">
<script src="/web_tree_duplicate/static/src/js/backend.js"></script>
</xpath>
</template>
</odoo>