Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix _document_fs_link to work with latest Odoo 8.0 code #64

Open
wants to merge 2 commits into
base: 8.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions document_fs/ir_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def _document_fs_sanitize(self, name):
def _get_document_fs_path(self, cr, uid, ids, field_name, arg, context=None):
r = {}
for attachment in self.browse(cr, uid, ids, context=context):
link_dir = self._full_path(cr, uid, 'file', 'models')
link_dir = self._full_path(cr, uid, 'models')
res_model = self._document_fs_sanitize(attachment.res_model)
res_id = self._document_fs_sanitize(attachment.res_id)
datas_fname = self._document_fs_sanitize(attachment.datas_fname)
Expand All @@ -40,7 +40,7 @@ def _document_fs_unlink(self, cr, uid, ids, context=None):

def _document_fs_link(self, cr, uid, ids, context=None):
for attachment in self.browse(cr, uid, ids, context=context):
src = self._full_path(cr, uid, 'file', attachment.store_fname)
src = self._full_path(cr, uid, attachment.store_fname)
path = attachment.document_fs_path
link_dir = os.path.dirname(path)
if not os.path.isdir(link_dir):
Expand All @@ -51,7 +51,7 @@ def _document_fs_sync(self, cr, uid, context=None):
# WARNING files must be atomically renamed(2) if used in a cron job as
# we read and unlink them
if self._storage(cr, uid, context)== 'file':
link_dir = self._full_path(cr, uid, 'file', 'models')
link_dir = self._full_path(cr, uid, 'models')
l = glob.glob('%s/*/*/*' % link_dir)
for path in l:
if not os.path.isfile(path):
Expand All @@ -64,7 +64,7 @@ def _document_fs_sync(self, cr, uid, context=None):
except UnicodeError:
continue
if res_model in self.pool:
ids = self.search(cr, uid, [('res_model','=',res_model),('res_id','=',res_id),('datas_fname','=',name)])
ids = self.search(cr, uid, [['res_model','=',res_model],['res_id','=',res_id],['datas_fname','=',name]])
if ids:
continue
data = open(path).read().encode('base64')
Expand All @@ -91,7 +91,7 @@ def write(self, cr, uid, ids, vals, context=None):
self._document_fs_link(cr, uid, ids, context=context)
return r

def unlink(self, cr, uid, ids, context=None):
def unlink(self, cr, uid, ids, context=None):
if self._storage(cr, uid, context) == 'file':
self._document_fs_unlink(cr, uid, ids, context=context)
return super(ir_attachment, self).unlink(cr, uid, ids, context)
Expand Down