Skip to content

Commit

Permalink
[FIX] l10n_es_aeat_mod369: code refactoring. simplify _compute_allow_…
Browse files Browse the repository at this point in the history
…posting method. Use of UserError and delete blank lines
  • Loading branch information
sergiobstoj committed May 20, 2024
1 parent d93469d commit f9bc450
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
7 changes: 3 additions & 4 deletions l10n_es_aeat_mod369/models/mod369.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)

from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
from odoo.exceptions import UserError


class L10nEsAeatMod369Report(models.Model):
Expand Down Expand Up @@ -127,8 +127,7 @@ def _compute_total_amount(self):
)

def _compute_allow_posting(self):
for report in self:
report.allow_posting = True
self.allow_posting = True

@api.model
def _get_period_from_date(self, date, monthly=False):
Expand Down Expand Up @@ -394,6 +393,6 @@ def create_regularization_move(self):
if self.total_amount != 0:
return super().create_regularization_move()
else:
raise ValidationError(
raise UserError(
_("It is not possible to create a move if the total amount is 0.")
)
5 changes: 0 additions & 5 deletions l10n_es_aeat_mod369/tests/test_l10n_es_aeat_mod369.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,8 @@ def create_account_move(self):
def test_model_369_account_move_positive_amount(self):
self.model369.button_calculate()
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
Expand All @@ -212,15 +210,12 @@ def test_model_369_account_move_negative_amount(self):
self.create_account_move()
else:
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
)

for ml in self.model369.move_id.line_ids:
if ml.credit > 0:
self.assertEqual(
Expand Down

0 comments on commit f9bc450

Please sign in to comment.