From 2477566483cc59c7b762a0b0bd771c6c3908592c Mon Sep 17 00:00:00 2001 From: Joan Sisquella Date: Wed, 29 Apr 2020 17:11:32 +0200 Subject: [PATCH] [IMP] account_financial_report: open_items * added option "show_partner_details" --- account_financial_report/report/open_items.py | 19 ++ .../report/open_items_xlsx.py | 37 ++- .../report/templates/general_ledger.xml | 15 +- .../report/templates/open_items.xml | 251 +++++++++--------- .../wizard/open_items_wizard.py | 5 + .../wizard/open_items_wizard_view.xml | 1 + 6 files changed, 184 insertions(+), 144 deletions(-) diff --git a/account_financial_report/report/open_items.py b/account_financial_report/report/open_items.py index 1765c7af..325adbae 100644 --- a/account_financial_report/report/open_items.py +++ b/account_financial_report/report/open_items.py @@ -259,6 +259,19 @@ class OpenItemsReport(models.AbstractModel): 'amount_residual'] return total_amount + @api.model + def _get_open_items_no_partners(self, open_items_move_lines_data): + new_open_items = {} + for acc_id in open_items_move_lines_data.keys(): + new_open_items[acc_id] = {} + move_lines = [] + for prt_id in open_items_move_lines_data[acc_id]: + for move_line in open_items_move_lines_data[acc_id][prt_id]: + move_lines += [move_line] + move_lines = sorted(move_lines, key=lambda k: (k['date'])) + new_open_items[acc_id] = move_lines + return new_open_items + @api.multi def _get_report_values(self, docids, data): wizard_id = data['wizard_id'] @@ -270,6 +283,7 @@ class OpenItemsReport(models.AbstractModel): date_at_object = datetime.strptime(date_at, '%Y-%m-%d').date() date_from = data['date_from'] target_move = data['target_move'] + show_partner_details = data['show_partner_details'] move_lines_data, partners_data, journals_data, accounts_data, \ open_items_move_lines_data = self._get_data( @@ -277,11 +291,16 @@ class OpenItemsReport(models.AbstractModel): target_move, company_id, date_from) total_amount = self._calculate_amounts(open_items_move_lines_data) + if not show_partner_details: + open_items_move_lines_data = self._get_open_items_no_partners( + open_items_move_lines_data + ) return{ 'doc_ids': [wizard_id], 'doc_model': 'open.items.report.wizard', 'docs': self.env['open.items.report.wizard'].browse(wizard_id), 'foreign_currency': data['foreign_currency'], + 'show_partner_details': data['show_partner_details'], 'company_name': company.display_name, 'currency_name': company.currency_id.name, 'date_at': date_at_object.strftime("%d/%m/%Y"), diff --git a/account_financial_report/report/open_items_xlsx.py b/account_financial_report/report/open_items_xlsx.py index c3cb3a2a..88ecf30b 100644 --- a/account_financial_report/report/open_items_xlsx.py +++ b/account_financial_report/report/open_items_xlsx.py @@ -93,6 +93,7 @@ class OpenItemsXslx(models.AbstractModel): accounts_data = res_data['accounts_data'] partners_data = res_data['partners_data'] total_amount = res_data['total_amount'] + show_partner_details = res_data['show_partner_details'] for account_id in Open_items.keys(): # Write account title self.write_array_title(accounts_data[account_id]['code'] + ' - ' + @@ -100,26 +101,34 @@ class OpenItemsXslx(models.AbstractModel): # For each partner if Open_items[account_id]: - for partner_id in Open_items[account_id]: - type_object = 'partner' - # Write partner title - self.write_array_title(partners_data[partner_id]['name']) - + if show_partner_details: + for partner_id in Open_items[account_id]: + type_object = 'partner' + # Write partner title + self.write_array_title(partners_data[partner_id]['name']) + + # Display array header for move lines + self.write_array_header() + + # Display account move lines + for line in Open_items[account_id][partner_id]: + self.write_line_from_dict(line) + + # Display ending balance line for partner + self.write_ending_balance_from_dict( + partners_data[partner_id], type_object, total_amount, + account_id, partner_id) + + # Line break + self.row_pos += 1 + else: # Display array header for move lines self.write_array_header() # Display account move lines - for line in Open_items[account_id][partner_id]: + for line in Open_items[account_id]: self.write_line_from_dict(line) - # Display ending balance line for partner - self.write_ending_balance_from_dict( - partners_data[partner_id], type_object, total_amount, - account_id, partner_id) - - # Line break - self.row_pos += 1 - # Display ending balance line for account type_object = 'account' self.write_ending_balance_from_dict(accounts_data[account_id], diff --git a/account_financial_report/report/templates/general_ledger.xml b/account_financial_report/report/templates/general_ledger.xml index e8dcfd44..95606d58 100644 --- a/account_financial_report/report/templates/general_ledger.xml +++ b/account_financial_report/report/templates/general_ledger.xml @@ -68,16 +68,15 @@ - - - - - - - - + + + + + + + diff --git a/account_financial_report/report/templates/open_items.xml b/account_financial_report/report/templates/open_items.xml index 7210940d..24842cb6 100644 --- a/account_financial_report/report/templates/open_items.xml +++ b/account_financial_report/report/templates/open_items.xml @@ -25,7 +25,6 @@ -
+ +
+ - - + + + + +
+
+
- - - - - - - - - - - + + + +
+ + + + + + +
+ + + + +
- -
@@ -89,119 +99,116 @@ -