Merge lp:~savoirfairelinux-openerp/knowledge-addons/cmis into lp:knowledge-addons/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
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: mp+212258@code.launchpad.net

Description of the change

This module allows to configure a CMIS backend in OpenERP.

To post a comment you must log in.
Revision history for this message
Holger Brunn (Therp) (hbrunn) 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

review: Needs Fixing (code review)
17. By El Hadji Dem (http://www.savoirfairelinux.com)

[IMP] add the good version for cmislib and add the external_dependencies

Revision history for this message
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

Revision history for this message
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

Revision history for this message
El Hadji Dem (http://www.savoirfairelinux.com) (eh-dem) wrote :

> Do you also have to change #135?

It's done

Revision history for this message
Holger Brunn (Therp) (hbrunn) :
review: Approve (code review)
19. By El Hadji Dem (http://www.savoirfairelinux.com)

[IMP] Check the permission when reading or writing doc

Revision history for this message
Maxime Chambreuil (http://www.savoirfairelinux.com) (max3903) :
review: Approve
Revision history for this message
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

review: Needs Fixing (test)
Revision history for this message
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/max/openerp/cmis/bzr/web/addons/web/session.py", line 89, in send
    return openerp.netsvc.dispatch_rpc(service_name, method, args)
  File "/opt/openerp/7.0/server/openerp/netsvc.py", line 296, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/opt/openerp/7.0/server/openerp/service/web_services.py", line 626, in dispatch
    res = fn(db, uid, *params)
  File "/opt/openerp/7.0/server/openerp/osv/osv.py", line 190, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/opt/openerp/7.0/server/openerp/osv/osv.py", line 132, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/opt/openerp/7.0/server/openerp/osv/osv.py", line 199, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/opt/openerp/7.0/server/openerp/osv/osv.py", line 187, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/max/openerp/cmis/bzr/knowledge/cmis/cmis_model.py", line 68, in check_directory_of_write
    repo = client.defaultRepository
  File "/home/max/openerp/cmis/git/openerp/tools/eggs/cmislib-0.5.1-py2.7.egg/cmislib/model.py", line 179, in getDefaultRepository
    doc = self.get(self.repositoryUrl, **self.extArgs)
  File "/home/max/openerp/cmis/git/openerp/tools/eggs/cmislib-0.5.1-py2.7.egg/cmislib/model.py", line 206, in get
    **kwargs)
  File "/home/max/openerp/cmis/git/openerp/tools/eggs/cmislib-0.5.1-py2.7.egg/cmislib/net.py", line 145, in get
    return opener.open(request)
  File "/usr/lib/python2.7/urllib2.py", line 404, in open
    response = self._open(req, data)
  File "/usr/lib/python2.7/urllib2.py", line 422, in _open
    '_open', req)
  File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 1214, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/usr/lib/python2.7/urllib2.py", line 1184, in do_open
    raise URLError(err)
URLError: <urlopen error [Errno 111] Connexion refusée>

review: Needs Fixing (test)
Revision history for this message
Maxime Chambreuil (http://www.savoirfairelinux.com) (max3903) wrote :

test

Revision history for this message
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

Revision history for this message
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_model.py:25:1: F401 'job' imported but unused
cmis/cmis_model.py:27:1: F401 'connector' imported but unused
cmis/cmis_model.py:28:1: F401 'ConnectorSession' imported but unused
cmis/cmis_model.py:29:1: F401 'base64' imported but unused
cmis/cmis_model.py:71:9: E265 block comment should start with '# '
cmis/cmis_model.py:84:13: F841 local variable 'someDoc' is assigned to but never used
cmis/cmis_model.py:92:9: F841 local variable 'ir_attach_dms_obj' is assigned to but never used
cmis/cmis_model.py:96:9: E265 block comment should start with '# '
cmis/cmis_model.py:97:9: E265 block comment should start with '# '
cmis/cmis_model.py:120:17: F841 local variable 'res' is assigned to but never used
cmis/connector.py:23:1: F401 'fields' imported but unused
cmis/connector.py:23:1: F401 'orm' imported but unused

review: Needs Fixing
Revision history for this message
Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) wrote :

Missing security model for cmis.backend

review: Needs Fixing
Revision history for this message
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

Revision history for this message
Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) wrote :

Flake8:
cmis/connector.py:23:1: F401 'fields' imported but unused
cmis/connector.py:23:1: F401 'orm' imported but unused

l.270 you still need to escape literals
http://wiki.alfresco.com/wiki/CMIS_Query_Language#Literals
http://pic.dhe.ibm.com/infocenter/p8docs/v5r0m0/index.jsp?topic=%2Fcom.ibm.installingp8cmis.doc%2Fcmidv022.htm

review: Needs Fixing
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

Revision history for this message
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.

review: Needs Information
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

Revision history for this message
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.

Revision history for this message
Sandy Carter (http://www.savoirfairelinux.com) (sandy-carter) wrote :

This MP have been moved to MP to https://github.com/OCA/knowledge/pull/6

review: Needs Resubmitting

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

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'cmis'
=== added file 'cmis/__init__.py'
--- cmis/__init__.py 1970-01-01 00:00:00 +0000
+++ cmis/__init__.py 2014-06-12 19:47:23 +0000
@@ -0,0 +1,26 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This module copyright (C) 2014 Savoir-faire Linux
6# (<http://www.savoirfairelinux.com>).
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as
10# published by the Free Software Foundation, either version 3 of the
11# License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23from . import cmis_model
24from . import backend
25
26# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
027
=== added file 'cmis/__openerp__.py'
--- cmis/__openerp__.py 1970-01-01 00:00:00 +0000
+++ cmis/__openerp__.py 2014-06-12 19:47:23 +0000
@@ -0,0 +1,62 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This module copyright (C) 2014 Savoir-faire Linux
6# (<http://www.savoirfairelinux.com>).
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as
10# published by the Free Software Foundation, either version 3 of the
11# License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23{
24 'name': 'CMIS',
25 'version': '0.1',
26 'category': 'Connector',
27 'summary': 'Cmis Connector',
28 'description': """
29Cmis Connector
30==============
31
32This module is the base for OpenERP modules implementing different integration scenario with a CMIS server.
33It allows you to configure a CMIS backend in OpenERP.
34
35Configuration
36=============
37
38Create a new CMIS backend with the host, login and password.
39
40Contributors
41------------
42* El Hadji Dem (elhadji.dem@savoirfairelinux.com)
43""",
44 'author': 'Savoir-faire Linux',
45 'website': 'www.savoirfairelinux.com',
46 'license': 'AGPL-3',
47 'depends': [
48 'connector',
49 ],
50 'data': [
51 'cmis_model_view.xml',
52 'cmis_menu.xml',
53 ],
54 'js': [],
55 'qweb': [],
56 'test': [],
57 'demo': [],
58 'installable': True,
59 'auto_install': False,
60}
61
62# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
063
=== added file 'cmis/backend.py'
--- cmis/backend.py 1970-01-01 00:00:00 +0000
+++ cmis/backend.py 2014-06-12 19:47:23 +0000
@@ -0,0 +1,32 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This module copyright (C) 2014 Savoir-faire Linux
6# (<http://www.savoirfairelinux.com>).
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as
10# published by the Free Software Foundation, either version 3 of the
11# License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23import openerp.addons.connector.backend as backend
24
25
26cmis = backend.Backend('cmis')
27""" Generic CMIS Backend """
28
29cmis1000 = backend.Backend(parent=cmis, version='1.0')
30""" CMIS Backend for version 1.0 """
31
32# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
033
=== added file 'cmis/cmis_menu.xml'
--- cmis/cmis_menu.xml 1970-01-01 00:00:00 +0000
+++ cmis/cmis_menu.xml 2014-06-12 19:47:23 +0000
@@ -0,0 +1,17 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4
5 <menuitem id="menu_cmis_root"
6 parent="connector.menu_connector_root"
7 name="Cmis"
8 sequence="10"
9 groups="connector.group_connector_manager"/>
10
11 <menuitem id="menu_cmis_backend"
12 name="Backends"
13 parent="menu_cmis_root"
14 action="action_cmis_backend"/>
15
16 </data>
17</openerp>
018
=== added file 'cmis/cmis_model.py'
--- cmis/cmis_model.py 1970-01-01 00:00:00 +0000
+++ cmis/cmis_model.py 2014-06-12 19:47:23 +0000
@@ -0,0 +1,183 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This module copyright (C) 2014 Savoir-faire Linux
6# (<http://www.savoirfairelinux.com>).
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as
10# published by the Free Software Foundation, either version 3 of the
11# License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23from openerp.osv import orm, fields
24from openerp.tools.translate import _
25from cmislib.model import CmisClient
26import cmislib.exceptions
27import urllib2
28
29
30class cmis_backend(orm.Model):
31 _name = 'cmis.backend'
32 _description = 'CMIS Backend'
33 _inherit = 'connector.backend'
34
35 _backend_type = 'cmis'
36
37 def _select_versions(self, cr, uid, context=None):
38 return [('1.0', '1.0')]
39
40 # Test connection with GED
41 def _auth(self, cr, uid, context=None):
42 if context is None:
43 context = {}
44 # Get the url, user and password for GED
45 ids = self.search(cr, uid, [])
46 res = self.read(cr, uid, ids,
47 ['location',
48 'username',
49 'password'], context=context)[0]
50 url = res['location']
51 user_name = res['username']
52 user_password = res['password']
53 client = CmisClient(url, user_name, user_password)
54
55 try:
56 return client.defaultRepository
57 except cmislib.exceptions.ObjectNotFoundException:
58 raise orm.except_orm(_('Cmis connection Error!'),
59 _("Check your cmis account configuration."))
60 except cmislib.exceptions.PermissionDeniedException:
61 raise orm.except_orm(_('Cmis connection Error!'),
62 _("Check your cmis account configuration."))
63 except urllib2.URLError:
64 raise orm.except_orm(_('Cmis connection Error!'),
65 _("SERVER is down."))
66
67 # Function to check if we have access right to write from the path
68 def check_directory_of_write(self, cr, uid, ids, context=None):
69 if context is None:
70 context = {}
71 cmis_backend_obj = self.pool.get('cmis.backend')
72 datas_fname = 'testdoc'
73 # login with the cmis account
74 repo = self._auth(cr, uid, context=context)
75 cmis_backend_rec = cmis_backend_obj.read(
76 cr, uid, ids, ['initial_directory_write'],
77 context=context)[0]
78 folder_path_write = cmis_backend_rec['initial_directory_write']
79 # Testing the path
80 rs = repo.query("SELECT cmis:path FROM cmis:folder")
81 bool_path_write = self.check_existing_path(rs, folder_path_write)
82 # Check if we can create a doc from OE to EDM
83 # Document properties
84 if bool_path_write:
85 sub = repo.getObjectByPath(folder_path_write)
86 try:
87 sub.createDocumentFromString(
88 datas_fname,
89 contentString='hello, world',
90 contentType='text/plain')
91 except cmislib.exceptions.UpdateConflictException:
92 raise orm.except_orm(
93 _('Cmis Error!'),
94 _("The test file is already existed in DMS. "
95 "Please remove it and try again."))
96 except cmislib.exceptions.RuntimeException:
97 raise orm.except_orm(
98 _('Cmis access right Error!'),
99 ("Please check your access right."))
100 self.get_error_for_path(bool_path_write, folder_path_write)
101
102 # Function to check if we have access right to read from the path
103 def check_directory_of_read(self, cr, uid, ids, context=None):
104 ir_attach_obj = self.pool.get('ir.attachment')
105 if context is None:
106 context = {}
107 cmis_backend_obj = self.pool.get('cmis.backend')
108 cmis_backend_rec = cmis_backend_obj.read(
109 cr, uid, ids, ['initial_directory_read'],
110 context=context)[0]
111 # Login with the cmis account
112 repo = self._auth(cr, uid, context=context)
113 folder_path_read = cmis_backend_rec['initial_directory_read']
114 # Testing the path
115 rs = repo.query("SELECT cmis:path FROM cmis:folder ")
116 bool_path_read = self.check_existing_path(rs, folder_path_read)
117 self.get_error_for_path(bool_path_read, folder_path_read)
118
119 # Function to check if the path is correct
120 def check_existing_path(self, rs, folder_path):
121 for one_rs in rs:
122 # Print name of files
123 props = one_rs.getProperties()
124 if props['cmis:path'] != folder_path:
125 bool = False
126 else:
127 bool = True
128 break
129 return bool
130
131 # Function to return following the boolean the right error message
132 def get_error_for_path(self, bool, path):
133 if bool:
134 raise orm.except_orm(_('Cmis Message'),
135 _("Path is correct for : " + path))
136 else:
137 raise orm.except_orm(_('Cmis Error!'),
138 _("Error path for : " + path))
139
140 # Escape the name for characters not supported in filenames
141 def sanitize_input(self, file_name):
142 # for avoiding SQL Injection
143 file_name = file_name.replace("'", "\\'")
144 file_name = file_name.replace("%", "\%")
145 file_name = file_name.replace("_", "\_")
146 return file_name
147
148 def safe_query(self, query, file_name, repo):
149 args = map(self.sanitize_input, file_name)
150 return repo.query(query % ''.join(args))
151
152 _columns = {
153 'version': fields.selection(
154 _select_versions,
155 string='Version',
156 required=True),
157 'location': fields.char('Location', size=128, required=True,
158 help="Location."),
159 'username': fields.char('Username', size=64, required=True,
160 help="Username."),
161 'password': fields.char('Password', size=64, required=True,
162 help="Password."),
163 'initial_directory_read': fields.char(
164 'Initial directory of read',
165 size=128,
166 required=True,
167 help="Initial directory of read."),
168 'initial_directory_write': fields.char(
169 'Initial directory of write',
170 size=128,
171 required=True,
172 help="Initial directory of write."),
173 'browsing_ok': fields.boolean('Allow browsing this backend',
174 help="Allow browsing this backend."),
175 'storing_ok': fields.boolean('Allow storing in this backend',
176 help="Allow storing in this backend."),
177 }
178 _defaults = {
179 'initial_directory_read': '/',
180 'initial_directory_write': '/',
181 }
182
183# vim:expandtab:smartindent:toabstop=4:softtabstop=4:shiftwidth=4:
0184
=== added file 'cmis/cmis_model_view.xml'
--- cmis/cmis_model_view.xml 1970-01-01 00:00:00 +0000
+++ cmis/cmis_model_view.xml 2014-06-12 19:47:23 +0000
@@ -0,0 +1,74 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4
5 <record id="view_cmis_backend_form" model="ir.ui.view">
6 <field name="name">cmis.backend.form</field>
7 <field name="model">cmis.backend</field>
8 <field name="arch" type="xml">
9 <form string="CMIS Backend" version="7.0">
10 <sheet>
11 <label for="name" class="oe_edit_only"/>
12 <h1>
13 <field name="name" class="oe_inline" />
14 </h1>
15 <group name="cmis" string="Cmis Configuration">
16 <group colspan="4" col="4">
17 <field name="version" colspan="4"/>
18 <field name="location" placeholder="e.g. http://localhost:8081/alfresco/s/cmis"
19 colspan="4"/>
20 <field name="username" colspan="2"/>
21 <field name="password" colspan="2" password="True"/>
22 </group>
23 </group>
24 <group name="directory_conf" string="Directory Configuration">
25 <group >
26 <field name="browsing_ok"/>
27 <newline/>
28 <group attrs="{'invisible':[('browsing_ok','=',False)]}"
29 colspan="4" col="4">
30 <field name="initial_directory_read"/>
31 <button name="check_directory_of_read"
32 type="object"
33 class="oe_highlight"
34 string="Test Directory of read"/>
35 </group>
36 <newline/>
37 <field name="storing_ok"/>
38 <newline/>
39 <group attrs="{'invisible':[('storing_ok','=',False)]}"
40 colspan="4" col="4">
41 <field name="initial_directory_write"/>
42 <button name="check_directory_of_write"
43 type="object"
44 class="oe_highlight"
45 string="Test Directory of write"/>
46 </group>
47 </group>
48 </group>
49 </sheet>
50 </form>
51 </field>
52 </record>
53
54 <record id="view_cmis_backend_tree" model="ir.ui.view">
55 <field name="name">cmis.backend.tree</field>
56 <field name="model">cmis.backend</field>
57 <field name="arch" type="xml">
58 <tree string="CMIS Backend" version="7.0">
59 <field name="name"/>
60 <field name="username"/>
61 <field name="location"/>
62 </tree>
63 </field>
64 </record>
65
66 <record id="action_cmis_backend" model="ir.actions.act_window">
67 <field name="name">CMIS Backends</field>
68 <field name="res_model">cmis.backend</field>
69 <field name="view_type">form</field>
70 <field name="view_mode">tree,form</field>
71 <field name="view_id" ref="view_cmis_backend_tree"/>
72 </record>
73 </data>
74</openerp>
075
=== added file 'cmis/connector.py'
--- cmis/connector.py 1970-01-01 00:00:00 +0000
+++ cmis/connector.py 2014-06-12 19:47:23 +0000
@@ -0,0 +1,38 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This module copyright (C) 2014 Savoir-faire Linux
6# (<http://www.savoirfairelinux.com>).
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as
10# published by the Free Software Foundation, either version 3 of the
11# License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23from openerp.addons.connector.connector import (Environment,
24 install_in_connector)
25
26install_in_connector()
27
28
29def get_environment(session, model_name, backend_id):
30 """ Create an environment to work with. """
31 backend_record = session.browse('cmis.backend', backend_id)
32 env = Environment(backend_record, session, model_name)
33 lang = backend_record.default_lang_id
34 lang_code = lang.code if lang else 'en_US'
35 env.set_lang(code=lang_code)
36 return env
37
38# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
039
=== added directory 'cmis/security'
=== added file 'cmis/security/ir.model.access.csv'
--- cmis/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
+++ cmis/security/ir.model.access.csv 2014-06-12 19:47:23 +0000
@@ -0,0 +1,2 @@
1"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
2access_cmis_backend_user,access_cmis_backend_user,model_cmis_backend,base.group_user,1,0,0,0
03
=== added directory 'cmis/tests'
=== added file 'cmis/tests/__init__.py'
--- cmis/tests/__init__.py 1970-01-01 00:00:00 +0000
+++ cmis/tests/__init__.py 2014-06-12 19:47:23 +0000
@@ -0,0 +1,29 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This module copyright (C) 2013-2014 Savoir-faire Linux
6# (<http://www.savoirfairelinux.com>).
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as
10# published by the Free Software Foundation, either version 3 of the
11# License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23from . import (
24 test_model,
25)
26
27checks = [
28 test_model,
29]
030
=== added file 'cmis/tests/test_model.py'
--- cmis/tests/test_model.py 1970-01-01 00:00:00 +0000
+++ cmis/tests/test_model.py 2014-06-12 19:47:23 +0000
@@ -0,0 +1,53 @@
1# -*- encoding: utf-8 -*-
2###############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This module copyright (C) 2010 - 2014 Savoir-faire Linux
6# (<http://www.savoirfairelinux.com>).
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as
10# published by the Free Software Foundation, either version 3 of the
11# License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21###############################################################################
22
23from openerp.tests.common import TransactionCase
24
25
26class test_model(TransactionCase):
27
28 def setUp(self):
29 super(test_model, self).setUp()
30 # Clean up registries
31 self.registry('ir.model').clear_caches()
32 self.registry('ir.model.data').clear_caches()
33 self.user_model = self.registry("res.users")
34
35 # Get registries
36 self.model = self.registry("cmis.backend")
37 # Get context
38 self.context = self.user_model.context_get(self.cr, self.uid)
39
40 self.vals = {
41 'name': "Test cmis",
42 'version': '1.0',
43 'location': "http://localhost:8081/alfresco/s/cmis",
44 'username': 'admin',
45 'password': 'admin',
46 'initial_directory_read': '/',
47 'initial_directory_write': '/',
48 }
49
50 def test_create_model(self):
51 model_id = self.model.create(
52 self.cr, self.uid, self.vals, context=self.context)
53 self.assertTrue(model_id)

Subscribers

People subscribed via source and target branches

to status/vote changes: