diff --git a/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py b/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py index 1f9a84ccb..242b18a6a 100644 --- a/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py +++ b/l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py @@ -272,6 +272,7 @@ def get_ob_sql_fragment(self): def get_ob_totals(self): """return totals of opening balance""" self.env.cr.execute( + # pylint: disable=sql-injection "select sum(l.balance), count(distinct a.id) " + self.get_ob_sql_fragment() + "and l.balance < 0" @@ -282,6 +283,7 @@ def get_ob_totals(self): count=row[1] or 0, ) self.env.cr.execute( + # pylint: disable=sql-injection "select sum(l.balance), count(distinct a.id) " + self.get_ob_sql_fragment() + "and l.balance > 0" @@ -295,6 +297,7 @@ def get_ob_totals(self): def get_ob_lines(self): """return opening balance entries""" self.env.cr.execute( + # pylint: disable=sql-injection "select a.id, a.code, sum(l.balance) " + self.get_ob_sql_fragment() + "group by a.id, a.code", diff --git a/l10n_nl_xaf_auditfile_export/tests/test_l10n_nl_xaf_auditfile_export.py b/l10n_nl_xaf_auditfile_export/tests/test_l10n_nl_xaf_auditfile_export.py index 176f71acc..7d899c92a 100644 --- a/l10n_nl_xaf_auditfile_export/tests/test_l10n_nl_xaf_auditfile_export.py +++ b/l10n_nl_xaf_auditfile_export/tests/test_l10n_nl_xaf_auditfile_export.py @@ -8,6 +8,7 @@ import os from zipfile import ZipFile + from odoo.tests.common import TransactionCase from odoo.tools import mute_logger @@ -21,7 +22,9 @@ def xaf_xpath(auditfile, query): remove_blank_text=True ) root = etree.XML(bytes(contents, encoding='utf8'), parser=parser) - for element in root.xpath(query, namespaces={'a': 'http://www.auditfiles.nl/XAF/3.2'}): + for element in root.xpath( + query, namespaces={'a': 'http://www.auditfiles.nl/XAF/3.2'} + ): yield element @@ -161,7 +164,10 @@ def test_07_opening_balance(self): record = self.env['xaf.auditfile.export'].create({}) acc_receivable = self.env['account.account'].search([ - ('user_type_id', '=', self.env.ref('account.data_account_type_receivable').id), + ( + 'user_type_id', '=', + self.env.ref('account.data_account_type_receivable').id + ), ], limit=1) acc_payable = self.env['account.account'].search([ ('user_type_id', '=', self.env.ref('account.data_account_type_payable').id), @@ -194,20 +200,25 @@ def test_07_opening_balance(self): def xaf_val(auditfile, xpath): return float(''.join(xaf_xpath(auditfile, xpath))) - total_credit = xaf_val(record.auditfile, '//a:openingBalance/a:totalCredit/text()') + total_credit = xaf_val( + record.auditfile, '//a:openingBalance/a:totalCredit/text()') self.assertEqual(total_credit, 42) - result = record.get_ob_totals() - total_debit = xaf_val(record.auditfile, '//a:openingBalance/a:totalDebit/text()') + total_debit = xaf_val( + record.auditfile, '//a:openingBalance/a:totalDebit/text()') self.assertEqual(total_debit, 0) - lines_count = xaf_val(record.auditfile, '//a:openingBalance/a:linesCount/text()') + lines_count = xaf_val( + record.auditfile, '//a:openingBalance/a:linesCount/text()') self.assertEqual(lines_count, 1) move_payable.post() record = self.env['xaf.auditfile.export'].create({}) record.button_generate() - total_credit = xaf_val(record.auditfile, '//a:openingBalance/a:totalCredit/text()') + total_credit = xaf_val( + record.auditfile, '//a:openingBalance/a:totalCredit/text()') self.assertEqual(total_credit, 42) - total_debit = xaf_val(record.auditfile, '//a:openingBalance/a:totalDebit/text()') + total_debit = xaf_val( + record.auditfile, '//a:openingBalance/a:totalDebit/text()') self.assertEqual(total_debit, 4242) - lines_count = xaf_val(record.auditfile, '//a:openingBalance/a:linesCount/text()') + lines_count = xaf_val( + record.auditfile, '//a:openingBalance/a:linesCount/text()') self.assertEqual(lines_count, 2)