2010-06-29 14:00:49 +00:00
|
|
|
-
|
|
|
|
In order to test the document management
|
|
|
|
-
|
|
|
|
I make sure the default installation has some storage and root directory.
|
2010-07-01 17:51:30 +00:00
|
|
|
-
|
|
|
|
!assert {model: document.storage, id: storage_default }:
|
|
|
|
- id != False
|
|
|
|
-
|
|
|
|
!assert {model: document.directory, id: dir_root}:
|
|
|
|
- storage_id != False
|
2010-06-29 14:00:49 +00:00
|
|
|
-
|
|
|
|
I create a "Testing" folder where all the test data will go.
|
2010-07-01 17:51:30 +00:00
|
|
|
-
|
|
|
|
!record {model: document.directory, id: dir_tests }:
|
|
|
|
name: 'Testing'
|
|
|
|
parent_id: dir_root
|
2010-06-29 14:00:49 +00:00
|
|
|
-
|
|
|
|
I create an attachment into the root folder (w. empty fields, test that
|
|
|
|
defaults work)
|
2010-07-01 17:51:31 +00:00
|
|
|
-
|
|
|
|
!record {model: ir.attachment, id: file_test1 }:
|
|
|
|
name: Test file
|
2010-06-29 14:00:49 +00:00
|
|
|
-
|
|
|
|
I delete the attachment from the root folder
|
2010-07-01 17:51:31 +00:00
|
|
|
-
|
|
|
|
!delete {model: ir.attachment, id: file_test1, search: }
|
2010-06-29 14:00:49 +00:00
|
|
|
-
|
|
|
|
I create an attachment into the Testing folder.
|
2010-07-01 17:51:31 +00:00
|
|
|
-
|
|
|
|
!record {model: ir.attachment, id: file_test2 }:
|
|
|
|
name: Test file 2
|
|
|
|
parent_id: dir_tests
|
2010-06-29 14:00:49 +00:00
|
|
|
-
|
|
|
|
I update the attachment with data, namely "abcd"
|
2010-07-01 17:51:31 +00:00
|
|
|
-
|
|
|
|
!record {model: ir.attachment, id: file_test2 }:
|
2010-07-01 17:51:31 +00:00
|
|
|
datas: "abcd"
|
2010-07-01 17:51:31 +00:00
|
|
|
-
|
|
|
|
I test that the datas of the attachment are correct
|
|
|
|
-
|
|
|
|
!assert {model: ir.attachment, id: file_test2 }:
|
2010-07-01 17:51:31 +00:00
|
|
|
- datas == "abcd\n"
|
2010-07-01 17:51:32 +00:00
|
|
|
- file_size == 5
|
|
|
|
- file_type == 'text/plain'
|
2010-06-29 14:00:49 +00:00
|
|
|
-
|
|
|
|
I rename the attachment.
|
2010-07-01 17:51:31 +00:00
|
|
|
-
|
|
|
|
!record {model: ir.attachment, id: file_test2 }:
|
|
|
|
name: Test renamed 2
|
2010-06-29 14:00:49 +00:00
|
|
|
-
|
|
|
|
I search the testing folder for attachments.
|
2010-07-01 17:51:31 +00:00
|
|
|
-
|
|
|
|
!python {model: ir.attachment}: |
|
|
|
|
ids = self.search(cr, uid, [('parent_id.name','=', 'Testing'), ('name','=','Test renamed 2')])
|
|
|
|
assert ids == [ ref("file_test2") ], ids
|
2010-06-29 14:00:49 +00:00
|
|
|
-
|
|
|
|
I create an attachment to a 3rd resource, eg. a res.country
|
2010-07-01 17:51:31 +00:00
|
|
|
-
|
|
|
|
!record {model: ir.attachment, id: attach_3rd }:
|
|
|
|
name: 'Res country attachment.txt'
|
2010-07-01 17:51:32 +00:00
|
|
|
parent_id: dir_tests
|
2010-07-01 17:51:31 +00:00
|
|
|
datas: 'defg'
|
|
|
|
res_model: res.country
|
|
|
|
res_id: !eval ref("base.za")
|
2010-06-29 14:00:49 +00:00
|
|
|
-
|
|
|
|
I search for the res.country attachment
|
2010-07-01 17:51:31 +00:00
|
|
|
-
|
|
|
|
!python {model: ir.attachment}: |
|
|
|
|
ids = self.search(cr, uid, [('res_model', '=', 'res.country'), ('res_id', '=', ref("base.za"))])
|
|
|
|
assert ids == [ ref("attach_3rd")], ids
|
2010-07-01 17:51:31 +00:00
|
|
|
-
|
2010-07-06 12:10:47 +00:00
|
|
|
!delete {model: ir.attachment, id: attach_3rd, search: }
|