summaryrefslogtreecommitdiff
path: root/addons/document
diff options
context:
space:
mode:
authordle@openerp.com <>2012-12-24 12:32:55 +0100
committerdle@openerp.com <>2012-12-24 12:32:55 +0100
commit3da0c3a878e4e0f2877e6f0569bb9346d6cfbb0f (patch)
tree5574dbd8a5e92af3f3070256441bfc699a1d0a81 /addons/document
parent94afe1ccef4ffa84abcbb6e753beacf91f91ec1b (diff)
[FIX]On_change missing + index content working when create/edit attachment
bzr revid: dle@openerp.com-20121224113255-zfezakhjp852bya8
Diffstat (limited to 'addons/document')
-rw-r--r--addons/document/document.py14
-rw-r--r--addons/document/document_view.xml2
2 files changed, 15 insertions, 1 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
diff --git a/addons/document/document_view.xml b/addons/document/document_view.xml
index 4c2456de827..68f294b251c 100644
--- a/addons/document/document_view.xml
+++ b/addons/document/document_view.xml
@@ -167,7 +167,7 @@
<field name="inherit_id" ref="base.view_attachment_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='datas_fname']" position="replace">
- <field name="datas_fname" invisible="1" on_change="onchange_file(datas_fname)"/>
+ <field name="datas_fname" invisible="1"/>
</xpath>
<field name="url" position="after">
<field name="user_id"/>