odoo/addons/document_ftp/test/document_ftp_test.yml

88 lines
3.8 KiB
YAML

- |
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.
-
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"
-
!record {model: 'document.directory', id: dir_label}:
name : "Labels"
storage_id : document.storage_default
type : ressource
content_ids:
- name: "Label"
report_id : base.res_partner_address_report
-
Assign "res.partner" object to ressource_type_id.
-
!python {model: document.directory}: |
ids = self.pool.get('ir.model').search(cr, uid, [('model','=','res.partner')])
id = self.write(cr, uid, [ref("dir_label")], {'ressource_type_id' : ids[0]}, context)
-
In order to check static directory in OpenERP which is the real directory just like system's local folders,
First I create a directory in OpenERP named "Directory 1" with storage as "Default File storage" and type as "Static Directory"
-
!record {model: 'document.directory', id: directory_file}:
name : "File"
storage_id : document.storage_default
type : directory
-
I am create one Document name "Document" and select "File" as its Directory,
-
When I am creating the record, "Resource Title" is filled automatic with "Document".
-
!record {model: 'ir.attachment', id: document_1}:
name : "Document"
parent_id : directory_file
-
In order to connect FTP server and set "File" path,
I create one directory "New" in "File" directory from FTP and check its effect in OpenERP.
-
Also Rename the directory name "New" to "New Directory".
-
Remove directory "New Directory" and remove file "Document".
-
!python {model: ir.attachment}: |
from ftplib import FTP
from tools.misc import detect_ip_addr
from tools import config
ftp = FTP()
if detect_ip_addr:
host = config.get('ftp_server_host', detect_ip_addr())
else:
host = config.get('ftp_server_host', '127.0.0.1')
port = config.get('ftp_server_port','8021')
ftp.connect(host,port)
user = self.pool.get('res.users').read(cr, uid, uid, context)
ftp.login(user.get('login',''),user.get('password',''))
ftp.cwd("/" + cr.dbname+"/Documents/File/")
ftp.mkd("New")
ftp.rename('New','New Directory')
ftp.cwd("/" + cr.dbname+"/Documents/File/")
ftp.rmd('New Directory')
ftp.delete('Document')
ftp.quit()
-
In order to check directory created from FTP is working perfectly
-
Now I will test the same for Resource directory which is mapped with OpenERP object.
When you open this directory from FTP clients, it displays each record of mapped resource object as directory.
-
Now I test FTP client and Open the "Labels" Directory to check Resource Directory in FTP.
I can see that all Labels of OpenERP are shown as children of "Labels" in FTP client as Directories.
-
!python {model: ir.attachment}: |
from ftplib import FTP
from tools.misc import detect_ip_addr
from tools import config
ftp = FTP()
if detect_ip_addr:
host = config.get('ftp_server_host', detect_ip_addr())
else:
host = config.get('ftp_server_host', '127.0.0.1')
port = config.get('ftp_server_port','8021')
ftp.connect(host,port)
user = self.pool.get('res.users').read(cr, uid, uid, context)
ftp.login(user.get('login',''),user.get('password',''))
ftp.cwd("/" + cr.dbname+"/Documents/Labels/")
-
I make sure that I Open Labels Directory successfully.