-
-
Notifications
You must be signed in to change notification settings - Fork 394
[MIG] document_url port v10 #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f1040fb
3c0ed6b
65e4a19
6caf5e7
34e0bb4
b74597d
00df69a
a63f0b3
ea8ebcd
b5961b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,15 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <templates id="template" xml:space="preserve"> | ||
| <t t-name="AddUrlDocumentItem"> | ||
| <li class="oe_sidebar_add_url"> | ||
| <a class="oe_file_attachment">Add URL...</a> | ||
| </li> | ||
| </t> | ||
| <templates> | ||
| <t t-extend="Sidebar"> | ||
| <!-- oe_ for Odoo CE, and o_ for Odoo EE --> | ||
| <t t-jquery=".oe_sidebar_add_attachment, .o_sidebar_add_attachment" | ||
| t-operation="after"> | ||
| <li class="oe_sidebar_add_url" | ||
| t-if="section.name == 'files' and widget.options.editable"> | ||
| <a class="oe_file_attachment" | ||
| data-section="url_doc" | ||
| data-index="0">Add URL...</a> | ||
| </li> | ||
| </t> | ||
| </t> | ||
| </templates> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,41 +2,38 @@ | |
| # © 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com) | ||
| # Pedro M. Baeza <pedro.baeza@serviciosbaeza.com> | ||
| # © 2016 ACSONE SA/NV (<http://acsone.eu>) | ||
| from openerp.osv import fields, orm | ||
| from odoo import models, fields, api, _ | ||
| try: | ||
| # Python 3 | ||
| from urllib import parse as urlparse | ||
| except: | ||
| from urlparse import urlparse | ||
|
|
||
|
|
||
| class AddUrlWizard(orm.TransientModel): | ||
| class AddUrlWizard(models.TransientModel): | ||
| _name = 'ir.attachment.add_url' | ||
|
|
||
| _columns = { | ||
| '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, cr, uid, ids, context=None): | ||
| @api.multi | ||
| def action_add_url(self): | ||
| """Adds the URL with the given name as an ir.attachment record.""" | ||
| if context is None: | ||
| context = {} | ||
| if not context.get('active_model'): | ||
|
|
||
| if not self._context.get('active_model'): | ||
| return | ||
| attachment_obj = self.pool['ir.attachment'] | ||
| for form in self.browse(cr, uid, ids, context=context): | ||
| 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 context.get('active_ids', []): | ||
| for active_id in self._context.get('active_ids', []): | ||
| attachment = { | ||
| 'name': form.name, | ||
| 'type': 'url', | ||
| 'url': url.geturl(), | ||
| 'user_id': uid, | ||
| 'res_id': active_id, | ||
| 'res_model': context['active_model'], | ||
| 'res_model': self._context.get('active_model') | ||
| } | ||
| attachment_obj.create(cr, uid, attachment, context=context) | ||
| return {'type': 'ir.actions.act_close_wizard_and_reload_view'} | ||
| attachment_obj.create(attachment) | ||
| return False | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is the return value now empty? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand why this action repoen the wizard is it a "quick next encode"? I agree with @difusionvisual to replace this by return false...
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was because in older versions of Odoo, it didn't refresh the view and you didn't see the new attachment number. I don't know if this happens also in v10. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
self.env.contextinstead.