Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] l10n_es_aeat_mod369: use of UserError on tests #73

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 34 additions & 30 deletions l10n_es_aeat_mod369/tests/test_l10n_es_aeat_mod369.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0
import logging

from odoo.exceptions import ValidationError
from odoo.exceptions import UserError

from odoo.addons.l10n_es_aeat.tests.test_l10n_es_aeat_mod_base import (
TestL10nEsAeatModBase,
Expand Down Expand Up @@ -188,40 +188,44 @@ def test_model_369_account_move_positive_amount(self):
self.create_account_move()
self.assertEqual(self.model369.name, self.model369.move_id.ref)
self.assertEqual(self.model369.move_id.journal_id, self.model369.journal_id)
account_template = self.env.ref("l10n_es.account_common_4750")
account_4750 = self.model369.company_id.get_account_from_template(
account_template
account_4750 = self.env["account.account"].search(
[
("company_id", "=", self.model369.company_id.id),
("code", "=ilike", "4750%"),
]
)
debit_line = self.model369.move_id.line_ids[1]
credit_line = self.model369.move_id.line_ids[0]
self.assertEqual(
self.model369.counterpart_account_id.id, debit_line.account_id.id
)
for ml in self.model369.move_id.line_ids:
if ml.debit > 0:
self.assertEqual(
self.model369.counterpart_account_id.id, ml.account_id.id
)
self.assertEqual(ml.debit, self.model369.total_amount)
elif ml.credit > 0:
self.assertEqual(account_4750.id, ml.account_id.id)
self.assertEqual(ml.credit, self.model369.total_amount)
self.assertEqual(debit_line.debit, self.model369.total_amount)
self.assertEqual(account_4750.id, credit_line.account_id.id)
self.assertEqual(credit_line.credit, self.model369.total_amount)

def test_model_369_account_move_negative_amount(self):
self.model369.button_calculate()
self.model369.total_amount *= -1
if self.model369.total_amount == 0:
with self.assertRaises(ValidationError):
self.create_account_move()
else:
self.create_account_move()
self.create_account_move()
self.assertEqual(self.model369.name, self.model369.move_id.ref)
self.assertEqual(self.model369.move_id.journal_id, self.model369.journal_id)
account_template = self.env.ref("l10n_es.account_common_4700")
account_4700 = self.model369.company_id.get_account_from_template(
account_template
account_4700 = self.env["account.account"].search(
[
("company_id", "=", self.model369.company_id.id),
("code", "=ilike", "4700%"),
]
)
for ml in self.model369.move_id.line_ids:
if ml.credit > 0:
self.assertEqual(
self.model369.counterpart_account_id.id, ml.account_id.id
)
self.assertEqual(ml.credit, abs(self.model369.total_amount))
elif ml.debit > 0:
self.assertEqual(account_4700.id, ml.account_id.id)
self.assertEqual(ml.debit, abs(self.model369.total_amount))
debit_line = self.model369.move_id.line_ids[0]
credit_line = self.model369.move_id.line_ids[1]
self.assertEqual(
self.model369.counterpart_account_id.id, credit_line.account_id.id
)
self.assertEqual(credit_line.credit, abs(self.model369.total_amount))
self.assertEqual(account_4700.id, debit_line.account_id.id)
self.assertEqual(debit_line.debit, abs(self.model369.total_amount))

def test_model_369_account_move_zero_amount(self):
self.model369.button_calculate()
self.model369.total_amount = 0
with self.assertRaises(UserError):
self.create_account_move()
Loading