-
-
Notifications
You must be signed in to change notification settings - Fork 307
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] l10n_it_vat_settlement_date: Prevent edit after posting
Make the field `l10n_it_vat_settlement_date` follow the same readonly logic as `date`: it cannot be edited when the invoice is in posted.
- Loading branch information
1 parent
3c1a3e0
commit 3b40999
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from . import test_account_move | ||
from . import test_vat_period_end_statement | ||
from . import test_vat_registry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Copyright 2024 Simone Rubino - Aion Tech | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
import datetime | ||
|
||
from dateutil.relativedelta import relativedelta | ||
|
||
from odoo.tests import Form, tagged | ||
|
||
from odoo.addons.account.tests.common import AccountTestInvoicingCommon | ||
|
||
|
||
@tagged("post_install", "-at_install") | ||
class TestAccountMove(AccountTestInvoicingCommon): | ||
def test_draft_not_readonly(self): | ||
"""VAT settlement date is not readonly when invoice is in draft.""" | ||
# Arrange | ||
bill = self.init_invoice( | ||
"in_invoice", | ||
invoice_date=datetime.date(2020, 1, 1), | ||
amounts=[ | ||
100, | ||
], | ||
) | ||
settlement_date = bill.invoice_date + relativedelta(days=1) | ||
# pre-condition | ||
self.assertEqual(bill.state, "draft") | ||
|
||
# Act | ||
with Form(bill) as bill_form: | ||
bill_form.l10n_it_vat_settlement_date = settlement_date | ||
|
||
# Assert | ||
self.assertEqual(bill.l10n_it_vat_settlement_date, settlement_date) | ||
|
||
def test_posted_readonly(self): | ||
"""VAT settlement date is readonly when invoice is posted.""" | ||
# Arrange | ||
bill = self.init_invoice( | ||
"in_invoice", | ||
invoice_date=datetime.date(2020, 1, 1), | ||
amounts=[ | ||
100, | ||
], | ||
post=True, | ||
) | ||
settlement_date = bill.invoice_date + relativedelta(days=1) | ||
# pre-condition | ||
self.assertEqual(bill.state, "posted") | ||
|
||
# Act | ||
with self.assertRaises(AssertionError) as ae: | ||
with Form(bill) as bill_form: | ||
bill_form.l10n_it_vat_settlement_date = settlement_date | ||
|
||
# Assert | ||
exc_message = ae.exception.args[0] | ||
self.assertIn("readonly field", exc_message) | ||
self.assertIn("l10n_it_vat_settlement_date", exc_message) | ||
self.assertNotEqual(bill.l10n_it_vat_settlement_date, settlement_date) |