[MIG] document_url: Migration to 14.0

TT30263
This commit is contained in:
Víctor Martínez 2021-10-11 12:10:26 +02:00 committed by Bhavesh Heliconia
parent 4ec002bcb9
commit b029c7ac0a
6 changed files with 38 additions and 36 deletions

View File

@ -14,13 +14,13 @@ URL attachment
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github
:target: https://github.com/OCA/knowledge/tree/13.0/document_url :target: https://github.com/OCA/knowledge/tree/14.0/document_url
:alt: OCA/knowledge :alt: OCA/knowledge
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/knowledge-13-0/knowledge-13-0-document_url :target: https://translation.odoo-community.org/projects/knowledge-14-0/knowledge-14-0-document_url
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/118/13.0 :target: https://runbot.odoo-community.org/runbot/118/14.0
:alt: Try me on Runbot :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@ -50,7 +50,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/knowledge/issues>`_. Bugs are tracked on `GitHub Issues <https://github.com/OCA/knowledge/issues>`_.
In case of trouble, please check there if your issue has already been reported. In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/knowledge/issues/new?body=module:%20document_url%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. `feedback <https://github.com/OCA/knowledge/issues/new?body=module:%20document_url%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues. Do not contact contributors directly about support or help with technical issues.
@ -86,6 +86,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/knowledge <https://github.com/OCA/knowledge/tree/13.0/document_url>`_ project on GitHub. This module is part of the `OCA/knowledge <https://github.com/OCA/knowledge/tree/14.0/document_url>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" /> <meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>URL attachment</title> <title>URL attachment</title>
<style type="text/css"> <style type="text/css">
@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" 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" 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" href="https://github.com/OCA/knowledge/tree/13.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" href="https://translation.odoo-community.org/projects/knowledge-13-0/knowledge-13-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" href="https://runbot.odoo-community.org/runbot/118/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p> <p><a class="reference external" 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" 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" href="https://github.com/OCA/knowledge/tree/14.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" href="https://translation.odoo-community.org/projects/knowledge-14-0/knowledge-14-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" href="https://runbot.odoo-community.org/runbot/118/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>Module that allows to attach an URL as a document.</p> <p>Module that allows to attach an URL as a document.</p>
<p><strong>Table of contents</strong></p> <p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents"> <div class="contents local topic" id="contents">
@ -399,7 +399,7 @@ the object.</li>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/knowledge/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/knowledge/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/knowledge/issues/new?body=module:%20document_url%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <a class="reference external" href="https://github.com/OCA/knowledge/issues/new?body=module:%20document_url%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@ -430,7 +430,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/knowledge/tree/13.0/document_url">OCA/knowledge</a> project on GitHub.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/knowledge/tree/14.0/document_url">OCA/knowledge</a> project on GitHub.</p>
<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> <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>
</div> </div>
</div> </div>

View File

@ -3,30 +3,31 @@
* Copyright 2016 ACSONE SA/NV (<http://acsone.eu>) * Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
* Copyright 2019 Tecnativa - Ernesto Tejeda * Copyright 2019 Tecnativa - Ernesto Tejeda
* Copyright 2020 Tecnativa - Manuel Calero * Copyright 2020 Tecnativa - Manuel Calero
* Copyright 2021 Tecnativa - Víctor Martínez
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
*/ */
odoo.define("document_url", function (require) { odoo.define("document_url", function (require) {
"use strict"; "use strict";
var AttachmentBox = require("mail.AttachmentBox"); const AttachmentBox = require("mail/static/src/components/attachment_box/attachment_box.js");
const {patch} = require("web.utils");
AttachmentBox.include({ patch(AttachmentBox, "document_url", {
events: _.extend(AttachmentBox.prototype.events, { _onAddUrl() {
"click button.o_add_url_button": "_onAddUrl", this.env.bus.trigger("do-action", {
}), action: "document_url.action_ir_attachment_add_url",
_onAddUrl: function () { options: {
// Opens wizard to add an URL attachment to the current record additional_context: {
this.do_action("document_url.action_ir_attachment_add_url", { active_id: this.thread.id,
additional_context: { active_ids: [this.thread.id],
active_id: this.currentResID, active_model: this.thread.model,
active_ids: [this.currentResID], },
active_model: this.currentResModel, on_close: this._onAddedUrl.bind(this),
}, },
on_close: this._onAddedUrl.bind(this),
}); });
}, },
_onAddedUrl: function () { _onAddedUrl() {
this.trigger_up("reload_attachment_box"); this.trigger("reload");
}, },
}); });
}); });

View File

@ -1,17 +1,18 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright 2018 Tecnativa - Ernesto Tejeda <!-- Copyright 2018 Tecnativa - Ernesto Tejeda
Copyright 2021 Tecnativa - Víctor Martínez
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<templates id="template" xml:space="preserve"> <templates xml:space="preserve">
<t t-extend="mail.AttachmentBox"> <t t-inherit="mail.AttachmentBox" t-inherit-mode="extension" owl="1">
<t t-jquery="button.o_AttachmentBox_buttonAdd" t-operation="after"> <xpath expr="//button[hasclass('o_AttachmentBox_buttonAdd')]" position="after">
<button <button
type="button" type="button"
class="o_add_url_button btn btn-link" class="o_add_url_button btn btn-link"
t-on-click="_onClickAdd" t-on-click="_onAddUrl"
> >
<i class="fa fa-plus-square" /> <i class="fa fa-plus-square" />
Add URL Add URL
</button> </button>
</t> </xpath>
</t> </t>
</templates> </templates>

View File

@ -5,7 +5,7 @@ from odoo.tests import common
class TestDocumentUrl(common.TransactionCase): class TestDocumentUrl(common.TransactionCase):
def setUp(self): def setUp(self):
super(TestDocumentUrl, self).setUp() super().setUp()
wizard_add_url = self.env["ir.attachment.add_url"] wizard_add_url = self.env["ir.attachment.add_url"]
ctx = { ctx = {
"active_model": "res.users", "active_model": "res.users",

View File

@ -9,12 +9,12 @@
<script type="text/javascript" src="/document_url/static/src/js/url.js" /> <script type="text/javascript" src="/document_url/static/src/js/url.js" />
</xpath> </xpath>
</template> </template>
<record model='ir.actions.act_window' id='action_ir_attachment_add_url'> <record model="ir.actions.act_window" id='action_ir_attachment_add_url'>
<field name='name'>Add URL</field> <field name="name">Add URL</field>
<field name='res_model'>ir.attachment.add_url</field> <field name="res_model">ir.attachment.add_url</field>
<field name='type'>ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name='target'>new</field> <field name="target">new</field>
<field name='view_mode'>form</field> <field name="view_mode">form</field>
</record> </record>
<record model="ir.ui.view" id="view_ir_attachment_add_url_form"> <record model="ir.ui.view" id="view_ir_attachment_add_url_form">
<field name="name">ir.attachment.add_url.form</field> <field name="name">ir.attachment.add_url.form</field>