Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
acc_operation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Le Filament
Opération Auto-Consommation Collective
acc_operation
Commits
94e22574
Commit
94e22574
authored
2 years ago
by
Juliana
Browse files
Options
Downloads
Patches
Plain Diff
[UPD]Add button and functionnality import file
parent
7dd29b65
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
models/acc_operation.py
+12
-3
12 additions, 3 deletions
models/acc_operation.py
views/acc_enedis_cdc_views.xml
+1
-0
1 addition, 0 deletions
views/acc_enedis_cdc_views.xml
views/acc_operation_views.xml
+1
-1
1 addition, 1 deletion
views/acc_operation_views.xml
with
14 additions
and
4 deletions
models/acc_operation.py
+
12
−
3
View file @
94e22574
...
...
@@ -2,6 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import
base64
import
pytz
from
datetime
import
datetime
,
timedelta
from
io
import
StringIO
...
...
@@ -121,7 +122,8 @@ class AccOperation(models.Model):
[(
"
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
.
seek
(
0
)
# reader = pd.read_csv(file_decode, header=None, delimiter=';')
...
...
@@ -132,7 +134,8 @@ class AccOperation(models.Model):
for
row
in
reader
.
values
:
# Create 1st slot 0-30min
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
(
{
"
name
"
:
file
.
name
,
...
...
@@ -141,10 +144,15 @@ class AccOperation(models.Model):
"
comp_data_type
"
:
computed_data_type
,
"
power
"
:
row
[
1
],
"
date_slot
"
:
date_slot
,
"
date_slot_utc
"
:
date_slot_utc
,
}
)
# 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
(
{
"
name
"
:
file
.
name
,
...
...
@@ -153,6 +161,7 @@ class AccOperation(models.Model):
"
comp_data_type
"
:
computed_data_type
,
"
power
"
:
row
[
2
],
"
date_slot
"
:
date_slot_30
,
"
date_slot_utc
"
:
date_slot_utc
,
}
)
...
...
This diff is collapsed.
Click to expand it.
views/acc_enedis_cdc_views.xml
+
1
−
0
View file @
94e22574
...
...
@@ -39,6 +39,7 @@
<field
name=
"acc_operation_id"
/>
<field
name=
"acc_counter_id"
/>
<field
name=
"date_slot_utc"
/>
<field
name=
"date_slot"
/>
<field
name=
"comp_data_type"
/>
<field
name=
"power"
/>
</tree>
...
...
This diff is collapsed.
Click to expand it.
views/acc_operation_views.xml
+
1
−
1
View file @
94e22574
...
...
@@ -25,7 +25,7 @@
<field
name=
"arch"
type=
"xml"
>
<form
string=
"Opération"
>
<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>
<sheet>
<widget
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment