[ADD] add yml file for document and document_ftp module.
bzr revid: ysa@tinyerp.co.in-20100423051445-pqs46sawemex2dda
This commit is contained in:
@@ -46,6 +46,9 @@
|
||||
'report/document_report_view.xml'
|
||||
],
|
||||
'demo_xml': [ 'document_demo.xml',],
|
||||
'test': [
|
||||
'test/document_test.yml',
|
||||
],
|
||||
'installable': True,
|
||||
'active': False,
|
||||
'certificate': None,
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
- |
|
||||
In order to test the Document Management System In OpenERP.
|
||||
-
|
||||
In order to test behaviour of resource Directory I will make one resource Directory "Partner Labels" in OpenERP having type "Other Resources" and Directory mapped to object "Partner"
|
||||
-
|
||||
!record {model: 'document.directory', id: dir_partner_label}:
|
||||
name : "Partner Labels"
|
||||
storage_id : 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_partner_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_1}:
|
||||
name : "Directory 1"
|
||||
storage_id : storage_default
|
||||
type : directory
|
||||
-
|
||||
In order to make a directory hierarchy in OpenERP I will make other static directory "Directory 2" and I put its Parent Item as "Directory 1",
|
||||
So I can see the directory hierarchy in OpenERP's client like :- Directory1 -> Directory2
|
||||
-
|
||||
!record {model: 'document.directory', id: directory_2}:
|
||||
name : "Directory 2"
|
||||
storage_id : storage_default
|
||||
type : directory
|
||||
parent_id : directory_1
|
||||
-
|
||||
I am create a one Document Attachment name "My document" and select "Directory 2" as its Directory,
|
||||
And in order to put a File content.
|
||||
-
|
||||
When I am creating the document then "Resource Title" is filled automatic with "My document".
|
||||
-
|
||||
!record {model: 'ir.attachment', id: document_1}:
|
||||
name : "My document"
|
||||
parent_id : directory_2
|
||||
-
|
||||
Attach a pdf file in "My document"
|
||||
-
|
||||
!python {model: ir.attachment}: |
|
||||
import tools
|
||||
import base64
|
||||
file = open(tools.config['addons_path'] + '/document/test/partner.pdf')
|
||||
id = self.write(cr, uid, [ref("document_1")], {'datas' : base64.encodestring(file.read())}, context)
|
||||
@@ -0,0 +1,118 @@
|
||||
%PDF-1.3
|
||||
%“Œ‹ž ReportLab Generated PDF document http://www.reportlab.com
|
||||
% 'BasicFonts': class PDFDictionary
|
||||
1 0 obj
|
||||
% The standard fonts dictionary
|
||||
<< /F1 2 0 R
|
||||
/F2 3 0 R
|
||||
/F3 4 0 R >>
|
||||
endobj
|
||||
% 'F1': class PDFType1Font
|
||||
2 0 obj
|
||||
% Font Helvetica
|
||||
<< /BaseFont /Helvetica
|
||||
/Encoding /WinAnsiEncoding
|
||||
/Name /F1
|
||||
/Subtype /Type1
|
||||
/Type /Font >>
|
||||
endobj
|
||||
% 'F2': class PDFType1Font
|
||||
3 0 obj
|
||||
% Font Helvetica-Bold
|
||||
<< /BaseFont /Helvetica-Bold
|
||||
/Encoding /WinAnsiEncoding
|
||||
/Name /F2
|
||||
/Subtype /Type1
|
||||
/Type /Font >>
|
||||
endobj
|
||||
% 'F3': class PDFType1Font
|
||||
4 0 obj
|
||||
% Font Times-Roman
|
||||
<< /BaseFont /Times-Roman
|
||||
/Encoding /WinAnsiEncoding
|
||||
/Name /F3
|
||||
/Subtype /Type1
|
||||
/Type /Font >>
|
||||
endobj
|
||||
% 'Page1': class PDFPage
|
||||
5 0 obj
|
||||
% Page dictionary
|
||||
<< /Contents 9 0 R
|
||||
/MediaBox [ 0
|
||||
0
|
||||
841.8898
|
||||
595.2756 ]
|
||||
/Parent 8 0 R
|
||||
/Resources << /Font 1 0 R
|
||||
/ProcSet [ /PDF
|
||||
/Text
|
||||
/ImageB
|
||||
/ImageC
|
||||
/ImageI ] >>
|
||||
/Rotate 0
|
||||
/Trans << >>
|
||||
/Type /Page >>
|
||||
endobj
|
||||
% 'R6': class PDFCatalog
|
||||
6 0 obj
|
||||
% Document Root
|
||||
<< /Outlines 10 0 R
|
||||
/PageMode /UseNone
|
||||
/Pages 8 0 R
|
||||
/Type /Catalog >>
|
||||
endobj
|
||||
% 'R7': class PDFInfo
|
||||
7 0 obj
|
||||
<< /Author (Generated by OpenERP, Fabien Pinckaers)
|
||||
/CreationDate (20100421145542)
|
||||
/Keywords ()
|
||||
/Producer (ReportLab http://www.reportlab.com)
|
||||
/Subject (\(unspecified\))
|
||||
/Title (Partner) >>
|
||||
endobj
|
||||
% 'R8': class PDFPages
|
||||
8 0 obj
|
||||
% page tree
|
||||
<< /Count 1
|
||||
/Kids [ 5 0 R ]
|
||||
/Type /Pages >>
|
||||
endobj
|
||||
% 'R9': class PDFStream
|
||||
9 0 obj
|
||||
% page stream
|
||||
<< /Filter [ /ASCII85Decode
|
||||
/FlateDecode ]
|
||||
/Length 524 >>
|
||||
stream
|
||||
Gat=(?#P<K'R_@f5MSc<`6.HPV2s@dQRlarfjrE>3i<Y4(hW<qY=/IHPo2nd;U2u=SpPc46=:icfCoF922oN\83q_*El(+<i)0C.\*qSa'orY`+p(cC^oTpn8t,B-+=I?_Q1#SGXQbKWJ5-M7"aXRSQCBTu'NHJF046Jno-.K&2kW+&Ddh9bXc1q%)-e?DSC(5(4%=lk+ql;XaX3m]F#7K:"]hph/QW?(0_J4kXQiP</;'9K=]Wd,jeGe.Ma6pqJ&iD]r%qkNclhVq5Q/gSmK+r&6mr`*Z[m8(n)Usu)MZo%TNta^h'I^g6m5Vp92+>e[>S,B2ME\)S7:@oo6@nF8`I+h##OY3a-n#Qm!>5jiD.9pQ@E1#Xj$=)27)F3RmD%fbqZh,T`gJd0/,?A3`0:_VVm`"l`>oOf9p&HGF7>WCGVJoD2&_+c#BDb)/&0>>rL5@]KY$9YOA<rrt#g)1a61mS([/:0_[`)!ctOhSA/p@bq]>qZHTJq8k]!o+?4a5\-KbB#NYJC'`~>endstream
|
||||
|
||||
endobj
|
||||
% 'R10': class PDFOutlines
|
||||
10 0 obj
|
||||
<< /Count 0
|
||||
/Type /Outlines >>
|
||||
endobj
|
||||
xref
|
||||
0 11
|
||||
0000000000 65535 f
|
||||
0000000113 00000 n
|
||||
0000000233 00000 n
|
||||
0000000398 00000 n
|
||||
0000000573 00000 n
|
||||
0000000740 00000 n
|
||||
0000001017 00000 n
|
||||
0000001152 00000 n
|
||||
0000001395 00000 n
|
||||
0000001500 00000 n
|
||||
0000002169 00000 n
|
||||
trailer
|
||||
<< /ID
|
||||
% ReportLab generated PDF document -- digest (http://www.reportlab.com)
|
||||
[(\210\344\006bE\230CUUi\010[\)Qif) (\210\344\006bE\230CUUi\010[\)Qif)]
|
||||
|
||||
/Info 7 0 R
|
||||
/Root 6 0 R
|
||||
/Size 11 >>
|
||||
startxref
|
||||
2221
|
||||
%%EOF
|
||||
@@ -37,6 +37,9 @@
|
||||
'security/ir.model.access.csv'
|
||||
],
|
||||
'demo_xml': [],
|
||||
'test': [
|
||||
'test/document_ftp_test.yml',
|
||||
],
|
||||
'installable': True,
|
||||
'active': False,
|
||||
'certificate': None,
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
- |
|
||||
In order to test the document_ftp module in OpenERP, I will try different operation on the FTP interface, and check their impacts on OpenERP's documents and vice-versa.
|
||||
-
|
||||
In order to test 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 a one Document name "Document" and select "File" as its Directory,
|
||||
-
|
||||
When I am creating the record then "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 records 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 Label 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.
|
||||
Reference in New Issue
Block a user