Skip to content

Commit

Permalink
[ADD][14.0] new module account_invoice_vat_statement_check
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiocorato committed Aug 26, 2024
1 parent 0eaeb44 commit 1f5993a
Show file tree
Hide file tree
Showing 13 changed files with 690 additions and 0 deletions.
85 changes: 85 additions & 0 deletions account_invoice_vat_statement_check/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
=====================================================
Check invoice change compatibility with vat statement
=====================================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:e6d5fca0cf75069737cb75ab0c97755adc50aba8bbe427800e3c8594326e1f06
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github
:target: https://github.com/OCA/l10n-italy/tree/14.0/account_invoice_vat_statement_check
:alt: OCA/l10n-italy
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/l10n-italy-14-0/l10n-italy-14-0-account_invoice_vat_statement_check
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-italy&target_branch=14.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module block change on some restricted fields on invoices when there is a validated VAT statement.

**Table of contents**

.. contents::
:local:

Usage
=====

Verrà mostrato un messaggio di errore al tentativo di salvare una fattura già registrata in precedenza e per la quale ci sia una liquidazione IVA validata per cui sia presente una modifica su uno dei campi non modificabili per l'IVA:

#. data fattura
#. importo della riga relativa all'IVA
#. conto della riga relativa all'IVA

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-italy/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/l10n-italy/issues/new?body=module:%20account_invoice_vat_statement_check%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Sergio Corato

Contributors
~~~~~~~~~~~~

* Sergio Corato <https://github.com/sergiocorato>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/l10n-italy <https://github.com/OCA/l10n-italy/tree/14.0/account_invoice_vat_statement_check>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions account_invoice_vat_statement_check/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions account_invoice_vat_statement_check/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 Sergio Corato <https://github.com/sergiocorato>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Check invoice change compatibility with vat statement",
"version": "14.0.1.0.0",
"category": "Localization/Italy",
"license": "AGPL-3",
"author": "Sergio Corato, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-italy",
"depends": [
"account_vat_period_end_statement",
],
"data": [],
"installable": True,
}
60 changes: 60 additions & 0 deletions account_invoice_vat_statement_check/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_vat_statement_check
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-08-26 17:00+0000\n"
"PO-Revision-Date: 2024-08-26 17:00+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: account_invoice_vat_statement_check
#: model:ir.model.fields,field_description:account_invoice_vat_statement_check.field_account_move__assigned_attachment_ids
#: model:ir.model.fields,field_description:account_invoice_vat_statement_check.field_account_move_line__assigned_attachment_ids
msgid "Assigned Attachments"
msgstr "Allegati assegnati"

#. module: account_invoice_vat_statement_check
#: model:ir.model.fields,field_description:account_invoice_vat_statement_check.field_account_move__display_name
#: model:ir.model.fields,field_description:account_invoice_vat_statement_check.field_account_move_line__display_name
msgid "Display Name"
msgstr "Nome visualizzato"

#. module: account_invoice_vat_statement_check
#: model:ir.model.fields,field_description:account_invoice_vat_statement_check.field_account_move__id
#: model:ir.model.fields,field_description:account_invoice_vat_statement_check.field_account_move_line__id
msgid "ID"
msgstr ""

#. module: account_invoice_vat_statement_check
#: model:ir.model,name:account_invoice_vat_statement_check.model_account_move
msgid "Journal Entry"
msgstr "Registrazione contabile"

#. module: account_invoice_vat_statement_check
#: model:ir.model,name:account_invoice_vat_statement_check.model_account_move_line
msgid "Journal Item"
msgstr "Movimento contabile"

#. module: account_invoice_vat_statement_check
#: model:ir.model.fields,field_description:account_invoice_vat_statement_check.field_account_move____last_update
#: model:ir.model.fields,field_description:account_invoice_vat_statement_check.field_account_move_line____last_update
msgid "Last Modified on"
msgstr "Ultima modifica il"

#. module: account_invoice_vat_statement_check
#: code:addons/account_invoice_vat_statement_check/models/invoice.py:0
#, python-format
msgid ""
"The operation is refused as it would impact already issued tax statements on %s.\n"
"Please restore the journal entry date or reset VAT statement to draft to proceed."
msgstr ""
"Non è possibile procedere in quanto questa modifica andrebbe ad invalidare la liquidazione iva %s.\n"
"Si prega di annullare la modifica o di reimpostare a bozza la liquidazione IVA per proseguire."
1 change: 1 addition & 0 deletions account_invoice_vat_statement_check/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import invoice
84 changes: 84 additions & 0 deletions account_invoice_vat_statement_check/models/invoice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
from odoo import _, models
from odoo.exceptions import UserError
from odoo.tools.misc import format_date


class AccountMoveLine(models.Model):
_inherit = "account.move.line"

def _check_tax_statement(self):
for line in self.filtered(lambda _l: _l.move_id.posted_before):
move = line.move_id
if not move.is_invoice():
continue

Check warning on line 13 in account_invoice_vat_statement_check/models/invoice.py

View check run for this annotation

Codecov / codecov/patch

account_invoice_vat_statement_check/models/invoice.py#L13

Added line #L13 was not covered by tests
account_vs_ids = (
self.env["account.tax"].search([]).mapped("vat_statement_account_id")
)
invoice_account_vat_ids = line.filtered(
lambda x: x.account_id in account_vs_ids
).mapped("account_id")
if not invoice_account_vat_ids:
continue
invoice_date_range_ids = self.env["date.range"].search(

Check warning on line 22 in account_invoice_vat_statement_check/models/invoice.py

View check run for this annotation

Codecov / codecov/patch

account_invoice_vat_statement_check/models/invoice.py#L22

Added line #L22 was not covered by tests
[
("date_start", "<=", move.date),
("date_end", ">=", move.date),
]
)
if not invoice_date_range_ids:
continue
vat_statement_obj = self.env["account.vat.period.end.statement"]
vat_statements = vat_statement_obj.search(

Check warning on line 31 in account_invoice_vat_statement_check/models/invoice.py

View check run for this annotation

Codecov / codecov/patch

account_invoice_vat_statement_check/models/invoice.py#L29-L31

Added lines #L29 - L31 were not covered by tests
[
("date_range_ids", "in", invoice_date_range_ids.ids),
("state", "!=", "draft"),
"|",
(
"credit_vat_account_line_ids.account_id",
"in",
invoice_account_vat_ids.ids,
),
(
"debit_vat_account_line_ids.account_id",
"in",
invoice_account_vat_ids.ids,
),
]
)
if vat_statements:
raise UserError(
_(
"The operation is refused as it would impact already issued "
"tax statements on %s.\n"
"Please restore the journal entry date or reset VAT statement "
"to draft to proceed."
)
% (
" - ".join(
format_date(self.env, x.date) for x in vat_statements
)
)
)

def write(self, vals):
for line in self:
if (
"account_id" in vals
and line.account_id != vals["account_id"]
or "credit" in vals
and line.credit != vals["credit"]
or "debit" in vals
and line.debit != vals["debit"]
):
line._check_tax_statement()
return super().write(vals)


class AccountMove(models.Model):
_inherit = "account.move"

def write(self, vals):
for move in self:
if "date" in vals and move.date != vals["date"]:
move.line_ids._check_tax_statement()

Check warning on line 83 in account_invoice_vat_statement_check/models/invoice.py

View check run for this annotation

Codecov / codecov/patch

account_invoice_vat_statement_check/models/invoice.py#L83

Added line #L83 was not covered by tests
return super().write(vals)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Sergio Corato <https://github.com/sergiocorato>
1 change: 1 addition & 0 deletions account_invoice_vat_statement_check/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module block change on some restricted fields on invoices when there is a validated VAT statement.
5 changes: 5 additions & 0 deletions account_invoice_vat_statement_check/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Verrà mostrato un messaggio di errore al tentativo di salvare una fattura già registrata in precedenza e per la quale ci sia una liquidazione IVA validata per cui sia presente una modifica su uno dei campi non modificabili per l'IVA:

#. data fattura
#. importo della riga relativa all'IVA
#. conto della riga relativa all'IVA
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 1f5993a

Please sign in to comment.