From 2de76dc9111df2e4a7180fd1fb88675e14cb4e80 Mon Sep 17 00:00:00 2001
From: Vang - Nguyen Phu
Date: Sat, 14 Dec 2024 20:49:34 +0700
Subject: [PATCH] [MIG] web_widget_url_advanced: Migration to 18.0
---
web_widget_url_advanced/README.rst | 46 ++++++++++---------
web_widget_url_advanced/__manifest__.py | 2 +-
.../readme/CONTRIBUTORS.md | 2 +
web_widget_url_advanced/readme/DESCRIPTION.md | 4 +-
web_widget_url_advanced/readme/USAGE.md | 4 +-
.../static/description/index.html | 27 ++++++-----
.../static/src/fields/url_field.esm.js | 23 ++++++----
7 files changed, 61 insertions(+), 47 deletions(-)
diff --git a/web_widget_url_advanced/README.rst b/web_widget_url_advanced/README.rst
index 62f569f19..7452cadba 100644
--- a/web_widget_url_advanced/README.rst
+++ b/web_widget_url_advanced/README.rst
@@ -17,21 +17,22 @@ Web URL widget advanced
: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/17.0/web_widget_url_advanced
+ :target: https://github.com/OCA/web/tree/18.0/web_widget_url_advanced
:alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
- :target: https://translation.odoo-community.org/projects/web-17-0/web-17-0-web_widget_url_advanced
+ :target: https://translation.odoo-community.org/projects/web-18-0/web-18-0-web_widget_url_advanced
: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=17.0
+ :target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=18.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
-Extend URL widget features to ease customization of anchor's text.
+Extend URL, CopyClipboardURL widget features to ease customization of
+anchor's text.
-By default, the URL widget will show the plain URL. You can specify an
-attribute to provide a static label too.
+By default, the URL, CopyClipboardURL widget will show the plain URL.
+You can specify an attribute to provide a static label too.
With this module, you can use a field for link's inner text using
attribute 'text_field'. You can also add a prefix to the link using
@@ -48,9 +49,9 @@ Until 13.0 this functionality was separated in modules
Usage
=====
-Use url widget as you do usually, then add an extra parameter text_field
-to indicate which field (present in the view already) must be used for
-the anchor text.
+Use url, CopyClipboardURL widget as you do usually, then add an extra
+parameter text\_ field to indicate which field (present in the view
+already) must be used for the anchor text.
.. code:: xml
@@ -85,8 +86,8 @@ both can be applied inside the options attribute too:
-.. |image1| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_widget_url_advanced/static/description/before.png
-.. |image2| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_widget_url_advanced/static/description/after.png
+.. |image1| image:: https://raw.githubusercontent.com/OCA/web/18.0/web_widget_url_advanced/static/description/before.png
+.. |image2| image:: https://raw.githubusercontent.com/OCA/web/18.0/web_widget_url_advanced/static/description/after.png
Bug Tracker
===========
@@ -94,7 +95,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.
@@ -109,16 +110,19 @@ Authors
Contributors
------------
-- Simone Orsi
-- `CorporateHub `__
+- Simone Orsi
+- `CorporateHub `__
- - Alexey Pelykh
+ - Alexey Pelykh
-- Jay Vora
-- Swapnesh Shah
-- Joan Sisquella
-- Peerapong Supasompob
-- Nedas Žilinskas
+- Jay Vora
+- Swapnesh Shah
+- Joan Sisquella
+- Peerapong Supasompob
+- Nedas Žilinskas
+- `Komit `__:
+
+ - Vang Nguyen Phu
Maintainers
-----------
@@ -133,6 +137,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_url_advanced/__manifest__.py b/web_widget_url_advanced/__manifest__.py
index e7437211d..7eae904a8 100644
--- a/web_widget_url_advanced/__manifest__.py
+++ b/web_widget_url_advanced/__manifest__.py
@@ -5,7 +5,7 @@
"summary": "This module extends URL widget "
"for displaying anchors with custom labels.",
"category": "Web",
- "version": "17.0.1.0.0",
+ "version": "18.0.1.0.0",
"license": "LGPL-3",
"author": "Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
diff --git a/web_widget_url_advanced/readme/CONTRIBUTORS.md b/web_widget_url_advanced/readme/CONTRIBUTORS.md
index 0ac59dd26..a3a09cf39 100644
--- a/web_widget_url_advanced/readme/CONTRIBUTORS.md
+++ b/web_widget_url_advanced/readme/CONTRIBUTORS.md
@@ -6,3 +6,5 @@
- Joan Sisquella \<\>
- Peerapong Supasompob \<\>
- Nedas Žilinskas \<\>
+- [Komit](https://komit-consulting.com):
+ - Vang Nguyen Phu
diff --git a/web_widget_url_advanced/readme/DESCRIPTION.md b/web_widget_url_advanced/readme/DESCRIPTION.md
index af45385be..78c2973ca 100644
--- a/web_widget_url_advanced/readme/DESCRIPTION.md
+++ b/web_widget_url_advanced/readme/DESCRIPTION.md
@@ -1,6 +1,6 @@
-Extend URL widget features to ease customization of anchor's text.
+Extend URL, CopyClipboardURL widget features to ease customization of anchor's text.
-By default, the URL widget will show the plain URL. You can specify an
+By default, the URL, CopyClipboardURL widget will show the plain URL. You can specify an
attribute to provide a static label too.
With this module, you can use a field for link's inner text using
diff --git a/web_widget_url_advanced/readme/USAGE.md b/web_widget_url_advanced/readme/USAGE.md
index f24106d2b..b4eaab404 100644
--- a/web_widget_url_advanced/readme/USAGE.md
+++ b/web_widget_url_advanced/readme/USAGE.md
@@ -1,5 +1,5 @@
-Use url widget as you do usually, then add an extra parameter text_field
-to indicate which field (present in the view already) must be used for
+Use url, CopyClipboardURL widget as you do usually, then add an extra parameter text_
+field to indicate which field (present in the view already) must be used for
the anchor text.
``` xml
diff --git a/web_widget_url_advanced/static/description/index.html b/web_widget_url_advanced/static/description/index.html
index 21732bba4..59da81d8c 100644
--- a/web_widget_url_advanced/static/description/index.html
+++ b/web_widget_url_advanced/static/description/index.html
@@ -369,10 +369,11 @@ ul.auto-toc {
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:3596008f4a705be27d5f63123a0330ad2e83c021846d6fe34e6007e82d5988fe
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-

-Extend URL widget features to ease customization of anchor’s text.
-By default, the URL widget will show the plain URL. You can specify an
-attribute to provide a static label too.
+

+Extend URL, CopyClipboardURL widget features to ease customization of
+anchor’s text.
+By default, the URL, CopyClipboardURL widget will show the plain URL.
+You can specify an attribute to provide a static label too.
With this module, you can use a field for link’s inner text using
attribute ‘text_field’. You can also add a prefix to the link using
attribute ‘prefix_name’.
@@ -393,9 +394,9 @@ attribute ‘prefix_name’.
-
Use url widget as you do usually, then add an extra parameter text_field
-to indicate which field (present in the view already) must be used for
-the anchor text.
+
Use url, CopyClipboardURL widget as you do usually, then add an extra
+parameter text_ field to indicate which field (present in the view
+already) must be used for the anchor text.
<field name="some_url" widget="url" text_field="another_field" />
@@ -406,9 +407,9 @@ link with partner’s name as anchor you can do:
<field name="website" widget="url" text_field="name" placeholder="e.g. www.odoo.com"/>
This is going to change the rendering from
-

+

to
-

+

Or user can add any hyperlink text using ‘prefix_name’ attribute
<field name="skype_name" widget="url" prefix_name="skype"/>
@@ -423,7 +424,7 @@ link with partner’s name as anchor you can do:
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.
@@ -458,7 +463,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
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_url_advanced/static/src/fields/url_field.esm.js b/web_widget_url_advanced/static/src/fields/url_field.esm.js
index bec036e9b..b17c32c1b 100644
--- a/web_widget_url_advanced/static/src/fields/url_field.esm.js
+++ b/web_widget_url_advanced/static/src/fields/url_field.esm.js
@@ -1,21 +1,23 @@
-/** @odoo-module **/
-
/* Copyright 2018 Simone Orsi - Camptocamp SA
License LGPLv3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.en.html). */
-import {patch} from "@web/core/utils/patch";
import {UrlField, formUrlField, urlField} from "@web/views/fields/url/url_field";
+import {copyClipboardURLField} from "@web/views/fields/copy_clipboard/copy_clipboard_field";
+import {patch} from "@web/core/utils/patch";
-patch(UrlField.props, {
+const AdvancedUrlFieldProps = {
text_field: {type: String, optional: true},
prefix_name: {type: String, optional: true},
-});
+};
+
+patch(UrlField.props, AdvancedUrlFieldProps);
+patch(copyClipboardURLField.component.props, AdvancedUrlFieldProps);
patch(UrlField.prototype, {
_get_text_field() {
if (this.props.text_field) {
let field_value = this.props.record.data[this.props.text_field];
- if (Array.isArray(field_value) && field_value.length == 2) {
+ if (Array.isArray(field_value) && field_value.length === 2) {
field_value = field_value[1];
}
return field_value;
@@ -43,14 +45,15 @@ patch(UrlField.prototype, {
},
});
-const patchExtractProps = {
+const patchExtractProps = () => ({
extractProps({attrs, options}) {
const props = super.extractProps(...arguments);
props.text_field = attrs.text_field || options.text_field;
props.prefix_name = attrs.prefix_name || options.prefix_name;
return props;
},
-};
+});
-patch(urlField, patchExtractProps);
-patch(formUrlField, patchExtractProps);
+patch(urlField, patchExtractProps());
+patch(formUrlField, patchExtractProps());
+patch(copyClipboardURLField, patchExtractProps());