mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-13 15:34:49 -06:00
[IMP] document_url: black, isort
This commit is contained in:
parent
0211bf41c2
commit
9260841adf
@ -1,23 +1,15 @@
|
||||
# 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 2020 Tecnativa - Manuel Calero
|
||||
{
|
||||
'name': 'URL attachment',
|
||||
'version': '12.0.1.0.0',
|
||||
'category': 'Tools',
|
||||
'author': "Tecnativa,"
|
||||
"Odoo Community Association (OCA)",
|
||||
'website': 'https://github.com/OCA/knowledge',
|
||||
'license': 'AGPL-3',
|
||||
'depends': [
|
||||
'document',
|
||||
],
|
||||
'data': [
|
||||
'view/document_url_view.xml',
|
||||
'security/ir.model.access.csv',
|
||||
],
|
||||
'qweb': [
|
||||
'static/src/xml/url.xml',
|
||||
],
|
||||
'installable': True,
|
||||
"name": "URL attachment",
|
||||
"version": "13.0.1.0.0",
|
||||
"category": "Tools",
|
||||
"author": "Tecnativa," "Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/knowledge",
|
||||
"license": "AGPL-3",
|
||||
"data": ["view/document_url_view.xml", "security/ir.model.access.csv"],
|
||||
"qweb": ["static/src/xml/url.xml"],
|
||||
"installable": True,
|
||||
}
|
||||
|
@ -3,3 +3,4 @@
|
||||
|
||||
* Pedro M. Baeza
|
||||
* Ernesto Tejeda
|
||||
* Manuel Calero
|
||||
|
@ -367,7 +367,7 @@ 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/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><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-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/13.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">
|
||||
@ -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>.
|
||||
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:%2012.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:%2013.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">
|
||||
@ -428,7 +428,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
|
||||
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/12.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/13.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>
|
||||
|
@ -2,6 +2,7 @@
|
||||
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
|
||||
* Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
|
||||
* Copyright 2019 Tecnativa - Ernesto Tejeda
|
||||
* Copyright 2020 Tecnativa - Manuel Calero
|
||||
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
*/
|
||||
odoo.define('document_url', function (require) {
|
||||
@ -13,13 +14,8 @@ odoo.define('document_url', function (require) {
|
||||
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) {
|
||||
_onAddUrl: function () {
|
||||
// Opens wizard to add an URL attachment to the current record
|
||||
this.do_action('document_url.action_ir_attachment_add_url', {
|
||||
additional_context: {
|
||||
'active_id': this.currentResID,
|
||||
@ -29,11 +25,8 @@ odoo.define('document_url', function (require) {
|
||||
on_close: this._onAddedUrl.bind(this),
|
||||
});
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_onAddedUrl: function () {
|
||||
this.trigger_up('reload_attachment_box');
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
@ -6,25 +6,24 @@ from odoo.tests import common
|
||||
class TestDocumentUrl(common.TransactionCase):
|
||||
def setUp(self):
|
||||
super(TestDocumentUrl, self).setUp()
|
||||
wizard_add_url = self.env['ir.attachment.add_url']
|
||||
wizard_add_url = self.env["ir.attachment.add_url"]
|
||||
ctx = {
|
||||
'active_model': 'res.users',
|
||||
'active_id': self.env.ref('base.user_demo').id,
|
||||
'active_ids': [self.env.ref('base.user_demo').id]
|
||||
"active_model": "res.users",
|
||||
"active_id": self.env.ref("base.user_demo").id,
|
||||
"active_ids": [self.env.ref("base.user_demo").id],
|
||||
}
|
||||
self.wizard_add_url = wizard_add_url.with_context(ctx).create({
|
||||
'name': 'Demo User (Website)',
|
||||
'url': 'http://www.odoodemouser.com'
|
||||
})
|
||||
self.wizard_add_url = wizard_add_url.with_context(ctx).create(
|
||||
{"name": "Demo User (Website)", "url": "http://www.odoodemouser.com"}
|
||||
)
|
||||
|
||||
def test_add_url_attachment(self):
|
||||
self.wizard_add_url.action_add_url()
|
||||
domain = [
|
||||
('type', '=', 'url'),
|
||||
('name', '=', 'Demo User (Website)'),
|
||||
('url', '=', 'http://www.odoodemouser.com'),
|
||||
('res_model', '=', 'res.users'),
|
||||
('res_id', '=', self.env.ref('base.user_demo').id)
|
||||
("type", "=", "url"),
|
||||
("name", "=", "Demo User (Website)"),
|
||||
("url", "=", "http://www.odoodemouser.com"),
|
||||
("res_model", "=", "res.users"),
|
||||
("res_id", "=", self.env.ref("base.user_demo").id),
|
||||
]
|
||||
attachment_added_count = self.env['ir.attachment'].search_count(domain)
|
||||
attachment_added_count = self.env["ir.attachment"].search_count(domain)
|
||||
self.assertEqual(attachment_added_count, 1)
|
||||
|
@ -1,33 +1,34 @@
|
||||
# Copyright 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com)
|
||||
# Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
|
||||
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>)
|
||||
from odoo import fields, models
|
||||
from urllib import parse
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class AddUrlWizard(models.Model):
|
||||
_name = 'ir.attachment.add_url'
|
||||
_description = 'Wizard to add URL attachment'
|
||||
_name = "ir.attachment.add_url"
|
||||
_description = "Wizard to add URL attachment"
|
||||
|
||||
name = fields.Char('Name', required=True)
|
||||
url = fields.Char('URL', required=True)
|
||||
name = fields.Char("Name", required=True)
|
||||
url = fields.Char("URL", required=True)
|
||||
|
||||
def action_add_url(self):
|
||||
"""Adds the URL with the given name as an ir.attachment record."""
|
||||
if not self.env.context.get('active_model'):
|
||||
if not self.env.context.get("active_model"):
|
||||
return
|
||||
attachment_obj = self.env['ir.attachment']
|
||||
attachment_obj = self.env["ir.attachment"]
|
||||
for form in self:
|
||||
url = parse.urlparse(form.url)
|
||||
if not url.scheme:
|
||||
url = parse.urlparse('%s%s' % ('http://', form.url))
|
||||
for active_id in self.env.context.get('active_ids', []):
|
||||
url = parse.urlparse("{}{}".format("http://", form.url))
|
||||
for active_id in self.env.context.get("active_ids", []):
|
||||
attachment = {
|
||||
'name': form.name,
|
||||
'type': 'url',
|
||||
'url': url.geturl(),
|
||||
'res_id': active_id,
|
||||
'res_model': self.env.context['active_model'],
|
||||
"name": form.name,
|
||||
"type": "url",
|
||||
"url": url.geturl(),
|
||||
"res_id": active_id,
|
||||
"res_model": self.env.context["active_model"],
|
||||
}
|
||||
attachment_obj.create(attachment)
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
return {"type": "ir.actions.act_window_close"}
|
||||
|
Loading…
Reference in New Issue
Block a user