Files
Odoo-Modules/Fusion Accounting/models/executive_summary_report.py
2026-02-22 01:22:18 -05:00

34 lines
1.3 KiB
Python

# Fusion Accounting - Executive Summary Report
from odoo import fields, models
from odoo.exceptions import UserError
class ExecutiveSummaryReport(models.Model):
"""Extends the accounting report to provide an executive summary metric
that computes the number of days in the selected reporting period."""
_inherit = 'account.report'
def _report_custom_engine_executive_summary_ndays(
self, expressions, options, date_scope,
current_groupby, next_groupby,
offset=0, limit=None, warnings=None,
):
"""Calculate the total number of calendar days within the report period.
This engine expression is used by the executive summary layout to
display the length of the chosen date window. Group-by is
intentionally unsupported because the metric is inherently scalar.
"""
if current_groupby or next_groupby:
raise UserError(
"The executive summary day-count expression "
"does not support grouping."
)
period_start = fields.Date.from_string(options['date']['date_from'])
period_end = fields.Date.from_string(options['date']['date_to'])
elapsed = period_end - period_start
return {'result': elapsed.days}