Skip to content
Snippets Groups Projects
Commit 7afc83a6 authored by Daniil Digtyar Vasilieva's avatar Daniil Digtyar Vasilieva :call_me: Committed by Enrico Stano
Browse files

[IMP] energy_selfconsumption: validation of format in effective date

parent 936e542e
No related branches found
No related tags found
2 merge requests!187Release 14.0.1.1.13,!155[IMP] energy_selfconsumption: importation of selfconsumption inscriptions, supply points and distribution tables by CSV
......@@ -71,7 +71,7 @@ class SelfconsumptionImportWizard(models.TransientModel):
def get_line_dict(self, line):
return {
"partner_vat": line[0] or False,
"effective_date": line[1] or fields.date.today(),
"effective_date": line[1] or False,
"code": line[2] or False,
"street": line[3] or False,
"street2": line[4] or False,
......@@ -124,12 +124,21 @@ class SelfconsumptionImportWizard(models.TransientModel):
if not project.inscription_ids.filtered_domain(
[("partner_id", "=", partner.id)]
):
if line_dict["effective_date"]:
try:
effective_date_iso = fields.date.fromisoformat(line_dict["effective_date"])
except ValueError as e:
return False, _("Could not create inscription for {vat}. {error}").format(
vat=line_dict["partner_vat"], error=e
)
else:
effective_date_iso = fields.date.today()
try:
self.env["energy_project.inscription"].create(
{
"project_id": project.id,
"partner_id": partner.id,
"effective_date": line_dict["effective_date"],
"effective_date": effective_date_iso,
}
)
except Exception as e:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment