diff --git a/data/mail_template_data.xml b/data/mail_template_data.xml index 2b1bdd5a28d3600051e51cf3b1e011631b7e1607..73ea5e129af8d0e37ee3928bcc720e328532eda7 100644 --- a/data/mail_template_data.xml +++ b/data/mail_template_data.xml @@ -29,10 +29,13 @@ D’après les données Enedis, des nouveaux PRM ont été ajoutés et/ou retirés de l’opération ou ont changé de propriétaire.<br /><br /> Numéros des PRM concernées :<br /> - <t t-out="object.updated_objects" t-options="{'widget':'html'}"/> + <t + t-out="object.updated_objects" + t-options="{'widget':'html'}" + /> - <br/> - <br/> + <br /> + <br /> Si des PRM sont ajoutés, afin qu’ils soient bien pris en compte dans Elocoop, nous vous remercions de renseigner les informations des participants liés à ces PRM dans votre espace d’administration Elocoop, de cette manière :<br /> diff --git a/models/acc_operation.py b/models/acc_operation.py index 12c7347110cf376d28a2d330af82ad7bc0747f88..576b8bd5546acd7cdad37539a31bea75c453d784 100644 --- a/models/acc_operation.py +++ b/models/acc_operation.py @@ -87,17 +87,17 @@ class AccOperation(models.Model): } return { - 'type': 'ir.actions.client', - 'tag': 'display_notification', - 'params': { - 'title': _('Actualisation du périmètre.'), - 'type': 'info', - 'message': "Le périmètre de l'opération a bien été mis à jour dans les onglets 'Points d'injection' et 'Points de soutirage'.", - 'sticky': True, - 'next': { - 'type': 'ir.actions.act_window_close', - } - } + "type": "ir.actions.client", + "tag": "display_notification", + "params": { + "title": _("Actualisation du périmètre."), + "type": "info", + "message": "Le périmètre de l'opération a bien été mis à jour dans les onglets 'Points d'injection' et 'Points de soutirage'.", + "sticky": True, + "next": { + "type": "ir.actions.act_window_close", + }, + }, } def _get_monthly_enedis_data(self, from_cron): @@ -249,6 +249,7 @@ class AccOperation(models.Model): "name": usage_point["usage_point_id"], } ) + counter_used.append(counter_id.name) self.env["acc.counter.period"].create( { @@ -259,7 +260,14 @@ class AccOperation(models.Model): "end_date": usage_point_end, } ) + + if self.check_priority_groups(counter=counter_id): + message += ( + "Ajout du nouveau PRM au premier groupe de priorité<br/>" + ) + message += "Fin de la création du PRM<br/>" + except ValidationError as e: message += ( "<strong>erreur lors de la tentative de création du PRM et/ou " @@ -267,6 +275,7 @@ class AccOperation(models.Model): + str(e) + "<br/>" ) + if usage_point_prm_type == "injection": if usage_point["usage_point_id"] not in list_injection: list_injection.append(usage_point["usage_point_id"]) @@ -308,3 +317,15 @@ class AccOperation(models.Model): # ------------------------------------------------------ # Business methods # ------------------------------------------------------ + def check_priority_groups(self, counter): + """ + add new counter to first priorirty group if exist counter + """ + + first_prio = self.env["acc.priority.group"].search( + [("acc_operation_id", "=", self.id), ("sequence", "=", 1)] + ) + if first_prio: + first_prio.add_counter(counter_id=counter) + return True + return False