[MIG] document_url: Migration to 12.0

This commit is contained in:
ernesto 2019-04-25 15:07:56 -04:00 committed by Bhavesh Heliconia
parent e36e20e554
commit 9991362a25
9 changed files with 95 additions and 97 deletions

View File

@ -14,13 +14,13 @@ URL attachment
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github
:target: https://github.com/OCA/knowledge/tree/11.0/document_url
:target: https://github.com/OCA/knowledge/tree/12.0/document_url
:alt: OCA/knowledge
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/knowledge-11-0/knowledge-11-0-document_url
:target: https://translation.odoo-community.org/projects/knowledge-12-0/knowledge-12-0-document_url
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/118/11.0
:target: https://runbot.odoo-community.org/runbot/118/12.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@ -37,8 +37,12 @@ Usage
To use this module, you need to:
* go to menu more and click on add an url.
* Insert name and url into the wizard.
#. Open the form view of an object (Example: Customer Invoice INV/2019/0007).
#. Go to the chatter and click on the attached icon.
#. Click **Add URL** link.
#. Fill the wizard fields and click on Add button.
#. You will see a new **URL attachment** in the set of attachments related to
the object.
Bug Tracker
===========
@ -46,7 +50,7 @@ Bug Tracker
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.
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:%2011.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:%2012.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.
@ -80,6 +84,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/knowledge <https://github.com/OCA/knowledge/tree/11.0/document_url>`_ project on GitHub.
This module is part of the `OCA/knowledge <https://github.com/OCA/knowledge/tree/12.0/document_url>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -3,11 +3,11 @@
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
{
'name': 'URL attachment',
'version': '11.0.1.0.0',
'version': '12.0.1.0.0',
'category': 'Tools',
'author': "Tecnativa,"
"Odoo Community Association (OCA)",
'website': 'http://www.serviciosbaeza.com',
'website': 'https://github.com/OCA/knowledge',
'license': 'AGPL-3',
'depends': [
'document',

View File

@ -1,4 +1,8 @@
To use this module, you need to:
* go to menu more and click on add an url.
* Insert name and url into the wizard.
#. Open the form view of an object (Example: Customer Invoice INV/2019/0007).
#. Go to the chatter and click on the attached icon.
#. Click **Add URL** link.
#. Fill the wizard fields and click on Add button.
#. You will see a new **URL attachment** in the set of attachments related to
the object.

View File

@ -367,7 +367,27 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! 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/11.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-11-0/knowledge-11-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/11.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/12.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-12-0/knowledge-12-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/12.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><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
@ -385,17 +405,27 @@ ul.auto-toc {
<div class="section" id="usage">
<h1><a class="toc-backref" href="#id1">Usage</a></h1>
<p>To use this module, you need to:</p>
<ul class="simple">
<li>go to menu more and click on add an url.</li>
<li>Insert name and url into the wizard.</li>
</ul>
<ol class="arabic simple">
<li>Open the form view of an object (Example: Customer Invoice
INV/2019/0007).
</li>
<li>Go to the chatter and click on the attached icon.</li>
<li>Click <strong>Add URL</strong> link.</li>
<li>Fill the wizard fields and click on Add button.</li>
<li>You will see a new <strong>URL attachment</strong> in the set of
attachments related to
the object.
</li>
</ol>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
<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.
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:%2011.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:%2012.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>
</div>
<div class="section" id="credits">
@ -424,7 +454,9 @@ 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
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/knowledge/tree/11.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/12.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>
</div>
</div>

View File

@ -1,76 +1,39 @@
/* Copyright 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com)
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
* Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
* Copyright 2019 Tecnativa - Ernesto Tejeda
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
*/
odoo.define('document_url', function (require) {
"use strict";
var core = require('web.core');
var Sidebar = require('web.Sidebar');
var ActionManager = require('web.ActionManager');
var Context = require('web.Context');
var pyeval = require('web.pyeval');
var AttachmentBox = require('mail.AttachmentBox');
var _t = core._t,
QWeb = core.qweb;
Sidebar.include({
_redraw: function () {
var self = this;
this._super.apply(this, arguments);
self.$el.find("a[href]").attr('target', '_blank');
self.$el
.find('.oe_sidebar_add_attachment, .o_sidebar_add_attachment')
.after(QWeb.render('AddUrlDocumentItem', {widget: self}));
self.$el.find('.o_sidebar_add_url').on('click', function (e) {
self.on_url_doc();
AttachmentBox.include({
events: _.extend(AttachmentBox.prototype.events, {
"click span.o_add_url_button": "_onAddUrl",
}),
/**
* Opens wizard to add an URL attachment to the current record
*
* @private
* @param {MouseEvent} ev
*/
_onAddUrl: function (ev) {
this.do_action('document_url.action_ir_attachment_add_url', {
additional_context: {
'active_id': this.currentResID,
'active_ids': [this.currentResID],
'active_model': this.currentResModel,
},
on_close: this._onAddedUrl.bind(this),
});
},
on_url_doc: function (event) {
var self = this;
var env = self.env;
var view = self.getParent();
var ids = self.env.activeIds;
if (!_.isEmpty(ids)) {
var activeIdsContext = {
active_id: env.activeIds[0],
active_ids: env.activeIds,
active_model: env.model,
};
if (env.domain) {
activeIdsContext.active_domain = env.domain;
}
var context = new Context(env.context, activeIdsContext);
context = pyeval.eval('context', context);
self._rpc({
route: "/web/action/load",
params: {
action_id: "document_url.action_ir_attachment_add_url",
context: context,
},
}).done(function (result) {
self.getParent().do_action(result, {
additional_context: {
'active_ids': ids,
'active_id': [ids[0]],
'active_model': env.model,
},
});
});
}
},
/**
* @private
*/
_onAddedUrl: function () {
this.trigger_up('reload_attachment_box');
}
});
ActionManager = ActionManager.include({
ir_actions_act_close_wizard_and_reload_view: function (action, options) {
if (!this.dialog) {
options.on_close();
}
this.dialog_stop();
this.inner_widget.views[this.inner_widget.active_view.type].controller.reload();
return $.when();
},
});
});

View File

@ -1,9 +0,0 @@
.o_cp_sidebar {
.o_sidebar_add_url span {
padding: 3px 25px;
color: @btn-default-color;
}
.o_sidebar_add_url:hover {
background-color: @table-bg-hover;
}
}

View File

@ -1,8 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2018 Tecnativa - Ernesto Tejeda
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<templates id="template" xml:space="preserve">
<t t-name="AddUrlDocumentItem">
<li class="o_sidebar_add_url">
<span>Add URL...</span>
</li>
<t t-extend="mail.chatter.AttachmentBox">
<t t-jquery="span.o_upload_attachments_button" t-operation="after">
<span class="btn btn-link o_add_url_button"><span class="fa fa-plus-square"/> Add URL</span>
</t>
</t>
</templates>

View File

@ -4,7 +4,6 @@
<template id="assets_backend" name="google_drive assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/document_url/static/src/js/url.js"></script>
<link rel="stylesheet" type="text/less" href="/document_url/static/src/less/url.less"/>
</xpath>
</template>

View File

@ -7,6 +7,7 @@ from urllib import parse
class AddUrlWizard(models.Model):
_name = 'ir.attachment.add_url'
_description = 'Wizard to add URL attachment'
name = fields.Char('Name', required=True)
url = fields.Char('URL', required=True)
@ -29,4 +30,4 @@ class AddUrlWizard(models.Model):
'res_model': self.env.context['active_model'],
}
attachment_obj.create(attachment)
return {'type': 'ir.actions.act_close_wizard_and_reload_view'}
return {'type': 'ir.actions.act_window_close'}