2 In order to test the document_ftp module in OpenERP, I will try different operations on the FTP interface and check their impacts on OpenERP's documents and vice-versa.
4 In order to test the behaviour of resource Directory, I will make one resource Directory "Labels" in OpenERP having type "Other Resources" and Directory mapped to object "Partner"
6 !record {model: 'document.directory', id: dir_label}:
8 storage_id : document.storage_default
12 report_id : base.res_partner_address_report
14 Assign "res.partner" object to ressource_type_id.
16 !python {model: document.directory}: |
17 ids = self.pool.get('ir.model').search(cr, uid, [('model','=','res.partner')])
18 id = self.write(cr, uid, [ref("dir_label")], {'ressource_type_id' : ids[0]}, context)
20 In order to check static directory in OpenERP which is the real directory just like system's local folders,
21 First I create a directory in OpenERP named "Directory 1" with storage as "Default File storage" and type as "Static Directory"
23 !record {model: 'document.directory', id: directory_file}:
25 storage_id : document.storage_default
28 I am create one Document name "Document" and select "File" as its Directory,
30 When I am creating the record, "Resource Title" is filled automatic with "Document".
32 !record {model: 'ir.attachment', id: document_1}:
34 parent_id : directory_file
36 In order to connect FTP server and set "File" path,
37 I create one directory "New" in "File" directory from FTP and check its effect in OpenERP.
39 Also Rename the directory name "New" to "New Directory".
41 Remove directory "New Directory" and remove file "Document".
43 !python {model: ir.attachment}: |
44 from ftplib import FTP
45 from tools.misc import detect_ip_addr
46 from tools import config
49 host = config.get('ftp_server_host', detect_ip_addr())
51 host = config.get('ftp_server_host', '127.0.0.1')
52 port = config.get('ftp_server_port','8021')
53 ftp.connect(host,port)
54 user = self.pool.get('res.users').read(cr, uid, uid, context)
55 ftp.login(user.get('login',''),user.get('password',''))
56 ftp.cwd("/" + cr.dbname+"/Documents/File/")
58 ftp.rename('New','New Directory')
59 ftp.cwd("/" + cr.dbname+"/Documents/File/")
60 ftp.rmd('New Directory')
61 ftp.delete('Document')
64 In order to check directory created from FTP is working perfectly
66 Now I will test the same for Resource directory which is mapped with OpenERP object.
67 When you open this directory from FTP clients, it displays each record of mapped resource object as directory.
69 Now I test FTP client and Open the "Labels" Directory to check Resource Directory in FTP.
70 I can see that all Labels of OpenERP are shown as children of "Labels" in FTP client as Directories.
72 !python {model: ir.attachment}: |
73 from ftplib import FTP
74 from tools.misc import detect_ip_addr
75 from tools import config
78 host = config.get('ftp_server_host', detect_ip_addr())
80 host = config.get('ftp_server_host', '127.0.0.1')
81 port = config.get('ftp_server_port','8021')
82 ftp.connect(host,port)
83 user = self.pool.get('res.users').read(cr, uid, uid, context)
84 ftp.login(user.get('login',''),user.get('password',''))
85 ftp.cwd("/" + cr.dbname+"/Documents/Labels/")
87 I make sure that I Open Labels Directory successfully.