mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-26 18:38:41 -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
|
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||||
:alt: Try me on Runbot
|
: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
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# © 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com)
|
# © 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com)
|
||||||
# Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
|
# Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
|
||||||
# © 2016 ACSONE SA/NV (<http://acsone.eu>)
|
# © 2016 ACSONE SA/NV (<http://acsone.eu>)
|
||||||
from odoo import models, fields, api, _
|
from odoo import models, fields, api
|
||||||
try:
|
try:
|
||||||
# Python 3
|
# Python 3
|
||||||
from urllib import parse as urlparse
|
from urllib import parse as urlparse
|
||||||
@ -20,20 +20,21 @@ class AddUrlWizard(models.TransientModel):
|
|||||||
def action_add_url(self):
|
def action_add_url(self):
|
||||||
"""Adds the URL with the given name as an ir.attachment record."""
|
"""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
|
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 self._context.get('active_ids', []):
|
for active_id in context.get('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': self._context.get('active_model')
|
'res_model': context.get('active_model')
|
||||||
}
|
}
|
||||||
attachment_obj.create(attachment)
|
attachment_obj.create(attachment)
|
||||||
return False
|
return False
|
Loading…
Reference in New Issue
Block a user