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

[debug] change _compute_is_a_jour_bool function + add debug

parent 2ea7c50f
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
# © 2022 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from datetime import date
from dateutil.relativedelta import relativedelta
from odoo import models, fields, api
......@@ -15,20 +18,12 @@ class ScopPartner(models.Model):
# ------------------------------------------------------
@api.multi
def _compute_is_a_jour_bool(self):
current_month = fields.Date.today().month
current_year = fields.Date.today().year
q1 = (str(current_year - 3) + '-10-01',
str(current_year - 1) + '-09-30')
q2 = (str(current_year - 2) + '-01-01', str(current_year) + '-12-31')
q3 = (str(current_year - 2) + '-04-01', str(current_year) + '-03-31')
q4 = (str(current_year - 2) + '-07-01', str(current_year) + '-06-30')
month_to_quarter = {
1: q1, 2: q1, 3: q1,
4: q2, 5: q2, 6: q2,
7: q3, 8: q3, 9: q3,
10: q4, 11: q4, 12: q4,
}
interval = month_to_quarter.get(current_month)
today = fields.Date.today()
quarter_start = date(today.year, 3 * ((today.month - 1) // 3 + 1) - 2, 1)
end_date = quarter_start - relativedelta(months=3, days=1)
start_date = quarter_start - relativedelta(months=27)
print(end_date)
print(start_date)
for r in self:
if r.type == 'facility' and r.parent_id:
r.is_a_jour_bool = r.parent_id.is_a_jour_bool
......@@ -64,10 +59,13 @@ class ScopPartner(models.Model):
)
) q
""" % (
r.id, interval[0], interval[1],
r.id, start_date, end_date,
r.id,
self.env.ref('cgscop_partner.riga_14397').id,
interval[0], interval[1]))
start_date, end_date))
print(query_a_jour)
self.env.cr.execute(query_a_jour)
r.is_a_jour_bool = self.env.cr.fetchall()[0][0]
is_a_jour_bool = self.env.cr.fetchall()[0][0]
print(is_a_jour_bool)
r.is_a_jour_bool = True if is_a_jour_bool == 1 else False
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