From 1302f1ce6431e7951d2b47969ec7dabfa6f01d6c Mon Sep 17 00:00:00 2001 From: Juliana <juliana@le-filament.com> Date: Thu, 29 Sep 2022 15:31:02 +0200 Subject: [PATCH] [UPD]Fix bug generation Bilan --- models/account.py | 13 +++++- models/hr_expense.py | 44 ++++++++++++++++++++- wizard/adefpat_project_justif_zip_wizard.py | 16 +++++++- 3 files changed, 68 insertions(+), 5 deletions(-) diff --git a/models/account.py b/models/account.py index b7d3f74..558a151 100644 --- a/models/account.py +++ b/models/account.py @@ -68,12 +68,21 @@ class AccountInvoice(models.Model): """ if self.task_ids: task_start = self.task_ids.sorted(key=lambda r: r.date_deadline)[0].date_deadline + if task_start: + start_date = fields.Datetime.to_datetime(task_start).isoformat() + else: + start_date = "" task_end = self.task_ids.sorted(key=lambda r: r.date_deadline, reverse=True)[0].date_deadline + if task_end: + end_date = fields.Datetime.to_datetime(task_end).isoformat() + else: + end_date = "" return { 'cmis:secondaryObjectTypeIds': ['P:adefpat:facture'], - 'adefpat:factureStartDate': fields.Datetime.to_datetime(task_start).isoformat(), - 'adefpat:factureEndDate': fields.Datetime.to_datetime(task_end).isoformat(), + 'adefpat:factureStartDate': start_date, + 'adefpat:factureEndDate': end_date, 'adefpat:factureTypeConvention': self.type_convention_id.name or "", + 'adefpat:factureProjet': self.project_id.name or "", } else: return { diff --git a/models/hr_expense.py b/models/hr_expense.py index be52f52..1fa3b58 100644 --- a/models/hr_expense.py +++ b/models/hr_expense.py @@ -1,8 +1,16 @@ # Copyright 2020 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +import logging + from odoo import api, models, fields -from odoo.exceptions import UserError +from odoo.exceptions import UserError, ValidationError +from cmislib.exceptions import ContentAlreadyExistsException, \ + ObjectNotFoundException, UpdateConflictException, InvalidArgumentException + +_logger = logging.getLogger(__name__) + +ALFRESCO_TRACKED_FIELDS = ['type_convention_id', 'date', 'employee_id'] class AdefpatHrExpense(models.Model): @@ -14,6 +22,40 @@ class AdefpatHrExpense(models.Model): # ------------------------------------------------------ # Override ORM # ------------------------------------------------------ + @api.multi + def write(self, vals): + """ Surcharge la fonction write() pour mettre à jour + le type de convention, la date et l'utilisateur + """ + # Ecriture des nouvelles valeurs + result = super(AdefpatHrExpense, self).write(vals) + change_fields = vals.keys() + # check intersection + is_alfresco_field = [ + value for value in change_fields if value in ALFRESCO_TRACKED_FIELDS] + + # Check des modifications sur les coopératives présentes dans RIGA + for record in self: + if record.proof_file: + if is_alfresco_field: + try: + properties = self.get_file_properties() + backend = self.env['cmis.backend'].search([], limit=1) + file = backend.get_cmis_repository().getObject( + self.proof_file + ) + file.updateProperties(properties) + except (ContentAlreadyExistsException, ObjectNotFoundException, + UpdateConflictException, InvalidArgumentException) as e: + _logger.error(e) + raise ValidationError("""Erreur de mise à jour Alfresco : + - Code : %s + - Url : %s + - Détail : %s""" % (e.status, e.url, e.details)) + except Exception as e: + raise ValidationError(e) + return result + @api.multi def unlink(self): for espense in self: diff --git a/wizard/adefpat_project_justif_zip_wizard.py b/wizard/adefpat_project_justif_zip_wizard.py index c54c571..04ff52f 100644 --- a/wizard/adefpat_project_justif_zip_wizard.py +++ b/wizard/adefpat_project_justif_zip_wizard.py @@ -72,7 +72,7 @@ class AdefpatProjectJustifZip(models.TransientModel): json_file = [] for project in project_ids: compteur += 1 - proj = project.name.replace(" ", "_x0020_") + proj = project.name.replace(" ", "_x0020_").replace("'", "_x0027") path = "PATH:'/app:company_home/st:sites/cm:odoo/cm:documentLibrary/cm:Projets/cm:" + proj json_file.append({ "id": bilan_nb + str(compteur), @@ -133,6 +133,18 @@ class AdefpatProjectJustifZip(models.TransientModel): "query": path + "/cm:admin//*'" + " AND (=adefpat:typeDocument:'convention d'accompagnement' OR =adefpat:typeDocument:'convention d'objectif')", }, }, + { + "id": bilan_nb + str(compteur) + "7", + "name": "Factures Fournisseurs", + "description": "Factures Fournisseurs", + "search": { + "language": "fts-alfresco", + "query": "(PATH:'/app:company_home/st:sites/cm:odoo/cm:documentLibrary/cm:Factures_x0020_fournisseurs//*') AND (+adefpat:factureEndDate:['" + str( + self.period_start) + "' TO '" + str( + self.period_end) + "'] OR +adefpat:factureSartDate:['" + str( + self.period_start) + "' TO '" + str(self.period_end) + "']) AND =adefpat:factureProjet:'"+ project.name +"'", + }, + }, ]}) virtual_json = { @@ -234,7 +246,7 @@ class AdefpatProjectJustifZip(models.TransientModel): if self.type_convention_id: query = "PATH:'/app:company_home/st:sites/cm:odoo/cm:documentLibrary/cm:Justificatifs//*' AND =adefpat:justificatifUtilisateurs:'" + user.login + "' AND (+adefpat:justificatifDate:['" + str( self.period_start) + "' TO '" + str( - self.period_end) + "']) AND =adefpat: justificatifTypeConvention:'" + self.type_convention_id.name + "'" + self.period_end) + "']) AND =adefpat:justificatifTypeConvention:'" + self.type_convention_id.name + "'" else: query = "PATH:'/app:company_home/st:sites/cm:odoo/cm:documentLibrary/cm:Justificatifs//*' AND =adefpat:justificatifUtilisateurs:'" + user.login + "' AND (+adefpat:justificatifDate:['" + str( self.period_start) + "' TO '" + str( -- GitLab