From 97c77bd563d65ea926d3252f41951b05e2f517eb Mon Sep 17 00:00:00 2001 From: Jordi Ballester Alomar Date: Wed, 2 Dec 2020 09:03:28 +0100 Subject: [PATCH] add option to show reconciliations in the open items report --- .../report/open_items.py | 24 ++++++++++++++++++- .../report/open_items_xlsx.py | 17 ++++++------- .../report/templates/open_items.xml | 14 +++++++++++ .../wizard/open_items_wizard.py | 4 ++++ .../wizard/open_items_wizard_view.xml | 1 + 5 files changed, 51 insertions(+), 9 deletions(-) diff --git a/account_financial_report_qweb/report/open_items.py b/account_financial_report_qweb/report/open_items.py index d939958c..658ad111 100644 --- a/account_financial_report_qweb/report/open_items.py +++ b/account_financial_report_qweb/report/open_items.py @@ -28,7 +28,7 @@ class OpenItemsReport(models.TransientModel): company_id = fields.Many2one(comodel_name='res.company') filter_account_ids = fields.Many2many(comodel_name='account.account') filter_partner_ids = fields.Many2many(comodel_name='res.partner') - + show_reconciliations = fields.Boolean() # Data fields, used to browse report data account_ids = fields.One2many( comodel_name='report_open_items_qweb_account', @@ -129,6 +129,14 @@ class OpenItemsReportMoveLine(models.TransientModel): # Data fields, used to keep link with real object move_line_id = fields.Many2one('account.move.line') + # Display full or partial reconciliations + reconcile_string = fields.Char( + compute='_compute_reconcile', string='Reconcile') + partial_reconcile_ids = fields.Many2many( + comodel_name='account.partial.reconcile', + compute='_compute_reconcile', + string='Reconciliation move lines') + # Data fields, used for report display date = fields.Date() date_due = fields.Date() @@ -143,6 +151,20 @@ class OpenItemsReportMoveLine(models.TransientModel): amount_total_due_currency = fields.Float(digits=(16, 2)) amount_residual_currency = fields.Float(digits=(16, 2)) + def _compute_reconcile(self): + for line in self: + ml = line.move_line_id + partial_recs = self.env['account.partial.reconcile'] + if ml.full_reconcile_id: + rec_str = ml.full_reconcile_id.name + else: + rec_str = ', '.join([ + 'a%d' % pr.id for pr in + ml.matched_debit_ids + ml.matched_credit_ids]) + partial_recs = ml.matched_debit_ids + ml.matched_credit_ids + line.reconcile_string = rec_str + line.partial_reconcile_ids = partial_recs + class OpenItemsReportCompute(models.TransientModel): """ Here, we just define methods. diff --git a/account_financial_report_qweb/report/open_items_xlsx.py b/account_financial_report_qweb/report/open_items_xlsx.py index 58343068..0d1d3222 100644 --- a/account_financial_report_qweb/report/open_items_xlsx.py +++ b/account_financial_report_qweb/report/open_items_xlsx.py @@ -27,12 +27,13 @@ class OpenItemsXslx(abstract_report_xlsx.AbstractReportXslx): 3: {'header': _('Account'), 'field': 'account', 'width': 9}, 4: {'header': _('Partner'), 'field': 'partner', 'width': 25}, 5: {'header': _('Ref - Label'), 'field': 'label', 'width': 40}, - 6: {'header': _('Due date'), 'field': 'date_due', 'width': 11}, - 7: {'header': _('Original'), + 6: {'header': _('Rec.'), 'field': 'reconcile_string', 'width': 11}, + 7: {'header': _('Due date'), 'field': 'date_due', 'width': 11}, + 8: {'header': _('Original'), 'field': 'amount_total_due', 'type': 'amount', 'width': 14}, - 8: {'header': _('Residual'), + 9: {'header': _('Residual'), 'field': 'amount_residual', 'field_final_balance': 'final_amount_residual', 'type': 'amount', @@ -40,15 +41,15 @@ class OpenItemsXslx(abstract_report_xlsx.AbstractReportXslx): } if report.foreign_currency: foreign_currency = { - 9: {'header': _('Cur.'), 'field': 'currency_id', - 'field_currency_balance': 'currency_id', - 'type': 'many2one', 'width': 7}, - 10: {'header': _('Cur. Original'), + 10: {'header': _('Cur.'), 'field': 'currency_id', + 'field_currency_balance': 'currency_id', + 'type': 'many2one', 'width': 7}, + 11: {'header': _('Cur. Original'), 'field': 'amount_total_due_currency', 'field_final_balance': 'final_amount_total_due_currency', 'type': 'amount_currency', 'width': 14}, - 11: {'header': _('Cur. Residual'), + 12: {'header': _('Cur. Residual'), 'field': 'amount_residual_currency', 'field_final_balance': 'final_amount_residual_currency', 'type': 'amount_currency', diff --git a/account_financial_report_qweb/report/templates/open_items.xml b/account_financial_report_qweb/report/templates/open_items.xml index 1f451505..9312c506 100644 --- a/account_financial_report_qweb/report/templates/open_items.xml +++ b/account_financial_report_qweb/report/templates/open_items.xml @@ -105,6 +105,10 @@
Ref - Label
+ + +
Rec.
+
Due date
@@ -160,6 +164,16 @@
+ + + + +
diff --git a/account_financial_report_qweb/wizard/open_items_wizard.py b/account_financial_report_qweb/wizard/open_items_wizard.py index 1a5a0f84..50da2904 100644 --- a/account_financial_report_qweb/wizard/open_items_wizard.py +++ b/account_financial_report_qweb/wizard/open_items_wizard.py @@ -53,6 +53,9 @@ class OpenItemsReportWizard(models.TransientModel): 'account currency is not setup through chart of accounts ' 'will display initial and final balance in that currency.' ) + show_reconciliations = fields.Boolean( + string='Display reconciliations', + ) @api.onchange('company_id') def onchange_company_id(self): @@ -153,6 +156,7 @@ class OpenItemsReportWizard(models.TransientModel): '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_reconciliations': self.show_reconciliations, } def _export(self, report_type): diff --git a/account_financial_report_qweb/wizard/open_items_wizard_view.xml b/account_financial_report_qweb/wizard/open_items_wizard_view.xml index c8a37ebf..e921a669 100644 --- a/account_financial_report_qweb/wizard/open_items_wizard_view.xml +++ b/account_financial_report_qweb/wizard/open_items_wizard_view.xml @@ -18,6 +18,7 @@ +