[IMP] document_url: black, isort

This commit is contained in:
Manuel Calero
2020-03-11 10:28:27 +01:00
committed by Bhavesh Heliconia
parent 0211bf41c2
commit 9260841adf
6 changed files with 47 additions and 61 deletions

View File

@@ -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"}