├── README.md ├── website_document ├── __init__.py ├── __openerp__.py └── website_document.py └── README.rst /README.md: -------------------------------------------------------------------------------- 1 | # odoo-knowledge-extra 2 | -------------------------------------------------------------------------------- /website_document/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import website_document 4 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | .. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg 2 | :alt: License 3 | 4 | Helpers for document management 5 | =============================== 6 | 7 | * website_document - download url for odoo-documents 8 | 9 | 10 | Credits 11 | ======= 12 | http://fkankan.se 13 | 14 | Contributors 15 | ------------ 16 | 17 | * Anders Wallenquist 18 | * Haojun Zou 19 | -------------------------------------------------------------------------------- /website_document/__openerp__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | ############################################################################## 3 | # 4 | # Copyright (C) 2015- Vertel AB (). 5 | # 6 | # This progrupdateam is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Affero General Public License as 8 | # published by the Free Software Foundation, either version 3 of the 9 | # License, or (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Affero General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Affero General Public License 17 | # along with this program. If not, see . 18 | # 19 | ############################################################################## 20 | 21 | { 22 | 'name': 'Website Document', 23 | 'category': 'knowledge', 24 | 'website': 'https://www.vertel.se', 25 | 'summary': 'Controller for download attachments', 26 | 'version': '1.0', 27 | 'description': """ 28 | 29 | Use this url: 30 | 31 | /attachment// 32 | 33 | Attachement are Odoo-attachment 34 | Filename are used only for display purposes. 35 | 36 | """, 37 | 'author': 'Vertel AB', 38 | 'license': 'AGPL-3', 39 | 'depends': [ 40 | 'website', 41 | 'document', 42 | ], 43 | 'data': [ ], 44 | 'qweb': [], 45 | 'installable': True, 46 | } 47 | -------------------------------------------------------------------------------- /website_document/website_document.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | ############################################################################## 3 | # 4 | # Copyright (C) 2015- Vertel AB (). 5 | # 6 | # This progrupdateam is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Affero General Public License as 8 | # published by the Free Software Foundation, either version 3 of the 9 | # License, or (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Affero General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Affero General Public License 17 | # along with this program. If not, see . 18 | # 19 | ############################################################################## 20 | 21 | from cStringIO import StringIO 22 | from openerp import models, fields, api, _ 23 | from openerp import SUPERUSER_ID 24 | from openerp import http 25 | from openerp.http import request 26 | #from openerp.http import request 27 | import werkzeug.urls 28 | import logging 29 | _logger = logging.getLogger(__name__) 30 | 31 | 32 | class WebsiteDocument(http.Controller): 33 | 34 | @http.route(['/attachment//'], type='http', auth="public", website=True) 35 | def get_attachment(self, attachment=None, file_name=None, **post): 36 | if attachment and attachment.datas: 37 | return http.send_file(StringIO(attachment.datas.decode('base64')), filename=attachment.datas_fname, mimetype=attachment.mimetype, mtime=attachment.write_date) 38 | 39 | --------------------------------------------------------------------------------