Merge lp:~savoirfairelinux-openerp/knowledge-addons/cmis into lp:knowledge-addons/7.0
- cmis
- Merge into 7.0
Status: | Rejected |
---|---|
Rejected by: | Sandy Carter (http://www.savoirfairelinux.com) |
Proposed branch: | lp:~savoirfairelinux-openerp/knowledge-addons/cmis |
Merge into: | lp:knowledge-addons/7.0 |
Diff against target: |
568 lines (+516/-0) 10 files modified
cmis/__init__.py (+26/-0) cmis/__openerp__.py (+62/-0) cmis/backend.py (+32/-0) cmis/cmis_menu.xml (+17/-0) cmis/cmis_model.py (+183/-0) cmis/cmis_model_view.xml (+74/-0) cmis/connector.py (+38/-0) cmis/security/ir.model.access.csv (+2/-0) cmis/tests/__init__.py (+29/-0) cmis/tests/test_model.py (+53/-0) |
To merge this branch: | bzr merge lp:~savoirfairelinux-openerp/knowledge-addons/cmis |
Related bugs: | |
Related blueprints: |
Allow DMS storage on a per domain basis
(Undefined)
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sandy Carter (http://www.savoirfairelinux.com) | Needs Resubmitting | ||
Maxime Chambreuil (http://www.savoirfairelinux.com) | test | Needs Fixing | |
Holger Brunn (Therp) | code review | Approve | |
Review via email:
|
Commit message
Description of the change
This module allows to configure a CMIS backend in OpenERP.

Holger Brunn (Therp) (hbrunn) wrote : | # |
- 17. By El Hadji Dem (http://www.savoirfairelinux.com)
-
[IMP] add the good version for cmislib and add the external_
dependencies

El Hadji Dem (http://www.savoirfairelinux.com) (eh-dem) wrote : | # |
> #95 add cmislib as external dependency
> #132 is there a version 1.7 of cmis? I only know of 1.0 and 1.1
Thanks for comments

Holger Brunn (Therp) (hbrunn) wrote : | # |
Do you also have to change #135?
- 18. By El Hadji Dem (http://www.savoirfairelinux.com)
-
[IMP] add the good version

El Hadji Dem (http://www.savoirfairelinux.com) (eh-dem) wrote : | # |
> Do you also have to change #135?
It's done

Holger Brunn (Therp) (hbrunn) : | # |
- 19. By El Hadji Dem (http://www.savoirfairelinux.com)
-
[IMP] Check the permission when reading or writing doc

Maxime Chambreuil (http://www.savoirfairelinux.com) (max3903) : | # |

Maxime Chambreuil (http://www.savoirfairelinux.com) (max3903) wrote : | # |
@ehdem
l205: Can you put CMIS versions (1.0 or 1.1, not sure) ? 1.7 is a Magento version.
Thanks

Maxime Chambreuil (http://www.savoirfairelinux.com) (max3903) wrote : | # |
I got a stacktrace instead of an error message when testing the connection:
Server Traceback (most recent call last):
File "/home/
return openerp.
File "/opt/openerp/
result = ExportService.
File "/opt/openerp/
res = fn(db, uid, *params)
File "/opt/openerp/
return self.execute(db, uid, obj, method, *args, **kw or {})
File "/opt/openerp/
return f(self, dbname, *args, **kwargs)
File "/opt/openerp/
res = self.execute_cr(cr, uid, obj, method, *args, **kw)
File "/opt/openerp/
return getattr(object, method)(cr, uid, *args, **kw)
File "/home/
repo = client.
File "/home/
doc = self.get(
File "/home/
**kwargs)
File "/home/
return opener.
File "/usr/lib/
response = self._open(req, data)
File "/usr/lib/
'_open', req)
File "/usr/lib/
result = func(*args)
File "/usr/lib/
return self.do_
File "/usr/lib/
raise URLError(err)
URLError: <urlopen error [Errno 111] Connexion refusée>

Maxime Chambreuil (http://www.savoirfairelinux.com) (max3903) wrote : | # |
test

El Hadji Dem (http://www.savoirfairelinux.com) (eh-dem) wrote : | # |
@Maxime: Thanks for comments, just need free time to fix it
- 20. By El Hadji Dem (http://www.savoirfairelinux.com)
-
[IMP] Add good version of cmis
- 21. By El Hadji Dem (http://www.savoirfairelinux.com)
-
[IMP] Change cmis version and add popup message we get issue if the configuration is not correct
- 22. By El Hadji Dem (http://www.savoirfairelinux.com)
-
[IMP] Add / as default value for Initial directory of read and Initial directory of write fields

Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) wrote : | # |
except_osv is depricated, please use except_orm
l.213 missing context propagation
l.276 POSSIBLE SQL INJECTION with filenames which contain quotes, please use appropriate code escapes from the library (don't write your own)
No Unittests
Flake8:
cmis/cmis_
cmis/cmis_
cmis/cmis_
cmis/cmis_
cmis/cmis_
cmis/cmis_
cmis/cmis_
cmis/cmis_
cmis/cmis_
cmis/cmis_
cmis/connector.
cmis/connector.

Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) wrote : | # |
Missing security model for cmis.backend

El Hadji Dem (http://www.savoirfairelinux.com) (eh-dem) wrote : | # |
@Sandy Carter: fixing your comments
- 23. By El Hadji Dem (http://www.savoirfairelinux.com)
-
[IMP] take Comments from LP

Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) wrote : | # |
Flake8:
cmis/connector.
cmis/connector.
l.270 you still need to escape literals
http://
http://
- 24. By El Hadji Dem (http://www.savoirfairelinux.com)
-
[IMP] Fixed comments from LP, modify check_directory
_of_write, check_directory _of_write, username and password fields to be required - 25. By El Hadji Dem (http://www.savoirfairelinux.com)
-
[IMP] fixed conflits
- 26. By El Hadji Dem (http://www.savoirfairelinux.com)
-
[IMp] updated test files

Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) wrote : | # |
l.225,259 can you please explain what you do here. It seems you attempt to write to a directory to test if you have write permission, surely there are safer ways of doing this.
In you unittest, can you test more of your functions, I know there is a challenge of not having a cmis server running to the tests, but even testing for a raised exception is better than just testing the model.
- 27. By El Hadji Dem (http://www.savoirfairelinux.com)
-
[IMP] Change the form view,add two booleans fields to check the write access right and the read access right
- 28. By El Hadji Dem (http://www.savoirfairelinux.com)
-
[IMP] Check if alfresco server is down
- 29. By El Hadji Dem (http://www.savoirfairelinux.com)
-
[IMP]Add functions for manage input filename and cmis query

Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) wrote : | # |
Looking a lot better, still issues about the comments preceding functions which would be more useful as docstrings.

Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) wrote : | # |
This MP have been moved to MP to https:/
Unmerged revisions
- 29. By El Hadji Dem (http://www.savoirfairelinux.com)
-
[IMP]Add functions for manage input filename and cmis query
- 28. By El Hadji Dem (http://www.savoirfairelinux.com)
-
[IMP] Check if alfresco server is down
- 27. By El Hadji Dem (http://www.savoirfairelinux.com)
-
[IMP] Change the form view,add two booleans fields to check the write access right and the read access right
- 26. By El Hadji Dem (http://www.savoirfairelinux.com)
-
[IMp] updated test files
- 25. By El Hadji Dem (http://www.savoirfairelinux.com)
-
[IMP] fixed conflits
- 24. By El Hadji Dem (http://www.savoirfairelinux.com)
-
[IMP] Fixed comments from LP, modify check_directory
_of_write, check_directory _of_write, username and password fields to be required - 23. By El Hadji Dem (http://www.savoirfairelinux.com)
-
[IMP] take Comments from LP
- 22. By El Hadji Dem (http://www.savoirfairelinux.com)
-
[IMP] Add / as default value for Initial directory of read and Initial directory of write fields
- 21. By El Hadji Dem (http://www.savoirfairelinux.com)
-
[IMP] Change cmis version and add popup message we get issue if the configuration is not correct
- 20. By El Hadji Dem (http://www.savoirfairelinux.com)
-
[IMP] Add good version of cmis
Preview Diff
1 | === added directory 'cmis' |
2 | === added file 'cmis/__init__.py' |
3 | --- cmis/__init__.py 1970-01-01 00:00:00 +0000 |
4 | +++ cmis/__init__.py 2014-06-12 19:47:23 +0000 |
5 | @@ -0,0 +1,26 @@ |
6 | +# -*- encoding: utf-8 -*- |
7 | +############################################################################## |
8 | +# |
9 | +# OpenERP, Open Source Management Solution |
10 | +# This module copyright (C) 2014 Savoir-faire Linux |
11 | +# (<http://www.savoirfairelinux.com>). |
12 | +# |
13 | +# This program is free software: you can redistribute it and/or modify |
14 | +# it under the terms of the GNU Affero General Public License as |
15 | +# published by the Free Software Foundation, either version 3 of the |
16 | +# License, or (at your option) any later version. |
17 | +# |
18 | +# This program is distributed in the hope that it will be useful, |
19 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
21 | +# GNU Affero General Public License for more details. |
22 | +# |
23 | +# You should have received a copy of the GNU Affero General Public License |
24 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
25 | +# |
26 | +############################################################################## |
27 | + |
28 | +from . import cmis_model |
29 | +from . import backend |
30 | + |
31 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
32 | |
33 | === added file 'cmis/__openerp__.py' |
34 | --- cmis/__openerp__.py 1970-01-01 00:00:00 +0000 |
35 | +++ cmis/__openerp__.py 2014-06-12 19:47:23 +0000 |
36 | @@ -0,0 +1,62 @@ |
37 | +# -*- encoding: utf-8 -*- |
38 | +############################################################################## |
39 | +# |
40 | +# OpenERP, Open Source Management Solution |
41 | +# This module copyright (C) 2014 Savoir-faire Linux |
42 | +# (<http://www.savoirfairelinux.com>). |
43 | +# |
44 | +# This program is free software: you can redistribute it and/or modify |
45 | +# it under the terms of the GNU Affero General Public License as |
46 | +# published by the Free Software Foundation, either version 3 of the |
47 | +# License, or (at your option) any later version. |
48 | +# |
49 | +# This program is distributed in the hope that it will be useful, |
50 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
51 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
52 | +# GNU Affero General Public License for more details. |
53 | +# |
54 | +# You should have received a copy of the GNU Affero General Public License |
55 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
56 | +# |
57 | +############################################################################## |
58 | + |
59 | +{ |
60 | + 'name': 'CMIS', |
61 | + 'version': '0.1', |
62 | + 'category': 'Connector', |
63 | + 'summary': 'Cmis Connector', |
64 | + 'description': """ |
65 | +Cmis Connector |
66 | +============== |
67 | + |
68 | +This module is the base for OpenERP modules implementing different integration scenario with a CMIS server. |
69 | +It allows you to configure a CMIS backend in OpenERP. |
70 | + |
71 | +Configuration |
72 | +============= |
73 | + |
74 | +Create a new CMIS backend with the host, login and password. |
75 | + |
76 | +Contributors |
77 | +------------ |
78 | +* El Hadji Dem (elhadji.dem@savoirfairelinux.com) |
79 | +""", |
80 | + 'author': 'Savoir-faire Linux', |
81 | + 'website': 'www.savoirfairelinux.com', |
82 | + 'license': 'AGPL-3', |
83 | + 'depends': [ |
84 | + 'connector', |
85 | + ], |
86 | + 'data': [ |
87 | + 'cmis_model_view.xml', |
88 | + 'cmis_menu.xml', |
89 | + ], |
90 | + 'js': [], |
91 | + 'qweb': [], |
92 | + 'test': [], |
93 | + 'demo': [], |
94 | + 'installable': True, |
95 | + 'auto_install': False, |
96 | +} |
97 | + |
98 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
99 | |
100 | === added file 'cmis/backend.py' |
101 | --- cmis/backend.py 1970-01-01 00:00:00 +0000 |
102 | +++ cmis/backend.py 2014-06-12 19:47:23 +0000 |
103 | @@ -0,0 +1,32 @@ |
104 | +# -*- encoding: utf-8 -*- |
105 | +############################################################################## |
106 | +# |
107 | +# OpenERP, Open Source Management Solution |
108 | +# This module copyright (C) 2014 Savoir-faire Linux |
109 | +# (<http://www.savoirfairelinux.com>). |
110 | +# |
111 | +# This program is free software: you can redistribute it and/or modify |
112 | +# it under the terms of the GNU Affero General Public License as |
113 | +# published by the Free Software Foundation, either version 3 of the |
114 | +# License, or (at your option) any later version. |
115 | +# |
116 | +# This program is distributed in the hope that it will be useful, |
117 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
118 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
119 | +# GNU Affero General Public License for more details. |
120 | +# |
121 | +# You should have received a copy of the GNU Affero General Public License |
122 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
123 | +# |
124 | +############################################################################## |
125 | + |
126 | +import openerp.addons.connector.backend as backend |
127 | + |
128 | + |
129 | +cmis = backend.Backend('cmis') |
130 | +""" Generic CMIS Backend """ |
131 | + |
132 | +cmis1000 = backend.Backend(parent=cmis, version='1.0') |
133 | +""" CMIS Backend for version 1.0 """ |
134 | + |
135 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
136 | |
137 | === added file 'cmis/cmis_menu.xml' |
138 | --- cmis/cmis_menu.xml 1970-01-01 00:00:00 +0000 |
139 | +++ cmis/cmis_menu.xml 2014-06-12 19:47:23 +0000 |
140 | @@ -0,0 +1,17 @@ |
141 | +<?xml version="1.0" encoding="utf-8"?> |
142 | +<openerp> |
143 | + <data> |
144 | + |
145 | + <menuitem id="menu_cmis_root" |
146 | + parent="connector.menu_connector_root" |
147 | + name="Cmis" |
148 | + sequence="10" |
149 | + groups="connector.group_connector_manager"/> |
150 | + |
151 | + <menuitem id="menu_cmis_backend" |
152 | + name="Backends" |
153 | + parent="menu_cmis_root" |
154 | + action="action_cmis_backend"/> |
155 | + |
156 | + </data> |
157 | +</openerp> |
158 | |
159 | === added file 'cmis/cmis_model.py' |
160 | --- cmis/cmis_model.py 1970-01-01 00:00:00 +0000 |
161 | +++ cmis/cmis_model.py 2014-06-12 19:47:23 +0000 |
162 | @@ -0,0 +1,183 @@ |
163 | +# -*- encoding: utf-8 -*- |
164 | +############################################################################## |
165 | +# |
166 | +# OpenERP, Open Source Management Solution |
167 | +# This module copyright (C) 2014 Savoir-faire Linux |
168 | +# (<http://www.savoirfairelinux.com>). |
169 | +# |
170 | +# This program is free software: you can redistribute it and/or modify |
171 | +# it under the terms of the GNU Affero General Public License as |
172 | +# published by the Free Software Foundation, either version 3 of the |
173 | +# License, or (at your option) any later version. |
174 | +# |
175 | +# This program is distributed in the hope that it will be useful, |
176 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
177 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
178 | +# GNU Affero General Public License for more details. |
179 | +# |
180 | +# You should have received a copy of the GNU Affero General Public License |
181 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
182 | +# |
183 | +############################################################################## |
184 | + |
185 | +from openerp.osv import orm, fields |
186 | +from openerp.tools.translate import _ |
187 | +from cmislib.model import CmisClient |
188 | +import cmislib.exceptions |
189 | +import urllib2 |
190 | + |
191 | + |
192 | +class cmis_backend(orm.Model): |
193 | + _name = 'cmis.backend' |
194 | + _description = 'CMIS Backend' |
195 | + _inherit = 'connector.backend' |
196 | + |
197 | + _backend_type = 'cmis' |
198 | + |
199 | + def _select_versions(self, cr, uid, context=None): |
200 | + return [('1.0', '1.0')] |
201 | + |
202 | + # Test connection with GED |
203 | + def _auth(self, cr, uid, context=None): |
204 | + if context is None: |
205 | + context = {} |
206 | + # Get the url, user and password for GED |
207 | + ids = self.search(cr, uid, []) |
208 | + res = self.read(cr, uid, ids, |
209 | + ['location', |
210 | + 'username', |
211 | + 'password'], context=context)[0] |
212 | + url = res['location'] |
213 | + user_name = res['username'] |
214 | + user_password = res['password'] |
215 | + client = CmisClient(url, user_name, user_password) |
216 | + |
217 | + try: |
218 | + return client.defaultRepository |
219 | + except cmislib.exceptions.ObjectNotFoundException: |
220 | + raise orm.except_orm(_('Cmis connection Error!'), |
221 | + _("Check your cmis account configuration.")) |
222 | + except cmislib.exceptions.PermissionDeniedException: |
223 | + raise orm.except_orm(_('Cmis connection Error!'), |
224 | + _("Check your cmis account configuration.")) |
225 | + except urllib2.URLError: |
226 | + raise orm.except_orm(_('Cmis connection Error!'), |
227 | + _("SERVER is down.")) |
228 | + |
229 | + # Function to check if we have access right to write from the path |
230 | + def check_directory_of_write(self, cr, uid, ids, context=None): |
231 | + if context is None: |
232 | + context = {} |
233 | + cmis_backend_obj = self.pool.get('cmis.backend') |
234 | + datas_fname = 'testdoc' |
235 | + # login with the cmis account |
236 | + repo = self._auth(cr, uid, context=context) |
237 | + cmis_backend_rec = cmis_backend_obj.read( |
238 | + cr, uid, ids, ['initial_directory_write'], |
239 | + context=context)[0] |
240 | + folder_path_write = cmis_backend_rec['initial_directory_write'] |
241 | + # Testing the path |
242 | + rs = repo.query("SELECT cmis:path FROM cmis:folder") |
243 | + bool_path_write = self.check_existing_path(rs, folder_path_write) |
244 | + # Check if we can create a doc from OE to EDM |
245 | + # Document properties |
246 | + if bool_path_write: |
247 | + sub = repo.getObjectByPath(folder_path_write) |
248 | + try: |
249 | + sub.createDocumentFromString( |
250 | + datas_fname, |
251 | + contentString='hello, world', |
252 | + contentType='text/plain') |
253 | + except cmislib.exceptions.UpdateConflictException: |
254 | + raise orm.except_orm( |
255 | + _('Cmis Error!'), |
256 | + _("The test file is already existed in DMS. " |
257 | + "Please remove it and try again.")) |
258 | + except cmislib.exceptions.RuntimeException: |
259 | + raise orm.except_orm( |
260 | + _('Cmis access right Error!'), |
261 | + ("Please check your access right.")) |
262 | + self.get_error_for_path(bool_path_write, folder_path_write) |
263 | + |
264 | + # Function to check if we have access right to read from the path |
265 | + def check_directory_of_read(self, cr, uid, ids, context=None): |
266 | + ir_attach_obj = self.pool.get('ir.attachment') |
267 | + if context is None: |
268 | + context = {} |
269 | + cmis_backend_obj = self.pool.get('cmis.backend') |
270 | + cmis_backend_rec = cmis_backend_obj.read( |
271 | + cr, uid, ids, ['initial_directory_read'], |
272 | + context=context)[0] |
273 | + # Login with the cmis account |
274 | + repo = self._auth(cr, uid, context=context) |
275 | + folder_path_read = cmis_backend_rec['initial_directory_read'] |
276 | + # Testing the path |
277 | + rs = repo.query("SELECT cmis:path FROM cmis:folder ") |
278 | + bool_path_read = self.check_existing_path(rs, folder_path_read) |
279 | + self.get_error_for_path(bool_path_read, folder_path_read) |
280 | + |
281 | + # Function to check if the path is correct |
282 | + def check_existing_path(self, rs, folder_path): |
283 | + for one_rs in rs: |
284 | + # Print name of files |
285 | + props = one_rs.getProperties() |
286 | + if props['cmis:path'] != folder_path: |
287 | + bool = False |
288 | + else: |
289 | + bool = True |
290 | + break |
291 | + return bool |
292 | + |
293 | + # Function to return following the boolean the right error message |
294 | + def get_error_for_path(self, bool, path): |
295 | + if bool: |
296 | + raise orm.except_orm(_('Cmis Message'), |
297 | + _("Path is correct for : " + path)) |
298 | + else: |
299 | + raise orm.except_orm(_('Cmis Error!'), |
300 | + _("Error path for : " + path)) |
301 | + |
302 | + # Escape the name for characters not supported in filenames |
303 | + def sanitize_input(self, file_name): |
304 | + # for avoiding SQL Injection |
305 | + file_name = file_name.replace("'", "\\'") |
306 | + file_name = file_name.replace("%", "\%") |
307 | + file_name = file_name.replace("_", "\_") |
308 | + return file_name |
309 | + |
310 | + def safe_query(self, query, file_name, repo): |
311 | + args = map(self.sanitize_input, file_name) |
312 | + return repo.query(query % ''.join(args)) |
313 | + |
314 | + _columns = { |
315 | + 'version': fields.selection( |
316 | + _select_versions, |
317 | + string='Version', |
318 | + required=True), |
319 | + 'location': fields.char('Location', size=128, required=True, |
320 | + help="Location."), |
321 | + 'username': fields.char('Username', size=64, required=True, |
322 | + help="Username."), |
323 | + 'password': fields.char('Password', size=64, required=True, |
324 | + help="Password."), |
325 | + 'initial_directory_read': fields.char( |
326 | + 'Initial directory of read', |
327 | + size=128, |
328 | + required=True, |
329 | + help="Initial directory of read."), |
330 | + 'initial_directory_write': fields.char( |
331 | + 'Initial directory of write', |
332 | + size=128, |
333 | + required=True, |
334 | + help="Initial directory of write."), |
335 | + 'browsing_ok': fields.boolean('Allow browsing this backend', |
336 | + help="Allow browsing this backend."), |
337 | + 'storing_ok': fields.boolean('Allow storing in this backend', |
338 | + help="Allow storing in this backend."), |
339 | + } |
340 | + _defaults = { |
341 | + 'initial_directory_read': '/', |
342 | + 'initial_directory_write': '/', |
343 | + } |
344 | + |
345 | +# vim:expandtab:smartindent:toabstop=4:softtabstop=4:shiftwidth=4: |
346 | |
347 | === added file 'cmis/cmis_model_view.xml' |
348 | --- cmis/cmis_model_view.xml 1970-01-01 00:00:00 +0000 |
349 | +++ cmis/cmis_model_view.xml 2014-06-12 19:47:23 +0000 |
350 | @@ -0,0 +1,74 @@ |
351 | +<?xml version="1.0" encoding="utf-8"?> |
352 | +<openerp> |
353 | + <data> |
354 | + |
355 | + <record id="view_cmis_backend_form" model="ir.ui.view"> |
356 | + <field name="name">cmis.backend.form</field> |
357 | + <field name="model">cmis.backend</field> |
358 | + <field name="arch" type="xml"> |
359 | + <form string="CMIS Backend" version="7.0"> |
360 | + <sheet> |
361 | + <label for="name" class="oe_edit_only"/> |
362 | + <h1> |
363 | + <field name="name" class="oe_inline" /> |
364 | + </h1> |
365 | + <group name="cmis" string="Cmis Configuration"> |
366 | + <group colspan="4" col="4"> |
367 | + <field name="version" colspan="4"/> |
368 | + <field name="location" placeholder="e.g. http://localhost:8081/alfresco/s/cmis" |
369 | + colspan="4"/> |
370 | + <field name="username" colspan="2"/> |
371 | + <field name="password" colspan="2" password="True"/> |
372 | + </group> |
373 | + </group> |
374 | + <group name="directory_conf" string="Directory Configuration"> |
375 | + <group > |
376 | + <field name="browsing_ok"/> |
377 | + <newline/> |
378 | + <group attrs="{'invisible':[('browsing_ok','=',False)]}" |
379 | + colspan="4" col="4"> |
380 | + <field name="initial_directory_read"/> |
381 | + <button name="check_directory_of_read" |
382 | + type="object" |
383 | + class="oe_highlight" |
384 | + string="Test Directory of read"/> |
385 | + </group> |
386 | + <newline/> |
387 | + <field name="storing_ok"/> |
388 | + <newline/> |
389 | + <group attrs="{'invisible':[('storing_ok','=',False)]}" |
390 | + colspan="4" col="4"> |
391 | + <field name="initial_directory_write"/> |
392 | + <button name="check_directory_of_write" |
393 | + type="object" |
394 | + class="oe_highlight" |
395 | + string="Test Directory of write"/> |
396 | + </group> |
397 | + </group> |
398 | + </group> |
399 | + </sheet> |
400 | + </form> |
401 | + </field> |
402 | + </record> |
403 | + |
404 | + <record id="view_cmis_backend_tree" model="ir.ui.view"> |
405 | + <field name="name">cmis.backend.tree</field> |
406 | + <field name="model">cmis.backend</field> |
407 | + <field name="arch" type="xml"> |
408 | + <tree string="CMIS Backend" version="7.0"> |
409 | + <field name="name"/> |
410 | + <field name="username"/> |
411 | + <field name="location"/> |
412 | + </tree> |
413 | + </field> |
414 | + </record> |
415 | + |
416 | + <record id="action_cmis_backend" model="ir.actions.act_window"> |
417 | + <field name="name">CMIS Backends</field> |
418 | + <field name="res_model">cmis.backend</field> |
419 | + <field name="view_type">form</field> |
420 | + <field name="view_mode">tree,form</field> |
421 | + <field name="view_id" ref="view_cmis_backend_tree"/> |
422 | + </record> |
423 | + </data> |
424 | +</openerp> |
425 | |
426 | === added file 'cmis/connector.py' |
427 | --- cmis/connector.py 1970-01-01 00:00:00 +0000 |
428 | +++ cmis/connector.py 2014-06-12 19:47:23 +0000 |
429 | @@ -0,0 +1,38 @@ |
430 | +# -*- encoding: utf-8 -*- |
431 | +############################################################################## |
432 | +# |
433 | +# OpenERP, Open Source Management Solution |
434 | +# This module copyright (C) 2014 Savoir-faire Linux |
435 | +# (<http://www.savoirfairelinux.com>). |
436 | +# |
437 | +# This program is free software: you can redistribute it and/or modify |
438 | +# it under the terms of the GNU Affero General Public License as |
439 | +# published by the Free Software Foundation, either version 3 of the |
440 | +# License, or (at your option) any later version. |
441 | +# |
442 | +# This program is distributed in the hope that it will be useful, |
443 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
444 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
445 | +# GNU Affero General Public License for more details. |
446 | +# |
447 | +# You should have received a copy of the GNU Affero General Public License |
448 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
449 | +# |
450 | +############################################################################## |
451 | + |
452 | +from openerp.addons.connector.connector import (Environment, |
453 | + install_in_connector) |
454 | + |
455 | +install_in_connector() |
456 | + |
457 | + |
458 | +def get_environment(session, model_name, backend_id): |
459 | + """ Create an environment to work with. """ |
460 | + backend_record = session.browse('cmis.backend', backend_id) |
461 | + env = Environment(backend_record, session, model_name) |
462 | + lang = backend_record.default_lang_id |
463 | + lang_code = lang.code if lang else 'en_US' |
464 | + env.set_lang(code=lang_code) |
465 | + return env |
466 | + |
467 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
468 | |
469 | === added directory 'cmis/security' |
470 | === added file 'cmis/security/ir.model.access.csv' |
471 | --- cmis/security/ir.model.access.csv 1970-01-01 00:00:00 +0000 |
472 | +++ cmis/security/ir.model.access.csv 2014-06-12 19:47:23 +0000 |
473 | @@ -0,0 +1,2 @@ |
474 | +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" |
475 | +access_cmis_backend_user,access_cmis_backend_user,model_cmis_backend,base.group_user,1,0,0,0 |
476 | |
477 | === added directory 'cmis/tests' |
478 | === added file 'cmis/tests/__init__.py' |
479 | --- cmis/tests/__init__.py 1970-01-01 00:00:00 +0000 |
480 | +++ cmis/tests/__init__.py 2014-06-12 19:47:23 +0000 |
481 | @@ -0,0 +1,29 @@ |
482 | +# -*- encoding: utf-8 -*- |
483 | +############################################################################## |
484 | +# |
485 | +# OpenERP, Open Source Management Solution |
486 | +# This module copyright (C) 2013-2014 Savoir-faire Linux |
487 | +# (<http://www.savoirfairelinux.com>). |
488 | +# |
489 | +# This program is free software: you can redistribute it and/or modify |
490 | +# it under the terms of the GNU Affero General Public License as |
491 | +# published by the Free Software Foundation, either version 3 of the |
492 | +# License, or (at your option) any later version. |
493 | +# |
494 | +# This program is distributed in the hope that it will be useful, |
495 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
496 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
497 | +# GNU Affero General Public License for more details. |
498 | +# |
499 | +# You should have received a copy of the GNU Affero General Public License |
500 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
501 | +# |
502 | +############################################################################## |
503 | + |
504 | +from . import ( |
505 | + test_model, |
506 | +) |
507 | + |
508 | +checks = [ |
509 | + test_model, |
510 | +] |
511 | |
512 | === added file 'cmis/tests/test_model.py' |
513 | --- cmis/tests/test_model.py 1970-01-01 00:00:00 +0000 |
514 | +++ cmis/tests/test_model.py 2014-06-12 19:47:23 +0000 |
515 | @@ -0,0 +1,53 @@ |
516 | +# -*- encoding: utf-8 -*- |
517 | +############################################################################### |
518 | +# |
519 | +# OpenERP, Open Source Management Solution |
520 | +# This module copyright (C) 2010 - 2014 Savoir-faire Linux |
521 | +# (<http://www.savoirfairelinux.com>). |
522 | +# |
523 | +# This program is free software: you can redistribute it and/or modify |
524 | +# it under the terms of the GNU Affero General Public License as |
525 | +# published by the Free Software Foundation, either version 3 of the |
526 | +# License, or (at your option) any later version. |
527 | +# |
528 | +# This program is distributed in the hope that it will be useful, |
529 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
530 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
531 | +# GNU Affero General Public License for more details. |
532 | +# |
533 | +# You should have received a copy of the GNU Affero General Public License |
534 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
535 | +# |
536 | +############################################################################### |
537 | + |
538 | +from openerp.tests.common import TransactionCase |
539 | + |
540 | + |
541 | +class test_model(TransactionCase): |
542 | + |
543 | + def setUp(self): |
544 | + super(test_model, self).setUp() |
545 | + # Clean up registries |
546 | + self.registry('ir.model').clear_caches() |
547 | + self.registry('ir.model.data').clear_caches() |
548 | + self.user_model = self.registry("res.users") |
549 | + |
550 | + # Get registries |
551 | + self.model = self.registry("cmis.backend") |
552 | + # Get context |
553 | + self.context = self.user_model.context_get(self.cr, self.uid) |
554 | + |
555 | + self.vals = { |
556 | + 'name': "Test cmis", |
557 | + 'version': '1.0', |
558 | + 'location': "http://localhost:8081/alfresco/s/cmis", |
559 | + 'username': 'admin', |
560 | + 'password': 'admin', |
561 | + 'initial_directory_read': '/', |
562 | + 'initial_directory_write': '/', |
563 | + } |
564 | + |
565 | + def test_create_model(self): |
566 | + model_id = self.model.create( |
567 | + self.cr, self.uid, self.vals, context=self.context) |
568 | + self.assertTrue(model_id) |
#95 add cmislib as external dependency
#132 is there a version 1.7 of cmis? I only know of 1.0 and 1.1