Skip to content
Snippets Groups Projects

Enable mass validation of monthly statements.

Merged Etienne Ferriere requested to merge topic/11.0/TG-5326 into branch/11.0
@@ -234,7 +234,7 @@
def test_monthly_statement_mass_validation(self):
"""Test monthly statements: Mass validation."""
lines_to_pay = []
lines_to_pay = {}
for partner in (
self.env.ref("base.res_partner_1")
| self.env.ref("base.res_partner_2")
@@ -246,7 +246,7 @@
lambda line: line.account_id.internal_type == "receivable"
)
self.assertEqual(len(line_to_pay), 1)
lines_to_pay.append(line_to_pay)
lines_to_pay[partner.id] = line_to_pay
# Configure the partner for monthly statements.
partner.has_monthly_statements = True
@@ -259,5 +259,5 @@
self.assertEqual(len(batch_ids), 3)
batches = self.env["account.monthly_statement"].browse(batch_ids)
for i, batch in enumerate(batches):
for batch in batches:
self.assertEqual(batch.account_move_line_count, 1)
@@ -263,5 +263,7 @@
self.assertEqual(batch.account_move_line_count, 1)
self.assertEqual(batch.account_move_line_ids, lines_to_pay[i])
self.assertEqual(
batch.account_move_line_ids, lines_to_pay[batch.partner_id.id]
)
self.assertAlmostEqual(batch.amount, AMOUNT)
self.assertEqual(batch.state, "draft")
@@ -281,6 +283,23 @@
batches.refresh()
self.assertTrue(all(batches.mapped(lambda r: r.state == "done")))
for batch in batches:
# Check Excel reports.
attach = self.env["ir.attachment"].search(
[("res_id", "=", batch.id), ("res_model", "=", batch._name)]
)
self.assertEqual(len(attach), 1)
self.assertEqual(attach.name, f"{batch.code}.xlsx")
# Check smart buttons.
line_action = batch.open_lines()
self.assertEqual(
line_action["domain"][0][2],
lines_to_pay[batch.partner_id.id].ids,
)
self.assertEqual(line_action["res_model"], "account.move.line")
with self.assertRaises(odoo.exceptions.UserError):
server_action.with_context(active_ids=batch_ids).run()
Loading