From 9991362a25232bf5f5cdfdf1680340822df44bab Mon Sep 17 00:00:00 2001 From: ernesto Date: Thu, 25 Apr 2019 15:07:56 -0400 Subject: [PATCH] [MIG] document_url: Migration to 12.0 --- document_url/README.rst | 18 +++-- document_url/__manifest__.py | 4 +- document_url/readme/USAGE.rst | 8 +- document_url/static/description/index.html | 46 +++++++++-- document_url/static/src/js/url.js | 91 +++++++--------------- document_url/static/src/less/url.less | 9 --- document_url/static/src/xml/url.xml | 12 ++- document_url/view/document_url_view.xml | 1 - document_url/wizard/document_url.py | 3 +- 9 files changed, 95 insertions(+), 97 deletions(-) delete mode 100644 document_url/static/src/less/url.less diff --git a/document_url/README.rst b/document_url/README.rst index 83d023a9..dc96b722 100644 --- a/document_url/README.rst +++ b/document_url/README.rst @@ -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 `_. 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 `_. +`feedback `_. 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 `_ project on GitHub. +This module is part of the `OCA/knowledge `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/document_url/__manifest__.py b/document_url/__manifest__.py index 828cb38d..376edae6 100644 --- a/document_url/__manifest__.py +++ b/document_url/__manifest__.py @@ -3,11 +3,11 @@ # Copyright 2016 ACSONE SA/NV () { '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', diff --git a/document_url/readme/USAGE.rst b/document_url/readme/USAGE.rst index e3b549bc..bdd8e738 100644 --- a/document_url/readme/USAGE.rst +++ b/document_url/readme/USAGE.rst @@ -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. diff --git a/document_url/static/description/index.html b/document_url/static/description/index.html index 4ad6cd5a..83a463df 100644 --- a/document_url/static/description/index.html +++ b/document_url/static/description/index.html @@ -367,7 +367,27 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/knowledge Translate me on Weblate Try me on Runbot

+

Beta + License: AGPL-3 + OCA/knowledge + Translate me on Weblate + Try me on Runbot +

Module that allows to attach an URL as a document.

Table of contents

@@ -385,17 +405,27 @@ ul.auto-toc {

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.
  • -
+
    +
  1. Open the form view of an object (Example: Customer Invoice + INV/2019/0007). +
  2. +
  3. Go to the chatter and click on the attached icon.
  4. +
  5. Click Add URL link.
  6. +
  7. Fill the wizard fields and click on Add button.
  8. +
  9. You will see a new URL attachment in the set of + attachments related to + the object. +
  10. +

Bug Tracker

Bugs are tracked on GitHub 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.

+ feedback. +

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

@@ -424,7 +454,9 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

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 project on GitHub.

+

This module is part of the OCA/knowledge + project on GitHub.

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

diff --git a/document_url/static/src/js/url.js b/document_url/static/src/js/url.js index 08062fd1..3a6b1ece 100644 --- a/document_url/static/src/js/url.js +++ b/document_url/static/src/js/url.js @@ -1,76 +1,39 @@ /* Copyright 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com) * Pedro M. Baeza * Copyright 2016 ACSONE SA/NV () + * 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(); - }, - }); - }); diff --git a/document_url/static/src/less/url.less b/document_url/static/src/less/url.less deleted file mode 100644 index 2e668f63..00000000 --- a/document_url/static/src/less/url.less +++ /dev/null @@ -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; - } -} diff --git a/document_url/static/src/xml/url.xml b/document_url/static/src/xml/url.xml index 75834e9f..dbc0adfa 100644 --- a/document_url/static/src/xml/url.xml +++ b/document_url/static/src/xml/url.xml @@ -1,8 +1,12 @@ + - -
  • - Add URL... -
  • + + + + Add URL + +
    diff --git a/document_url/view/document_url_view.xml b/document_url/view/document_url_view.xml index 7f1037b0..0c7dcffe 100644 --- a/document_url/view/document_url_view.xml +++ b/document_url/view/document_url_view.xml @@ -4,7 +4,6 @@ diff --git a/document_url/wizard/document_url.py b/document_url/wizard/document_url.py index cd9df144..717f70a5 100644 --- a/document_url/wizard/document_url.py +++ b/document_url/wizard/document_url.py @@ -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'}