Skip to content

Commit 684dcb2

Browse files
Nedas ŽilinskasVang-NguyenPhu
authored andcommitted
[MIG] web_widget_url_advanced: Migration to 17.0
1 parent 4f50022 commit 684dcb2

9 files changed

Lines changed: 113 additions & 82 deletions

File tree

web_widget_url_advanced/README.rst

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Or user can add any hyperlink text using 'prefix_name' attribute
7777

7878
.. code:: xml
7979
80-
<field name="skype_name" widget="url" 'prefix_name': 'skype'/>
80+
<field name="skype_name" widget="url" prefix_name="skype"/>
8181
8282
both can be applied inside the options attribute too:
8383

@@ -88,11 +88,6 @@ both can be applied inside the options attribute too:
8888
.. |image1| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_widget_url_advanced/static/description/before.png
8989
.. |image2| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_widget_url_advanced/static/description/after.png
9090

91-
Known issues / Roadmap
92-
======================
93-
94-
- ``<field text_field="foo"/>`` is not supported in tree views.
95-
9691
Bug Tracker
9792
===========
9893

@@ -123,6 +118,7 @@ Contributors
123118
- Swapnesh Shah <s.shah.serpentcs@gmail.com>
124119
- Joan Sisquella <joan.sisquella@forgeflow.com>
125120
- Peerapong Supasompob <peerapong.supasompob@gmail.com>
121+
- Nedas Žilinskas <nedas.zilinskas@avoin.systems>
126122

127123
Maintainers
128124
-----------

web_widget_url_advanced/__manifest__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
"summary": "This module extends URL widget "
66
"for displaying anchors with custom labels.",
77
"category": "Web",
8-
"version": "15.0.1.0.0",
8+
"version": "17.0.1.0.0",
99
"license": "LGPL-3",
1010
"author": "Camptocamp, Odoo Community Association (OCA)",
1111
"website": "https://github.com/OCA/web",
1212
"depends": ["web"],
1313
"data": [],
1414
"assets": {
15-
"web.assets_backend": ["web_widget_url_advanced/static/src/js/url_widget.js"],
15+
"web.assets_backend": [
16+
"web_widget_url_advanced/static/src/fields/**/*",
17+
],
1618
},
1719
"installable": True,
1820
}

web_widget_url_advanced/readme/CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
- Swapnesh Shah \<<s.shah.serpentcs@gmail.com>\>
66
- Joan Sisquella \<<joan.sisquella@forgeflow.com>\>
77
- Peerapong Supasompob \<<peerapong.supasompob@gmail.com>\>
8+
- Nedas Žilinskas \<<nedas.zilinskas@avoin.systems>\>

web_widget_url_advanced/readme/ROADMAP.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

web_widget_url_advanced/readme/USAGE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ to
2626
Or user can add any hyperlink text using 'prefix_name' attribute
2727

2828
``` xml
29-
<field name="skype_name" widget="url" 'prefix_name': 'skype'/>
29+
<field name="skype_name" widget="url" prefix_name="skype"/>
3030
```
3131

3232
both can be applied inside the options attribute too:

web_widget_url_advanced/static/description/index.html

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88

99
/*
1010
:Author: David Goodger (goodger@python.org)
11-
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
11+
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
1212
:Copyright: This stylesheet has been placed in the public domain.
1313
1414
Default cascading style sheet for the HTML output of Docutils.
15+
Despite the name, some widely supported CSS2 features are used.
1516
1617
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
1718
customize this style sheet.
@@ -274,7 +275,7 @@
274275
margin-left: 2em ;
275276
margin-right: 2em }
276277

277-
pre.code .ln { color: grey; } /* line numbers */
278+
pre.code .ln { color: gray; } /* line numbers */
278279
pre.code, code { background-color: #eeeeee }
279280
pre.code .comment, code .comment { color: #5C6576 }
280281
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -300,7 +301,7 @@
300301
span.pre {
301302
white-space: pre }
302303

303-
span.problematic {
304+
span.problematic, pre.problematic {
304305
color: red }
305306

306307
span.section-subtitle {
@@ -381,12 +382,11 @@ <h1 class="title">Web URL widget advanced</h1>
381382
<div class="contents local topic" id="contents">
382383
<ul class="simple">
383384
<li><a class="reference internal" href="#usage" id="toc-entry-1">Usage</a></li>
384-
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-2">Known issues / Roadmap</a></li>
385-
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-3">Bug Tracker</a></li>
386-
<li><a class="reference internal" href="#credits" id="toc-entry-4">Credits</a><ul>
387-
<li><a class="reference internal" href="#authors" id="toc-entry-5">Authors</a></li>
388-
<li><a class="reference internal" href="#contributors" id="toc-entry-6">Contributors</a></li>
389-
<li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
385+
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-2">Bug Tracker</a></li>
386+
<li><a class="reference internal" href="#credits" id="toc-entry-3">Credits</a><ul>
387+
<li><a class="reference internal" href="#authors" id="toc-entry-4">Authors</a></li>
388+
<li><a class="reference internal" href="#contributors" id="toc-entry-5">Contributors</a></li>
389+
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li>
390390
</ul>
391391
</li>
392392
</ul>
@@ -411,37 +411,31 @@ <h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
411411
<p><img alt="image2" src="https://raw.githubusercontent.com/OCA/web/17.0/web_widget_url_advanced/static/description/after.png" /></p>
412412
<p>Or user can add any hyperlink text using ‘prefix_name’ attribute</p>
413413
<pre class="code xml literal-block">
414-
<span class="nt">&lt;field</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;skype_name&quot;</span><span class="w"> </span><span class="na">widget=</span><span class="s">&quot;url&quot;</span><span class="w"> </span><span class="err">'prefix_name':</span><span class="w"> </span><span class="err">'skype'</span><span class="nt">/&gt;</span>
414+
<span class="nt">&lt;field</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;skype_name&quot;</span><span class="w"> </span><span class="na">widget=</span><span class="s">&quot;url&quot;</span><span class="w"> </span><span class="na">prefix_name=</span><span class="s">&quot;skype&quot;</span><span class="nt">/&gt;</span>
415415
</pre>
416416
<p>both can be applied inside the options attribute too:</p>
417417
<pre class="code xml literal-block">
418418
<span class="nt">&lt;field</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;skype_name&quot;</span><span class="w"> </span><span class="na">widget=</span><span class="s">&quot;url&quot;</span><span class="w"> </span><span class="na">options=</span><span class="s">&quot;{'prefix_name': 'skype'}&quot;</span><span class="nt">/&gt;</span>
419419
</pre>
420420
</div>
421-
<div class="section" id="known-issues-roadmap">
422-
<h1><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h1>
423-
<ul class="simple">
424-
<li><tt class="docutils literal">&lt;field <span class="pre">text_field=&quot;foo&quot;/&gt;</span></tt> is not supported in tree views.</li>
425-
</ul>
426-
</div>
427421
<div class="section" id="bug-tracker">
428-
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
422+
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
429423
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
430424
In case of trouble, please check there if your issue has already been reported.
431425
If you spotted it first, help us to smash it by providing a detailed and welcomed
432426
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_widget_url_advanced%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
433427
<p>Do not contact contributors directly about support or help with technical issues.</p>
434428
</div>
435429
<div class="section" id="credits">
436-
<h1><a class="toc-backref" href="#toc-entry-4">Credits</a></h1>
430+
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
437431
<div class="section" id="authors">
438-
<h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
432+
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
439433
<ul class="simple">
440434
<li>Camptocamp</li>
441435
</ul>
442436
</div>
443437
<div class="section" id="contributors">
444-
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
438+
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
445439
<ul class="simple">
446440
<li>Simone Orsi &lt;<a class="reference external" href="mailto:simone.orsi&#64;camptocamp.com">simone.orsi&#64;camptocamp.com</a>&gt;</li>
447441
<li><a class="reference external" href="https://corporatehub.eu/">CorporateHub</a><ul>
@@ -452,12 +446,15 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
452446
<li>Swapnesh Shah &lt;<a class="reference external" href="mailto:s.shah.serpentcs&#64;gmail.com">s.shah.serpentcs&#64;gmail.com</a>&gt;</li>
453447
<li>Joan Sisquella &lt;<a class="reference external" href="mailto:joan.sisquella&#64;forgeflow.com">joan.sisquella&#64;forgeflow.com</a>&gt;</li>
454448
<li>Peerapong Supasompob &lt;<a class="reference external" href="mailto:peerapong.supasompob&#64;gmail.com">peerapong.supasompob&#64;gmail.com</a>&gt;</li>
449+
<li>Nedas Žilinskas &lt;<a class="reference external" href="mailto:nedas.zilinskas&#64;avoin.systems">nedas.zilinskas&#64;avoin.systems</a>&gt;</li>
455450
</ul>
456451
</div>
457452
<div class="section" id="maintainers">
458-
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
453+
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
459454
<p>This module is maintained by the OCA.</p>
460-
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
455+
<a class="reference external image-reference" href="https://odoo-community.org">
456+
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
457+
</a>
461458
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
462459
mission is to support the collaborative development of Odoo features and
463460
promote its widespread use.</p>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/** @odoo-module **/
2+
3+
/* Copyright 2018 Simone Orsi - Camptocamp SA
4+
License LGPLv3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.en.html). */
5+
6+
import {patch} from "@web/core/utils/patch";
7+
import {UrlField, formUrlField, urlField} from "@web/views/fields/url/url_field";
8+
9+
patch(UrlField.props, {
10+
text_field: {type: String, optional: true},
11+
prefix_name: {type: String, optional: true},
12+
});
13+
14+
patch(UrlField.prototype, {
15+
_get_text_field() {
16+
if (this.props.text_field) {
17+
let field_value = this.props.record.data[this.props.text_field];
18+
if (Array.isArray(field_value) && field_value.length == 2) {
19+
field_value = field_value[1];
20+
}
21+
return field_value;
22+
}
23+
return false;
24+
},
25+
26+
get title() {
27+
return (
28+
this._get_text_field() ||
29+
this.props.text ||
30+
this.props.record.data[this.props.name] ||
31+
""
32+
);
33+
},
34+
35+
get formattedHrefWithPrefix() {
36+
let value = this.formattedHref;
37+
38+
if (this.props.prefix_name) {
39+
value = this.props.prefix_name + ":" + value;
40+
}
41+
42+
return value;
43+
},
44+
});
45+
46+
const patchExtractProps = {
47+
extractProps({attrs, options}) {
48+
const props = super.extractProps(...arguments);
49+
props.text_field = attrs.text_field || options.text_field;
50+
props.prefix_name = attrs.prefix_name || options.prefix_name;
51+
return props;
52+
},
53+
};
54+
55+
patch(urlField, patchExtractProps);
56+
patch(formUrlField, patchExtractProps);
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<templates id="template" xml:space="preserve">
3+
4+
<t
5+
t-name="web_widget_url_advanced.UrlField"
6+
t-inherit="web.UrlField"
7+
t-inherit-mode="extension"
8+
>
9+
10+
<xpath expr="//a[hasclass('o_field_widget')]" position="attributes">
11+
<attribute name="t-esc">title</attribute>
12+
<attribute name="t-att-href">formattedHrefWithPrefix</attribute>
13+
</xpath>
14+
15+
</t>
16+
17+
<t
18+
t-name="web_widget_url_advanced.FormUrlField"
19+
t-inherit="web.FormUrlField"
20+
t-inherit-mode="extension"
21+
>
22+
23+
<xpath expr="//a[hasclass('o_field_widget')]" position="attributes">
24+
<attribute name="t-esc">title</attribute>
25+
<attribute name="t-att-href">formattedHrefWithPrefix</attribute>
26+
</xpath>
27+
28+
</t>
29+
30+
</templates>

web_widget_url_advanced/static/src/js/url_widget.js

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)