From a54c2dfa04d588c4dac8492bbf7bedef0e08cdc7 Mon Sep 17 00:00:00 2001 From: collo Date: Mon, 4 Nov 2024 15:53:16 +0300 Subject: [PATCH] quarterly period --- mis_builder/models/mis_report_instance.py | 19 +++++++++++++++++-- mis_builder/views/mis_report_instance.xml | 4 ++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/mis_builder/models/mis_report_instance.py b/mis_builder/models/mis_report_instance.py index 400e2128e..1a91bbabc 100644 --- a/mis_builder/models/mis_report_instance.py +++ b/mis_builder/models/mis_report_instance.py @@ -133,6 +133,19 @@ def _compute_dates(self): record.date_from = fields.Date.to_string(date_from) record.date_to = fields.Date.to_string(date_to) record.valid = True + + elif record.mode == MODE_REL and record.type == "q": # Quarterly period logic + date_from = d.replace(day=1) + date_from = date_from + relativedelta(months=record.offset * 3) + date_to = ( + date_from + + relativedelta(months=(record.duration * 3) - 1) + + relativedelta(day=31) + ) + record.date_from = fields.Date.to_string(date_from) + record.date_to = fields.Date.to_string(date_to) + record.valid = True + elif record.mode == MODE_REL and record.type == "date_range": date_range_obj = record.env["date.range"] current_periods = date_range_obj.search( @@ -190,16 +203,18 @@ def _compute_dates(self): ("d", _("Day")), ("w", _("Week")), ("m", _("Month")), + ("q", _("quarterly")), ("y", _("Year")), ("date_range", _("Date Range")), ], string="Period type", ) - is_ytd = fields.Boolean( + is_ytd = ( + fields.Boolean( default=False, string="Year to date", help="Forces the start date to Jan 1st of the relevant year", - ) + )) date_range_type_id = fields.Many2one( comodel_name="date.range.type", string="Date Range Type", diff --git a/mis_builder/views/mis_report_instance.xml b/mis_builder/views/mis_report_instance.xml index 2692c45e0..6ed099b62 100644 --- a/mis_builder/views/mis_report_instance.xml +++ b/mis_builder/views/mis_report_instance.xml @@ -380,8 +380,8 @@ invisible="type != 'date_range'" required="type == 'date_range' and mode == 'relative'" /> - - + +