-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
9.0 cmis field #3
Changes from 120 commits
cc8d79a
e2e8e1e
4c0747d
f1bf89b
f4123db
3c5e03e
55a4d13
8f05562
b383b50
01eac37
1d59765
76d0a81
ce1f733
9d870dc
76e663c
976a87a
10f4860
8b00a0b
62451da
2fc01ff
9ceb685
551efd3
05a1619
de845c7
190ee98
c8e8c74
dfe6b2a
ade0cf0
769d46e
9ed6999
4ae90ba
2cfdd92
e898a77
b544ae5
3c46d83
8b195ff
10395c9
a20356f
4fd111c
3977a4c
a1ec0a8
030df9e
6b296c5
a54490d
3ca7e98
6ceddf8
fad1d85
b043dcd
b45b463
d469e46
9596ff9
8256edf
61fa82c
5444df8
beb53b4
26081d5
2f5c4f5
571e68f
3b5edc0
98b13ef
3964b8b
b66dacf
1103f1d
3d266dd
098bbf6
8e05c18
b8bbb99
ca04649
99639ef
b45f5a9
5a1fa7d
b8d733c
4a2a842
37e0ea5
36bb193
884a861
65ff8cd
451eb9e
a221fa2
08ba662
7b5d610
1039035
8c3692d
147d9a5
7b3af94
7e353f1
6afb766
22cfcb4
d6139b7
6e1b4f7
ad102d9
594972a
5b734a1
4a21856
b06ccf0
a949883
1d44535
26bda64
447b36e
218261a
c630be1
11dc878
ce190b6
7b1686a
a4eca73
c106391
68c1240
b477fb6
640a882
9fc6b25
cce4311
e08dee3
e30eb69
51f3315
7bf3843
19f3739
25ce644
a27e8ef
3cfbd0f
ecbe9d8
d7421a5
9edc5de
f8912b8
aea49bd
e6f127f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,21 @@ | ||
[![Build Status](https://travis-ci.org/OCA/connector-cmis.svg?branch=7.0)](https://travis-ci.org/OCA/connector-cmis) | ||
[![Coverage Status](https://coveralls.io/repos/OCA/connector-cmis/badge.png?branch=7.0)](https://coveralls.io/r/OCA/connector-cmis?branch=7.0) | ||
[![Build Status](https://travis-ci.org/OCA/connector-cmis.svg?branch=9.0)](https://travis-ci.org/OCA/connector-cmis) | ||
[![Coverage Status](https://coveralls.io/repos/OCA/connector-cmis/badge.png?branch=9.0)](https://coveralls.io/r/OCA/connector-cmis?branch=9.0) | ||
|
||
Connector-cmis | ||
============== | ||
|
||
[//]: # (addons) | ||
Unported addons | ||
--------------- | ||
addon | version | summary | ||
--- | --- | --- | ||
[cmis](cmis/) | 7.0.1.1.0 (unported) | Connect OpenERP with a CMIS server | ||
[cmis_read](cmis_read/) | 7.0.1.0.0 (unported) | Store Document File from a Remote CMIS Server | ||
[cmis_write](cmis_write/) | 7.0.0.1.0 (unported) | Create Document in DMS from Odoo/OpenERP | ||
|
||
[//]: # (end addons) | ||
|
||
|
||
Translation Status | ||
------------------ | ||
[![Transifex Status](https://www.transifex.com/projects/p/OCA-connector-cmis-9-0/chart/image_png)](https://www.transifex.com/projects/p/OCA-connector-cmis-9-0) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
============== | ||
CMIS Connector | ||
============== | ||
|
||
This module is the base for Odoo modules implementing different integration | ||
scenario with a CMIS server. | ||
It allows you to configure a CMIS backend in Odoo. | ||
|
||
Installation | ||
============ | ||
|
||
To be compliant with the latest version of CMIS (1.1), the connector use | ||
the latest version of the python cmislib library not yet released at this | ||
stage. The lib can be installed with: | ||
|
||
pip install svn+https://svn.apache.org/repos/asf/chemistry/cmislib/trunk#egg=cmislib | ||
|
||
Configuration | ||
============= | ||
|
||
Create a new CMIS backend with the host, login and password. | ||
|
||
Usage | ||
===== | ||
|
||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
:alt: Try me on Runbot | ||
:target: https://runbot.odoo-community.org/runbot/104/9.0 | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/OCA/connector-cmis/issues>`_. In case of trouble, please | ||
check there if your issue has already been reported. If you spotted it first, | ||
help us smashing it by providing a detailed and welcomed `feedback | ||
<https://github.com/OCA/ | ||
connector-cmis/issues/new?body=module:%20 | ||
cmis%0Aversion:%20 | ||
9.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Credits | ||
======= | ||
|
||
Images | ||
------ | ||
|
||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_. | ||
|
||
Contributors | ||
------------ | ||
|
||
* El Hadji Dem <elhadji.dem@savoirfairelinux.com> | ||
* Maxime Chambreuil <maxime.chambreuil@savoirfairelinux.com> | ||
* Laurent Mignon <laurent.mignon@acsone.eu> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
To contribute to this module, please visit https://odoo-community.org. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2014-2015 Savoir-faire Linux (<http://www.savoirfairelinux.com>). | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
import logging | ||
import httplib2 | ||
import functools | ||
from . import models | ||
from . import controllers | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
logger.warning('Disable SSL Certificate Validation by python code') | ||
httplib2.Http = functools.partial( | ||
httplib2.Http, disable_ssl_certificate_validation=True) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2014-2015 Savoir-faire Linux (<http://www.savoirfairelinux.com>). | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
{ | ||
'name': 'CMIS', | ||
'version': '9.0.1.0.0', | ||
'category': 'Connector', | ||
'summary': 'Connect OpenERP with a CMIS server', | ||
'author': "Savoir-faire Linux, " | ||
"ACSONE SA/NV, " | ||
"Odoo Community Association (OCA)", | ||
'website': 'https://odoo-community.org/', | ||
'license': 'AGPL-3', | ||
'external_dependencies': { | ||
'python': ['cmislib'], | ||
}, | ||
'data': [ | ||
'security/cmis_backend.xml', | ||
'views/cmis_menu.xml', | ||
'views/cmis_backend.xml', | ||
], | ||
'installable': True, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import main |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
import json | ||
import werkzeug | ||
from openerp import http | ||
from openerp.addons.web.controllers import main | ||
|
||
|
||
class CmisController(http.Controller): | ||
|
||
@http.route('/web/cmis/field/init_value', type='json', methods=['POST'], | ||
auth="user") | ||
@main.serialize_exception | ||
def init_field_value(self, model_name, res_id, field_name): | ||
model_inst = http.request.env[model_name].browse(int(res_id)) | ||
value = model_inst._fields[field_name].init_value(model_inst) | ||
response = werkzeug.Response(json.dumps( | ||
{'value': value}), mimetype='application/json') | ||
return response |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# -*- coding: utf-8 -*- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sbidoul I wonder if it would be better to delete these exceptions and to use only those available in Odoo There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which exceptions? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. those above... |
||
# © 2016 ACSONE SA/NV (<http://acsone.eu>). | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from openerp.exceptions import UserError | ||
|
||
|
||
class CMISError(UserError): | ||
"""CMIS Error!""" | ||
def __init__(self, value): | ||
super(CMISError, self).__init__(value) | ||
|
||
|
||
class CMISConnectionError(CMISError): | ||
"""CMIS connection Error!""" | ||
def __init__(self, value): | ||
super(CMISConnectionError, self).__init__(value) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 ACSONE SA/NV (<http://acsone.eu>) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from operator import attrgetter | ||
from openerp import fields | ||
from openerp.exceptions import UserError | ||
|
||
|
||
class CmisFolder(fields.Field): | ||
""" A reference to a cmis:folder. The reference must be formatted as | ||
follow: backend_name + ':' cmis:objectId | ||
|
||
:param backend_name: | ||
|
||
The attribute ``backend_name`` is mandatory | ||
|
||
:param allow_create: (by default True) | ||
|
||
:param allow_delete: (by default False) | ||
|
||
:param cmis_create_method: | ||
|
||
:param cmis_path: (by default backend.initial_directory_write + '/' model._name) | ||
|
||
:param cmis_name_get: (by default instance.name_get) | ||
|
||
""" | ||
type = 'char' # Postgresl | ||
widget = 'cmis_folder' # Web widget | ||
_slots = { | ||
'backend_name': None, | ||
'cmis_name_get': 'name_get', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. create_name_get ? |
||
'allow_create': True, | ||
'allow_delete': False, | ||
'cmis_path': None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. create_root_get ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could be a method too, since the most common override is changing the root. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sbidoul
What do you think of the idea of having one parameter for each item
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, good idea. |
||
'cmis_create_method': None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. create_method ? If create_root_get and create_name_get are method, this will rarely be used, but could be useful nevertheless. |
||
} | ||
|
||
def __init__(self, backend_name=None, string=None, **kwargs): | ||
super(CmisFolder, self).__init__( | ||
backend_name=backend_name, string=string, **kwargs) | ||
|
||
|
||
def get_description(self, env): | ||
""" Return a dictionary that describes the field ``self``. """ | ||
desc = super(CmisFolder, self).get_description(env) | ||
desc['type'] = self.widget | ||
return desc | ||
|
||
_description_backend_name = property(attrgetter('backend_name')) | ||
|
||
def init_value(self, record): | ||
if record is None: | ||
return self # the field is accessed through the owner class | ||
|
||
env = record.env | ||
if not record: | ||
# null record -> return the null value for this field | ||
return self.null(env) | ||
|
||
self._check_null(record) | ||
|
||
value = None | ||
backend = env['cmis.backend'].get_by_name(name=self.backend_name) | ||
if self.cmis_create_method: | ||
fct = self.cmis_create_method | ||
if not callable(fct): | ||
fct = getattr(record, fct) | ||
value = fct(backend) | ||
else: | ||
value = self._create_in_cmis(record, backend) | ||
self.__set__(record, value) | ||
return value | ||
|
||
def _create_in_cmis(self, record, backend): | ||
name = self._get_cmis_name(record) | ||
path = self._get_cmis_path(record, backend) | ||
#create | ||
parent_cmis_object = backend.get_folder_by_path( | ||
path, create_if_not_found=True) | ||
repo = backend.get_cmis_repository() | ||
new_folder = repo.createFolder( | ||
parent_cmis_object, name) | ||
return new_folder.getObjectId() | ||
|
||
def _check_null(self, record, raise_exception=True): | ||
val = self.__get__(record, record) | ||
if val and raise_exception: | ||
raise UserError('A value is already assigned to %s' % self) | ||
return val | ||
|
||
def _get_cmis_name(self, record): | ||
if self.cmis_name_get == 'name_get': | ||
return record.name_get()[0][1] | ||
fct = self.cmis_name_get | ||
if not callable(fct): | ||
fct = getattr(record, fct) | ||
return fct() | ||
|
||
def _get_cmis_path(self, record, backend): | ||
if self.cmis_path: | ||
return self.cmis_path | ||
else: | ||
return '/'.join([backend.initial_directory_write, | ||
record._name.replace('.', '_')]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: document CmisFolder when it is stable.