8000 [FIX] l10n_it_edi_ndd: recompute l10n_it_document_type for credit note by kitan191 · Pull Request #208654 · odoo/odoo · GitHub
[go: up one dir, main page]

Skip to content

[FIX] l10n_it_edi_ndd: recompute l10n_it_document_type for credit note #208654

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

Conversation

kitan191
Copy link
Contributor
@kitan191 kitan191 commented May 6, 2025

Steps to reproduce:

  • Install l10n_it_edi_ndd
  • Switch to an Italian company (e.g. IT Company)
  • Create an invoice
  • Confirm the invoice
    => Document Type (in "Electronic Invoicing" tab) is computed
  • Create a credit note from the invoice
  • On credit note wizard, click on "Reverse and Create Invoice"
  • Check the created credit note

Issue:
The credit note is posted but its Document Type field (l10n_it_document_type) is empty.
l10n_it_document_type should be computed when it doesn't have a value already and the state of the move is "posted".
The credit note will be rejected when sent to SDI because this field is empty.

Cause:
In the reverse method, the field is set to False in order to be recomputed.
However, the compute method is triggered when the state changes, but the credit note not is already posted.
Therefore the field will not be recomputed.

Solution:
Set the value to False before the creation of the credit note.
So that, the field will be recomputed when posting the credit note.

opw-4689755


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@robodoo
Copy link
Contributor
robodoo commented May 6, 2025

Pull request status dashboard

@C3POdoo C3POdoo requested review from a team and yosuanicolaus and removed request for a team May 6, 2025 15:43
@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label May 6, 2025
@kitan191 kitan191 force-pushed the 17.0-opw-4689755-fix_l10n_it_document_type_compute_reverse-pta branch from 9da329a to b77f5bc Compare May 7, 2025 09:57
@kitan191 kitan191 requested review from malb-odoo and removed request for yosuanicolaus May 7, 2025 09:58
@kitan191 kitan191 force-pushed the 17.0-opw-4689755-fix_l10n_it_document_type_compute_reverse-pta branch 2 times, most recently from ef41812 to 1bf9283 Compare May 7, 2025 10:02
Copy link
Contributor
@malb-odoo malb-odoo left a comment

Choose a reason for hiding this comment

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

Since it's not in my scope anymore i will jol team take the review of this but either way looked a bit and seems ok to me 😄

@@ -80,6 +80,7 @@ def _reverse_moves(self, default_values_list=None, cancel=False):
reverse_moves = super()._reverse_moves(default_values_list, cancel)
for move in reverse_moves:
move.l10n_it_document_type = False
move._compute_l10n_it_document_type()
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI i had receive a message for Xavier (xal) few weeks back about an issues with that
"""
We got a bug report from one of our internal Italian accoutant, tl;dr the Document Type for Italian invoice is resetted to False on reversal which prevent them to be accepted by the SDI (Italian EDi)
Do you remember if there was a specific reson to reset it to False here https://github.com/odoo/odoo/blame/master/addons/l10n_it_edi/models/account_move.py#L242 instead of setting copy=False on the field ? 🤔
(here in case of reversal (cancel = True), the invoice is already posted so the field in never recomputed afterward)
"""
I don't know if @epictete was contacted about this ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The fix is linked to the ticket that Xavier has created.

@malb-odoo malb-odoo requested review from a team and Megaaaaaa and removed request for a team May 7, 2025 13:54
Copy link
Contributor
@Megaaaaaa Megaaaaaa left a comment

Choose a reason for hiding this comment

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

Hello 👋

Thank you for the fix! I think something can be done to slightly improve the fix, would you mind giving it a try, please ? Otherwise everything looks good to me 👍

Thanks!

@@ -80,6 +80,7 @@ def _reverse_moves(self, default_values_list=None, cancel=False):
reverse_moves = super()._reverse_moves(default_values_list, cancel)
for move in reverse_moves:
move.l10n_it_document_type = False
move._compute_l10n_it_document_type()
Copy link
Contributor
@Megaaaaaa Megaaaaaa May 12, 2025

Choose a reason for hiding this comment

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

Technically it works but it's preferable to avoid calling _compute_... methods manually when it's possible and it this case, the document type is False because the compute triggers on state changes so in this case when the reversal is posted and then we come back to this method and for move in self: move.document_type = False which erases the compute method's work. I think what we actually need is to modify the method to use False as default value before posting the reversals and have the _compute_l10n_it_document_type to trigger only once without manual calls. So something like this:

def _reverse_moves(self, default_values_list=None, cancel=False):
   default_values_list = default_values_list or [{}] * len(self)
   [dict.update({'l10n_it_document_type': False}) for dict in default_values_list]
   reverse_moves = super()._reverse_moves(default_values_list, cancel)
   return reverse_moves

I've tested it and it does what I expect it to do, could you test it aswell and see if it does what you expect it to ? To make sure I didn't oversee something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. It's working well. 👍

I've updated the fix.

Thanks for the review. 🙂

@kitan191 kitan191 force-pushed the 17.0-opw-4689755-fix_l10n_it_document_type_compute_reverse-pta branch from 1bf9283 to 1b3af06 Compare May 12, 2025 10:59
@Megaaaaaa
Copy link
Contributor

The ci/template fails looks like it needs a rebase to be fixed 🫤

@kitan191 kitan191 force-pushed the 17.0-opw-4689755-fix_l10n_it_document_type_compute_reverse-pta branch from 1b3af06 to beede87 Compare May 13, 2025 08:46
Steps to reproduce:
- Install l10n_it_edi_ndd
- Switch to an Italian company (e.g. IT Company)
- Create an invoice
- Confirm the invoice
=> Document Type (in "Electronic Invoicing" tab) is computed
- Create a credit note from the invoice
- On credit note wizard, click on "Reverse and Create Invoice"
- Check the created credit note

Issue:
The credit note is posted but its Document Type field (l10n_it_document_type)
is empty.
l10n_it_document_type should be computed when it doesn't have a value already
and the state of the move is "posted".
The credit note will be rejected when sent to SDI because this field is empty.

Cause:
In the reverse method, the field is set to False in order to be recomputed.
However, the compute method is triggered when the state changes, but the
credit note is already posted.
Therefore the field will not be recomputed.

Solution:
Set the value to False before the creation of the credit note.
So that, the field will be recomputed when posting the credit note.

opw-4689755
@kitan191 kitan191 force-pushed the 17.0-opw-4689755-fix_l10n_it_document_type_compute_reverse-pta branch from beede87 to dbd03b8 Compare May 13, 2025 08:59
@kitan191 kitan191 requested a review from Megaaaaaa May 16, 2025 05:57
@Megaaaaaa
Copy link
Contributor

robodoo r+

My first ever r+ is for you, I hope you didn't break anything 😆

robodoo pushed a commit that referenced this pull request May 16, 2025
Steps to reproduce:
- Install l10n_it_edi_ndd
- Switch to an Italian company (e.g. IT Company)
- Create an invoice
- Confirm the invoice
=> Document Type (in "Electronic Invoicing" tab) is computed
- Create a credit note from the invoice
- On credit note wizard, click on "Reverse and Create Invoice"
- Check the created credit note

Issue:
The credit note is posted but its Document Type field (l10n_it_document_type)
is empty.
l10n_it_document_type should be computed when it doesn't have a value already
and the state of the move is "posted".
The credit note will be rejected when sent to SDI because this field is empty.

Cause:
In the reverse method, the field is set to False in order to be recomputed.
However, the compute method is triggered when the state changes, but the
credit note is already posted.
Therefore the field will not be recomputed.

Solution:
Set the value to False before the creation of the credit note.
So that, the field will be recomputed when posting the credit note.

opw-4689755

closes #208654

Signed-off-by: Thomas Becquevort (thbe) <thbe@odoo.com>
@robodoo robodoo closed this May 16, 2025
@fw-bot fw-bot deleted the 17.0-opw-4689755-fix_l10n_it_document_type_compute_reverse-pta branch May 23, 2025 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OE the report is linked to a support ticket (opw-...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0