From f239c3c5d3ab6e4b6bb055a467783ab7b7e76331 Mon Sep 17 00:00:00 2001 From: Carlos Roca Date: Tue, 16 Apr 2024 17:13:10 +0200 Subject: [PATCH] [MIG] web_widget_one2many_tree_line_duplicate: Migration to 16.0 --- .../README.rst | 13 +- .../__manifest__.py | 14 +- .../readme/CONTRIBUTORS.rst | 1 + .../static/description/index.html | 20 ++- .../basic_relational_model.esm.js | 22 +++ .../src/js/one2many_tree_line_duplicate.js | 163 ----------------- .../{js => legacy/basic_model}/basic_model.js | 169 +++++++++++------- .../static/src/list/list_renderer.esm.js | 38 ++++ .../static/src/list/list_renderer.xml | 43 +++++ .../scss/one2many_tree_line_duplicate.scss | 22 --- .../view/assets.xml | 21 --- 11 files changed, 236 insertions(+), 290 deletions(-) create mode 100644 web_widget_one2many_tree_line_duplicate/static/src/basic_relational_model/basic_relational_model.esm.js delete mode 100644 web_widget_one2many_tree_line_duplicate/static/src/js/one2many_tree_line_duplicate.js rename web_widget_one2many_tree_line_duplicate/static/src/{js => legacy/basic_model}/basic_model.js (74%) create mode 100644 web_widget_one2many_tree_line_duplicate/static/src/list/list_renderer.esm.js create mode 100644 web_widget_one2many_tree_line_duplicate/static/src/list/list_renderer.xml delete mode 100644 web_widget_one2many_tree_line_duplicate/static/src/scss/one2many_tree_line_duplicate.scss delete mode 100644 web_widget_one2many_tree_line_duplicate/view/assets.xml diff --git a/web_widget_one2many_tree_line_duplicate/README.rst b/web_widget_one2many_tree_line_duplicate/README.rst index e9b229e07..4bac1287c 100644 --- a/web_widget_one2many_tree_line_duplicate/README.rst +++ b/web_widget_one2many_tree_line_duplicate/README.rst @@ -7,7 +7,7 @@ Web Widget One2many Tree Line Duplicate !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:9cd7a43eab907d7d3ed3380c20cda1be40d288c01feb25dd54108e69cb350314 + !! source digest: sha256:0a96e20808687d52d22565143495374cad5121234c141e804bf8b9f06f9616d4 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png @@ -17,13 +17,13 @@ Web Widget One2many Tree Line Duplicate :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/13.0/web_widget_one2many_tree_line_duplicate + :target: https://github.com/OCA/web/tree/16.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-13-0/web-13-0-web_widget_one2many_tree_line_duplicate + :target: https://translation.odoo-community.org/projects/web-16-0/web-16-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=13.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=16.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -61,7 +61,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -79,6 +79,7 @@ Contributors * `Tecnativa `_: * Alexandre Díaz + * Carlos Roca Maintainers ~~~~~~~~~~~ @@ -93,6 +94,6 @@ 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. +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/__manifest__.py b/web_widget_one2many_tree_line_duplicate/__manifest__.py index ff256e183..501392a33 100644 --- a/web_widget_one2many_tree_line_duplicate/__manifest__.py +++ b/web_widget_one2many_tree_line_duplicate/__manifest__.py @@ -4,12 +4,22 @@ { "name": "Web Widget One2many Tree Line Duplicate", "category": "web", - "version": "13.0.1.0.2", + "version": "16.0.1.0.0", "author": "Tecnativa, Odoo Community Association (OCA)", "license": "AGPL-3", "website": "https://github.com/OCA/web", "depends": ["web"], - "data": ["view/assets.xml"], "auto_install": False, "installable": True, + "assets": { + "web.assets_backend": [ + "/web_widget_one2many_tree_line_duplicate/static/src/legacy/**/*.js", + "/web_widget_one2many_tree_line_duplicate/static/src/**/*.esm.js", + ( + "after", + "/web/static/src/views/list/list_renderer.xml", + "/web_widget_one2many_tree_line_duplicate/static/src/list/list_renderer.xml", + ), + ], + }, } diff --git a/web_widget_one2many_tree_line_duplicate/readme/CONTRIBUTORS.rst b/web_widget_one2many_tree_line_duplicate/readme/CONTRIBUTORS.rst index f1d7070a5..2ee38b271 100644 --- a/web_widget_one2many_tree_line_duplicate/readme/CONTRIBUTORS.rst +++ b/web_widget_one2many_tree_line_duplicate/readme/CONTRIBUTORS.rst @@ -1,3 +1,4 @@ * `Tecnativa `_: * Alexandre Díaz + * Carlos Roca diff --git a/web_widget_one2many_tree_line_duplicate/static/description/index.html b/web_widget_one2many_tree_line_duplicate/static/description/index.html index d2661f185..ebcf6500b 100644 --- a/web_widget_one2many_tree_line_duplicate/static/description/index.html +++ b/web_widget_one2many_tree_line_duplicate/static/description/index.html @@ -9,10 +9,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -275,7 +276,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code { margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -301,7 +302,7 @@ span.option { span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -367,9 +368,9 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:9cd7a43eab907d7d3ed3380c20cda1be40d288c01feb25dd54108e69cb350314 +!! source digest: sha256:0a96e20808687d52d22565143495374cad5121234c141e804bf8b9f06f9616d4 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

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

+

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

@@ -408,7 +409,7 @@ ul.auto-toc {

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.

+feedback.

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

@@ -424,6 +425,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome @@ -431,11 +433,13 @@ If you spotted it first, help us to smash it by providing a detailed and welcome

Maintainers

This module is maintained by the OCA.

-Odoo Community Association + +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.

+

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/basic_relational_model/basic_relational_model.esm.js b/web_widget_one2many_tree_line_duplicate/static/src/basic_relational_model/basic_relational_model.esm.js new file mode 100644 index 000000000..a014408ae --- /dev/null +++ b/web_widget_one2many_tree_line_duplicate/static/src/basic_relational_model/basic_relational_model.esm.js @@ -0,0 +1,22 @@ +/** @odoo-module **/ +/* Copyright 2024 Tecnativa - Carlos Roca + * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ + +import {StaticList} from "@web/views/basic_relational_model"; +import {patch} from "@web/core/utils/patch"; + +patch(StaticList.prototype, "web_widget_one2many_tree_line_duplicate.StaticList", { + async cloneRecord(recordId, params) { + const operation = { + context: [params.context], + operation: "CLONE", + position: "bottom", + id: recordId, + }; + await this.model.__bm__.save(this.__bm_handle__, {savePoint: true}); + this.model.__bm__.freezeOrder(this.__bm_handle__); + await this.__syncParent(operation); + const newRecord = this.records[this.records.length - 1]; + return newRecord; + }, +}); diff --git a/web_widget_one2many_tree_line_duplicate/static/src/js/one2many_tree_line_duplicate.js b/web_widget_one2many_tree_line_duplicate/static/src/js/one2many_tree_line_duplicate.js deleted file mode 100644 index 2717eda49..000000000 --- a/web_widget_one2many_tree_line_duplicate/static/src/js/one2many_tree_line_duplicate.js +++ /dev/null @@ -1,163 +0,0 @@ -/* Copyright 2021 Tecnativa - Alexandre Díaz - * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) */ - -odoo.define( - "web_widget_one2many_tree_line_duplicate.One2manyTreeLineDuplicate", - function (require) { - "use strict"; - - const core = require("web.core"); - const FieldOne2Many = require("web.relational_fields").FieldOne2Many; - const ListRenderer = require("web.ListRenderer"); - - const _t = core._t; - - ListRenderer.include({ - events: _.extend({}, ListRenderer.prototype.events, { - "click tr .o_list_record_clone": "_onCloneIconClick", - }), - - /** - * @override - */ - init: function (parent) { - this._super.apply(this, arguments); - let allow_clone = - parent.attrs && - parent.attrs.options && - parent.attrs.options.allow_clone; - allow_clone = typeof allow_clone === "undefined" ? false : allow_clone; - this.addCloneIcon = - allow_clone && - !parent.isReadonly && - parent.activeActions && - parent.activeActions.create; - }, - - /** - * @private - * @override - */ - _renderHeader: function () { - var $thead = this._super.apply(this, arguments); - if (this.addCloneIcon) { - $thead - .find("tr") - .append($("", {class: "o_list_record_clone_header"})); - } - return $thead; - }, - - /** - * @override - * @private - */ - _renderFooter: function () { - const $footer = this._super.apply(this, arguments); - if (this.addCloneIcon) { - $footer.find("tr").append($("")); - } - return $footer; - }, - - /** - * Inject the icon for clone action - * - * @private - * @override - */ - _renderRow: function (record, index) { - const $row = this._super.apply(this, arguments); - if (this.addCloneIcon) { - const $icon = $("