1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2014-TODAY OpenERP SA (http://www.openerp.com)
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##############################################################################
22 from openerp.osv import fields, osv
27 class IrAttachment(osv.Model):
28 """ Update partner to add a field about notification preferences """
29 _name = "ir.attachment"
30 _inherit = 'ir.attachment'
101 'key': 'presentation',
102 'keynote': 'presentation',
122 'numbers': 'spreadsheet',
125 'odp': 'presentation',
126 'ods': 'spreadsheet',
131 'p12': 'certificate',
135 'pem': 'certificate',
136 'pfx': 'certificate',
145 'pps': 'presentation',
146 'ppt': 'presentation',
160 'sxc': 'spreadsheet',
180 'xls': 'spreadsheet',
181 'xlsx': 'spreadsheet',
186 def get_attachment_type(self, cr, uid, ids, name, args, context=None):
188 for attachment in self.browse(cr, uid, ids, context=context):
189 fileext = os.path.splitext(attachment.datas_fname or '')[1].lower()[1:]
190 result[attachment.id] = self._fileext_to_type.get(fileext, 'unknown')
194 'file_type_icon': fields.function(get_attachment_type, type='char', string='File Type Icon'),
195 'file_type': fields.related('file_type_icon', type='char'), # FIXME remove in trunk