[10.0] Improvement to l10n_it_fiscalcode - #278
Conversation
|
Hey @Giuliano69, thank you for your Pull Request. It looks like some users haven't signed our Contributor License Agreement, yet.
Appreciation of efforts, |
| # Copyright 2014 Associazione Odoo Italia (<http://www.odoo-italia.org>) | ||
| # Copyright 2016 Andrea Gallina (Apulia Software) | ||
| # Copyright 2016 Giuliano Lotta | ||
| # version 0.1- changed method check_fiscalcode() to consider multiple situation |
There was a problem hiding this comment.
The history of the module is in the commits. We don't need of a description of every version.
| # - https://github.com/OCA/maintainer-tools/blob/master/CONTRIBUTING.md#oca-guidelines | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
|
||
| # 1: imports of python lib |
There was a problem hiding this comment.
ciao Fabrizio,
revisioni effettuate
| # Constraints and onchanges | ||
| @api.multi | ||
| def check_fiscalcode(self): | ||
| def _check_fiscalcode(self): |
There was a problem hiding this comment.
Are you sure that this functin isn't inherit by other modules? If you change function name, every module after this will crash.
There was a problem hiding this comment.
ciao Fabrizio,
la funzione è un contrain (ora in api.constrain) richiamato internamento nella fase di scrittura record.
Non viene invocato "esternamente". Modifica sicura.
Changes to be committed:
+ modified: l10n_it_fiscalcode/model/res_partner.py
-Removed _constrain field and function, as they have been deprecated
in Odoo V8.
-Modified check funcion to work with new @api.
-Iserted different messages to explain error found in fiscalcode
+ modified: l10n_it_fiscalcode/tests/test_fiscalcode.py
- removed link to base.res.partner_2 (Agrolait) to the test the module
(may be not present in each installation or may be a business company
without applicable fiscalcode)
Created a temporary partner (is a person) to test the fiscalcode.
Changes to be committed:
+ modified: l10n_it_fiscalcode/model/res_partner.py
-Removed _constrain field and function, as they have been deprecated
in Odoo V8.
-Modified constrain check funcion to work with new @api.
-Different messages to explain error found in fiscalcode
+ modified: l10n_it_fiscalcode/tests/test_fiscalcode.py
- removed link to base.res.partner_2 (Agrolait) to the test the module
(may be not present in each installation or may be a business company
without applicable fiscalcode)
Created a temporary partner (is a person) to test the fiscalcode.
|
Hi Fabrizio, I'm getting some strange error from travis about the test unit files, that I cannot understand... |
| - python-lxml # because pip installation is slow | ||
| - python-simplejson | ||
| - python-serial | ||
| - python-yaml |
There was a problem hiding this comment.
Questo file non dovrebbe essere modificato
There was a problem hiding this comment.
Grazie della segnalazione, rimetto come in origine.
Mi chiedevo come mai il file travis del progetto italiano non è uguale al template dei quality tools:
https://github.com/OCA/maintainer-quality-tools/blob/master/sample_files/.travis.yml
| # fiscalcode empty. Nothing o check.. | ||
| elif partner.is_company: | ||
| # fiscalcode not empty and partner is a company | ||
| if partner.country_id.name == u"Italia": |
There was a problem hiding this comment.
res.country.name è un campo traducibile. Userei il campo code
| "The fiscal code doesn't seem to be correct.", ["fiscalcode"]) | ||
| ] | ||
| if not is_fc_ok: | ||
| raise ValidationError(msg) |
There was a problem hiding this comment.
Il messaggio deve essere traducibile.
Vedi
https://github.com/OCA/maintainer-tools/blob/master/CONTRIBUTING.md
e in particolare
from openerp.tools.translate import _
There was a problem hiding this comment.
Scusa Lorenzo,
forse ho interpretato male le istruzioni per le traduzioni odoo (sono nuovo....) , ma i messaggi di errore e di help non dovrebbero venir tradotti automaticamente dal sistema senza usara _() ?
Oppure intendi che devo metterla in unicode ?
Leggevo su
https://www.odoo.com/documentation/10.0/reference/translations.html
Odoo automatically exports translatable strings from "data"-type content:
help/error messages of _constraints and _sql_constraints are exported
There was a problem hiding this comment.
Modifiche effettuate.
Verifiche e test travis a buon fine.
|
@Giuliano69 grazie della PR. Controlla gli errorei sollevati da lint: I problemi di |
|
Volevo proporre una fase di brainstorming con contributi di tutti, sia per una versione ancora migliore che per il backporting in corso. FUNZIONALITÀ attese
Algoritmo CONSTRAIN campo codicefiscale Allo stato attuale una verifica sulla completa correttezza del codice ficale non è possibile. Tuttavia a seconda dei casi è possibile “filtrare” alcuni casi principali:
|
|
@Giuliano69 ti ho gia' risposto ... ma repetita iuvant. Il codice fiscale che qui stiam discutento è qualcosa di semplicemente italiano, quindi solo numeri (niente IT) per aziende/enti/quel_che_ti_pare mentre per le persone fisiche e ditte individuali segue le regole del "codice fiscale". Generalmente, ma non necessariamente, il codice fiscale di un'azienda coincide con la partita iva. Nel caso di cambio di sede legale i due valori diventano diversi seppur i caratteri di controllo coincidono (originariamente era una PI). L'attuale modulo (v8) del codice fiscale permette il calcolo su tabelle proprie di codici comuni, questo rende lungo il processo di aggiornamento ed oltretutto questi dati non si capisce a quando son aggiornate etc etc ... sarebbe un bene dividere il modulo in una parte solo CF e l'altra calcolo che andrebbe installata separatamente. Non capisco che fastidio ti dia il flag individual ... questo è strutturale del modulo CF e se valorizzato dice al sistema che la verifica del CF va fatta come se fosse un individuo e non un'azienda. mi sembra un modo pulito a differenza di quel che suggerisci te che diventerebbe un casino. |
|
Ciao gigi. Se TOGLIAMO is_individual
Se METTIAMO is_individual,
La prima soluzione è più semplice, e non aggiunge ulteriori campi. Se il campo è stato sempre presente nella V8, e gli utenti ci sono ormai abituati, lo rimette ed implemento le varie modifiche nel caso di persona/azienda dette sopra.... |
removed python libraries not present in original
branch
modified: l10n_it_fiscalcode/i18n/it.po
translated new terms in Italian
modified: l10n_it_fiscalcode/model/res_partner.py
Reinroduced field (_is_sole_trader) to idemtify
when a company is a sole trader.
Modified check method to consider lenght and alphanum
when checking the fiscalcode in different situation
modified: l10n_it_fiscalcode/tests/test_fiscalcode.py
modified: l10n_it_fiscalcode/view/fiscalcode_view.xml
field is_soletrader dinamically get visible when
partner is a company
modified: l10n_it_fiscalcode/wizard/compute_fc.py
Only literal strings can be marked for exports,
not expressions or variables.
modified: l10n_it_fiscalcode/wizard/compute_fc_view.xml
|
Nuova versione: reintrodotto il campo per impresa individuale nel caso di partner azienda; gestione dinamica del campo stesso e del pulsante calcolo CF, a seconda che il contatto sia azienda o meno, e che sia impresa individuale o meno. Per la validazione del codice fiscale "sicura" con l'attuale libreria "codicefiscale", ho aperto una domanda agli siluppatori: DOMANDE Travis si inchioda sempre lamentandosi che non può spedire mail (u"Unable to send email, please configure the sender's email address.", None)... si può aggirare ? Esiste un modo per cambiare dinamicamente colore/stile ad un campo per segnalare che un valore (fiscalcode) richiede attenzione ? |
…check (omocodie) modified: l10n_it_fiscalcode/i18n/it.po (translation update) modified: l10n_it_fiscalcode/model/res_partner.py (fiscal code validation against omocodie) modified: l10n_it_fiscalcode/tests/test_fiscalcode.py (changed defaut use to admin)
…de.py:21:13: E124 closing bracket does not match visual indentation
modified: l10n_it_fiscalcode/tests/test_fiscalcode.py - changed user reference in setup, and gived him an email
…ode from fiscalcode check in wizard, to validation of constrains in partner record creation
…in filter; added test for empty fiscalcode field
… command for Italian country id, and added test for no fiscalcode in partner
…compamy = False" assignement
…o valid email problem
…n changed from "is False" to "not"
… error condition tests
|
Copertura test codice raggiunta anche con codecov. |
|
Chiedo un aiuto per le prossime volte... |
eLBati
left a comment
There was a problem hiding this comment.
@Giuliano69 grazie mille per il contributo.
Ti ho lasciato qualche commento.
Relativamente ai problemi con i test, questo https://www.odoo.com/forum/how-to/developers-13/how-to-run-tests-526 non aiuta?
Infine, riesci a fare squash di un po' di commits in modo da unirli secondo la loro logica?
Grazie
| 'Changing partner type from company to ' | ||
| 'person will remove the "Sole Trader" selection ' | ||
| 'in the Accounting tab.\nFiscal code may need ' | ||
| 'to be changed accordingly.') |
There was a problem hiding this comment.
Visualizzerei il messaggio solo se is_soletrader fosse True, per avvisare del cambiamento
There was a problem hiding this comment.
Implementato la condizione su is_soletrader e la traduzione in italiano.
| msg = _( | ||
| 'Insert fiscal code %s is different' | ||
| ' from the computed one ( %s ).\nIf you want to use' | ||
| ' the computed one, please remove first the insert' |
|
Ciao Lorenzo, Ho un PROBLEMA: Mi dai qualche indizio ? :-) |
|
@Giuliano69 Vedo che travis è verde. Mentre mancherebbe ancora la copertura dei test. |
…w degubg in onchange method
…g trace modified: l10n_it_fiscalcode/tests/test_partner.py commented out debug trace
…withespaces in comments (flake8)
new file: view/report_fiscalcode_invoice_document.xml - added fiscal code to partner data in invoice
modified: l10n_it_fiscalcode/tests/test_partner.py - removed debug code
|
Ciao Lorenzo,
Tutti i test tranne codecov sono superati. |
|
TransactionCase fa girare i metodi in transazioni differenti. Pertanto i metodi sono isolati. Nel tuo caso, se non ho capito male, ti serve SingleTransactionCase https://www.odoo.com/documentation/8.0/reference/testing.html#openerp.tests.common.TransactionCase |
… functionalities modified: l10n_it_fiscalcode/i18n/it.po - added new terms modified: l10n_it_fiscalcode/model/res_partner.py - modified onchange() to check for same fiscalcode modified: l10n_it_fiscalcode/tests/test_partner.py - modified test unit for same fiscalcode testcase
… made flake8 to fail
|
Hey @Giuliano69, Appreciation of efforts, |
eLBati
left a comment
There was a problem hiding this comment.
Grazie @Giuliano69 , ti ho lasciato dei commenti, fammi sapere cosa ne pensi.
Poi faccio un test manuale completo e direi che possiamo andare avanti
| * Python module to handle/check standardized numbers and codes `python-stdnum`_. | ||
| * Python library for Italian fiscal code creation - `codicefiscale`_. | ||
|
|
||
| .. _python-stdnum: https://pypi.python.org/pypi/python-stdnum/ |
There was a problem hiding this comment.
Ciao @Giuliano69 , non è necessaria un'altra libreria: codicefiscale permette di verificare la validità del CF , vedi https://github.com/ema/pycodicefiscale
| after_success: | ||
| - travis_after_tests_success | ||
| - coveralls | ||
| - codecov |
There was a problem hiding this comment.
Queste 2 righe non dovrebbero essere aggiunte
| """ Each test method is run independently and the database transaction | ||
| is rolled back after each. | ||
| """ | ||
| def setUp(self): |
There was a problem hiding this comment.
Questo metodo può essere rimosso
|
@eLBati @Giuliano69 @OpenCode I see that PR is in stand-by from a while, can I help you to finalize it? |
|
Chiudo per mancanza di risposte. Se qualcuno è interessato può ovviamente riaprirla |
Hi
I modified it_fiscalcode module.
Changed :
-the check_fiscalcode algorithm, to consider different Italian fiscalcode length depending if partner is an Italian person or an Italian company. Removed field "individual" using instead "old" is_company field. Prefixed underscore "_" in name for OCA compatibility
-the button for the fiscalcode calculation based on personal data, is now visible only if the partner is a person and not if it is a company (in this case VAT code is the fiscalcode for any company, firm, business corporation...)
PS
I also have PROBLEM adding onchange() method on the fiscalcode field for further functionalities.
The method seems not to be called (nor in normal run, nor in debug mode..) .
May you please test if you get the same behaviour ?
I found a similar claim on
http://stackoverflow.com/questions/32326483/odoo-8-onchange-on-inherited-models
but classic inheritance should work for the onchange() method....