@@ -1773,7 +1773,7 @@ class account_account_template(osv.osv):
|
||||
"can have children accounts for multi-company consolidations, payable/receivable are for "\
|
||||
"partners accounts (for debit/credit computations), closed for deprecated accounts."),
|
||||
'user_type': fields.many2one('account.account.type', 'Account Type', required=True,
|
||||
"These types are defined according to your country. The type contain more information "\
|
||||
help="These types are defined according to your country. The type contain more information "\
|
||||
"about the account and it's specificities."),
|
||||
'reconcile': fields.boolean('Allow Reconciliation', help="Check this option if you want the user to reconcile entries in this account."),
|
||||
'shortcut': fields.char('Shortcut', size=12),
|
||||
|
||||
+21
-18
@@ -136,7 +136,7 @@ class node_class(object):
|
||||
res = pool.get('document.directory').browse(self.cr, self.uid, ids,self.context)
|
||||
return res
|
||||
|
||||
def _child_get(self, nodename=False):
|
||||
def _child_get(self, nodename=False):
|
||||
if self.type not in ('collection','database'):
|
||||
return []
|
||||
res = self.directory_list_for_child(nodename)
|
||||
@@ -153,19 +153,8 @@ class node_class(object):
|
||||
result +=map(lambda x: node_class(self.cr, self.uid, self.path+'/'+x.name, x, False, type='file', root=self.root), res)
|
||||
if self.type=='collection' and self.object.type=="ressource":
|
||||
where = self.object.domain and eval(self.object.domain, {'active_id':self.root}) or []
|
||||
pool = pooler.get_pool(self.cr.dbname)
|
||||
pool = pooler.get_pool(self.cr.dbname)
|
||||
obj = pool.get(self.object.ressource_type_id.model)
|
||||
|
||||
if self.object.ressource_tree:
|
||||
if obj._parent_name in obj.fields_get(self.cr,self.uid):
|
||||
where.append((obj._parent_name,'=',self.object2 and self.object2.id or False))
|
||||
else :
|
||||
if self.object2:
|
||||
return result
|
||||
else:
|
||||
if self.object2:
|
||||
return result
|
||||
|
||||
name_for = obj._name.split('.')[-1]
|
||||
if nodename and nodename.find(name_for) == 0 :
|
||||
id = int(nodename.replace(name_for,''))
|
||||
@@ -177,6 +166,22 @@ class node_class(object):
|
||||
if nodename.find(INVALID_CHARS[invalid]) :
|
||||
nodename=nodename.replace(INVALID_CHARS[invalid],invalid)
|
||||
where.append(('name','like',nodename))
|
||||
|
||||
if self.object.ressource_tree:
|
||||
if obj._parent_name in obj.fields_get(self.cr,self.uid):
|
||||
where.append((obj._parent_name,'=',self.object2 and self.object2.id or False))
|
||||
ids = obj.search(self.cr, self.uid, where, self.context)
|
||||
res = obj.browse(self.cr, self.uid, ids,self.context)
|
||||
result+= map(lambda x: node_class(self.cr, self.uid, self.path+'/'+x.name.replace('/','__'), self.object, x, root=x.id), res)
|
||||
return result
|
||||
else :
|
||||
if self.object2:
|
||||
return result
|
||||
else:
|
||||
if self.object2:
|
||||
return result
|
||||
|
||||
|
||||
ids = obj.search(self.cr, self.uid, where, self.context)
|
||||
res = obj.browse(self.cr, self.uid, ids,self.context)
|
||||
for r in res:
|
||||
@@ -184,10 +189,10 @@ class node_class(object):
|
||||
r.name = name_for+'%d'%r.id
|
||||
for invalid in INVALID_CHARS:
|
||||
if r.name.find(invalid) :
|
||||
r.name=r.name.replace(invalid,INVALID_CHARS[invalid])
|
||||
result2 = map(lambda x: node_class(self.cr, self.uid, self.path+'/'+x.name.replace('/','__'), self.object, x, root=r.id), res)
|
||||
r.name=r.name.replace(invalid,INVALID_CHARS[invalid])
|
||||
result2 = map(lambda x: node_class(self.cr, self.uid, self.path+'/'+x.name.replace('/','__'), self.object, x, root=x.id), res)
|
||||
if result2:
|
||||
result = result2
|
||||
result = result2
|
||||
return result
|
||||
|
||||
def children(self):
|
||||
@@ -772,5 +777,3 @@ class document_configuration_wizard(osv.osv_memory):
|
||||
'target':'new',
|
||||
}
|
||||
document_configuration_wizard()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -27,7 +27,7 @@ import abstracted_fs
|
||||
import netsvc
|
||||
|
||||
from tools import config
|
||||
PORT = config.get('ftp_server_port', 8021)
|
||||
PORT = int(config.get('ftp_server_port', 8021))
|
||||
HOST = ''
|
||||
|
||||
class ftp_server(threading.Thread):
|
||||
@@ -49,7 +49,6 @@ class ftp_server(threading.Thread):
|
||||
address = (HOST, PORT)
|
||||
ftpd = ftpserver.FTPServer(address, ftpserver.FTPHandler)
|
||||
ftpd.serve_forever()
|
||||
|
||||
ds = ftp_server()
|
||||
ds.start()
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import time
|
||||
from tarfile import filemode
|
||||
@@ -17,6 +16,47 @@ from service import security
|
||||
def log(message):
|
||||
logger = netsvc.Logger()
|
||||
logger.notifyChannel('DMS', netsvc.LOG_ERROR, message)
|
||||
|
||||
|
||||
def _get_month_name(month):
|
||||
month=int(month)
|
||||
if month==1:return 'Jan'
|
||||
elif month==2:return 'Feb'
|
||||
elif month==3:return 'Mar'
|
||||
elif month==4:return 'Apr'
|
||||
elif month==5:return 'May'
|
||||
elif month==6:return 'Jun'
|
||||
elif month==7:return 'Jul'
|
||||
elif month==8:return 'Aug'
|
||||
elif month==9:return 'Sep'
|
||||
elif month==10:return 'Oct'
|
||||
elif month==11:return 'Nov'
|
||||
elif month==12:return 'Dec'
|
||||
|
||||
def _to_unicode(s):
|
||||
try:
|
||||
return s.encode('ascii')
|
||||
except UnicodeError:
|
||||
try:
|
||||
return s.decode('utf-8')
|
||||
except UnicodeError:
|
||||
try:
|
||||
return s.decode('latin')
|
||||
except UnicodeError:
|
||||
return s
|
||||
|
||||
def _to_decode(s):
|
||||
try:
|
||||
return s.encode('utf-8')
|
||||
except UnicodeError:
|
||||
try:
|
||||
return s.encode('latin')
|
||||
except UnicodeError:
|
||||
try:
|
||||
return s.decode('ascii')
|
||||
except UnicodeError:
|
||||
return s
|
||||
|
||||
|
||||
class file_wrapper(StringIO.StringIO):
|
||||
def __init__(self, sstr='', ressource_id=False, dbname=None, uid=1, name=''):
|
||||
@@ -145,6 +185,7 @@ class abstracted_fs:
|
||||
path = self.ftpnorm(path_orig)
|
||||
if path and path=='/':
|
||||
return None
|
||||
path=_to_unicode(path)
|
||||
path2 = filter(None,path.split('/'))[1:]
|
||||
(cr, uid, pool) = data
|
||||
res = pool.get('document.directory').get_object(cr, uid, path2[:])
|
||||
@@ -153,8 +194,8 @@ class abstracted_fs:
|
||||
return res
|
||||
|
||||
# Ok
|
||||
def fs2ftp(self, node):
|
||||
res = node and ('/' + node.cr.dbname + '/' + node.path.encode('ascii','replace').replace('?','_')) or '/'
|
||||
def fs2ftp(self, node):
|
||||
res = node and ('/' + node.cr.dbname + '/' + _to_decode(node.path)) or '/'
|
||||
return res
|
||||
|
||||
# Ok
|
||||
@@ -174,6 +215,7 @@ class abstracted_fs:
|
||||
|
||||
# Ok
|
||||
def create(self, node, objname, mode):
|
||||
objname=_to_unicode(objname)
|
||||
cr = node.cr
|
||||
uid = node.uid
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
@@ -195,7 +237,7 @@ class abstracted_fs:
|
||||
cid=False
|
||||
|
||||
where=[('name','=',objname)]
|
||||
if object and (object.type in ('directory','ressource')) or object2:
|
||||
if object and (object.type in ('directory')) or object2:
|
||||
where.append(('parent_id','=',object.id))
|
||||
else:
|
||||
where.append(('parent_id','=',False))
|
||||
@@ -214,7 +256,7 @@ class abstracted_fs:
|
||||
'file_size': 0L,
|
||||
'file_type': ext,
|
||||
}
|
||||
if object and (object.type in ('directory','ressource')) or not object2:
|
||||
if object and (object.type in ('directory')) or not object2:
|
||||
val['parent_id']= object and object.id or False
|
||||
partner = False
|
||||
if object2:
|
||||
@@ -310,6 +352,7 @@ class abstracted_fs:
|
||||
if not node:
|
||||
raise OSError(1, 'Operation not permited.')
|
||||
try:
|
||||
basename=_to_unicode(basename)
|
||||
object2=node and node.object2 or False
|
||||
object=node and node.object or False
|
||||
cr = node.cr
|
||||
@@ -322,7 +365,7 @@ class abstracted_fs:
|
||||
'ressource_parent_type_id': object and object.ressource_type_id.id or False,
|
||||
'ressource_id': object2 and object2.id or False
|
||||
}
|
||||
if (object and (object.type in ('directory'))) or not object2:
|
||||
if (object and (object.type in ('directory'))) or not object2:
|
||||
val['parent_id'] = object and object.id or False
|
||||
# Check if it alreayd exists !
|
||||
pool.get('document.directory').create(cr, uid, val)
|
||||
@@ -410,6 +453,7 @@ class abstracted_fs:
|
||||
* A directory: change the parent and reassign childs to ressource
|
||||
"""
|
||||
try:
|
||||
dst_basename=_to_unicode(dst_basename)
|
||||
if src.type=='collection':
|
||||
if src.object._table_name <> 'document.directory':
|
||||
raise OSError(1, 'Operation not permited.')
|
||||
@@ -449,11 +493,12 @@ class abstracted_fs:
|
||||
ressource_type_id = pool.get('ir.model').search(cr,uid,[('model','=',dst_basedir.object2._name)])[0]
|
||||
ressource_id = dst_basedir.object2.id
|
||||
title = dst_basedir.object2.name
|
||||
ressource_model = dst_basedir.object2._name
|
||||
ressource_model = dst_basedir.object2._name
|
||||
if dst_basedir.object2._name=='res.partner':
|
||||
partner_id=dst_basedir.object2.id
|
||||
else:
|
||||
partner_id= dst_basedir.object2.partner_id and dst_basedir.object2.partner_id.id or False
|
||||
obj2=pool.get(dst_basedir.object2._name)
|
||||
partner_id= obj2.fields_get(cr,uid,['partner_id']) and dst_basedir.object2.partner_id.id or False
|
||||
else:
|
||||
ressource_type_id = False
|
||||
ressource_id=False
|
||||
@@ -463,7 +508,7 @@ class abstracted_fs:
|
||||
|
||||
pool.get('document.directory').write(cr, uid, result['directory'], {
|
||||
'ressource_id': ressource_id,
|
||||
'ressource_parent_type_id': ressource_type_id
|
||||
'ressource_type_id': ressource_type_id
|
||||
})
|
||||
val = {
|
||||
'res_id': ressource_id,
|
||||
@@ -499,7 +544,8 @@ class abstracted_fs:
|
||||
if dst_basedir.object2._name=='res.partner':
|
||||
val['partner_id']=dst_basedir.object2.id
|
||||
else:
|
||||
val['partner_id']= dst_basedir.object2.partner_id and dst_basedir.object2.partner_id.id or False
|
||||
obj2=pool.get(dst_basedir.object2._name)
|
||||
val['partner_id']= obj2.fields_get(cr,uid,['partner_id']) and dst_basedir.object2.partner_id.id or False
|
||||
elif src.object.res_id:
|
||||
# I had to do that because writing False to an integer writes 0 instead of NULL
|
||||
# change if one day we decide to improve osv/fields.py
|
||||
@@ -612,7 +658,7 @@ class abstracted_fs:
|
||||
def get_list_dir(self, path):
|
||||
""""Return an iterator object that yields a directory listing
|
||||
in a form suitable for LIST command.
|
||||
"""
|
||||
"""
|
||||
if self.isdir(path):
|
||||
listing = self.listdir(path)
|
||||
#listing.sort()
|
||||
@@ -647,7 +693,7 @@ class abstracted_fs:
|
||||
listing.sort()
|
||||
return self.format_list(basedir, listing)
|
||||
|
||||
# Ok
|
||||
# Ok
|
||||
def format_list(self, basedir, listing, ignore_err=True):
|
||||
"""Return an iterator object that yields the entries of given
|
||||
directory emulating the "/bin/ls -lA" UNIX command output.
|
||||
@@ -686,13 +732,15 @@ class abstracted_fs:
|
||||
# stat.st_mtime could fail (-1) if last mtime is too old
|
||||
# in which case we return the local time as last mtime
|
||||
try:
|
||||
mtime = time.strftime("%b %d %H:%M", time.localtime(st.st_mtime))
|
||||
mname=_get_month_name(time.strftime("%m", time.localtime(st.st_mtime)))
|
||||
mtime = mname+' '+time.strftime("%d %H:%M", time.localtime(st.st_mtime))
|
||||
except ValueError:
|
||||
mtime = time.strftime("%b %d %H:%M")
|
||||
|
||||
mname=_get_month_name(time.strftime("%m"))
|
||||
mtime = mname+' '+time.strftime("%d %H:%M")
|
||||
# formatting is matched with proftpd ls output
|
||||
path=_to_decode(file.path) #file.path.encode('ascii','replace').replace('?','_')
|
||||
yield "%s %3s %-8s %-8s %8s %s %s\r\n" %(perms, nlinks, uname, gname,
|
||||
size, mtime, file.path.encode('ascii','replace').replace('?','_').split('/')[-1])
|
||||
size, mtime, path.split('/')[-1])
|
||||
|
||||
# Ok
|
||||
def format_mlsx(self, basedir, listing, perms, facts, ignore_err=True):
|
||||
@@ -786,8 +834,9 @@ class abstracted_fs:
|
||||
# on Windows NTFS filesystems MTF records could be used).
|
||||
if 'unique' in facts:
|
||||
unique = "unique=%x%x;" %(st.st_dev, st.st_ino)
|
||||
|
||||
basename=_to_decode(basename)
|
||||
yield "%s%s%s%s%s%s%s%s%s %s\r\n" %(type, size, perm, modify, create,
|
||||
mode, uid, gid, unique, basename)
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user