diff --git a/setup/web_widget_one2many_tree_line_duplicate/odoo/addons/web_widget_one2many_tree_line_duplicate b/setup/web_widget_one2many_tree_line_duplicate/odoo/addons/web_widget_one2many_tree_line_duplicate new file mode 120000 index 000000000..8ba1faf8d --- /dev/null +++ b/setup/web_widget_one2many_tree_line_duplicate/odoo/addons/web_widget_one2many_tree_line_duplicate @@ -0,0 +1 @@ +../../../../web_widget_one2many_tree_line_duplicate \ No newline at end of file diff --git a/setup/web_widget_one2many_tree_line_duplicate/setup.py b/setup/web_widget_one2many_tree_line_duplicate/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/web_widget_one2many_tree_line_duplicate/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/web_widget_one2many_tree_line_duplicate/README.rst b/web_widget_one2many_tree_line_duplicate/README.rst new file mode 100644 index 000000000..f79885137 --- /dev/null +++ b/web_widget_one2many_tree_line_duplicate/README.rst @@ -0,0 +1,98 @@ +======================================= +Web Widget One2many Tree Line Duplicate +======================================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:620c16e6d6bd0ad72a9d7eb3c8f243fbbf721898252fea9c26d70b2e0a7822d7 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github + :target: https://github.com/OCA/web/tree/15.0/web_widget_one2many_tree_line_duplicate + :alt: OCA/web +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/web-15-0/web-15-0-web_widget_one2many_tree_line_duplicate + :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=15.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Allow to add a icon to clone the line. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +This module works on all one2many tree views. The cloning process doesn't trigger onchange/default calls. + +**Available Options** + +- allow_clone > Add the icon to clone the line (default: false) + +**Examples** + +.. code:: xml + + + +Known issues / Roadmap +====================== + +* Add an option to control which columns are copied + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_: + + * Alexandre Díaz + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_widget_one2many_tree_line_duplicate/__init__.py b/web_widget_one2many_tree_line_duplicate/__init__.py new file mode 100644 index 000000000..f0b902299 --- /dev/null +++ b/web_widget_one2many_tree_line_duplicate/__init__.py @@ -0,0 +1 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) diff --git a/web_widget_one2many_tree_line_duplicate/__manifest__.py b/web_widget_one2many_tree_line_duplicate/__manifest__.py new file mode 100644 index 000000000..aaa23767d --- /dev/null +++ b/web_widget_one2many_tree_line_duplicate/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2021 Tecnativa - Alexandre Díaz +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) + +{ + "name": "Web Widget One2many Tree Line Duplicate", + "category": "web", + "version": "15.0.1.0.0", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "AGPL-3", + "website": "https://github.com/OCA/web", + "depends": ["web"], + "auto_install": False, + "installable": True, + "assets": { + "web.assets_backend": [ + "/web_widget_one2many_tree_line_duplicate/static/src/list/list_renderer.scss", + "/web_widget_one2many_tree_line_duplicate/static/src/list/list_renderer.esm.js", + ], + }, +} diff --git a/web_widget_one2many_tree_line_duplicate/i18n/web_widget_one2many_tree_line_duplicate.pot b/web_widget_one2many_tree_line_duplicate/i18n/web_widget_one2many_tree_line_duplicate.pot new file mode 100644 index 000000000..f0e93a927 --- /dev/null +++ b/web_widget_one2many_tree_line_duplicate/i18n/web_widget_one2many_tree_line_duplicate.pot @@ -0,0 +1,21 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_widget_one2many_tree_line_duplicate +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \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_one2many_tree_line_duplicate +#. openerp-web +#: code:addons/web_widget_one2many_tree_line_duplicate/static/src/js/one2many_tree_line_duplicate.js:0 +#, python-format +msgid "Clone row " +msgstr "" diff --git a/web_widget_one2many_tree_line_duplicate/readme/CONTRIBUTORS.rst b/web_widget_one2many_tree_line_duplicate/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..f1d7070a5 --- /dev/null +++ b/web_widget_one2many_tree_line_duplicate/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Tecnativa `_: + + * Alexandre Díaz diff --git a/web_widget_one2many_tree_line_duplicate/readme/DESCRIPTION.rst b/web_widget_one2many_tree_line_duplicate/readme/DESCRIPTION.rst new file mode 100644 index 000000000..a8a1fbfbf --- /dev/null +++ b/web_widget_one2many_tree_line_duplicate/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Allow to add a icon to clone the line. diff --git a/web_widget_one2many_tree_line_duplicate/readme/ROADMAP.rst b/web_widget_one2many_tree_line_duplicate/readme/ROADMAP.rst new file mode 100644 index 000000000..a21a75715 --- /dev/null +++ b/web_widget_one2many_tree_line_duplicate/readme/ROADMAP.rst @@ -0,0 +1 @@ +* Add an option to control which columns are copied diff --git a/web_widget_one2many_tree_line_duplicate/readme/USAGE.rst b/web_widget_one2many_tree_line_duplicate/readme/USAGE.rst new file mode 100644 index 000000000..4ab2eb200 --- /dev/null +++ b/web_widget_one2many_tree_line_duplicate/readme/USAGE.rst @@ -0,0 +1,11 @@ +This module works on all one2many tree views. The cloning process doesn't trigger onchange/default calls. + +**Available Options** + +- allow_clone > Add the icon to clone the line (default: false) + +**Examples** + +.. code:: xml + + diff --git a/web_widget_one2many_tree_line_duplicate/static/description/icon.png b/web_widget_one2many_tree_line_duplicate/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/web_widget_one2many_tree_line_duplicate/static/description/icon.png differ diff --git a/web_widget_one2many_tree_line_duplicate/static/description/index.html b/web_widget_one2many_tree_line_duplicate/static/description/index.html new file mode 100644 index 000000000..c33fc0eaa --- /dev/null +++ b/web_widget_one2many_tree_line_duplicate/static/description/index.html @@ -0,0 +1,444 @@ + + + + + + +Web Widget One2many Tree Line Duplicate + + + +
+

Web Widget One2many Tree Line Duplicate

+ + +

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runboat

+

Allow to add a icon to clone the line.

+

Table of contents

+ +
+

Usage

+

This module works on all one2many tree views. The cloning process doesn’t trigger onchange/default calls.

+

Available Options

+
    +
  • allow_clone > Add the icon to clone the line (default: false)
  • +
+

Examples

+
+<field name="order_line" widget="section_and_note_one2many" mode="tree,kanban" options="{'allow_clone': True}" attrs="{'readonly': [('state', 'in', ('done','cancel'))]}">
+
+
+
+

Known issues / Roadmap

+
    +
  • Add an option to control which columns are copied
  • +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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 project on GitHub.

+

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

+
+
+
+ + diff --git a/web_widget_one2many_tree_line_duplicate/static/src/list/list_renderer.esm.js b/web_widget_one2many_tree_line_duplicate/static/src/list/list_renderer.esm.js new file mode 100644 index 000000000..ac614551f --- /dev/null +++ b/web_widget_one2many_tree_line_duplicate/static/src/list/list_renderer.esm.js @@ -0,0 +1,101 @@ +/** @odoo-module **/ +/* Copyright 2024 Tecnativa - Alexandre D. Díaz + * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ + +import ListRenderer from "web.ListRenderer"; +import core from "web.core"; + +var _t = core._t; + +ListRenderer.include({ + events: _.extend({}, ListRenderer.prototype.events, { + "click tr .o_list_record_clone": "_onCloneIconClick", + }), + + init: function (parent, state, params) { + this._super(parent, state, params); + this.addCloneIcon = + parent && + parent.attrs && + parent.attrs.options && + parent.attrs.options.allow_clone && + !parent.isReadonly && + parent.activeActions && + parent.activeActions.create; + }, + + _onCloneIconClick: function (ev) { + ev.preventDefault(); + ev.stopPropagation(); + var $row = $(event.target).closest("tr"); + var id = $row.data("id"); + var record = this.state.data.find(function (rec) { + return rec.id === id; + }); + + var self = this; + this.unselectRow().then(function () { + self._rpc({ + model: record.model, + method: "copy_data", + args: [record.res_id], + }).then(function (dict) { + var newContext = {}; + for (var key in dict) { + if (dict.hasOwnProperty(key)) { + newContext["default_" + key] = dict[key]; + } + } + self.trigger_up("add_record", { + context: [newContext], + forceEditable: "bottom", + }); + }); + }); + }, + + _getNumberOfCols: function () { + var n = this._super(); + if (this.addCloneIcon) { + n++; + } + return n; + }, + + _renderHeader: function () { + var $thead = this._super.apply(this, arguments); + if (this.addCloneIcon) { + $thead.find("tr").append($("", {class: "o_list_record_clone"})); + } + return $thead; + }, + + _renderFooter: function () { + const $footer = this._super.apply(this, arguments); + if (this.addCloneIcon) { + $footer.find("tr").append($("")); + } + return $footer; + }, + + _renderRow: function (record, index) { + var $row = this._super.apply(this, arguments); + if (this.addCloneIcon) { + const isDisabled = !record.res_id; + const $icon = $("