Skip to content

Commit cc249b0

Browse files
[MIG] document_url: Migration to 19.0
1 parent 75d9527 commit cc249b0

File tree

6 files changed

+134
-40
lines changed

6 files changed

+134
-40
lines changed

document_url/README.rst

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
.. image:: https://odoo-community.org/readme-banner-image
2+
:target: https://odoo-community.org/get-involved?utm_source=readme
3+
:alt: Odoo Community Association
4+
15
==============
26
URL attachment
37
==============
@@ -13,17 +17,17 @@ URL attachment
1317
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
1418
:target: https://odoo-community.org/page/development-status
1519
:alt: Beta
16-
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
20+
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
1721
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1822
:alt: License: AGPL-3
1923
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github
20-
:target: https://github.com/OCA/knowledge/tree/18.0/document_url
24+
:target: https://github.com/OCA/knowledge/tree/19.0/document_url
2125
:alt: OCA/knowledge
2226
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/knowledge-18-0/knowledge-18-0-document_url
27+
:target: https://translation.odoo-community.org/projects/knowledge-19-0/knowledge-19-0-document_url
2428
:alt: Translate me on Weblate
2529
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/knowledge&target_branch=18.0
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/knowledge&target_branch=19.0
2731
:alt: Try me on Runboat
2832

2933
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -54,7 +58,7 @@ Bug Tracker
5458
Bugs are tracked on `GitHub Issues <https://github.com/OCA/knowledge/issues>`_.
5559
In case of trouble, please check there if your issue has already been reported.
5660
If you spotted it first, help us to smash it by providing a detailed and welcomed
57-
`feedback <https://github.com/OCA/knowledge/issues/new?body=module:%20document_url%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
61+
`feedback <https://github.com/OCA/knowledge/issues/new?body=module:%20document_url%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
5862

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

@@ -95,6 +99,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
9599
mission is to support the collaborative development of Odoo features and
96100
promote its widespread use.
97101

98-
This module is part of the `OCA/knowledge <https://github.com/OCA/knowledge/tree/18.0/document_url>`_ project on GitHub.
102+
This module is part of the `OCA/knowledge <https://github.com/OCA/knowledge/tree/19.0/document_url>`_ project on GitHub.
99103

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

document_url/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Copyright 2020 Tecnativa - Manuel Calero
33
{
44
"name": "URL attachment",
5-
"version": "18.0.1.0.0",
5+
"version": "19.0.1.0.0",
66
"category": "Tools",
77
"author": "Tecnativa, Odoo Community Association (OCA)",
88
"website": "https://github.com/OCA/knowledge",

document_url/static/description/index.html

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6-
<title>URL attachment</title>
6+
<title>README.rst</title>
77
<style type="text/css">
88

99
/*
@@ -360,16 +360,21 @@
360360
</style>
361361
</head>
362362
<body>
363-
<div class="document" id="url-attachment">
364-
<h1 class="title">URL attachment</h1>
363+
<div class="document">
365364

365+
366+
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
367+
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
368+
</a>
369+
<div class="section" id="url-attachment">
370+
<h1>URL attachment</h1>
366371
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
367372
!! This file is generated by oca-gen-addon-readme !!
368373
!! changes will be overwritten. !!
369374
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370375
!! source digest: sha256:8ed037012bcf490a1ebf24d0315e26fe25b0d7ae2cb864dc18ca8b4eb875b218
371376
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<p><a class="reference external image-reference" 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 image-reference" 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 image-reference" href="https://github.com/OCA/knowledge/tree/18.0/document_url"><img alt="OCA/knowledge" src="https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/knowledge-18-0/knowledge-18-0-document_url"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/knowledge&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
377+
<p><a class="reference external image-reference" 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 image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/knowledge/tree/19.0/document_url"><img alt="OCA/knowledge" src="https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/knowledge-19-0/knowledge-19-0-document_url"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/knowledge&amp;target_branch=19.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373378
<p>Module that allows to attach an URL as a document.</p>
374379
<p><strong>Table of contents</strong></p>
375380
<div class="contents local topic" id="contents">
@@ -385,7 +390,7 @@ <h1 class="title">URL attachment</h1>
385390
</ul>
386391
</div>
387392
<div class="section" id="usage">
388-
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
393+
<h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
389394
<p>To use this module, you need to:</p>
390395
<ol class="arabic simple">
391396
<li>Open the form view of an object (Example: Customer Invoice
@@ -398,23 +403,23 @@ <h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
398403
</ol>
399404
</div>
400405
<div class="section" id="bug-tracker">
401-
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
406+
<h2><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h2>
402407
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/knowledge/issues">GitHub Issues</a>.
403408
In case of trouble, please check there if your issue has already been reported.
404409
If you spotted it first, help us to smash it by providing a detailed and welcomed
405-
<a class="reference external" href="https://github.com/OCA/knowledge/issues/new?body=module:%20document_url%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
410+
<a class="reference external" href="https://github.com/OCA/knowledge/issues/new?body=module:%20document_url%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
406411
<p>Do not contact contributors directly about support or help with technical issues.</p>
407412
</div>
408413
<div class="section" id="credits">
409-
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
414+
<h2><a class="toc-backref" href="#toc-entry-3">Credits</a></h2>
410415
<div class="section" id="authors">
411-
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
416+
<h3><a class="toc-backref" href="#toc-entry-4">Authors</a></h3>
412417
<ul class="simple">
413418
<li>Tecnativa</li>
414419
</ul>
415420
</div>
416421
<div class="section" id="contributors">
417-
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
422+
<h3><a class="toc-backref" href="#toc-entry-5">Contributors</a></h3>
418423
<ul class="simple">
419424
<li>Jonathan Nemry &lt;<a class="reference external" href="mailto:jonathan.nemry&#64;acsone.eu">jonathan.nemry&#64;acsone.eu</a>&gt;</li>
420425
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
@@ -432,18 +437,19 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
432437
</ul>
433438
</div>
434439
<div class="section" id="maintainers">
435-
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
440+
<h3><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h3>
436441
<p>This module is maintained by the OCA.</p>
437442
<a class="reference external image-reference" href="https://odoo-community.org">
438443
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
439444
</a>
440445
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
441446
mission is to support the collaborative development of Odoo features and
442447
promote its widespread use.</p>
443-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/knowledge/tree/18.0/document_url">OCA/knowledge</a> project on GitHub.</p>
448+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/knowledge/tree/19.0/document_url">OCA/knowledge</a> project on GitHub.</p>
444449
<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>
445450
</div>
446451
</div>
447452
</div>
453+
</div>
448454
</body>
449455
</html>
Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,45 @@
1-
.o_image.o_Attachment_url_ico {
2-
background-image: none;
3-
i {
4-
display: block;
5-
text-align: center;
6-
line-height: revert;
1+
.o-mail-AttachmentContainer.o_attachment_url_container {
2+
width: auto !important;
3+
height: 36px !important;
4+
min-width: 100px;
5+
max-width: 200px;
6+
background: linear-gradient(135deg, #e8e9ed 0%, #dfe1e6 100%);
7+
border: 1.5px solid rgba(0, 0, 0, 0.1);
8+
border-radius: 8px;
9+
margin-right: 10px;
10+
margin-bottom: 10px;
11+
padding: 0 10px;
12+
overflow: hidden;
13+
display: inline-flex !important;
14+
align-items: center;
15+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
16+
transition: all 0.2s ease;
17+
animation: slideInScale 0.3s cubic-bezier(0.4, 0, 0.2, 1);
18+
19+
&:hover {
20+
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
21+
border-color: rgba(0, 0, 0, 0.15);
22+
}
23+
}
24+
25+
.o_attachment_url_link_icon {
26+
display: inline-flex;
27+
align-items: center;
28+
text-decoration: none;
29+
cursor: pointer;
30+
}
31+
32+
.o_attachment_url_delete {
33+
padding: 4px 6px 4px 8px;
34+
margin-left: 8px;
35+
font-size: 1.1em;
36+
opacity: 0.6;
37+
color: #000000;
38+
border-left: 1px solid rgb(0, 0, 0);
39+
cursor: pointer;
40+
41+
&:hover {
42+
opacity: 1;
43+
color: #ef4444;
744
}
845
}

document_url/static/src/xml/url.xml

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
55
<templates>
66
<t t-inherit="mail.Chatter" t-inherit-mode="extension">
7-
<xpath expr="//AttachmentList//..//FileUploader/t" position="replace">
7+
<xpath
8+
expr="//div[hasclass('o-mail-AttachmentBox')]//FileUploader/t[@t-set-slot='toggler']"
9+
position="replace"
10+
>
811
<t t-set-slot="toggler">
912
<div class="d-flex mx-auto">
1013
<button
@@ -30,22 +33,60 @@
3033
</t>
3134
<t t-inherit="mail.AttachmentList" t-inherit-mode="extension">
3235
<xpath
33-
expr="//div[hasclass('o-mail-AttachmentCard-image')]"
36+
expr="//div[hasclass('o-mail-AttachmentContainer')]"
3437
position="attributes"
3538
>
39+
<attribute name="t-att-class">{
40+
'o-inMessage': env.inMessage,
41+
'o-isImage': attachment.isImage,
42+
'o-isUploading opacity-25': attachment.uploading,
43+
'o-viewable': attachment.isViewable,
44+
'o_attachment_url_container': attachment.mimetype === 'application/link',
45+
}</attribute>
46+
</xpath>
47+
48+
<xpath expr="//div[hasclass('o-mail-AttachmentCard')]" position="before">
49+
<div
50+
t-elif="attachment.mimetype === 'application/link'"
51+
class="o_attachment_url_chip d-flex align-items-center w-100 h-100"
52+
t-att-title="attachment.name"
53+
>
54+
<div class="d-flex align-items-center text-truncate flex-grow-1">
55+
<a
56+
t-att-href="attachment.url"
57+
target="_blank"
58+
t-on-click.stop=""
59+
class="o_attachment_url_link_icon"
60+
>
61+
<i class="fa fa-link fa-lg o_attachment_url_icon" />
62+
</a>
63+
<span class="text-truncate ms-1" t-esc="attachment.name" />
64+
</div>
65+
<i
66+
t-if="attachment.isDeletable"
67+
class="fa fa-trash-o o_attachment_url_delete"
68+
t-on-click.stop="() => this.onClickUnlink(attachment)"
69+
title="Remove"
70+
/>
71+
</div>
72+
</xpath>
73+
74+
<xpath expr="//div[hasclass('o-mail-AttachmentCard')]" position="attributes">
3675
<attribute
3776
name="t-if"
3877
>attachment.mimetype !== 'application/link'</attribute>
3978
</xpath>
40-
<xpath expr="//div[hasclass('o-mail-AttachmentCard-image')]" position="before">
41-
<a
42-
class="o_Attachment_url_ico o_image flex-shrink-0 m-1"
43-
t-att-href="attachmentUrl"
44-
target="_blank"
45-
t-if="attachment.mimetype === 'application/link'"
46-
>
47-
<i class="fa fa-link fa-2x" />
48-
</a>
79+
80+
<xpath expr="//div[hasclass('o-mail-Attachment-hover')]" position="attributes">
81+
<attribute
82+
name="t-if"
83+
>!isMobileOS and attachment.mimetype !== 'application/link'</attribute>
84+
</xpath>
85+
<xpath expr="//Actions" position="replace">
86+
<Actions
87+
t-elif="isMobileOS and attachment.mimetype !== 'application/link'"
88+
actions="getActions(attachment)"
89+
/>
4990
</xpath>
5091
</t>
5192
</templates>

document_url/tests/test_document_url.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,24 @@
22

33
import base64
44

5-
from odoo.tests import common
5+
from odoo.tests import common, new_test_user
66

77

88
class TestDocumentUrl(common.TransactionCase):
99
def setUp(self):
1010
super().setUp()
1111
wizard_add_url = self.env["ir.attachment.add_url"]
12+
self.user = new_test_user(
13+
self.env,
14+
login="test_user",
15+
name="Test User",
16+
email="test@example.com",
17+
)
1218

1319
self.wizard_add_url = wizard_add_url.with_context(
1420
active_model="res.users",
15-
active_id=self.env.ref("base.user_demo").id,
16-
active_ids=[self.env.ref("base.user_demo").id],
21+
active_id=self.user.id,
22+
active_ids=[self.user.id],
1723
).create({"name": "Demo User (Website)", "url": "http://www.odoodemouser.com"})
1824

1925
def test_add_url_attachment(self):
@@ -23,7 +29,7 @@ def test_add_url_attachment(self):
2329
("name", "=", "Demo User (Website)"),
2430
("url", "=", "http://www.odoodemouser.com"),
2531
("res_model", "=", "res.users"),
26-
("res_id", "=", self.env.ref("base.user_demo").id),
32+
("res_id", "=", self.user.id),
2733
]
2834
attachment_added_count = self.env["ir.attachment"].search_count(domain)
2935
self.assertEqual(attachment_added_count, 1)

0 commit comments

Comments
 (0)