diff --git a/l10n_es_aeat_mod369/models/mod369.py b/l10n_es_aeat_mod369/models/mod369.py index 57dd88f8952..a65b2457805 100644 --- a/l10n_es_aeat_mod369/models/mod369.py +++ b/l10n_es_aeat_mod369/models/mod369.py @@ -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): @@ -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): @@ -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.") ) diff --git a/l10n_es_aeat_mod369/tests/test_l10n_es_aeat_mod369.py b/l10n_es_aeat_mod369/tests/test_l10n_es_aeat_mod369.py index a443c762952..e440a5412d3 100644 --- a/l10n_es_aeat_mod369/tests/test_l10n_es_aeat_mod369.py +++ b/l10n_es_aeat_mod369/tests/test_l10n_es_aeat_mod369.py @@ -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 @@ -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(