Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cgscop_alfresco
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Le Filament
Confédération Générale des SCOP
cgscop_alfresco
Commits
3fdef02d
Commit
3fdef02d
authored
3 years ago
by
Benjamin - Le Filament
Browse files
Options
Downloads
Patches
Plain Diff
[add] cmis file upload function
parent
3e368593
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
models/api_alfresco.py
+45
-1
45 additions, 1 deletion
models/api_alfresco.py
with
45 additions
and
1 deletion
models/api_alfresco.py
+
45
−
1
View file @
3fdef02d
...
...
@@ -5,7 +5,9 @@ import requests
import
logging
import
xml.etree.ElementTree
as
et
from
odoo
import
models
,
exceptions
,
tools
from
odoo
import
models
,
exceptions
,
fields
from
cmislib.exceptions
import
ContentAlreadyExistsException
,
\
ObjectNotFoundException
,
UpdateConflictException
,
InvalidArgumentException
_logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -205,3 +207,45 @@ class CgscopAlfresco(models.AbstractModel):
"""
return
result
.
get
(
'
nodeRef
'
,
''
).
replace
(
'
workspace://SpacesStore/
'
,
''
)
def
push_alfresco_file
(
self
,
file
,
name
,
partner
,
type
,
context
=
'
STD
'
,
year
=
fields
.
Datetime
.
now
().
year
):
"""
Ajoute un fichier sur la GED Alfresco
@return: fonction get_partner_files() de res.partner
"""
backend
=
self
.
env
[
'
cmis.backend
'
].
search
([],
limit
=
1
)
if
not
partner
.
partner_cmis_folder
:
# TODO: commit value on creation because of error
folder
=
partner
.
create_cmis_folder
()
else
:
folder
=
partner
.
partner_cmis_folder
try
:
cmis_obj
=
backend
.
get_cmis_repository
().
getObject
(
folder
)
file_upload
=
cmis_obj
.
createDocument
(
name
=
name
,
properties
=
{
'
cmis:objectTypeId
'
:
'
D:crm:document
'
,
'
cmis:secondaryObjectTypeIds
'
:
[
'
P:crm:organisme
'
],
'
crm:type
'
:
type
,
'
crm:contexte
'
:
context
,
'
crm:annee
'
:
year
},
contentFile
=
file
,
contentType
=
'
application/pdf
'
)
except
(
ContentAlreadyExistsException
,
ObjectNotFoundException
,
UpdateConflictException
,
InvalidArgumentException
)
as
e
:
_logger
.
error
(
e
)
raise
exceptions
.
ValidationError
(
"""
Erreur de mise à jour Alfresco :
- Code : %s
- Url : %s
- Détail : %s
"""
%
(
e
.
status
,
e
.
url
,
e
.
details
))
except
Exception
as
e
:
raise
exceptions
.
ValidationError
(
e
)
return
file_upload
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment