diff --git a/models/api_enedis.py b/models/api_enedis.py index 9715e231fa3ce4c653c0a641e2842664c1a226ca..402885170bc08e7f9ef3b591edc7ceb205de994a 100644 --- a/models/api_enedis.py +++ b/models/api_enedis.py @@ -267,6 +267,8 @@ class ApiEnedis(models.AbstractModel): is_delivery = True if usage_point['type'] == 'PROD': is_injection = True + self.date_start_contract = date.fromisoformat(usage_point['start']) + self.date_end_contract = date.fromisoformat(usage_point['end']) prm_id = self.env['enercoop.counter'].create({ 'name': usage_point['usage_point_id'], diff --git a/wizards/enercoop_operation_wizard.py b/wizards/enercoop_operation_wizard.py index 908f6f05cc0a36b55cb3703558261830f2b0f6a2..3e31665011844462d68fbaeae2cf1664f36faebb 100644 --- a/wizards/enercoop_operation_wizard.py +++ b/wizards/enercoop_operation_wizard.py @@ -2,6 +2,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import fields, models +from odoo.exceptions import UserError class EnercoopOperationWizard(models.TransientModel): @@ -38,6 +39,9 @@ class EnercoopOperationWizard(models.TransientModel): # Actions # ------------------------------------------------------ def get_curves(self): + if (self.date_end - self.date_start).days > 31: + raise UserError( + "L'intervalle de temps ne doit pas dépasser 31 Jours") context = dict(self._context or {}) if context.get('active_ids', False): self.env['enercoop.operation'].browse(context.get('active_ids')).get_curves(self.date_start, self.date_end)