Skip to content
Snippets Groups Projects
Commit d1c6c947 authored by Julien - Le Filament's avatar Julien - Le Filament
Browse files

[UPD] Typo from rust

parent 70b460e5
Branches
No related tags found
1 merge request!116.0 add date
# Copyright 2023 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import pytz
from datetime import datetime, time
import pytz
from dateutil.relativedelta import relativedelta
from odoo import _, models
from odoo.exceptions import ValidationError, UserError
from odoo.exceptions import UserError, ValidationError
from odoo.osv import expression
from odoo.tools import date_utils
......@@ -46,10 +48,11 @@ class AccOperation(models.Model):
# Get last date slot recorded
last_record = self.get_last_cdc_record()
start_date, end_date = self.get_interval("month", last_record)
end_date_mounth = end_date + relativedelta(days=1)
end_date_month = end_date + relativedelta(days=1)
query = """
SELECT
date_trunc('month', cdc.date_slot AT TIME ZONE 'UTC' AT TIME ZONE 'Europe/Paris') AS date_slot,
date_trunc('month', cdc.date_slot AT TIME ZONE 'UTC' \
AT TIME ZONE 'Europe/Paris') AS date_slot,
(SUM( (CASE
WHEN cdc.comp_data_type = 'cons' THEN cdc.power
ELSE 0 END) )/2) / 1000 as conso_tot,
......@@ -67,12 +70,13 @@ class AccOperation(models.Model):
cdc.acc_operation_id = %s
AND cdc.date_slot >= %s
AND cdc.date_slot < %s
GROUP BY date_trunc('month', cdc.date_slot AT TIME ZONE 'UTC' AT TIME ZONE 'Europe/Paris');
GROUP BY date_trunc('month', cdc.date_slot AT TIME ZONE 'UTC' \
AT TIME ZONE 'Europe/Paris');
"""
query_params = (
self.id,
self._convert_time(start_date),
self._convert_time(end_date_mounth),
self._convert_time(end_date_month),
)
self.env.cr.execute(query, query_params)
raw_data = self.env.cr.fetchone()
......@@ -197,7 +201,8 @@ class AccOperation(models.Model):
query = """
SELECT
date_trunc(%s, cdc.date_slot AT TIME ZONE 'UTC' AT TIME ZONE 'Europe/Paris') AS date_slot,
date_trunc(%s, cdc.date_slot AT TIME ZONE 'UTC' \
AT TIME ZONE 'Europe/Paris') AS date_slot,
(SUM( (CASE
WHEN cdc.comp_data_type = 'cons'
THEN cdc.power ELSE 0 END) )/2) / 1000 as cons,
......@@ -217,7 +222,8 @@ class AccOperation(models.Model):
AND cdc.date_slot >= %s
AND cdc.date_slot <= %s
AND cdc.partner_id IN %s
GROUP BY date_trunc(%s, cdc.date_slot AT TIME ZONE 'UTC' AT TIME ZONE 'Europe/Paris')
GROUP BY date_trunc(%s, cdc.date_slot AT TIME ZONE 'UTC' \
AT TIME ZONE 'Europe/Paris')
ORDER BY date_slot ASC;
"""
query_params = (
......@@ -266,7 +272,8 @@ class AccOperation(models.Model):
query = """
SELECT
date_trunc('day', cdc.date_slot AT TIME ZONE 'UTC' AT TIME ZONE 'Europe/Paris') AS date_slot,
date_trunc('day', cdc.date_slot AT TIME ZONE 'UTC' \
AT TIME ZONE 'Europe/Paris') AS date_slot,
(SUM( (CASE
WHEN cdc.comp_data_type = 'autocons'
THEN cdc.power ELSE 0 END) )/2) / 1000 as autocons,
......@@ -284,7 +291,8 @@ class AccOperation(models.Model):
AND cdc.date_slot >= %s
AND cdc.date_slot <= %s
AND cdc.partner_id IN %s
GROUP BY date_trunc('day', cdc.date_slot AT TIME ZONE 'UTC' AT TIME ZONE 'Europe/Paris')
GROUP BY date_trunc('day', cdc.date_slot AT TIME ZONE 'UTC' \
AT TIME ZONE 'Europe/Paris')
ORDER BY date_slot ASC;
"""
query_params = (
......@@ -329,7 +337,8 @@ class AccOperation(models.Model):
query = """
SELECT
date_trunc(%s, cdc.date_slot AT TIME ZONE 'UTC' AT TIME ZONE 'Europe/Paris') AS date_slot,
date_trunc(%s, cdc.date_slot AT TIME ZONE 'UTC' \
AT TIME ZONE 'Europe/Paris') AS date_slot,
((SUM((CASE
WHEN cdc.comp_data_type = 'prod' THEN cdc.power
ELSE 0 END))
......@@ -348,7 +357,8 @@ class AccOperation(models.Model):
AND cdc.date_slot >= %s
AND cdc.date_slot <= %s
AND cdc.partner_id IN %s
GROUP BY date_trunc(%s, cdc.date_slot AT TIME ZONE 'UTC' AT TIME ZONE 'Europe/Paris')
GROUP BY date_trunc(%s, cdc.date_slot AT TIME ZONE 'UTC' \
AT TIME ZONE 'Europe/Paris')
ORDER BY date_slot ASC;
"""
query_params = (
......@@ -393,7 +403,8 @@ class AccOperation(models.Model):
query = """
SELECT
date_trunc('day', cdc.date_slot AT TIME ZONE 'UTC' AT TIME ZONE 'Europe/Paris') AS date_slot,
date_trunc('day', cdc.date_slot AT TIME ZONE 'UTC' \
AT TIME ZONE 'Europe/Paris') AS date_slot,
((SUM((CASE
WHEN cdc.comp_data_type = 'prod' THEN cdc.power
ELSE 0 END))
......@@ -412,7 +423,8 @@ class AccOperation(models.Model):
AND cdc.date_slot >= %s
AND cdc.date_slot <= %s
AND cdc.partner_id IN %s
GROUP BY date_trunc('day', cdc.date_slot AT TIME ZONE 'UTC' AT TIME ZONE 'Europe/Paris')
GROUP BY date_trunc('day', cdc.date_slot AT TIME ZONE 'UTC' \
AT TIME ZONE 'Europe/Paris')
ORDER BY date_slot ASC;
"""
query_params = (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment