diff options
| author | Ravish Murari (OpenERP) <rmu@tinyerp.com> | 2012-08-23 17:16:08 +0530 |
|---|---|---|
| committer | Ravish Murari (OpenERP) <rmu@tinyerp.com> | 2012-08-23 17:16:08 +0530 |
| commit | 05acae2e2fe8b72d7b1523fa0dd91a8e7d2ea09f (patch) | |
| tree | 337084f7e348d9a84e2530c2eb8362a5c966d024 /addons/document/document.py | |
| parent | c5f7f6ecdf710985f29cc73e310ea1f3852b468d (diff) | |
| parent | 79224ea6722e0f2644239b582d86346f32021c0a (diff) | |
[merge] with latest addons
bzr revid: rmu@tinyerp.com-20120823114608-zerb6vg7l1ckf5mi
Diffstat (limited to 'addons/document/document.py')
| -rw-r--r-- | addons/document/document.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/addons/document/document.py b/addons/document/document.py index 92ece063a47..3ee52f8e4fb 100644 --- a/addons/document/document.py +++ b/addons/document/document.py @@ -23,19 +23,22 @@ import base64 from osv import osv, fields import os -# from psycopg2 import Binary +#from psycopg2 import Binary #from tools import config import tools from tools.translate import _ import nodes import logging +_logger = logging.getLogger(__name__) + DMS_ROOT_PATH = tools.config.get('document_path', os.path.join(tools.config['root_path'], 'filestore')) class document_file(osv.osv): _inherit = 'ir.attachment' _rec_name = 'datas_fname' + def _attach_parent_id(self, cr, uid, ids=None, context=None): """Migrate ir.attachments to the document module. @@ -54,11 +57,11 @@ class document_file(osv.osv): parent_id = self.pool.get('document.directory')._get_root_directory(cr,uid) if not parent_id: - logging.getLogger('document').warning("at _attach_parent_id(), still not able to set the parent!") + _logger.warning("at _attach_parent_id(), still not able to set the parent!") return False if ids is not None: - raise NotImplementedError("Ids is just there by convention! Don't use it yet, please.") + raise NotImplementedError("Ids are just there by convention, please do not use it.") cr.execute("UPDATE ir_attachment " \ "SET parent_id = %s, db_datas = decode(encode(db_datas,'escape'), 'base64') " \ @@ -140,8 +143,8 @@ class document_file(osv.osv): _defaults = { 'user_id': lambda self, cr, uid, ctx:uid, + 'parent_id': __get_def_directory, 'file_size': lambda self, cr, uid, ctx:0, - 'parent_id': __get_def_directory } _sql_constraints = [ # filename_uniq is not possible in pure SQL @@ -291,7 +294,7 @@ class document_file(osv.osv): ('datas_fname', '=', vals['datas_fname']), ] attach_ids = self.search(cr, uid, domain, context=context) - super(document_file, self).write(cr, uid, attach_ids, + super(document_file, self).write(cr, uid, attach_ids, {'datas' : vals['datas']}, context=context) result = attach_ids[0] @@ -336,7 +339,7 @@ class document_file(osv.osv): if r: unres.append(r) else: - logging.getLogger('document').warning("Unlinking attachment #%s %s that has no storage", + self.loggerdoc.warning("Unlinking attachment #%s %s that has no storage.", f.id, f.name) res = super(document_file, self).unlink(cr, uid, ids, context) stor.do_unlink(cr, uid, unres) |
