From 6b1f475bb5a873953044e4ff7a4e5d49638dd738 Mon Sep 17 00:00:00 2001 From: Wolfgang Taferner Date: Thu, 22 Jan 2015 16:36:37 +0100 Subject: [PATCH] [FIX] Missing possibility to define a file_type on creation/write of a document which leads to an error message in case the indexer could not retrieve the content type automatically. --- addons/document/document.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/document/document.py b/addons/document/document.py index 96868d3d66b..29b8aa1e8b3 100644 --- a/addons/document/document.py +++ b/addons/document/document.py @@ -125,18 +125,18 @@ class document_file(osv.osv): if vals.get('res_id', False) and vals.get('res_model', False) and not vals.get('partner_id', False): vals['partner_id'] = self.__get_partner_id(cr, uid, vals['res_model'], vals['res_id'], context) if vals.get('datas', False): - vals['file_type'], vals['index_content'] = self._index(cr, uid, vals['datas'].decode('base64'), vals.get('datas_fname', False), None) + vals['file_type'], vals['index_content'] = self._index(cr, uid, vals['datas'].decode('base64'), vals.get('datas_fname', False), vals.get('file_type', None)) return super(document_file, self).create(cr, uid, vals, context) def write(self, cr, uid, ids, vals, context=None): if context is None: context = {} if vals.get('datas', False): - vals['file_type'], vals['index_content'] = self._index(cr, uid, vals['datas'].decode('base64'), vals.get('datas_fname', False), None) + vals['file_type'], vals['index_content'] = self._index(cr, uid, vals['datas'].decode('base64'), vals.get('datas_fname', False), vals.get('file_type', None)) return super(document_file, self).write(cr, uid, ids, vals, context) def _index(self, cr, uid, data, datas_fname, file_type): - mime, icont = cntIndex.doIndex(data, datas_fname, file_type or None, None) + mime, icont = cntIndex.doIndex(data, datas_fname, file_type or None, None) icont_u = ustr(icont) return mime, icont_u