mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-22 20:12:04 -06:00
[IMP] FIxed comments from LP, added unittests,fix pep8 errors
This commit is contained in:
parent
43025f0073
commit
b62e8a5ec4
@ -24,9 +24,9 @@
|
||||
'name': 'CMIS Write',
|
||||
'version': '0.1',
|
||||
'category': 'Knowledge Management',
|
||||
'summary': 'Create Document in DMS from OpenErp',
|
||||
'summary': 'Create Document in DMS from OpenERP',
|
||||
'description': """
|
||||
Add Documents from OpenErp
|
||||
Add Documents from OpenERP
|
||||
==========================
|
||||
|
||||
This module allows you to store OpenERP document in the DMS repository.
|
||||
@ -55,7 +55,7 @@ you have to:
|
||||
http://wiki.alfresco.com/wiki/Step-By-Step:_Creating_A_Custom_Model.
|
||||
|
||||
* Add the custom aspect to the document you upload or create in Alfresco.
|
||||
Using CMIS I suggest you:
|
||||
Using CMIS I suggest you:
|
||||
http://docs.alfresco.com/4.1/index.jsp?topic=%2Fcom.alfresco.enterprise.doc%2Fconcepts%2Fopencmis-ext-adding.html.
|
||||
|
||||
* Set the custom property in the way you probably know using CMIS.
|
||||
|
@ -122,7 +122,7 @@ def create_doc_in_edm(session, model_name, value, res,
|
||||
value['datas']),
|
||||
contentType=value['file_type'])
|
||||
# TODO: create custom properties on a document (Alfresco)
|
||||
#someDoc.getProperties().update(props)
|
||||
# someDoc.getProperties().update(props)
|
||||
# Updating ir.attachment object with the new id
|
||||
# of document generated by DMS
|
||||
ir_attach_obj.write(session.cr, session.uid, res, {
|
||||
|
@ -54,8 +54,8 @@ class metadata(orm.Model):
|
||||
return {'value': {'model_ids': [(6, 0, [])]}}
|
||||
model_ids = [model_id]
|
||||
model_obj = self.pool.get('ir.model')
|
||||
active_model_obj = self.pool.get(model_obj.browse(cr, uid,
|
||||
model_id).model)
|
||||
active_model_obj = self.pool.get(model_obj.browse(
|
||||
cr, uid, model_id, context=context).model)
|
||||
if active_model_obj._inherits:
|
||||
for key, val in active_model_obj._inherits.items():
|
||||
found_model_ids = model_obj.search(cr,
|
||||
|
29
cmis_write/tests/__init__.py
Normal file
29
cmis_write/tests/__init__.py
Normal file
@ -0,0 +1,29 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2014 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from . import (
|
||||
test_attachment,
|
||||
)
|
||||
|
||||
checks = [
|
||||
test_attachment,
|
||||
]
|
88
cmis_write/tests/test_attachment.py
Normal file
88
cmis_write/tests/test_attachment.py
Normal file
@ -0,0 +1,88 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
###############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# This module copyright (C) 2010 - 2014 Savoir-faire Linux
|
||||
# (<http://www.savoirfairelinux.com>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
from openerp.tests.common import TransactionCase
|
||||
from openerp.addons.connector.session import ConnectorSession
|
||||
|
||||
|
||||
class test_attachment(TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super(test_attachment, self).setUp()
|
||||
# Clean up registries
|
||||
self.registry('ir.model').clear_caches()
|
||||
self.registry('ir.model.data').clear_caches()
|
||||
# Get registries
|
||||
self.user_model = self.registry("res.users")
|
||||
self.ir_attachment_model = self.registry("ir.attachment")
|
||||
self.partner_model = self.registry('res.partner')
|
||||
self.metadata_model = self.registry('metadata')
|
||||
# Get context
|
||||
self.context = self.user_model.context_get(self.cr, self.uid)
|
||||
|
||||
partner_id = self.partner_model.create(
|
||||
self.cr, self.uid,
|
||||
{'name': 'Test Partner',
|
||||
'email': 'test@localhost',
|
||||
'is_company': True,
|
||||
}, context=None)
|
||||
|
||||
blob1 = 'blob1'
|
||||
blob1_b64 = blob1.encode('base64')
|
||||
|
||||
self.vals = {
|
||||
'name': 'a1',
|
||||
'datas': blob1_b64,
|
||||
'attachment_document_ids': [(0, 0, {
|
||||
'res_model': "res.partner",
|
||||
'res_id': partner_id,
|
||||
'res_name': 'Test Partner',
|
||||
})],
|
||||
}
|
||||
|
||||
def test_create_test_attachment(self):
|
||||
cr, uid, vals, context = self.cr, self.uid, self.vals, self.context
|
||||
metadata_ids = self.metadata_model.search(cr, uid, [], context=context)
|
||||
dict_metadata = {}
|
||||
list_fields = []
|
||||
|
||||
# Get list of metadata
|
||||
if vals['res_model']:
|
||||
for line in self.metadata_obj.browse(
|
||||
cr, uid, metadata_ids, context=context):
|
||||
if line.model_id.model == vals['res_model']:
|
||||
if line.metadata_list_ids:
|
||||
for one_field in line.metadata_list_ids:
|
||||
list_fields.append(one_field.field_id.name)
|
||||
result = self.pool.get(vals['res_model']).read(cr, uid, [
|
||||
vals['res_id']], list_fields, context=context)[0]
|
||||
|
||||
for one_field in list_fields:
|
||||
dict_metadata['cmis:' + one_field] = result[one_field]
|
||||
context['bool_testdoc'] = True
|
||||
|
||||
ir_attachment_id = self.ir_attachment_model.create(
|
||||
cr, uid, vals, context=context)
|
||||
ir_attachment_pool = self.ir_attachment_model.browse(
|
||||
cr, uid, ir_attachment_id, context=context)
|
||||
|
||||
self.assertEqual(ir_attachment_pool.name, vals['name'])
|
Loading…
Reference in New Issue
Block a user