diff --git a/wizard/adefpat_project_justif_zip_wizard.py b/wizard/adefpat_project_justif_zip_wizard.py index c980bba1208225fad6b13fb591f6743869c5832d..980b8b3ff749abfad33c071ed663f8c675bae238 100644 --- a/wizard/adefpat_project_justif_zip_wizard.py +++ b/wizard/adefpat_project_justif_zip_wizard.py @@ -139,10 +139,11 @@ class AdefpatProjectJustifZip(models.TransientModel): ] } if self.type_convention_id: - file_name = "justifs_factures_fournisseurs_"+ str(date.today()) + "_" + self.type_convention_id.name + file_name = "justifs_factures_fournisseurs_" + str(date.today()) + "_" + self.type_convention_id.name else: - file_name = "justifs_factures_fournisseurs_"+ str(date.today()) - self.create_json_file(file_name, virtual_json) + file_name = "justifs_factures_fournisseurs_" + str(date.today()) + json_file_cmis = self.env.user.company_id.proof_justif_cmis + self.create_json_file(file_name, virtual_json, json_file_cmis) @api.multi def build_facture_client(self): @@ -167,10 +168,11 @@ class AdefpatProjectJustifZip(models.TransientModel): ] } if self.type_convention_id: - file_name = "justifs_factures_clients_"+ str(date.today()) + "_" + self.type_convention_id.name + file_name = "justifs_factures_clients_" + str(date.today()) + "_" + self.type_convention_id.name else: - file_name = "justifs_factures_clients_"+ str(date.today()) - self.create_json_file(file_name, virtual_json) + file_name = "justifs_factures_clients_" + str(date.today()) + json_file_cmis = self.env.user.company_id.proof_justif_cmis + self.create_json_file(file_name, virtual_json, json_file_cmis) @api.multi def build_expense_zip(self): @@ -215,56 +217,5 @@ class AdefpatProjectJustifZip(models.TransientModel): else: file_name = "justifs_frais_" + str( date.today()) - self.create_json_file(file_name, virtual_json) - - - def create_json_file(self, file_name, virtual_json): - - backend = self.env['cmis.backend'].search([], limit=1) json_file_cmis = self.env.user.company_id.proof_justif_cmis - parent_path = backend.get_cmis_repository().getFolder( - json_file_cmis).getPaths() - - path_to_create = parent_path + [file_name] - path = '/'.join(path_to_create) - - try: - # Mise à jour des propriétés du dossier virtuel - cmis_folder = backend.get_folder_by_path(path) - - js = json.dumps(virtual_json, indent=4) - prop = { - 'cmis:secondaryObjectTypeIds': ['P:adefpat:justificatif'], - } - - repo = backend.get_cmis_repository().getObject(json_file_cmis) - file = repo.createDocument( - name=file_name + ".json", - properties=prop, - contentFile=js, - contentType="application/json" - ) - noderef_file_id = file.getProperties().get('alfcmis:nodeRef') - prop_folder = { - 'cmis:secondaryObjectTypeIds': [ - 'P:smf:customConfigSmartFolder', - 'P:cm:taggable', - 'P:up:UploadFolder', - 'P:cm:titled', - 'P:sys:localized' - ], - } - - cmis_folder.updateProperties(prop_folder) - noderef_folder_id = cmis_folder.getProperties().get('cmis:objectId') - url = '/alfresco/s/api/node/workspace/SpacesStore/' + noderef_folder_id + '/formprocessor' - result = self.alfresco_get_by_url( - url=url, - call_type='post', - json={ - "assoc_smf_custom-template-association_added": noderef_file_id - }, - backend=backend) - - except Exception as e: - raise UserError(json.loads(e.details).get('message')) \ No newline at end of file + self.create_json_file(file_name, virtual_json, json_file_cmis)