Skip to content

[16.0] [FIX] l10n_it_fatturapa_in_rc: flag RC in importazione e-fattura con raggruppamento per Aliquota#4434

Merged
OCA-git-bot merged 2 commits into
OCA:16.0from
mktsrl:16.0-fix-l10n_it_fatturapa_in_rc-flg_rc_import_e_invoice
Nov 13, 2024
Merged

[16.0] [FIX] l10n_it_fatturapa_in_rc: flag RC in importazione e-fattura con raggruppamento per Aliquota#4434
OCA-git-bot merged 2 commits into
OCA:16.0from
mktsrl:16.0-fix-l10n_it_fatturapa_in_rc-flg_rc_import_e_invoice

Conversation

@TennyMkt

@TennyMkt TennyMkt commented Nov 4, 2024

Copy link
Copy Markdown
Contributor

risolve #3768 per la 16.0

Estende funzione _prepareInvoiceLineAliquota per mettere a True la flag RC nelle linee della fattura se viene importata una fattura con Reverse Charge per Aliquota IVA

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @sergiocorato,
some modules you are maintaining are being modified, check this out!

@SirAionTech SirAionTech left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Grazie della PR!
Potresti aggiungere un test o modificarne uno esistente per verificare il nuovo comportamento? Così si evitano regressioni.
Visto che esiste già un test in questo modulo, magari ti basta aggiungere un self.assert... nel test esistente.

Potresti modificare il messaggio del commit in modo che segua le linee guida in https://github.com/OCA/odoo-community.org/blob/master/website/Contribution/CONTRIBUTING.rst#71commit-message? In particolare

Commit messages are in English

@SirAionTech SirAionTech added the is porting This pull request is porting a change from another version label Nov 8, 2024
@TheMule71 TheMule71 mentioned this pull request Nov 8, 2024
35 tasks
@TennyMkt TennyMkt force-pushed the 16.0-fix-l10n_it_fatturapa_in_rc-flg_rc_import_e_invoice branch from ab210a5 to 3f600a9 Compare November 12, 2024 09:24
@TennyMkt

Copy link
Copy Markdown
Contributor Author

Grazie della PR! Potresti aggiungere un test o modificarne uno esistente per verificare il nuovo comportamento? Così si evitano regressioni. Visto che esiste già un test in questo modulo, magari ti basta aggiungere un self.assert... nel test esistente.

Potresti modificare il messaggio del commit in modo che segua le linee guida in https://github.com/OCA/odoo-community.org/blob/master/website/Contribution/CONTRIBUTING.rst#71commit-message? In particolare

Commit messages are in English

Ho modificato il messaggio di commit.

Ho provato ad aggiungere un test perchè per testare serve un'importazione per Aliquota e il test già esistente non lo faceva.
Però il test va in errore ma non capisco perchè, sapreste aiutarmi a come sistemarlo?

@SirAionTech SirAionTech added the needs fixing Has conflicts or is failing mandatory CI checks label Nov 12, 2024
@SirAionTech

Copy link
Copy Markdown
Contributor

Ho provato ad aggiungere un test perchè per testare serve un'importazione per Aliquota e il test già esistente non lo faceva. Però il test va in errore ma non capisco perchè, sapreste aiutarmi a come sistemarlo?

Grazie dell'aggiunta! Lo stack dell'errore preso da https://github.com/OCA/l10n-italy/actions/runs/11794311853/job/32851644723?pr=4434#step:8:893 è

Stack

2024-11-12 09:30:21,508 528 ERROR odoo odoo.addons.l10n_it_fatturapa_in_rc.tests.test_fatturapa_in_rc: ERROR: TestInvoiceRC.test_01_xml_import
Traceback (most recent call last):
File "/__w/l10n-italy/l10n-italy/l10n_it_fatturapa_in_rc/tests/test_fatturapa_in_rc.py", line 13, in setUp
self._create_account()
File "/__w/l10n-italy/l10n-italy/l10n_it_fatturapa_in_rc/tests/test_fatturapa_in_rc.py", line 22, in _create_account
self.account_selfinvoice = account_model.create(
File "", line 2, in create
File "/opt/odoo/odoo/api.py", line 414, in _model_create_multi
return create(self, [arg])
File "/__w/l10n-italy/l10n-italy/l10n_it_account/models/account_account.py", line 34, in create
return super().create(vals_list)
File "", line 2, in create
File "/opt/odoo/odoo/api.py", line 415, in _model_create_multi
return create(self, arg)
File "/opt/odoo/addons/mail/models/mail_thread.py", line 258, in create
threads = super(MailThread, self).create(vals_list)
File "", line 2, in create
File "/opt/odoo/odoo/api.py", line 415, in _model_create_multi
return create(self, arg)
File "/opt/odoo/odoo/addons/base/models/ir_fields.py", line 670, in create
recs = super().create(vals_list)
File "", line 2, in create
File "/opt/odoo/odoo/api.py", line 415, in _model_create_multi
return create(self, arg)
File "/opt/odoo/odoo/models.py", line 3984, in create
records = self._create(data_list)
File "/opt/odoo/odoo/models.py", line 4165, in _create
cr.execute(
File "/opt/odoo/odoo/sql_db.py", line 321, in execute
res = self._obj.execute(query, params)
psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "account_account_code_company_uniq"
DETAIL: Key (code, company_id)=(295000, 10) already exists.

Da qui si vede che durante il setUp cerca di creare un conto avente codice 295000, ma fallisce perché esiste già.

Questo succede perché la classe dei test è SingleTransactionCase:

class FatturapaCommon(SingleTransactionCase):
quindi ogni test (setUp + test + tearDown) viene eseguito in un'unica transazione: finché c'è solo un test no problemo; però ora che hai aggiunto un altro test esegue di nuovo il setUp, cerca di creare di nuovo lo stesso conto e giustamente fallisce.

Per risolvere puoi trasformare l'attuale setUp in setUpClass, se possibile andrebbe fatto in un commit di refactoring precedente alla fix che stai proponendo.

@TennyMkt TennyMkt force-pushed the 16.0-fix-l10n_it_fatturapa_in_rc-flg_rc_import_e_invoice branch from 3f600a9 to 2ae136e Compare November 12, 2024 11:09
@TennyMkt

Copy link
Copy Markdown
Contributor Author

Ho provato ad aggiungere un test perchè per testare serve un'importazione per Aliquota e il test già esistente non lo faceva. Però il test va in errore ma non capisco perchè, sapreste aiutarmi a come sistemarlo?

Grazie dell'aggiunta! Lo stack dell'errore preso da https://github.com/OCA/l10n-italy/actions/runs/11794311853/job/32851644723?pr=4434#step:8:893 è

Stack
Da qui si vede che durante il setUp cerca di creare un conto avente codice 295000, ma fallisce perché esiste già.

Questo succede perché la classe dei test è SingleTransactionCase:

class FatturapaCommon(SingleTransactionCase):

quindi ogni test (setUp + test + tearDown) viene eseguito in un'unica transazione: finché c'è solo un test no problemo; però ora che hai aggiunto un altro test esegue di nuovo il setUp, cerca di creare di nuovo lo stesso conto e giustamente fallisce.
Per risolvere puoi trasformare l'attuale setUp in setUpClass, se possibile andrebbe fatto in un commit di refactoring precedente alla fix che stai proponendo.

Grazie dell'aiuto, ho fatto quanto richiesto

@SirAionTech SirAionTech self-requested a review November 13, 2024 10:06
@SirAionTech SirAionTech removed the needs fixing Has conflicts or is failing mandatory CI checks label Nov 13, 2024

@SirAionTech SirAionTech left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Grazie dell'aiuto, ho fatto quanto richiesto

Grazie a te, bel lavoro 🏅

/ocabot merge patch

@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 16.0-ocabot-merge-pr-4434-by-SirAionTech-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit af447ca into OCA:16.0 Nov 13, 2024
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at a8b2008. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

16.0 is porting This pull request is porting a change from another version merged 🎉

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[l10n_it_fatturapa_in_rc] flag rc importando fattura elettronica con livello di dettaglio: aliquota fiscale

4 participants