diff options
Diffstat (limited to 'indoteknik_custom/models/account_financial_report.py')
| -rw-r--r-- | indoteknik_custom/models/account_financial_report.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/indoteknik_custom/models/account_financial_report.py b/indoteknik_custom/models/account_financial_report.py index 315515f6..6147a3f3 100644 --- a/indoteknik_custom/models/account_financial_report.py +++ b/indoteknik_custom/models/account_financial_report.py @@ -23,10 +23,11 @@ class AccountingReport(models.TransientModel): output = io.BytesIO() workbook = xlsxwriter.Workbook(output, {'in_memory': True}) - + journal_entries = self.env['account.move'].search([('move_type', '=', 'entry')], order='date asc', limit=1) + first_journal_date = journal_entries.date data = {} data['form'] = obj.read([])[0] - + date_from = data['form']['date_from'] date_to = data['form']['date_to'] @@ -69,7 +70,7 @@ class AccountingReport(models.TransientModel): for date_range in date_ranges: row_number = 9 data['form']['used_context']['date_to'] = date_range['date_to'] - data['form']['used_context']['date_from'] = date_range['date_from'] + data['form']['used_context']['date_from'] = first_journal_date comp_dic['state'] = 'posted' comp_dic['journal_ids'] = data['form']['journal_ids'] data['form']['comparison_context'] = comp_dic @@ -164,9 +165,7 @@ class AccountingReport(models.TransientModel): while current_date <= date_to: next_month = current_date.replace(day=1) + timedelta(days=32) - end_of_month = next_month - timedelta(days=next_month.day) - if end_of_month > date_to: - end_of_month = date_to + end_of_month = min(next_month - timedelta(days=next_month.day), date_to) date_ranges.append({ "date_from": current_date, @@ -175,4 +174,4 @@ class AccountingReport(models.TransientModel): current_date = end_of_month + timedelta(days=1) - return date_ranges
\ No newline at end of file + return date_ranges |
