summaryrefslogtreecommitdiff
path: root/addons/document/document.py
diff options
context:
space:
mode:
authorVo Minh Thu <vmt@openerp.com>2013-01-04 10:39:53 +0100
committerVo Minh Thu <vmt@openerp.com>2013-01-04 10:39:53 +0100
commit5e8f418d4154bf70a4959de49f823cb9efbcbb34 (patch)
treedc6c9c84eb4aed76992c4426c7cdaf0cef52d0b9 /addons/document/document.py
parent013efb71cbc93e76f5b36e17a44d1916162aacbe (diff)
parentf881997d6007b7c1c7497ffa8a11eb885b919a2b (diff)
[MERGE] Forward port of 7.0 until rev. 8534.
bzr revid: vmt@openerp.com-20130104093953-p92uylaux9u24isn
Diffstat (limited to 'addons/document/document.py')
-rw-r--r--addons/document/document.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/addons/document/document.py b/addons/document/document.py
index 6cb2cabbf38..1671b6bc1ba 100644
--- a/addons/document/document.py
+++ b/addons/document/document.py
@@ -117,8 +117,22 @@ class document_file(osv.osv):
# take partner from uid
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)
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)
+ 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)
+ icont_u = ustr(icont)
+ return mime, icont_u
+
def __get_partner_id(self, cr, uid, res_model, res_id, context=None):
""" A helper to retrieve the associated partner from any res_model+id
It is a hack that will try to discover if the mentioned record is