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

[IMP] Data di competenza IVA non modificabile dopo registrazione #4514

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions l10n_it_vat_settlement_date/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ class AccountMove(models.Model):
store=True,
readonly=False,
copy=False,
states={
"posted": [
("readonly", True),
],
},
)

@api.depends(
Expand Down
1 change: 1 addition & 0 deletions l10n_it_vat_settlement_date/tests/__init__.py
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
60 changes: 60 additions & 0 deletions l10n_it_vat_settlement_date/tests/test_account_move.py
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)
Loading