Skip to content

[20.0][MIG] document_url: Migration to version 20.0 - #668

Open
adasatorres-tecnativa wants to merge 47 commits into
OCA:20.0from
Tecnativa:20.0-mig-document_url
Open

adasatorres-tecnativa wants to merge 47 commits into
OCA:20.0from
Tecnativa:20.0-mig-document_url

Conversation

@adasatorres-tecnativa

Copy link
Copy Markdown

@Tecnativa TT65747

@oca-cla-bot

oca-cla-bot Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

The following commit authors need to sign the Contributor License Agreement:

CLA not signed

@fcvalgar

Copy link
Copy Markdown

Could you please check Runboat @adasatorres-tecnativa ? It's returning the following error: {"detail":"Not Found"}.

Thanks!

pedrobaeza and others added 25 commits November 24, 2026 15:30
[MIG] document_url

* bump version to 9.0.1.0.0 and make it installable
* Update JS structure
* Add css in order to be compliant with odoo style
* Add a README.rst and OCA conventions
* Improve selector
* add fr.po for fr translation
* open link with target='_blank'
Without this patch, when you hover on the menu item, its background color does not change, and its cursor is a text one.

With this patch, the menu item styling matches those available in all surrounding menus.
Replace char © by word Copyright
Change format in usage description
Currently translated at 100.0% (14 of 14 strings)

Translation: knowledge-12.0/knowledge-12.0-document_url
Translate-URL: https://translation.odoo-community.org/projects/knowledge-12-0/knowledge-12-0-document_url/hr/
[MIG] document_url: Migration to 14.0
Define the add attachment and add URL buttons on the same line.
Allow downloading of url type attachments by clicking on the icon or the name.
Define the name of the url type attachments as links (allows to open it in a new tab).
Hide the download button for url attachments.
Force to set mimetype to "application/link" for url attachments.
Displays a link icon for url attachments.
TT30263
Currently translated at 100.0% (14 of 14 strings)

Translation: knowledge-16.0/knowledge-16.0-document_url
Translate-URL: https://translation.odoo-community.org/projects/knowledge-16-0/knowledge-16-0-document_url/it/
Currently translated at 100.0% (14 of 14 strings)

Translation: knowledge-16.0/knowledge-16.0-document_url
Translate-URL: https://translation.odoo-community.org/projects/knowledge-16-0/knowledge-16-0-document_url/it/
Other modules like web_pwa_oca uses url field for storing an indexed
path for later being searched in the controller, so let's restrict the
mimetype change if both url and type=url is set.
Currently translated at 100.0% (14 of 14 strings)

Translation: knowledge-16.0/knowledge-16.0-document_url
Translate-URL: https://translation.odoo-community.org/projects/knowledge-16-0/knowledge-16-0-document_url/it/
Currently translated at 92.8% (13 of 14 strings)

Translation: knowledge-16.0/knowledge-16.0-document_url
Translate-URL: https://translation.odoo-community.org/projects/knowledge-16-0/knowledge-16-0-document_url/sl/
Currently translated at 100.0% (14 of 14 strings)

Translation: knowledge-16.0/knowledge-16.0-document_url
Translate-URL: https://translation.odoo-community.org/projects/knowledge-16-0/knowledge-16-0-document_url/it/
DemchukM and others added 16 commits November 24, 2026 15:30
Currently translated at 100.0% (17 of 17 strings)

Translation: knowledge-16.0/knowledge-16.0-document_url
Translate-URL: https://translation.odoo-community.org/projects/knowledge-16-0/knowledge-16-0-document_url/pt/
Currently translated at 100.0% (17 of 17 strings)

Translation: knowledge-17.0/knowledge-17.0-document_url
Translate-URL: https://translation.odoo-community.org/projects/knowledge-17-0/knowledge-17-0-document_url/sv/
Currently translated at 100.0% (17 of 17 strings)

Translation: knowledge-17.0/knowledge-17.0-document_url
Translate-URL: https://translation.odoo-community.org/projects/knowledge-17-0/knowledge-17-0-document_url/ca/
Fix download atachment widget.

Document_url when activated causes error when opening attachment link on the chatter window
This commit (odoo/odoo@366676c) move download buttons into a sub-component.
I modified the module behavior to use canDownload() method instead of adding a t-if in the view and prevent the chatter component from breaking when the message has attachments.
- In a first step, instead of replacing a node content with its verbatim copy, we uses the xpath "replace" command with "$0" magic keyword to move all the <t> content into a <div>.
- In a second step, the "Add URL" button is added after the existing "Attach files"button.
Currently translated at 76.4% (13 of 17 strings)

Translation: knowledge-19.0/knowledge-19.0-document_url
Translate-URL: https://translation.odoo-community.org/projects/knowledge-19-0/knowledge-19-0-document_url/sl/
Currently translated at 100.0% (17 of 17 strings)

Translation: knowledge-19.0/knowledge-19.0-document_url
Translate-URL: https://translation.odoo-community.org/projects/knowledge-19-0/knowledge-19-0-document_url/sl/
Currently translated at 58.8% (10 of 17 strings)

Translation: knowledge-19.0/knowledge-19.0-document_url
Translate-URL: https://translation.odoo-community.org/projects/knowledge-19-0/knowledge-19-0-document_url/pl/
@adasatorres-tecnativa

Copy link
Copy Markdown
Author

@fcvalgar Check now.

@fcvalgar

Copy link
Copy Markdown

Thanks for fixing the Runboat issue!

I can now access the test environment, but I get the following error when trying to add an attachment from the chatter:

UncaughtPromiseError > TypeError: Cannot read properties of undefined (reading 'inMessage')

The error occurs in the mail.AttachmentList template. It seems to be related to the env.inMessage reference in document_url/static/src/xml/url.xml, which may no longer be compatible with Odoo 20.

This issue prevents me from completing the functional tests.

Could you please check it? I will test the module again once it is fixed.

Thanks for your work!

@adasatorres-tecnativa

Copy link
Copy Markdown
Author

@fcvalgar ready .

@fcvalgar fcvalgar left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work on this migration @adasatorres-tecnativa and for fixing the previously reported error!

I have performed the following functional tests in Odoo 20:

Test 1: OK with remarks – Adding a URL attachment works, but a standard file must be attached first.
Test 2: OK – Opening the attached URL in a new browser tab.
Test 3: OK – Adding standard file attachments alongside URL attachments.
Test 4: OK – Removing a URL attachment without affecting other attachments.

In the latest Odoo versions, clicking the paperclip icon when there are no attachments opens the file browser directly. The Add URL option is only available after attaching at least one file.

I suggest updating the README to explain this prerequisite or, alternatively, adapting the module to allow users to add a URL without attaching a file first.

image image

Functional approval with this remark. Thanks!

@fcvalgar fcvalgar left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on this migration @adasatorres-tecnativa and thanks for improving the behavior of the attachment button.

I have performed the following tests in Odoo 20:
Test 1: OK - The attachment button now opens the attachments area and shows the Add URL option without requiring a first standard attachment.
Test 2: OK - A URL attachment can be created from the chatter and is correctly linked to the record.
Test 3: OK - The attached URL opens correctly in a new browser tab.
Test 4: OK - URL attachments and standard file attachments work together correctly.
Test 5: OK - A URL attachment can be removed without affecting other attachments.

Functional approval.

@pedrobaeza

Copy link
Copy Markdown
Member

/ocabot migration document_url

@OCA-git-bot OCA-git-bot added this to the 20.0 milestone Nov 25, 2026
@OCA-git-bot OCA-git-bot mentioned this pull request Nov 25, 2026
2 of 9 tasks
Comment on lines +66 to +76
onClickUnlink(attachment) {
if (this.env.inComposer) {
return this.props.unlinkAttachment(attachment);
}
this.dialog.add(ConfirmationDialog, {
body: _t('Do you really want to delete "%s"?', attachment.name),
// eslint-disable-next-line no-empty-function
cancel: () => {},
confirm: () => this.onConfirmUnlink([attachment]),
});
},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unlinkAttachment prop doesn't exist anymore in 20.0, this breaks removing any attachment in the composer. Core already asks for confirmation, so the override can go:

Suggested change
onClickUnlink(attachment) {
if (this.env.inComposer) {
return this.props.unlinkAttachment(attachment);
}
this.dialog.add(ConfirmationDialog, {
body: _t('Do you really want to delete "%s"?', attachment.name),
// eslint-disable-next-line no-empty-function
cancel: () => {},
confirm: () => this.onConfirmUnlink([attachment]),
});
},

Comment on lines +40 to +50
onClickAddAttachments(ev) {
ev.stopPropagation();
const isOpening = this.state.activePanel !== this.CHATTER_PANEL.ATTACHMENT;
this.state.activePanel = isOpening
? this.CHATTER_PANEL.ATTACHMENT
: this.CHATTER_PANEL.NONE;
if (isOpening) {
this.rootRef().scrollTop = 0;
this.state.thread.scrollTop = "bottom";
}
},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the empty case needs changes, keep core behavior otherwise:

Suggested change
onClickAddAttachments(ev) {
ev.stopPropagation();
const isOpening = this.state.activePanel !== this.CHATTER_PANEL.ATTACHMENT;
this.state.activePanel = isOpening
? this.CHATTER_PANEL.ATTACHMENT
: this.CHATTER_PANEL.NONE;
if (isOpening) {
this.rootRef().scrollTop = 0;
this.state.thread.scrollTop = "bottom";
}
},
onClickAddAttachments(ev) {
if (this.attachments.length) {
return super.onClickAddAttachments(...arguments);
}
ev.stopPropagation();
this.closeSearch();
this.state.activePanel =
this.state.activePanel === this.CHATTER_PANEL.ATTACHMENT
? this.CHATTER_PANEL.NONE
: this.CHATTER_PANEL.ATTACHMENT;
},

expr="//div[hasclass('o-mail-AttachmentContainer')]"
position="attributes"
>
<attribute name="t-att-class">{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This drops o-inChatter and the !this.props.isSelecting check from core. Better put o_attachment_url_container on the chip and don't override the container class.

>
<i class="oi oi-filled me-1" data-icon="link" />
</a>
<span class="text-truncate ms-1" t-esc="attachment.name" />

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<span class="text-truncate ms-1" t-esc="attachment.name" />
<span class="text-truncate ms-1" t-out="attachment.name" />

Also .o_attachment_url_delete in the SCSS is no longer used.

<xpath expr="//div[hasclass('o-mail-Attachment-hover')]" position="attributes">
<attribute
name="t-if"
>!isMobileOS and attachment.mimetype !== 'application/link'</attribute>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
>!isMobileOS and attachment.mimetype !== 'application/link'</attribute>
>!this.isMobileOS and attachment.mimetype !== 'application/link'</attribute>

Comment on lines +73 to +78
<xpath expr="//Actions" position="replace">
<Actions
t-elif="this.isMobileOS and attachment.mimetype !== 'application/link'"
actions="getActions(attachment)"
/>
</xpath>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lost !this.props.isSelecting and group.duplicates; also getActions needs this. now (same as env.inMessage). Patch only the condition:

Suggested change
<xpath expr="//Actions" position="replace">
<Actions
t-elif="this.isMobileOS and attachment.mimetype !== 'application/link'"
actions="getActions(attachment)"
/>
</xpath>
<xpath expr="//Actions" position="attributes">
<attribute
name="t-elif"
>!this.props.isSelecting and attachment.mimetype !== 'application/link'</attribute>
</xpath>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.