2 In order to test the document management I make sure the default installation has some storage.
4 !assert {model: document.storage, id: storage_default }:
7 I make sure the default installation has some root directory.
9 !assert {model: document.directory, id: dir_root}:
12 I create a "Testing" folder where all the test data will go.
14 !record {model: document.directory, id: dir_tests }:
15 name: 'Testing (will be deleted!)'
18 I create an attachment into the root folder (w. empty fields, test that
21 !record {model: ir.attachment, id: file_test1 }:
24 I delete the attachment from the root folder
26 !python {model: ir.attachment}: |
27 self.unlink(cr, uid, [ref('file_test1')])
29 I create an attachment into the Testing folder.
31 !record {model: ir.attachment, id: file_test2 }:
35 I update the attachment with data, namely "abcd"
37 !record {model: ir.attachment, id: file_test2 }:
40 I test that the datas of the attachment are correct
42 !assert {model: ir.attachment, id: file_test2 }:
43 - datas == "YWJjZA==\n"
45 - file_type == 'text/plain'
47 I rename the attachment.
49 !record {model: ir.attachment, id: file_test2 }:
52 I search the testing folder for attachments.
54 !python {model: ir.attachment}: |
55 ids = self.search(cr, uid, [('parent_id.name','=', 'Testing (will be deleted!)'), ('name','=','Test renamed 2')])
56 assert ids == [ ref("file_test2") ], ids
58 I create an attachment to a 3rd resource, eg. a res.country
60 !record {model: ir.attachment, id: attach_3rd }:
61 name: 'Country attachment.txt'
63 datas: "Q291bnRyeSBhdHRhY2htZW50IGNvbnRlbnQ=\n"
64 res_model: res.country
65 res_id: !eval ref("base.za")
67 I search for the res.country attachment
69 !python {model: ir.attachment}: |
70 ids = self.search(cr, uid, [('res_model', '=', 'res.country'), ('res_id', '=', ref("base.za"))])
71 assert ids == [ ref("attach_3rd")], ids
73 I delete the attachments
75 !python {model: ir.attachment}: |
76 self.unlink(cr, uid, [ref('file_test2')])
77 self.unlink(cr, uid, [ref('attach_3rd')])
79 I delete the tests folder
81 !python {model: document.directory}: |
82 self.unlink(cr, uid, [ref('dir_tests')])