-
-
Notifications
You must be signed in to change notification settings - Fork 303
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
[10.0] pyxb 1.2.6 #998
[10.0] pyxb 1.2.6 #998
Conversation
@@ -0,0 +1,89 @@ | |||
--- Schema_del_file_xml_FatturaPA_versione_1.2.xsd.orig 2019-02-12 02:28:11.342236082 +0100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quindi questo sarebbe il diff con https://www.fatturapa.gov.it/export/fatturazione/sdi/fatturapa/v1.2.1/Schema_del_file_xml_FatturaPA_versione_1.2.1.xsd giusto?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in realtà con la 1.2 ma si aggiorna agevole
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ma è sbagliato l'xsd! c'è <xsd:import
invece di <xs:import
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perchè xsd:import
sarebbe sbagliato?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
non c'è nessuna definizione di namespace xsd sopra (e pyxbgen mi rimbalza)
ma nell' # pyxb is referenced in several in top-level statements in
# fatturapa_v_1_1, so we guard the import of the entire file
try:
from . import fatturapa_v_1_1
except ImportError:
_logger.debug('Cannot `import pyxb`.') # Avoid init error if not installed v_1_1? |
aggiunto un README.md con la procedura per l'aggiornamento dei bindings |
faillisce il doppio zero :( devo trovare un modo per farlo andare senza mettere le mani dentro i .py |
per specifica i decimal non possono avere trailing zero: quindi tocca considerarle stringhe |
Probabilmente roba vecchia |
patchato l'xsd anche per i decimal |
@sherpya cosa succede alle installazioni dove c'è pyxb 1.2.5, nel momento in cui aggiornano questo modulo? |
Direi di prenderci un pochino di tempo per valutare il da farsi con pyxb, considerato questo #879 (comment) |
sembra ok, cmq prima di mergiare vorrei fare ed avere qualche feedback "su strada" |
o forse deve dare solo il warn e non morire? cmq si può sistemare |
Penso che così vada bene: così eventualmente all'avvio del server ci si accorge della mancanza |
@sherpya questa è |
in realtà wip si può levare ma volevo provarla su dati reali prima di mergiarla |
l10n_it_fatturapa/__manifest__.py
Outdated
@@ -6,7 +6,7 @@ | |||
|
|||
{ | |||
'name': 'Italian Localization - Fattura elettronica - Base', | |||
'version': '10.0.2.3.6', | |||
'version': '10.0.2.3.7', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Data l'entità della modifica, farei almeno 2.4.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sherpya c'è anche da risolvere i conflitti con un rebase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fatturapa_v_1_1
l'ho potato questo e messo un __init__.py vuoto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
che poi in effetti se si mette lì il check forse si può evitare nel due autogenerati
La testo su un cliente |
Per ora nessun problema rilevato |
@sherpya dovresti fare rebase per risolvere i conflitti. Grazie |
Per me si può procedere. @OCA/local-italy-developers ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grazie mille @sherpya!
Solo qualche commento, approfondirò review quando troverò il xsd
di cosa accetta/non accetta SDI
|
||
## Incongruenze rispetto alle specifiche del file xsd | ||
|
||
* StringNNType: nelle specifiche da 1 a NN, lo SDI accetta da 0 a N |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok il file da cui parti è https://www.fatturapa.gov.it/export/fatturazione/sdi/fatturapa/v1.2.1/Schema_del_file_xml_FatturaPA_versione_1.2.1.xsd, ma dove hai trovato quello che SDI accetta o meno? (Posto che non dovrebbero essercene accidenti a loro)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
non l'ho trovato io, è già nel codice corrente ma fatto direttamente nel codice python generato (vedi cb063e9#diff-f548cc151f6b5372dd653cb1c1378ba0)
Li ho riportati nell'xsd per minimizzare le modifiche al file generato
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concordo che è la soluzione più pulita, ma mi chiedevo il motivo di questi aggiustamenti, forse @eLBati lo sai?
Se avessimo un xsd
di cosa accetta SDI sarebbe perfetto, ma forse esiste e solo io non lo trovo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
non c'è, ho visto su un pdf una fantomatica 1.3 ma non trovo l'xsd, io credo abbiano fatto la specifica ma poi nella pratica accettano anche stringa vuota
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SimoRubi ti chiedi da quale XSD sia stato generato l'attuale fatturapa_v_1_2.py
? Penso da versioni precedenti dell'XSD pubblicato su https://www.fatturapa.gov.it/export/fatturazione/it/normativa/f-2.htm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non esattamente @eLBati, mi (e ti) chiedo il motivo delle modifiche al file cb063e9#diff-f548cc151f6b5372dd653cb1c1378ba0, in particolare come mai le stringhe sono passate da {1, x}
a {0, x}
?
E' stato per a una nuova versione del XSD o altro?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SimoRubi il motivo è nel commento:
strings of blank spaces are allowed by SDI.
{1,60} would produce
SimpleFacetValueError: Type
{http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2}
String1000LatinType pattern constraint violated by value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quindi sono modifiche fatte su base empirica? Cioè gli XML inviati a SDI fallivano quindi hai cambiato il codice? Speravo fossero dedotti da una qualche specifica su cosa accetta SDI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ciò che accetta SDI è qui https://www.fatturapa.gov.it/export/fatturazione/sdi/fatturapa/v1.2.1/Schema_del_file_xml_FatturaPA_versione_1.2.1.xsd
Quindi nello specifico [\p{IsBasicLatin}\p{IsLatin-1Supplement}]{1,60}
.
Il problema è che per pyXB (o meglio per python) la stringa " "
non passa tale espressione, mentre per SDI sì
## Incongruenze rispetto alle specifiche del file xsd | ||
|
||
* StringNNType: nelle specifiche da 1 a NN, lo SDI accetta da 0 a N | ||
* Amount8DecimalType, Amount2DecimalType, RateType, QuantitaType sono xs:decimal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modificare da decimal
a string
non mi pare proprio il massimo, quando rispondi alla mia domanda qui sopra vedo se ci possono essere altre soluzioni
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stessa cosa di su (la modifica c'era già), il problema è che xs:decimal non permette trailing zeros quindi 5.00 lo rappresenta come 5.0 quando crea una fattura
per esempio:
RateType
ha un pattern [0-9]{1,3}\.[0-9]{2}
che non è fattibile con un xs:decimal
forse si può aggiungere fractionMinDigits
ma non so se pyxb lo considera, posso provare
l10n_it_fatturapa/bindings/README.md
Outdated
|
||
* rinominare `binding.py` in `fatturapa_v_1_2.py` | ||
* riportare il prologo dai file `fatturapa_v_1_2.py` e `_ds.py` precedenti, | ||
in particolare da `# flake8: noqa` a fine import, software come `meld` o similari |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Il mio prologo di _ds.py
è
# ./_ds.py
# -*- coding: utf-8 -*-
# PyXB bindings for NM:f1c343a882e7a65fb879f4ee813309f8231f28c8
# Generated 2019-03-13 11:37:03.086990 by PyXB version 1.2.6 using Python 2.7.15.candidate.1
# Namespace http://www.w3.org/2000/09/xmldsig# [xmlns:ds]
from __future__ import unicode_literals
import pyxb
import pyxb.binding
import pyxb.binding.saxer
import io
import pyxb.utils.utility
import pyxb.utils.domutils
import sys
import pyxb.utils.six as _six
# Unique identifier for bindings created at the same time
_GenerationUID = pyxb.utils.utility.UniqueIdentifier('urn:uuid:e74caf7a-457b-11e9-82e4-144f8a914443')
# Version of PyXB used to generate the bindings
_PyXBVersion = '1.2.6'
# Generated bindings are not compatible across PyXB versions
if pyxb.__version__ != _PyXBVersion:
raise pyxb.PyXBVersionError(_PyXBVersion)
# A holder for module-level binding classes so we can access them from
# inside class definitions where property names may conflict.
_module_typeBindings = pyxb.utils.utility.Object()
# Import bindings for namespaces imported into schema
import pyxb.binding.datatypes
# NOTE: All namespace declarations are reserved within the binding
Namespace = pyxb.namespace.NamespaceForURI('http://www.w3.org/2000/09/xmldsig#', create_if_missing=True)
Namespace.configureCategories(['typeBinding', 'elementBinding'])
e non ho riferimenti a flake8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nell'altro file (fatturapa_v_1_2.py
) c'è in ogni caso per farlo passare a flake8 erano state fatte delle modifiche alla formattazione,
dubito che possa esserci utile stare dietro alla formattazione di un file generato
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probabilmente si potrebbero anche fare meno modifiche ai file generati e fare un import in __init__.py
come già c'era (ma scassato)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SimoRubi #998 (comment) non capisco a cosa ti stai riferendo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avevo letto male, pensavo che nei file generati ci dovesse essere un # flake8
invece è nei file precedenti
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anche in quelli nuovi:
# flake8: noqa |
E concordo su
dubito che possa esserci utile stare dietro alla formattazione di un file generato
l10n_it_fatturapa/bindings/README.md
Outdated
return result.replace(tzinfo=None) | ||
``` | ||
|
||
La patch dell'xsd modifica il range di caratteri delle stringhe portandolo da 1-N a 0-N, inoltre aggiungere il tipo documento TD20 (Autofattura). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fa anche il cambio di alcuni campi da decimal
a string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
verifico se fractionMinDigits
ci piace altrimenti lo aggiungo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ho notato che nel caso in cui si spediscano fatture con destinatario estero, spesso capita di avere caratteri non Latin1 o con accenti nei nomi delle città, vie etc etc. Inoltre ci sono casi come città L'Aquila
non viene accettata, ma se la cambio in L' Aquila
allora passa la validazione.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@robyf70 non è che l'apostrofo originale è questo carattere qui? https://www.fileformat.info/info/unicode/char/2019/index.htm non è latin1 o extended latin1
se il nome del destinatario contiene un carattere non latin1 o extended latin1 ti attacchi, ringrazia chi ha fatto la specifica 😃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SimoRubi purtroppo nulla, pyxb non supporta fractionMinDigits
quindi ci tocca usare stringa, ho aggiornato il readme e minimizzato le modifiche ai file generati mettendo il controllo in __init__
@sherpya sai come mai lint è diventato rosso? (mi pare fosse verde qualche giorno fa) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per me ok quando travis e runbot saranno ✔️
Non è roba mia, ma:
Qualcuno ha cambiato la configurazione del pylint? |
@moylop260 hi, do you know why lint is red complaining about lines not changed by this PR? |
“Oops, we couldn't find that build!“ Could you rebase it in order to make a new build, please? |
@moylop260 it's already rebased, should I close this one and make new PR instead? |
@sherpya I think you can just rebase or |
@moylop260 done |
@moylop260 https://travis-ci.org/OCA/l10n-italy/jobs/507972110 still red for files not changed by this PR |
@OCA/local-italy-developers direi di ignorare gli errori LINT e procedere. Attenzione che dopo questa PR sarà necessario aggiornare pyxb alla versione 1.2.6 |
|
||
_logger = logging.getLogger(__name__) | ||
|
||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
il travis si lamenta della rimozione di questo try, per quale motivo era stato tolto? scusate se non l'ho visto magari nella conversazione, non lo trovo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
il travis si lamenta della rimozione di questo try
In quale riga di https://travis-ci.org/OCA/l10n-italy/jobs/507972110 vedi questo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://travis-ci.org/OCA/l10n-italy/jobs/507972110#L633 in avanti, sbaglio?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scusa, L642
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ho spostato il check e il log in __init__.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sergiocorato ah ok, sì, però come anche tutti gli altri import di _ds.py
. Quindi direi che ce ne possiamo disinteressare
try: | ||
from . import fatturapa_v_1_1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sherpya intendi qui? il try c'era mica già? temo comunque che il controllo fatto da Travis richieda il try dovunque ci siano import
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quello è un refuso nel codice corrente, nella mia pr ora è così:
import logging
_logger = logging.getLogger(__name__)
try:
from . import fatturapa_v_1_2
except Exception as e: # ImportError or pyxb.PyXBVersionError
_logger.warning('%s: %s' % (e.__class__.__name__, e))
e se non hai pyxb 1.2.6:
from odoo.addons.l10n_it_fatturapa.bindings import fatturapa_v_1_2
File "/home/sherpya/workspace/odoo/odoo/addons10/l10n_it_fatturapa/bindings/fatturapa_v_1_2.py", line 23, in <module>
raise pyxb.PyXBVersionError(_PyXBVersion)
PyXBVersionError: 1.2.6
added xsd patch and README.md to generate new bindings includes workaround for pyxb bug in mindate check pyxb is unable to check order of dates if only one has timezone checking if the date > 1970-01-01 we remove tzinfo from parsed date only types as a workaround
Faccio merge visto che gli errori travis non sono collegati |
Ho fatto il porting a 1.2.6 + la fix del mindate
approccio un po' diverso, ho fatto meno modifiche possibili al file generato
il resto è stato fatto sull'xsd, ed ho aggiunto il diff
potete controllare se le cose cambiate siano quelle del diff e basta?
TD20
- Autofattura (da v1.3)il file con le diff è
l10n-italy/l10n_it_fatturapa/bindings/FatturaPA_versione_1.2.xsd.diff
bindings generati con pyxbgen da file locale patchato, poi ho fatto questo per rimuovere i riferimenti al file locale: