diff --git a/account_financial_report/__manifest__.py b/account_financial_report/__manifest__.py index 416b42b2..9d58e8eb 100644 --- a/account_financial_report/__manifest__.py +++ b/account_financial_report/__manifest__.py @@ -44,11 +44,6 @@ 'view/report_aged_partner_balance.xml', 'view/report_vat_report.xml', ], - "external_dependencies": { - "python": ['natsort', - 'pandas', - ], - }, 'installable': True, 'application': True, 'auto_install': False, diff --git a/account_financial_report/report/aged_partner_balance.py b/account_financial_report/report/aged_partner_balance.py index f715b55a..c12d7ede 100644 --- a/account_financial_report/report/aged_partner_balance.py +++ b/account_financial_report/report/aged_partner_balance.py @@ -5,7 +5,7 @@ from odoo import models, api from odoo.tools import float_is_zero from datetime import date, datetime, timedelta -import pandas as pd +import operator class AgedPartnerBalanceReport(models.AbstractModel): @@ -174,7 +174,6 @@ class AgedPartnerBalanceReport(models.AbstractModel): move_lines = self.env['account.move.line'].search_read( domain=domain, fields=ml_fields ) - ml_ids = set(pd.DataFrame(move_lines).id.to_list()) journals_ids = set() partners_ids = set() partners_data = {} @@ -183,9 +182,11 @@ class AgedPartnerBalanceReport(models.AbstractModel): acc_partial_rec, debit_amount, credit_amount = \ self._get_account_partial_reconciled(company_id, date_at_object) if acc_partial_rec: - acc_partial_rec_data = pd.DataFrame(acc_partial_rec) - debit_ids = set(acc_partial_rec_data.debit_move_id.to_list()) - credit_ids = set(acc_partial_rec_data.credit_move_id.to_list()) + ml_ids = map(operator.itemgetter('id'), move_lines) + debit_ids = map(operator.itemgetter('debit_move_id'), + acc_partial_rec) + credit_ids = map(operator.itemgetter('credit_move_id'), + acc_partial_rec) move_lines = self._recalculate_move_lines( move_lines, debit_ids, credit_ids, debit_amount, credit_amount, ml_ids, account_ids, diff --git a/account_financial_report/report/general_ledger.py b/account_financial_report/report/general_ledger.py index 1ccb5c79..5ebfe25c 100644 --- a/account_financial_report/report/general_ledger.py +++ b/account_financial_report/report/general_ledger.py @@ -3,8 +3,6 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import models, api -from operator import itemgetter -from natsort import natsorted import calendar import datetime @@ -472,6 +470,7 @@ class GeneralLedgerReport(models.AbstractModel): account.update({ml_id: gen_led_data[acc_id][ml_id]}) else: move_lines += [gen_led_data[acc_id][ml_id]] + move_lines = sorted(move_lines, key=lambda k: (k['date'])) account.update({'move_lines': move_lines}) else: list_partner = [] @@ -488,6 +487,8 @@ class GeneralLedgerReport(models.AbstractModel): else: move_lines += [ gen_led_data[acc_id][prt_id][ml_id]] + move_lines = sorted(move_lines, + key=lambda k: (k['date'])) partner.update({'move_lines': move_lines}) list_partner += [partner] account.update({'list_partner': list_partner}) @@ -584,7 +585,7 @@ class GeneralLedgerReport(models.AbstractModel): account['move_lines'] = centralized_ml account['partners'] = False del account['list_partner'] - general_ledger = natsorted(general_ledger, key=itemgetter('code')) + general_ledger = sorted(general_ledger, key=lambda k: k['code']) return { 'doc_ids': [wizard_id], 'doc_model': 'general.ledger.report.wizard', diff --git a/account_financial_report/report/journal_ledger.py b/account_financial_report/report/journal_ledger.py index 04f19b01..9f7fbb96 100644 --- a/account_financial_report/report/journal_ledger.py +++ b/account_financial_report/report/journal_ledger.py @@ -184,21 +184,22 @@ class JournalLedgerReport(models.AbstractModel): move_lines = self.env['account.move.line'].search( self._get_move_lines_domain(move_ids, wizard, journal_ids), order=self._get_move_lines_order(move_ids, wizard, journal_ids)) - # Get the taxes ids for the move lines - query_taxes_params = self._get_query_taxes_params(move_lines) - query_taxes = self._get_query_taxes() move_line_ids_taxes_data = {} - self.env.cr.execute(query_taxes, - query_taxes_params) - # Fetch the taxes associated to the move line - for move_line_id, account_tax_id, tax_description, tax_name in \ - self.env.cr.fetchall(): - if move_line_id not in move_line_ids_taxes_data.keys(): - move_line_ids_taxes_data[move_line_id] = {} - move_line_ids_taxes_data[move_line_id][account_tax_id] = { - 'name': tax_name, - 'description': tax_description - } + if move_lines: + # Get the taxes ids for the move lines + query_taxes_params = self._get_query_taxes_params(move_lines) + query_taxes = self._get_query_taxes() + self.env.cr.execute(query_taxes, + query_taxes_params) + # Fetch the taxes associated to the move line + for move_line_id, account_tax_id, tax_description, tax_name in \ + self.env.cr.fetchall(): + if move_line_id not in move_line_ids_taxes_data.keys(): + move_line_ids_taxes_data[move_line_id] = {} + move_line_ids_taxes_data[move_line_id][account_tax_id] = { + 'name': tax_name, + 'description': tax_description + } Move_Lines = {} accounts = self.env['account.account'] partners = self.env['res.partner'] diff --git a/account_financial_report/report/open_items.py b/account_financial_report/report/open_items.py index e484f063..1765c7af 100644 --- a/account_financial_report/report/open_items.py +++ b/account_financial_report/report/open_items.py @@ -6,7 +6,7 @@ from odoo import models, api from odoo.tools import float_is_zero from odoo.osv import expression from datetime import date, datetime -import pandas as pd +import operator class OpenItemsReport(models.AbstractModel): @@ -151,12 +151,11 @@ class OpenItemsReport(models.AbstractModel): query = self._get_query(account_ids, partner_ids, date_at_object, target_move, company_id, date_from) self._cr.execute(query) - move_lines_data = pd.DataFrame(self._cr.dictfetchall()) - account_ids = set(move_lines_data.account_id.to_list()) + move_lines_data = self._cr.dictfetchall() + account_ids = map(operator.itemgetter('account_id'), move_lines_data) accounts_data = self._get_accounts_data(list(account_ids)) - journal_ids = set(move_lines_data.journal_id.to_list()) + journal_ids = map(operator.itemgetter('journal_id'), move_lines_data) journals_data = self._get_journals_data(list(journal_ids)) - move_lines_data = move_lines_data.fillna(0).to_dict(orient='records') if date_at_object < date.today(): accounts_partial_reconcile, debit_accounts_partial_amount, \ @@ -164,12 +163,10 @@ class OpenItemsReport(models.AbstractModel): self._get_account_partial_reconciled(move_lines_data, date_at_object) if accounts_partial_reconcile: - accounts_partial_reconcile_data = pd.DataFrame( - accounts_partial_reconcile) - debit_ids = set(accounts_partial_reconcile_data.debit_move_id - .to_list()) - credit_ids = set( - accounts_partial_reconcile_data.credit_move_id.to_list()) + debit_ids = map(operator.itemgetter('debit_move_id'), + accounts_partial_reconcile) + credit_ids = map(operator.itemgetter('credit_move_id'), + accounts_partial_reconcile) for move_line in move_lines_data: if move_line['id'] in debit_ids: move_line['amount_residual'] += \ @@ -195,7 +192,7 @@ class OpenItemsReport(models.AbstractModel): for move_line in move_lines_data: no_partner = True # Partners data - if move_line['partner_id'] and not pd.isna(move_line['partner_id']): + if move_line['partner_id']: no_partner = False partners_data.update({ move_line['partner_id']: { @@ -219,7 +216,8 @@ class OpenItemsReport(models.AbstractModel): move_line.update({ 'date': move_line['date'].strftime("%d/%m/%Y"), - 'date_maturity': move_line['date_maturity'].strftime("%d/%m/%Y"), + 'date_maturity': move_line["date_maturity"] + and move_line["date_maturity"].strftime("%d/%m/%Y"), 'original': original, 'partner_id': 0 if no_partner else move_line['partner_id'], 'partner_name': '' if no_partner else move_line['partner_name'], diff --git a/account_financial_report/report/trial_balance.py b/account_financial_report/report/trial_balance.py index 15582b6c..76a02326 100644 --- a/account_financial_report/report/trial_balance.py +++ b/account_financial_report/report/trial_balance.py @@ -4,8 +4,6 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import models, api -from operator import itemgetter -from natsort import natsorted class TrialBalanceReport(models.AbstractModel): @@ -595,9 +593,8 @@ class TrialBalanceReport(models.AbstractModel): accounts_data, total_amount, foreign_currency) trial_balance = list(groups_data.values()) trial_balance += list(accounts_data.values()) - trial_balance = natsorted(trial_balance, - key=itemgetter('complete_code', - 'code')) + trial_balance = sorted(trial_balance, key=lambda k: k[ + 'complete_code']) for trial in trial_balance: counter = trial['complete_code'].count('/') trial['level'] = counter @@ -606,12 +603,10 @@ class TrialBalanceReport(models.AbstractModel): accounts_data, total_amount, foreign_currency) trial_balance = list(groups_data.values()) trial_balance += list(accounts_data.values()) - trial_balance = natsorted(trial_balance, - key=itemgetter('code')) + trial_balance = sorted(trial_balance, key=lambda k: k['code']) if hierarchy_on == 'none': trial_balance = list(accounts_data.values()) - trial_balance = natsorted(trial_balance, - key=itemgetter('code')) + trial_balance = sorted(trial_balance, key=lambda k: k['code']) else: if foreign_currency: for account_id in accounts_data.keys(): diff --git a/account_financial_report/report/trial_balance_xlsx.py b/account_financial_report/report/trial_balance_xlsx.py index dc031759..db8ab57c 100644 --- a/account_financial_report/report/trial_balance_xlsx.py +++ b/account_financial_report/report/trial_balance_xlsx.py @@ -38,11 +38,11 @@ class TrialBalanceXslx(models.AbstractModel): 'type': 'amount', 'width': 14}, 5: {'header': _('Period balance'), - 'field': 'period_balance', + 'field': 'balance', 'type': 'amount', 'width': 14}, 6: {'header': _('Ending balance'), - 'field': 'final_balance', + 'field': 'ending_balance', 'type': 'amount', 'width': 14}, } diff --git a/account_financial_report/tests/test_journal_ledger.py b/account_financial_report/tests/test_journal_ledger.py index edee2ab5..4b4caa5c 100644 --- a/account_financial_report/tests/test_journal_ledger.py +++ b/account_financial_report/tests/test_journal_ledger.py @@ -184,7 +184,8 @@ class TestJournalReport(TransactionCase): 'date_from': self.fy_date_start, 'date_to': self.fy_date_end, 'company_id': self.company.id, - 'journal_ids': [(6, 0, self.journal_sale.ids)] + 'journal_ids': [(6, 0, self.journal_sale.ids)], + 'move_target': "all", }) data = wiz._prepare_report_journal_ledger() res_data = self.JournalLedgerReport._get_report_values(wiz, data) diff --git a/account_financial_report/tests/test_vat_report.py b/account_financial_report/tests/test_vat_report.py index 9f9c2a80..43bd466e 100644 --- a/account_financial_report/tests/test_vat_report.py +++ b/account_financial_report/tests/test_vat_report.py @@ -34,15 +34,18 @@ class TestVATReport(common.TransactionCase): ], limit=1) self.tax_tag_01 = self.env['account.account.tag'].create({ 'name': 'Tag 01', - 'applicability': 'taxes' + 'applicability': 'taxes', + 'country_id': self.company.country_id.id, }) self.tax_tag_02 = self.env['account.account.tag'].create({ 'name': 'Tag 02', - 'applicability': 'taxes' + 'applicability': 'taxes', + 'country_id': self.company.country_id.id, }) self.tax_tag_03 = self.env['account.account.tag'].create({ 'name': 'Tag 03', - 'applicability': 'taxes' + 'applicability': 'taxes', + 'country_id': self.company.country_id.id, }) self.tax_group_10 = self.env['account.tax.group'].create({ 'name': 'Tax 10%', diff --git a/account_financial_report/wizard/aged_partner_balance_wizard.py b/account_financial_report/wizard/aged_partner_balance_wizard.py index c8c61a22..57f32d66 100644 --- a/account_financial_report/wizard/aged_partner_balance_wizard.py +++ b/account_financial_report/wizard/aged_partner_balance_wizard.py @@ -25,7 +25,7 @@ class AgedPartnerBalanceWizard(models.TransientModel): ('all', 'All Entries')], string='Target Moves', required=True, - default='all') + default='posted') account_ids = fields.Many2many( comodel_name='account.account', string='Filter accounts', diff --git a/account_financial_report/wizard/general_ledger_wizard.py b/account_financial_report/wizard/general_ledger_wizard.py index f5b52527..a0e5c73b 100644 --- a/account_financial_report/wizard/general_ledger_wizard.py +++ b/account_financial_report/wizard/general_ledger_wizard.py @@ -39,7 +39,7 @@ class GeneralLedgerReportWizard(models.TransientModel): ('all', 'All Entries')], string='Target Moves', required=True, - default='all') + default='posted') account_ids = fields.Many2many( comodel_name='account.account', string='Filter accounts', diff --git a/account_financial_report/wizard/journal_ledger_wizard.py b/account_financial_report/wizard/journal_ledger_wizard.py index d5e908a2..af430fa3 100644 --- a/account_financial_report/wizard/journal_ledger_wizard.py +++ b/account_financial_report/wizard/journal_ledger_wizard.py @@ -36,7 +36,7 @@ class JournalLedgerReportWizard(models.TransientModel): ) move_target = fields.Selection( selection='_get_move_targets', - default='all', + default='posted', required=True, ) foreign_currency = fields.Boolean() diff --git a/account_financial_report/wizard/open_items_wizard.py b/account_financial_report/wizard/open_items_wizard.py index 72e98c46..fa626b4d 100644 --- a/account_financial_report/wizard/open_items_wizard.py +++ b/account_financial_report/wizard/open_items_wizard.py @@ -26,7 +26,7 @@ class OpenItemsReportWizard(models.TransientModel): ('all', 'All Entries')], string='Target Moves', required=True, - default='all') + default='posted') account_ids = fields.Many2many( comodel_name='account.account', string='Filter accounts', diff --git a/account_financial_report/wizard/trial_balance_wizard.py b/account_financial_report/wizard/trial_balance_wizard.py index c02ead39..1f0a797f 100644 --- a/account_financial_report/wizard/trial_balance_wizard.py +++ b/account_financial_report/wizard/trial_balance_wizard.py @@ -32,7 +32,7 @@ class TrialBalanceReportWizard(models.TransientModel): ('all', 'All Entries')], string='Target Moves', required=True, - default='all') + default='posted') hierarchy_on = fields.Selection( [('computed', 'Computed Accounts'), ('relation', 'Child Accounts'), diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 1d1eb705..00000000 --- a/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -natsort -pandas