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

[ADD] new module l10n_it_fatturapa_auto_downpayment #4230

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
116 changes: 116 additions & 0 deletions l10n_it_fatturapa_auto_downpayment/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
===============================================
ITA - Fattura PA - select TD02 for downpayments
===============================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:62e9ea53b28e2845aa4728960d96554f12afac66d2b7d62c36aca149fd2f13ea
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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/16.0/l10n_it_fatturapa_auto_downpayment
: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-16-0/l10n-italy-16-0-l10n_it_fatturapa_auto_downpayment
: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=16.0
:alt: Try me on Runboat

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

**Italiano**

Modulo opzionale per impostare automaticamente TD02 come tipo di
documento fiscale nelle fatture di acconto (necessario per la
fatturazione elettronica).

**English**

Additional module to set TD02 as fiscal document type for downpayment
invoices (needed for FatturaPA e-invoice).

**Table of contents**

.. contents::
:local:

Installation
============


Comment on lines +47 to +50
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puoi eliminare INSTALL.md? Altrimenti viene creata questa sezione vuota.


Configuration
=============

**Italiano**

Alla creazione di una fattura di downpayment, viene settato TD02 come
fiscal document type.

**English**

When creating a downpayment invoice, set TD02 as fiscal document type.

Usage
=====

**Italiano**

Il modulo imposta automaticamente TD02 alla creazione di una fattura di
acconto.

**English**

The module sets TD02 for downpayment invoices automatically.

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:%20l10n_it_fatturapa_auto_downpayment%0Aversion:%2016.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
-------

* Marco Colombo

Contributors
------------

- `Phi Srl <https://www.phi.technology/>`__:

- Marco Colombo <https://github.com/TheMule71>

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/16.0/l10n_it_fatturapa_auto_downpayment>`_ 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 l10n_it_fatturapa_auto_downpayment/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions l10n_it_fatturapa_auto_downpayment/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "ITA - Fattura PA - select TD02 for downpayments",
"version": "16.0.1.0.0",
"sequence": 10,
"summary": "Automatically set TD02 for downpayments",
"category": "Localization/Italy",
"depends": [
"sale",
"l10n_it_fiscal_document_type",
],
"author": "Marco Colombo, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-italy",
"license": "AGPL-3",
"installable": True,
"application": False,
"auto_install": True,
}
1 change: 1 addition & 0 deletions l10n_it_fatturapa_auto_downpayment/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import account_move
24 changes: 24 additions & 0 deletions l10n_it_fatturapa_auto_downpayment/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from odoo import models


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

def _get_document_fiscal_type(
self, move_type=None, partner=None, fiscal_position=None, journal=None
):
self.ensure_one()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il metodo in super

non impone questo vincolo, quindi in teoria può gestire un recordset.
È possibile spostare questo vincolo e il resto del codice che ne ha bisogno dentro un if len(self) == 1 o qualcosa di analogo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L'unico punto in cui è chiamata è la _compute_set_document_fiscal_type(), all'interno di un loop fattura per fattura.

Piu di quello però, il valore di ritorno è un alista di possibili TDxx validi per una sola fattura. La funziona ignora self di fatto (potrebbe essere @api.model), ma gli vengono passati un solo partner, una sola posizione fiscale, un solo journal, relativi ad una sola fattura.

In pratica la funzione originale è usata come se fosse self.ensure_one() e scritta come se fosse @api.model . Non credo possa essere chiamata su un recordset, visto che per avere un risultato sensato dovresti assicurarti a priori che sono fatture con lo stesso partner, stessa fpos, stesso journal.

Io ho aggiunto self.ensure_one() perché effettivamente uso self.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

È vero che il metodo in super si comporta come un api.model e il risultato dipende solo dai suoi parametri, però credo che questo sia un motivo in più perché l'override aggiunto in questa PR non debba aggiungere vincoli a self.

Attualmente potrebbero esserci altri moduli che chiamano _get_document_fiscal_type su un recordset e funzionano; dopo l'installazione di questo modulo invece verrebbe sollevato un errore, credo sia meglio evitarlo e rimanere compatibili con il codice esistente.
Non è detto che lo facciano perché si aspettano un risultato in base a self, ma semplicemente perché è possibile farlo (come è possibile farlo per i metodi api.model).


dt = super()._get_document_fiscal_type(
move_type=move_type,
partner=partner,
fiscal_position=fiscal_position,
journal=journal,
)
if self.is_sale_document() and self._is_downpayment():
td02 = self.env["fiscal.document.type"].search(
[("code", "=", "TD02")], limit=1
)
if td02:
dt.insert(0, td02.id)
return dt
3 changes: 3 additions & 0 deletions l10n_it_fatturapa_auto_downpayment/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
9 changes: 9 additions & 0 deletions l10n_it_fatturapa_auto_downpayment/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
**Italiano**

Alla creazione di una fattura di downpayment, viene settato
TD02 come fiscal document type.
Comment on lines +3 to +4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Visto che non c'è nulla da configurare, penso sia meglio rimuovere questo file.


**English**

When creating a downpayment invoice, set TD02 as fiscal
document type.
2 changes: 2 additions & 0 deletions l10n_it_fatturapa_auto_downpayment/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [Phi Srl](https://www.phi.technology/):
- Marco Colombo \<<https://github.com/TheMule71>\>
10 changes: 10 additions & 0 deletions l10n_it_fatturapa_auto_downpayment/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**Italiano**

Modulo opzionale per impostare automaticamente TD02
come tipo di documento fiscale nelle fatture di
acconto (necessario per la fatturazione elettronica).

**English**

Additional module to set TD02 as fiscal document type
for downpayment invoices (needed for FatturaPA e-invoice).
Empty file.
8 changes: 8 additions & 0 deletions l10n_it_fatturapa_auto_downpayment/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
**Italiano**

Il modulo imposta automaticamente TD02 alla creazione di una fattura
di acconto.

**English**

The module sets TD02 for downpayment invoices automatically.
SirAionTech marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading