Skip to content

Conversation

Chionne27
Copy link

@Chionne27 Chionne27 commented Feb 17, 2025

No description provided.

Copy link
Contributor

@francesco-ooops francesco-ooops left a comment

Choose a reason for hiding this comment

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

Errata approvazione

@francesco-ooops francesco-ooops self-requested a review February 17, 2025 15:34
@francesco-ooops francesco-ooops linked an issue Feb 17, 2025 that may be closed by this pull request
2 tasks
@Chionne27 Chionne27 force-pushed the 14.0-IMP-l10n_it_fatturapa_in branch 4 times, most recently from ed30f19 to c28b517 Compare February 19, 2025 08:15
Copy link
Contributor

@francesco-ooops francesco-ooops left a comment

Choose a reason for hiding this comment

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

Functional ok

@Chionne27 Chionne27 force-pushed the 14.0-IMP-l10n_it_fatturapa_in branch 3 times, most recently from 37f7831 to f6b31d2 Compare February 20, 2025 08:31
@Chionne27 Chionne27 force-pushed the 14.0-IMP-l10n_it_fatturapa_in branch 2 times, most recently from 1e7be0b to 4c3b6da Compare February 25, 2025 13:32
@Chionne27 Chionne27 force-pushed the 14.0-IMP-l10n_it_fatturapa_in branch 4 times, most recently from 2f2ce53 to 9b1bc90 Compare March 13, 2025 13:19
@Chionne27 Chionne27 force-pushed the 14.0-IMP-l10n_it_fatturapa_in branch 3 times, most recently from 3a52536 to 67261be Compare March 18, 2025 11:54
@Chionne27 Chionne27 force-pushed the 14.0-IMP-l10n_it_fatturapa_in branch from 67261be to 7c229f6 Compare March 19, 2025 08:43
@Chionne27 Chionne27 force-pushed the 14.0-IMP-l10n_it_fatturapa_in branch from 7c229f6 to 3095bbc Compare March 25, 2025 11:04
@Chionne27 Chionne27 force-pushed the 14.0-IMP-l10n_it_fatturapa_in branch 4 times, most recently from 0fe8bf8 to 06f1a50 Compare July 8, 2025 12:19
@Chionne27 Chionne27 force-pushed the 14.0-IMP-l10n_it_fatturapa_in branch 2 times, most recently from e917c43 to 2f752bb Compare July 16, 2025 12:00
Copy link
Contributor

@SirPyTech SirPyTech left a comment

Choose a reason for hiding this comment

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

Mi pare che questi 3 commit siano un po' mischiati, se possibile sarebbe meglio fare:

  • 1 commit [REF] di refactoring prima dove estrai tutti i metodi che ti serve estrarre, senza cambiare il comportamento che c'era prima della PR.
    Se possibile, come scrivevo in #4621 (comment), sulla linea di #3100 visto che prima o poi dovremo allinearci
  • 1 commit [IMP] dove aggiungi la nuova funzionalità

# XXX maybe San Marino needs special formatting too?
else:
vat = id_codice
vat = self.extract_vat(DatiAnagrafici)
Copy link
Contributor

Choose a reason for hiding this comment

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

Questo commit ha lo scopo di

[IMP] l10n_it_fatturapa_in: intermediary contact creation depending b…
…y vat

(riesci a riassumere in modo che non vada a capo?)

Però ci sono dentro diversi refactoring, sicuramente utili, che non fanno capire cosa sia davvero necessario allo scopo del commit e cosa no.

Puoi riunire i refactoring in un commit dedicato, precedente agli altri?
Nota che il refactoring per definizione non dovrebbe cambiare il comportamento attuale.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ora è tutto in un commit 👍

Comment on lines 17 to 18
"name": line.name,
"name": line.lastname,
"firstname": line.firstname or False,
"lastname": line.lastname or line.name,
Copy link
Contributor

Choose a reason for hiding this comment

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

Questa modifica non mi pare abbia a che fare con lo scopo del commit

[IMP] l10n_it_fatturapa_in: better partner search

Forse andrebbe nel commit in cui è stato definito il wizard?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ora è tutto in un commit 👍

)

def getPartnerBase(self, DatiAnagrafici): # noqa: C901
def getPartnerBase(self, DatiAnagrafici, partnerCreate=True): # noqa: C901
Copy link
Contributor

Choose a reason for hiding this comment

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

Ora che il metodo è stato semplificato forse si può riattivare il linting

Suggested change
def getPartnerBase(self, DatiAnagrafici, partnerCreate=True): # noqa: C901
def getPartnerBase(self, DatiAnagrafici, partnerCreate=True):

Copy link
Contributor

Choose a reason for hiding this comment

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

👍


return vals

def _find_partners_by_cf_vat(self, DatiAnagrafici):
Copy link
Contributor

Choose a reason for hiding this comment

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

In che senso questa ricerca è meglio di com'era prima?
A me sembra che venga cercato esattamente allo stesso modo, sono solo stati estratti dei metodi, oppure mi son perso qualche pezzo?
Se è solo un'estrazione di metodi puoi metterla in un commit di refactoring [REF]?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ora è tutto in un commit 👍

Comment on lines 1856 to 1908
"name": name,
"vat": vat,
"name": partner_vals.get("name"),
"firstname": partner_vals.get("firstname"),
"lastname": partner_vals.get("lastname"),
"vat": partner_vals["vat"],
Copy link
Contributor

Choose a reason for hiding this comment

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

Ci sono diversi valori in partner_vals che sono stati faticosamente trovati da _prepare_partner_values, e altri override potrebbero includerne altri.
Sicuramente aggiungerei il codice fiscale perché insieme alla partita IVA identifica il partner (come hai visto nelle diverse search).

Dopo questa PR l'intermediario avrà meno campi valorizzati, che è una regressione, puoi correggere?
Per riuscire a passarli tutti al wizard si potrebbero mettere in una stringa con json.dump e salvarli in un campo del wizard che poi riotterrà il dizionario con json.loads, cosa ne pensi?

Copy link
Contributor

Choose a reason for hiding this comment

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

Questo non è risolto

Comment on lines 16 to 17
{
"name": line.lastname,
"firstname": line.firstname or False,
Copy link
Contributor

Choose a reason for hiding this comment

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

Questo come ha a che fare con

[IMP] l10n_it_fatturapa_in: commercial partner search improvement

?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ora è tutto in un commit 👍


return vals

def _find_commercial_partner(self, DatiAnagrafici, partners):
Copy link
Contributor

Choose a reason for hiding this comment

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

In che senso questa ricerca è meglio di com'era prima?
A me sembra che venga cercato esattamente allo stesso modo, sono solo stati estratti dei metodi, oppure mi son perso qualche pezzo?
Se è solo un'estrazione di metodi puoi metterla in un commit di refactoring [REF]?

Copy link
Author

Choose a reason for hiding this comment

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

Non avevamo detto si semplificare il metodo get_partner_base? per questo ho pensato fosse una buona idea cercare i partner associati in base al dominio in una funzione e poi il commercial partner in un'altra

Copy link
Contributor

Choose a reason for hiding this comment

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

Ora è tutto in un commit 👍

Comment on lines 277 to 299
vat = self.extract_vat(DatiAnagrafici)
vat = False
if DatiAnagrafici.IdFiscaleIVA:
id_paese = DatiAnagrafici.IdFiscaleIVA.IdPaese.upper()
id_codice = re.sub(r"\W+", "", DatiAnagrafici.IdFiscaleIVA.IdCodice).upper()
# Format Italian VAT ID to always have 11 char
# to avoid validation error when creating the given partner
if id_paese == "IT" and not id_codice.startswith("IT"):
vat = "IT{}".format(id_codice.rjust(11, "0")[:11])
# XXX maybe San Marino needs special formatting too?
else:
vat = id_codice
Copy link
Contributor

Choose a reason for hiding this comment

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

Perché ora non va più bene extract_vat?

Copy link
Author

@Chionne27 Chionne27 Aug 18, 2025

Choose a reason for hiding this comment

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

A me sembra meglio la nuova funzione. Anche perché così riusciamo ad evitare una funzione che deve restituire il cf (estrarre ripetutamente il cf dai dati anagrafici in giro non è una ripetizione del codice?). Prima extract_vat andava a restituire solo la partita iva quindi sostituire quella funzione con una che dia anche il cf mi sembra più pratico da usare quando serve. Poi la funzione l'ho spostata con le altre nuove prima era in fondo

Copy link
Contributor

Choose a reason for hiding this comment

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

estrarre ripetutamente il cf dai dati anagrafici in giro non è una ripetizione del codice?

Secondo me no perché si parla semplicemente di recuperare il valore di un campo:

cf = DatiAnagrafici.CodiceFiscale

è come quando devi recuperare il partner di una fattura: partner = invoice.partner_id è scritto mille volte, ma non è codice ripetuto.

Ora che c'è la nuova _define_vat_fiscalcode va bene, quando scrissi il commento era stato rimosso extract_vat e c'era semplicemente scritto tutto l'if:
image
👍

@Chionne27
Copy link
Author

Chionne27 commented Aug 18, 2025

Mi pare che questi 3 commit siano un po' mischiati, se possibile sarebbe meglio fare:

  • 1 commit [REF] di refactoring prima dove estrai tutti i metodi che ti serve estrarre, senza cambiare il comportamento che c'era prima della PR.
    Se possibile, come scrivevo in #4621 (comment), sulla linea di [12.0] [FIX] l10n_it_fatturapa_in - Gruppi IVA #3100 visto che prima o poi dovremo allinearci
  • 1 commit [IMP] dove aggiungi la nuova funzionalità

Quando ho finito di fare le modifiche la mia intenzione sarà quella di fare squash dei commit perché ovviamente le modifiche fatte fino ad ora erano dati da tentativi di implementazione. Nella descrizione del commit ho messo che è stato fatto anche un refactoring iniziale. Fare un commit REF risulterebbe ora troppo complesso perché significherebbe ripristinare tutto quello che ho fatto e ripeterlo da capo ed è secondo me un lavoro evitabile

@Chionne27 Chionne27 force-pushed the 14.0-IMP-l10n_it_fatturapa_in branch 8 times, most recently from aa8db53 to 1ad5242 Compare August 18, 2025 12:33
Comment on lines 17 to 19
data = json.loads(line.intermediary_data_json)
if isinstance(data, str):
data = json.loads(data)
Copy link
Contributor

Choose a reason for hiding this comment

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

Perché serve ripetere loads?

Copy link
Author

Choose a reason for hiding this comment

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

Errore mio

Comment on lines 1892 to 1900
partner = self.getPartnerBase(
Intermediary.DatiAnagrafici, partnerCreate=False
)

if isinstance(partner, int):
partner_id = self.env["res.partner"].browse(partner)
invoice.write({"intermediary": partner_id})
Copy link
Contributor

Choose a reason for hiding this comment

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

Qui mi pare ci sia un po' di confusione tra l'ID del partner (un intero) e un record del partner perché non si sa bene cosa potrà uscire dalla nuova implementazione di getPartnerBase.

In generale penso sia più chiaro usare il suffisso _id quando si parla di un ID (es partner_id), e nessun suffisso quando si parla di un record (es partner).

Quindi suggerirei

Suggested change
partner = self.getPartnerBase(
Intermediary.DatiAnagrafici, partnerCreate=False
)
if isinstance(partner, int):
partner_id = self.env["res.partner"].browse(partner)
invoice.write({"intermediary": partner_id})
partner_id = self.getPartnerBase(
Intermediary.DatiAnagrafici, partnerCreate=False
)
if isinstance(partner_id, int):
invoice.write({"intermediary": partner_id})

che è anche più simile al codice prima di questa PR (era intermediary_id).

Copy link
Author

@Chionne27 Chionne27 Aug 21, 2025

Choose a reason for hiding this comment

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

Però in questo caso getPartnerBase può restituire o in intero (se trova il partner) oppure un dizionario che verra sfruttato nella funzione di import. Per questo avevo pensato di generalizzare e scrivere partner. Infatti c'è anche la seconda condizione sotto che valuta se viene restituito un dizionario

Copy link
Contributor

Choose a reason for hiding this comment

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

Però in questo caso getPartnerBase può restituire o in intero (se trova il partner) oppure un dizionario che verra sfruttato nella funzione di import. Per questo avevo pensato di generalizzare e scrivere partner. Infatti c'è anche la seconda condizione sotto che valuta se viene restituito un dizionario

Ok, però dentro partner di solito c'è un record; se non è così si crea confusione nel resto del codice.
Ad esempio

partner_id = self.env["res.partner"].browse(partner)

è il contrario di quello che si farebbe normalmente.
Se non si sa di che tipo sia la variabile puoi chiamarla tipo partner_id_or_vals.

Ho come la sensazione che questo metodo che può restituire un dizionario o un intero ci stia complicando la vita, forse sarebbe più semplice qualcosa del tipo:

partner_id = self._find_partner(...)
if partner_id:
    invoice.write(...)
else:
    partner_values = self._prepare_partner_values(...)

Cosa ne pensi?

Comment on lines 1911 to 1912
elif isinstance(partner, bool):
invoice.write({"intermediary": False})
Copy link
Contributor

Choose a reason for hiding this comment

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

Qui non si entra mai perché il primo if controlla se partner è un intero e

>>> isinstance(False, int)
True

Comment on lines 1891 to 1897
if Intermediary.DatiAnagrafici.IdFiscaleIVA:
partner = self.getPartnerBase(
Intermediary.DatiAnagrafici, partnerCreate=False
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Perché ora questo viene fatto solo quando c'è il nodo Intermediary.DatiAnagrafici.IdFiscaleIVA?
Può essere utile per recuperare i dati dai nodi del XML anche se non troverà la partita IVA, come veniva fatto prima di questa PR.

Era già stato segnalato in #4621 (comment).


return vals

def _find_commercial_partner(self, DatiAnagrafici, partners):
Copy link
Contributor

Choose a reason for hiding this comment

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

Quando c'è solo un record in partners questo metodo ritorna False, dovrebbe invece restituire il commercial partner dell'unico record in partners.


return vals

def _find_commercial_partner(self, DatiAnagrafici, partners):
Copy link
Contributor

Choose a reason for hiding this comment

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

In questo metodo cf e vat vengono usati solo per loggare l'inconsistenza, si può evitare di calcolarli sempre?

Comment on lines 310 to 311
"vat": vat if vat else False,
"fiscalcode": cf if cf else False,
Copy link
Contributor

Choose a reason for hiding this comment

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

Se vat (o cf) sono vuoti, cosa cambia scriverci invece False?
Se non cambia nulla puoi rimettere com'era prima?

Suggested change
"vat": vat if vat else False,
"fiscalcode": cf if cf else False,
"vat": vat,
"fiscalcode": cf,

Comment on lines 1916 to 1923
"name": denominazione,
"firstname": nome,
"lastname": cognome,
"vat": vat,
"invoice_id": invoice.id,
"intermediary_data_json": {
"name": denominazione,
"firstname": nome,
"lastname": cognome,
"vat": vat,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"name": denominazione,
"firstname": nome,
"lastname": cognome,
"vat": vat,
"invoice_id": invoice.id,
"intermediary_data_json": {
"name": denominazione,
"firstname": nome,
"lastname": cognome,
"vat": vat,
},
"invoice_id": invoice.id,
"intermediary_data_json": {
"name": denominazione,
"firstname": nome,
"lastname": cognome,
"vat": vat,
},

I valori dei primi campi potrebbero essere calcolati in base a quello che c'è in intermediary_data_json invece di ripeterli.

Copy link
Author

Choose a reason for hiding this comment

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

È necessario allora implementare una funzione in WizardCheckIntermediaryVatLine che estragga i dati da intermediary_data_json

Comment on lines +1999 to +1992
"lastname": new_data.get("lastname")
or new_data.get("name"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Come mai non mettiamo invece un name dedicato? C'era nelle vecchie versioni della PR. Sarebbe da valorizzare solo quando c'è Denominazione.

Copy link
Author

Choose a reason for hiding this comment

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

Ci può stare

@Chionne27 Chionne27 force-pushed the 14.0-IMP-l10n_it_fatturapa_in branch 9 times, most recently from 21ffd97 to 1da39c1 Compare August 22, 2025 07:23
@Chionne27 Chionne27 force-pushed the 14.0-IMP-l10n_it_fatturapa_in branch from 1da39c1 to f319210 Compare August 22, 2025 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

l10n_it_fatturapa_in - scelta creazione contatto intermediario
7 participants