Skip to content
Extraits de code Groupes Projets
Valider a6adb0e2 rédigé par Juliana's avatar Juliana
Parcourir les fichiers

[FIX] Pb fichier supprimé

parent 551e5b89
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
# Copyright 2021 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import fields, models, api
class LeFilamentAlfresco(models.AbstractModel):
""" Appelle l'API alfresco et implémente les fonctions suivantes :
"""
_inherit = 'lefilament.alfresco'
def _publipostage_documents_malette_avenant(self, template_doc, keys_obj=None, versionable=None):
url = '/alfresco/s/publipostage'
# Récupération du backend
backend_name = self._fields['cmis_folder']
backend = backend_name.get_backend(self.env)
# Path du dossier projet
# Création du path
# If not parent_id, path = dossier.name
path_all, dossier_id = template_doc.get_path_all()
if dossier_id.model_id.model == 'res.partner.porteur.project':
object_ids = self.env['res.partner.porteur.project'].search([
('project_id', '=', self.id),
('is_malette_ok', '=', False)
])
for obj in object_ids:
if obj.cmis_folder:
parent_path = backend.get_cmis_repository().getFolder(
obj.cmis_folder).getPaths()
if path_all:
path_n0 = parent_path + [path_all]
else:
path_n0 = parent_path
path = '/'.join(path_n0)
keys = obj.fill_data()
keys_obj.update(keys)
# Document PDF
cmis_obj_nodeRef = backend.get_folder_by_path(path).getProperties()['alfcmis:nodeRef']
mimetype = template_doc.name.split('.')[1]
if mimetype == 'pdf':
# get ID document to copy
id_doc = template_doc.noderef_document.replace('workspace://SpacesStore/', '')
# Get ID to noderef Folder parent
id_parent = cmis_obj_nodeRef.replace('workspace://SpacesStore/', '')
uri = '/alfresco/s/slingshot/doclib/action/copy-to/node/workspace/SpacesStore/' + id_parent
workspace = 'workspace://SpacesStore/' + id_doc
workspace_parent = 'workspace://SpacesStore/' + id_parent
# Copy the document and retur the objectId Created
nodeDoc = self.copy_document(
url=uri,
workspace=workspace,
workspace_parent=workspace_parent,
backend=backend)
self.update_doc_properties(template_doc, nodeDoc)
else:
document = self.publipostage_documents(url, path, template_doc, backend, keys_obj, versionable)
nodeDoc = document.json().get('nodeRef', '').replace('workspace://SpacesStore/', '')
self.update_doc_properties(template_doc, nodeDoc)
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter