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
91ddcd9b
Commit
91ddcd9b
authored
2 years ago
by
Juliana
Browse files
Options
Downloads
Patches
Plain Diff
[UPD]Change format date slot
parent
94e22574
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
+21
-12
21 additions, 12 deletions
models/acc_operation.py
views/acc_operation_views.xml
+6
-1
6 additions, 1 deletion
views/acc_operation_views.xml
views/res_partner_views.xml
+4
-1
4 additions, 1 deletion
views/res_partner_views.xml
with
31 additions
and
14 deletions
models/acc_operation.py
+
21
−
12
View file @
91ddcd9b
...
...
@@ -2,11 +2,11 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import
base64
import
pytz
from
datetime
import
datetime
,
timedelta
from
datetime
import
datetime
,
timedelta
,
timezone
from
io
import
StringIO
import
pandas
as
pd
from
dateutil
import
tz
from
odoo
import
_
,
api
,
fields
,
models
from
odoo.exceptions
import
UserError
...
...
@@ -123,6 +123,8 @@ class AccOperation(models.Model):
)
computed_data_type
=
data_filename
[
3
].
lower
()
if
computed_data_type
!=
"
prod
"
and
computed_data_type
!=
"
surplus
"
:
computed_data_type
=
data_filename
[
3
].
lower
()[:
-
1
]
file_decode
=
StringIO
(
base64
.
b64decode
(
file
.
datas
).
decode
(
"
UTF-8
"
))
file_decode
.
seek
(
0
)
...
...
@@ -133,8 +135,18 @@ class AccOperation(models.Model):
# Create Data for the CDC
for
row
in
reader
.
values
:
# Create 1st slot 0-30min
date_slot
=
datetime
.
strptime
(
row
[
0
],
"
%d/%m/%Y %H:%M
"
)
date_slot_utc
=
fields
.
Datetime
.
to_string
(
date_slot
)
slot_datetime_tz
=
datetime
.
strptime
(
row
[
0
],
"
%d/%m/%Y %H:%M
"
)
slot_tz
=
datetime
.
strftime
(
slot_datetime_tz
,
"
%Y-%m-%d %H:%M:%S
"
)
slot_date_tz
=
datetime
.
fromisoformat
(
slot_tz
).
replace
(
tzinfo
=
tz
.
gettz
(
"
Europe/Paris
"
)
)
date_slot_utc
=
slot_date_tz
.
astimezone
(
timezone
.
utc
).
replace
(
tzinfo
=
None
)
self
.
env
[
"
acc.enedis.cdc
"
].
create
(
{
...
...
@@ -143,16 +155,11 @@ class AccOperation(models.Model):
"
acc_counter_id
"
:
counter_id
.
id
or
False
,
"
comp_data_type
"
:
computed_data_type
,
"
power
"
:
row
[
1
],
"
date_slot
"
:
date_slot
,
"
date_slot
"
:
slot_datetime_tz
,
"
date_slot_utc
"
:
date_slot_utc
,
}
)
# Create 2nd slot 30-60min
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
,
...
...
@@ -160,8 +167,10 @@ class AccOperation(models.Model):
"
acc_counter_id
"
:
counter_id
.
id
or
False
,
"
comp_data_type
"
:
computed_data_type
,
"
power
"
:
row
[
2
],
"
date_slot
"
:
date_slot_30
,
"
date_slot_utc
"
:
date_slot_utc
,
"
date_slot
"
:
slot_datetime_tz
+
timedelta
(
minutes
=
30
),
"
date_slot_utc
"
:
date_slot_utc
+
timedelta
(
minutes
=
30
),
}
)
...
...
This diff is collapsed.
Click to expand it.
views/acc_operation_views.xml
+
6
−
1
View file @
91ddcd9b
...
...
@@ -25,7 +25,12 @@
<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.
views/res_partner_views.xml
+
4
−
1
View file @
91ddcd9b
...
...
@@ -42,7 +42,10 @@
<field
name=
"is_producer"
/>
<field
name=
"is_consumer"
/>
<field
name=
"is_pmo"
/>
<field
name=
"mail_contact_pmo"
attrs=
"{'invisible': [('is_pmo', '!=', True)]}"
/>
<field
name=
"mail_contact_pmo"
attrs=
"{'invisible': [('is_pmo', '!=', True)]}"
/>
<field
name=
"is_buyer_surplus"
/>
</field>
<xpath
expr=
"//notebook"
position=
"inside"
>
...
...
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