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

[14.0] IMP l10n_account_it: add format_vat_it to res_partner #2314

Closed
wants to merge 1 commit into from

Conversation

TheMule71
Copy link
Contributor

Aggiunge formattazione per IT con rimozione spazi.

--
Confermo di aver firmato il CLA https://odoo-community.org/page/cla e di aver letto le linee guida su https://odoo-community.org/page/contributing

@TheMule71 TheMule71 changed the title IMP l10n_account_id: add format_vat_it to res_partner IMP l10n_account_it: add format_vat_it to res_partner Jun 4, 2021
@TheMule71 TheMule71 force-pushed the 14.0-imp-add-format_vat_it branch from 8d64d42 to 5136fa7 Compare June 4, 2021 13:34
@TheMule71
Copy link
Contributor Author

Segnalo una certa sovrapposizione con odoo/odoo#71920

TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Jun 18, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Jun 18, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Jun 18, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Jul 2, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Jul 2, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Jul 9, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Jul 9, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Jul 9, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Jul 9, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Jul 17, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Jul 20, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Jul 30, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Jul 30, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Aug 6, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Aug 20, 2021
Copy link
Member

@SimoRubi SimoRubi left a comment

Choose a reason for hiding this comment

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

Grazie della PR!
Puoi aggiungere un test che mostri quando verrebbe utilizzato questo metodo con qualche casistica di P.IVA che viene ripulita?

@eLBati eLBati changed the title IMP l10n_account_it: add format_vat_it to res_partner [14.0] IMP l10n_account_it: add format_vat_it to res_partner Sep 2, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Sep 3, 2021
@TheMule71 TheMule71 force-pushed the 14.0-imp-add-format_vat_it branch from 5136fa7 to ea2f2c3 Compare September 10, 2021 15:32
@TheMule71
Copy link
Contributor Author

Grazie della PR!
Puoi aggiungere un test che mostri quando verrebbe utilizzato questo metodo con qualche casistica di P.IVA che viene ripulita?

Fatto. Le casistiche non è che siano molte, rimuove gli spazi, mette maiuscole le prime due lettere.
Altre casistiche sono comperte da odoo/odoo#71920. In effetti, è necessario che le prime due lettere siano 'IT' (non case-sensitive), se ci sono spazi, la funzione di questa PR non viene nemmeno chiamata perché non riconosce la country. Serve la odoo/odoo#71920 per ripulire spazi nei primi due caratteri.

Copy link
Member

@SimoRubi SimoRubi left a comment

Choose a reason for hiding this comment

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

Revisione del codice, per me è ok

class ResPartner(models.Model):
_inherit = "res.partner"

def format_vat_it(self, vat):
Copy link
Member

Choose a reason for hiding this comment

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

Questo metodo viene chiamato da base_vat in https://github.com/odoo/odoo/blob/0268986b60477c7fb46d93f45f3355f546f0155c/addons/base_vat/models/res_partner.py#L545 quindi potresti aggiungere la dipendenza da base_vat?

Attualmente viene comunque chiamato dai test (è coperto) solo perché altri moduli dipendono da base_vat quindi viene comunque installato nell'ambiente di Travis.
Puoi verificarlo in locale installando solo questo modulo: questo metodo non viene mai chiamato.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Non so se ho ben capito.

base_vat chiama questo modulo, non viceversa. Sarebbe una dipendenza se questo modulo chiamasse funzioni di base_vat.

Ora, la funzionalità del test non è disponibile se manca base_vat. Non so se è possibile specificare una dipendenza che valga solo per i test, o se a livello di test abbia senso controllare che ci sia base_vat e sono in quel caso eseguire il test.

Copy link
Member

Choose a reason for hiding this comment

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

In generale una situazione del genere si risolverebbe con un modulo ponte ma in questo caso mi pare eccessivo, quindi lasciamo pure così 👍🏻

@@ -128,3 +128,11 @@ def test_vat_22_50(self):
self.assertEqual(tax.balance, -22)
self.assertEqual(tax.deductible_balance, -11)
self.assertEqual(tax.undeductible_balance, -11)

def test_format_vat_it(self):
partner_id = self.env.ref("base.res_partner_12")
Copy link
Member

Choose a reason for hiding this comment

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

Pare che questo test passi anche senza il metodo che hai aggiunto a res.partner, puoi verificare?

Se aggiungi un test per una modifica, il test dovrebbe fallire senza la tua modifica e passare con essa.

Copy link
Contributor Author

@TheMule71 TheMule71 Sep 16, 2021

Choose a reason for hiding this comment

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

Ero abbastanza sicuro che fallisse senza, anche perché mi ero scordato di mettere from . import res_partner in models/__init__.py e ho litigato 5 minuti col debugger prima di capire perché la funzione venisse ignorata. E il test falliva. Non mi pare di aver modificato altro dopo. Domani controllo.

Copy link
Member

Choose a reason for hiding this comment

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

Stamattina in chiamata abbiamo verificato che questo test passa anche senza il nuovo metodo che hai aggiunto a res.partner, vedi tu se chiudere tutto o aggiungere solo il test

_inherit = "res.partner"

def format_vat_it(self, vat):
return vat and re.sub(r"\W+", "", vat).upper() or False
Copy link
Member

Choose a reason for hiding this comment

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

Da come viene chiamato questo metodo in base_vat (https://github.com/odoo/odoo/blob/0268986b60477c7fb46d93f45f3355f546f0155c/addons/base_vat/models/res_partner.py#L545), pare che qui ci debbano essere solo cifre.
Potresti quindi modificare l'espressione regolare in modo da rimuovere tutto ciò che non è una cifra?
Attualmente inserendo la P.IVA IT1234567s0017, questa non viene ripulita ma viene sollevato l'errore
image

Questo perché l'espressione regolare in pratica rimuove solo tutto ciò che non è alfanumerico lasciando i caratteri alfabetici.

Essendo fuori dallo scope di questa PR (rimuovere solo gli spazi), questo non lo valuterei come bloccante per il merge ma solo un nice to have.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Trovo corretta l'eccezione. Rimuovere gli spazi (che la 99% vuol dire lo spazio tra IT e il numero) è una cosa di formattazione del campo: "IT 12345670017" e "IT12345670017" sono la stessa piva formattata in due modi diversi.

Se l'utente inserisce un errore di battitura, trovo giusto segnalarlo e non inserire un euristica per "correggere" l'input per es. rimuovendo le lettere.

@TheMule71 TheMule71 marked this pull request as draft September 17, 2021 10:10
@TheMule71
Copy link
Contributor Author

Messa in draft perché apparentemente non serve, core lo fa già...

Vd. https://github.com/OCA/OCB/blob/b0748569791dd645785f5c7a6bc138c33e3abc86/addons/base_vat/models/res_partner.py#L540

TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Sep 17, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Sep 17, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Oct 1, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Oct 1, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Oct 8, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Oct 8, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Oct 15, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Oct 15, 2021
TheMule71 added a commit to TheMule71/l10n-italy that referenced this pull request Jan 21, 2022
TheMule71 added a commit to TheMule71/l10n-italy that referenced this pull request Jan 21, 2022
TheMule71 added a commit to TheMule71/l10n-italy that referenced this pull request Jan 21, 2022
TheMule71 added a commit to TheMule71/l10n-italy that referenced this pull request Jan 21, 2022
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Jun 29, 2022
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Jun 29, 2022
Copy link

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Apr 21, 2024
@github-actions github-actions bot closed this May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
14.0 missing issue stale PR/Issue without recent activity, it'll be soon closed automatically.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants