Fixed review

This commit is contained in:
Nicolás 2016-11-18 09:51:46 +00:00
parent a63f0b3dbf
commit ea8ebcdfbf
3 changed files with 4 additions and 6 deletions

View File

@ -41,8 +41,6 @@ Contributors
* Jonathan Nemry <jonathan.nemry@acsone.eu> * Jonathan Nemry <jonathan.nemry@acsone.eu>
* Pedro M. Baeza <pedro.baeza@tecnativa.com> * Pedro M. Baeza <pedro.baeza@tecnativa.com>
* Nicolás Ramos <contacto@difusionvisual.com>
* Antonio Cánovas <antonio.canovas@ingenieriacloud.com>
Maintainer Maintainer
---------- ----------

View File

@ -21,20 +21,20 @@ class AddUrlWizard(models.TransientModel):
"""Adds the URL with the given name as an ir.attachment record.""" """Adds the URL with the given name as an ir.attachment record."""
context = self.env.context context = self.env.context
if not context.get('active_model'): if not context['active_model']:
return return
attachment_obj = self.env['ir.attachment'] attachment_obj = self.env['ir.attachment']
for form in self: for form in self:
url = urlparse(form.url) url = urlparse(form.url)
if not url.scheme: if not url.scheme:
url = urlparse('%s%s' % ('http://', form.url)) url = urlparse('%s%s' % ('http://', form.url))
for active_id in context.get('active_ids', []): for active_id in context['active_ids', []]:
attachment = { attachment = {
'name': form.name, 'name': form.name,
'type': 'url', 'type': 'url',
'url': url.geturl(), 'url': url.geturl(),
'res_id': active_id, 'res_id': active_id,
'res_model': context.get('active_model') 'res_model': context['active_model']
} }
attachment_obj.create(attachment) attachment_obj.create(attachment)
return False return False