Skip to content
Extraits de code Groupes Projets
Valider d1c6c947 rédigé par Julien - Le Filament's avatar Julien - Le Filament
Parcourir les fichiers

[UPD] Typo from rust

parent 70b460e5
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!116.0 add date
# Copyright 2023 Le Filament (<http://www.le-filament.com>) # Copyright 2023 Le Filament (<http://www.le-filament.com>)
# 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 pytz
from datetime import datetime, time from datetime import datetime, time
import pytz
from dateutil.relativedelta import relativedelta from dateutil.relativedelta import relativedelta
from odoo import _, models from odoo import _, models
from odoo.exceptions import ValidationError, UserError from odoo.exceptions import UserError, ValidationError
from odoo.osv import expression from odoo.osv import expression
from odoo.tools import date_utils from odoo.tools import date_utils
...@@ -46,10 +48,11 @@ class AccOperation(models.Model): ...@@ -46,10 +48,11 @@ class AccOperation(models.Model):
# Get last date slot recorded # Get last date slot recorded
last_record = self.get_last_cdc_record() last_record = self.get_last_cdc_record()
start_date, end_date = self.get_interval("month", last_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 = """ query = """
SELECT 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 (SUM( (CASE
WHEN cdc.comp_data_type = 'cons' THEN cdc.power WHEN cdc.comp_data_type = 'cons' THEN cdc.power
ELSE 0 END) )/2) / 1000 as conso_tot, ELSE 0 END) )/2) / 1000 as conso_tot,
...@@ -67,12 +70,13 @@ class AccOperation(models.Model): ...@@ -67,12 +70,13 @@ class AccOperation(models.Model):
cdc.acc_operation_id = %s cdc.acc_operation_id = %s
AND cdc.date_slot >= %s AND cdc.date_slot >= %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 = ( query_params = (
self.id, self.id,
self._convert_time(start_date), self._convert_time(start_date),
self._convert_time(end_date_mounth), self._convert_time(end_date_month),
) )
self.env.cr.execute(query, query_params) self.env.cr.execute(query, query_params)
raw_data = self.env.cr.fetchone() raw_data = self.env.cr.fetchone()
...@@ -197,7 +201,8 @@ class AccOperation(models.Model): ...@@ -197,7 +201,8 @@ class AccOperation(models.Model):
query = """ query = """
SELECT 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 (SUM( (CASE
WHEN cdc.comp_data_type = 'cons' WHEN cdc.comp_data_type = 'cons'
THEN cdc.power ELSE 0 END) )/2) / 1000 as cons, THEN cdc.power ELSE 0 END) )/2) / 1000 as cons,
...@@ -217,7 +222,8 @@ class AccOperation(models.Model): ...@@ -217,7 +222,8 @@ class AccOperation(models.Model):
AND cdc.date_slot >= %s AND cdc.date_slot >= %s
AND cdc.date_slot <= %s AND cdc.date_slot <= %s
AND cdc.partner_id IN %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; ORDER BY date_slot ASC;
""" """
query_params = ( query_params = (
...@@ -266,7 +272,8 @@ class AccOperation(models.Model): ...@@ -266,7 +272,8 @@ class AccOperation(models.Model):
query = """ query = """
SELECT 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 (SUM( (CASE
WHEN cdc.comp_data_type = 'autocons' WHEN cdc.comp_data_type = 'autocons'
THEN cdc.power ELSE 0 END) )/2) / 1000 as autocons, THEN cdc.power ELSE 0 END) )/2) / 1000 as autocons,
...@@ -284,7 +291,8 @@ class AccOperation(models.Model): ...@@ -284,7 +291,8 @@ class AccOperation(models.Model):
AND cdc.date_slot >= %s AND cdc.date_slot >= %s
AND cdc.date_slot <= %s AND cdc.date_slot <= %s
AND cdc.partner_id IN %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; ORDER BY date_slot ASC;
""" """
query_params = ( query_params = (
...@@ -329,7 +337,8 @@ class AccOperation(models.Model): ...@@ -329,7 +337,8 @@ class AccOperation(models.Model):
query = """ query = """
SELECT 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 ((SUM((CASE
WHEN cdc.comp_data_type = 'prod' THEN cdc.power WHEN cdc.comp_data_type = 'prod' THEN cdc.power
ELSE 0 END)) ELSE 0 END))
...@@ -348,7 +357,8 @@ class AccOperation(models.Model): ...@@ -348,7 +357,8 @@ class AccOperation(models.Model):
AND cdc.date_slot >= %s AND cdc.date_slot >= %s
AND cdc.date_slot <= %s AND cdc.date_slot <= %s
AND cdc.partner_id IN %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; ORDER BY date_slot ASC;
""" """
query_params = ( query_params = (
...@@ -393,7 +403,8 @@ class AccOperation(models.Model): ...@@ -393,7 +403,8 @@ class AccOperation(models.Model):
query = """ query = """
SELECT 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 ((SUM((CASE
WHEN cdc.comp_data_type = 'prod' THEN cdc.power WHEN cdc.comp_data_type = 'prod' THEN cdc.power
ELSE 0 END)) ELSE 0 END))
...@@ -412,7 +423,8 @@ class AccOperation(models.Model): ...@@ -412,7 +423,8 @@ class AccOperation(models.Model):
AND cdc.date_slot >= %s AND cdc.date_slot >= %s
AND cdc.date_slot <= %s AND cdc.date_slot <= %s
AND cdc.partner_id IN %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; ORDER BY date_slot ASC;
""" """
query_params = ( query_params = (
......
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