Skip to content

Commit

Permalink
Merge PR #400 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by thomaspaulb
  • Loading branch information
OCA-git-bot committed Oct 6, 2023
2 parents 201d1ab + 9e4db5e commit b3aaa5f
Showing 1 changed file with 33 additions and 12 deletions.
45 changes: 33 additions & 12 deletions l10n_nl_tax_statement/tests/test_l10n_nl_vat_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,18 @@ def _create_test_invoice(self):
self.invoice_1 = invoice_form.save()
self.assertEqual(len(self.invoice_1.line_ids), 5)

def _check_export_xls(self, statement):
"""Generate XLS report from action"""
report = "l10n_nl_tax_statement.action_report_tax_statement_xls_export"
self.report_action = self.env.ref(report)
self.assertEqual(self.report_action.report_type, "xlsx")
model = self.env["report.%s" % self.report_action["report_name"]].with_context(
active_model="l10n.nl.vat.statement"
)
res = model.create_xlsx_report(statement.ids, data=None)
self.assertTrue(res[0])
self.assertEqual(res[1], "xlsx")

def test_01_onchange(self):
form = Form(self.statement_1)
form.from_date = datetime.date(2016, 1, 1)
Expand All @@ -160,6 +172,9 @@ def test_01_onchange(self):
self.assertEqual(statement.unreported_move_from_date, new_date)
self.assertEqual(statement.btw_total, 0.0)

# Export XLS without errors
self._check_export_xls(statement)

def test_02_post_final(self):
# in draft
self.assertEqual(self.statement_1.state, "draft")
Expand Down Expand Up @@ -199,6 +214,9 @@ def test_02_post_final(self):

self.assertEqual(self.statement_1.btw_total, 0.0)

# Export XLS without errors
self._check_export_xls(self.statement_1)

def test_03_reset(self):
self.statement_1.reset()
self.assertEqual(self.statement_1.state, "draft")
Expand All @@ -211,13 +229,19 @@ def test_03_reset(self):
self.assertTrue(line.view_base_lines())
self.assertTrue(line.view_tax_lines())

# Export XLS without errors
self._check_export_xls(self.statement_1)

def test_04_write(self):
self.statement_1.post()
with self.assertRaises(UserError):
self.statement_1.write({"name": "Test Name"})

self.assertEqual(self.statement_1.btw_total, 0.0)

# Export XLS without errors
self._check_export_xls(self.statement_1)

def test_05_unlink_exception(self):
self.statement_1.post()
with self.assertRaises(UserError):
Expand Down Expand Up @@ -256,6 +280,9 @@ def test_09_update_working(self):
self.assertEqual(self.statement_1.btw_total, 21.0)
self.assertEqual(self.statement_1.format_btw_total, "21.00")

# Export XLS without errors
self._check_export_xls(self.statement_1)

def test_10_line_unlink_exception(self):
self.assertEqual(len(self.statement_1.line_ids.ids), 0)
self.assertEqual(self.statement_1.btw_total, 0.0)
Expand Down Expand Up @@ -301,6 +328,9 @@ def test_12_undeclared_invoice(self):
self.assertTrue(line.view_base_lines())
self.assertTrue(line.view_tax_lines())

# Export XLS without errors
self._check_export_xls(self.statement_1)

invoice2 = self.invoice_1.copy()
invoice2.action_post()
statement2 = self.env["l10n.nl.vat.statement"].create({"name": "Statement 2"})
Expand Down Expand Up @@ -330,6 +360,9 @@ def test_12_undeclared_invoice(self):
with self.assertRaises(UserError):
invoice_lines[0].date = fields.Date.today()

# Export XLS without errors
self._check_export_xls(statement2)

def test_13_no_previous_statement_posted(self):
statement2 = self.env["l10n.nl.vat.statement"].create({"name": "Statement 2"})
statement2.statement_update()
Expand Down Expand Up @@ -535,15 +568,3 @@ def test_20_multicompany(self):

company_ids_full_list = statement_parent._get_company_ids_full_list()
self.assertEqual(len(company_ids_full_list), 3)

def test_21_action_xls(self):
"""Generate XLS report from action"""
report = "l10n_nl_tax_statement.action_report_tax_statement_xls_export"
self.report_action = self.env.ref(report)
self.assertEqual(self.report_action.report_type, "xlsx")
model = self.env["report.%s" % self.report_action["report_name"]].with_context(
active_model="l10n.nl.vat.statement"
)
res = model.create_xlsx_report(self.statement_1.ids, data=None)
self.assertTrue(res[0])
self.assertEqual(res[1], "xlsx")

0 comments on commit b3aaa5f

Please sign in to comment.