Skip to content
Extraits de code Groupes Projets
Valider 94e22574 rédigé par Juliana's avatar Juliana
Parcourir les fichiers

[UPD]Add button and functionnality import file

parent 7dd29b65
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import base64 import base64
import pytz
from datetime import datetime, timedelta from datetime import datetime, timedelta
from io import StringIO from io import StringIO
...@@ -121,7 +122,8 @@ class AccOperation(models.Model): ...@@ -121,7 +122,8 @@ class AccOperation(models.Model):
[("name", "=", id_pdm)] [("name", "=", id_pdm)]
) )
computed_data_type = data_filename[3] computed_data_type = data_filename[3].lower()
file_decode = StringIO(base64.b64decode(file.datas).decode("UTF-8")) file_decode = StringIO(base64.b64decode(file.datas).decode("UTF-8"))
file_decode.seek(0) file_decode.seek(0)
# reader = pd.read_csv(file_decode, header=None, delimiter=';') # reader = pd.read_csv(file_decode, header=None, delimiter=';')
...@@ -132,7 +134,8 @@ class AccOperation(models.Model): ...@@ -132,7 +134,8 @@ class AccOperation(models.Model):
for row in reader.values: for row in reader.values:
# Create 1st slot 0-30min # Create 1st slot 0-30min
date_slot = datetime.strptime(row[0], "%d/%m/%Y %H:%M") date_slot = datetime.strptime(row[0], "%d/%m/%Y %H:%M")
# date_slot = row[0] date_slot_utc = fields.Datetime.to_string(date_slot)
self.env["acc.enedis.cdc"].create( self.env["acc.enedis.cdc"].create(
{ {
"name": file.name, "name": file.name,
...@@ -141,10 +144,15 @@ class AccOperation(models.Model): ...@@ -141,10 +144,15 @@ class AccOperation(models.Model):
"comp_data_type": computed_data_type, "comp_data_type": computed_data_type,
"power": row[1], "power": row[1],
"date_slot": date_slot, "date_slot": date_slot,
"date_slot_utc": date_slot_utc,
} }
) )
# Create 2nd slot 30-60min # Create 2nd slot 30-60min
date_slot_30 = date_slot + timedelta(minutes=30) date_slot_30 = datetime.strptime(row[0], "%d/%m/%Y %H:%M") + timedelta(minutes=30)
date_slot_utc = fields.Datetime.to_string(date_slot_30)
# date_slot_utc = fields.Datetime.to_string(date_slot_30)
self.env["acc.enedis.cdc"].create( self.env["acc.enedis.cdc"].create(
{ {
"name": file.name, "name": file.name,
...@@ -153,6 +161,7 @@ class AccOperation(models.Model): ...@@ -153,6 +161,7 @@ class AccOperation(models.Model):
"comp_data_type": computed_data_type, "comp_data_type": computed_data_type,
"power": row[2], "power": row[2],
"date_slot": date_slot_30, "date_slot": date_slot_30,
"date_slot_utc": date_slot_utc,
} }
) )
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
<field name="acc_operation_id" /> <field name="acc_operation_id" />
<field name="acc_counter_id" /> <field name="acc_counter_id" />
<field name="date_slot_utc" /> <field name="date_slot_utc" />
<field name="date_slot" />
<field name="comp_data_type" /> <field name="comp_data_type" />
<field name="power" /> <field name="power" />
</tree> </tree>
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Opération"> <form string="Opération">
<header> <header>
<!-- <button string="Intégration des données ENEDIS" type="object" class="btn-primary" name="import_enedis_data"/>--> <button string="Intégration des données ENEDIS" type="object" class="btn-primary" name="import_enedis_data"/>
</header> </header>
<sheet> <sheet>
<widget <widget
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter