diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2023-08-16 10:53:14 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2023-08-16 10:53:14 +0700 |
| commit | 43ccd7dae4940fcbf40f069e6b5a36aeedc59555 (patch) | |
| tree | b175b3b883a673fd1f37c0a5a86ecf200cf05a40 | |
| parent | a14ca5491216591cd1142c11daf681634bff4ac1 (diff) | |
fix financial report
| -rw-r--r-- | indoteknik_custom/models/account_financial_report.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/indoteknik_custom/models/account_financial_report.py b/indoteknik_custom/models/account_financial_report.py index 3adc1bd8..6147a3f3 100644 --- a/indoteknik_custom/models/account_financial_report.py +++ b/indoteknik_custom/models/account_financial_report.py @@ -24,14 +24,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] - if obj.date_from: - date_from = data['form']['date_from'] - else: - date_from = journal_entries.date - + date_from = data['form']['date_from'] date_to = data['form']['date_to'] obj = self.search([('id', '=', options['form']['id'])]) @@ -65,7 +62,7 @@ class AccountingReport(models.TransientModel): sheet.set_column('I:I', 10, format4) sheet.set_column('J:J', 10, format4) - date_ranges = self.generate_date_ranges(date_from, date_to, obj) + date_ranges = self.generate_date_ranges(date_from, date_to) col_number = 0 balance_col_number = 4 @@ -73,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 @@ -162,7 +159,7 @@ class AccountingReport(models.TransientModel): response.stream.write(output.read()) output.close() - def generate_date_ranges(self, date_from, date_to, obj): + def generate_date_ranges(self, date_from, date_to): current_date = date_from date_ranges = [] @@ -171,7 +168,7 @@ class AccountingReport(models.TransientModel): end_of_month = min(next_month - timedelta(days=next_month.day), date_to) date_ranges.append({ - "date_from": current_date if obj.date_from else date_from, + "date_from": current_date, "date_to": end_of_month }) |
