Browse Source

Extract dictionary used for report creation to a separate method

pull/367/head
jcoux 8 years ago
committed by Jordi Ballester
parent
commit
76d5c196d0
  1. 18
      account_financial_report_qweb/report/aged_partner_balance.py
  2. 22
      account_financial_report_qweb/report/trial_balance.py
  3. 14
      account_financial_report_qweb/wizard/aged_partner_balance_wizard.py
  4. 14
      account_financial_report_qweb/wizard/general_ledger_wizard.py
  5. 14
      account_financial_report_qweb/wizard/open_items_wizard.py
  6. 14
      account_financial_report_qweb/wizard/trial_balance_wizard.py

18
account_financial_report_qweb/report/aged_partner_balance.py

@ -197,6 +197,16 @@ class AgedPartnerBalanceReportCompute(models.TransientModel):
return self.env['report'].get_action(records=self,
report_name=report_name)
def _prepare_report_open_items(self):
self.ensure_one()
return {
'date_at': self.date_at,
'only_posted_moves': self.only_posted_moves,
'company_id': self.company_id.id,
'filter_account_ids': [(6, 0, self.filter_account_ids.ids)],
'filter_partner_ids': [(6, 0, self.filter_partner_ids.ids)],
}
@api.multi
def compute_data_for_report(self):
self.ensure_one()
@ -204,13 +214,7 @@ class AgedPartnerBalanceReportCompute(models.TransientModel):
# The data of Aged Partner Balance Report
# are based on Open Items Report data.
model = self.env['report_open_items_qweb']
self.open_items_id = model.create({
'date_at': self.date_at,
'only_posted_moves': self.only_posted_moves,
'company_id': self.company_id.id,
'filter_account_ids': [(6, 0, self.filter_account_ids.ids)],
'filter_partner_ids': [(6, 0, self.filter_partner_ids.ids)],
})
self.open_items_id = model.create(self._prepare_report_open_items())
self.open_items_id.compute_data_for_report()
# Compute report data

22
account_financial_report_qweb/report/trial_balance.py

@ -133,14 +133,9 @@ class TrialBalanceReportCompute(models.TransientModel):
return self.env['report'].get_action(records=self,
report_name=report_name)
@api.multi
def compute_data_for_report(self):
def _prepare_report_general_ledger(self):
self.ensure_one()
# Compute General Ledger Report Data.
# The data of Trial Balance Report
# are based on General Ledger Report data.
model = self.env['report_general_ledger_qweb']
self.general_ledger_id = model.create({
return {
'date_from': self.date_from,
'date_to': self.date_to,
'only_posted_moves': self.only_posted_moves,
@ -149,7 +144,18 @@ class TrialBalanceReportCompute(models.TransientModel):
'filter_account_ids': [(6, 0, self.filter_account_ids.ids)],
'filter_partner_ids': [(6, 0, self.filter_partner_ids.ids)],
'fy_start_date': self.fy_start_date,
})
}
@api.multi
def compute_data_for_report(self):
self.ensure_one()
# Compute General Ledger Report Data.
# The data of Trial Balance Report
# are based on General Ledger Report data.
model = self.env['report_general_ledger_qweb']
self.general_ledger_id = model.create(
self._prepare_report_general_ledger()
)
self.general_ledger_id.compute_data_for_report()
# Compute report data

14
account_financial_report_qweb/wizard/aged_partner_balance_wizard.py

@ -63,15 +63,19 @@ class AgedPartnerBalance(models.TransientModel):
self.ensure_one()
return self._export(xlsx_report=True)
def _export(self, xlsx_report=False):
"""Default export is PDF."""
model = self.env['report_aged_partner_balance_qweb']
report = model.create({
def _prepare_report_aged_partner_balance(self):
self.ensure_one()
return {
'date_at': self.date_at,
'only_posted_moves': self.target_move == 'posted',
'company_id': self.company_id.id,
'filter_account_ids': [(6, 0, self.account_ids.ids)],
'filter_partner_ids': [(6, 0, self.partner_ids.ids)],
'show_move_line_details': self.show_move_line_details,
})
}
def _export(self, xlsx_report=False):
"""Default export is PDF."""
model = self.env['report_aged_partner_balance_qweb']
report = model.create(self._prepare_report_aged_partner_balance())
return report.print_report(xlsx_report)

14
account_financial_report_qweb/wizard/general_ledger_wizard.py

@ -98,10 +98,9 @@ class GeneralLedgerReportWizard(models.TransientModel):
self.ensure_one()
return self._export(xlsx_report=True)
def _export(self, xlsx_report=False):
"""Default export is PDF."""
model = self.env['report_general_ledger_qweb']
report = model.create({
def _prepare_report_general_ledger(self):
self.ensure_one()
return {
'date_from': self.date_from,
'date_to': self.date_to,
'only_posted_moves': self.target_move == 'posted',
@ -112,5 +111,10 @@ class GeneralLedgerReportWizard(models.TransientModel):
'filter_cost_center_ids': [(6, 0, self.cost_center_ids.ids)],
'centralize': self.centralize,
'fy_start_date': self.fy_start_date,
})
}
def _export(self, xlsx_report=False):
"""Default export is PDF."""
model = self.env['report_general_ledger_qweb']
report = model.create(self._prepare_report_general_ledger())
return report.print_report(xlsx_report)

14
account_financial_report_qweb/wizard/open_items_wizard.py

@ -69,15 +69,19 @@ class OpenItemsReportWizard(models.TransientModel):
self.ensure_one()
return self._export(xlsx_report=True)
def _export(self, xlsx_report=False):
"""Default export is PDF."""
model = self.env['report_open_items_qweb']
report = model.create({
def _prepare_report_open_items(self):
self.ensure_one()
return {
'date_at': self.date_at,
'only_posted_moves': self.target_move == 'posted',
'hide_account_balance_at_0': self.hide_account_balance_at_0,
'company_id': self.company_id.id,
'filter_account_ids': [(6, 0, self.account_ids.ids)],
'filter_partner_ids': [(6, 0, self.partner_ids.ids)],
})
}
def _export(self, xlsx_report=False):
"""Default export is PDF."""
model = self.env['report_open_items_qweb']
report = model.create(self._prepare_report_open_items())
return report.print_report(xlsx_report)

14
account_financial_report_qweb/wizard/trial_balance_wizard.py

@ -92,10 +92,9 @@ class TrialBalanceReportWizard(models.TransientModel):
self.ensure_one()
return self._export(xlsx_report=True)
def _export(self, xlsx_report=False):
"""Default export is PDF."""
model = self.env['report_trial_balance_qweb']
report = model.create({
def _prepare_report_trial_balance(self):
self.ensure_one()
return {
'date_from': self.date_from,
'date_to': self.date_to,
'only_posted_moves': self.target_move == 'posted',
@ -105,5 +104,10 @@ class TrialBalanceReportWizard(models.TransientModel):
'filter_partner_ids': [(6, 0, self.partner_ids.ids)],
'fy_start_date': self.fy_start_date,
'show_partner_details': self.show_partner_details,
})
}
def _export(self, xlsx_report=False):
"""Default export is PDF."""
model = self.env['report_trial_balance_qweb']
report = model.create(self._prepare_report_trial_balance())
return report.print_report(xlsx_report)
Loading…
Cancel
Save