diff --git a/document_url/README.rst b/document_url/README.rst index 91b4afe0..833cf082 100644 --- a/document_url/README.rst +++ b/document_url/README.rst @@ -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 =========== diff --git a/document_url/wizard/document_url.py b/document_url/wizard/document_url.py index 0731ad6d..932060f7 100644 --- a/document_url/wizard/document_url.py +++ b/document_url/wizard/document_url.py @@ -2,7 +2,7 @@ # © 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com) # Pedro M. Baeza # © 2016 ACSONE SA/NV () -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 \ No newline at end of file + return False