mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-26 02:18:40 -06:00
Fixed review
This commit is contained in:
parent
00df69a46c
commit
a63f0b3dbf
@ -23,7 +23,7 @@ To use this module, you need to:
|
||||
|
||||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||
:alt: Try me on Runbot
|
||||
:target: https://runbot.odoo-community.org/runbot/118/9.0
|
||||
:target: https://runbot.odoo-community.org/runbot/118/10.0
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
@ -2,7 +2,7 @@
|
||||
# © 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com)
|
||||
# Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
|
||||
# © 2016 ACSONE SA/NV (<http://acsone.eu>)
|
||||
from odoo import models, fields, api, _
|
||||
from odoo import models, fields, api
|
||||
try:
|
||||
# Python 3
|
||||
from urllib import parse as urlparse
|
||||
@ -20,20 +20,21 @@ class AddUrlWizard(models.TransientModel):
|
||||
def action_add_url(self):
|
||||
"""Adds the URL with the given name as an ir.attachment record."""
|
||||
|
||||
if not self._context.get('active_model'):
|
||||
context = self.env.context
|
||||
if not context.get('active_model'):
|
||||
return
|
||||
attachment_obj = self.env['ir.attachment']
|
||||
for form in self:
|
||||
url = urlparse(form.url)
|
||||
if not url.scheme:
|
||||
url = urlparse('%s%s' % ('http://', form.url))
|
||||
for active_id in self._context.get('active_ids', []):
|
||||
for active_id in context.get('active_ids', []):
|
||||
attachment = {
|
||||
'name': form.name,
|
||||
'type': 'url',
|
||||
'url': url.geturl(),
|
||||
'res_id': active_id,
|
||||
'res_model': self._context.get('active_model')
|
||||
'res_model': context.get('active_model')
|
||||
}
|
||||
attachment_obj.create(attachment)
|
||||
return False
|
||||
return False
|
||||
|
Loading…
Reference in New Issue
Block a user