-
Notifications
You must be signed in to change notification settings - Fork 28.1k
[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
[FIX] l10n_it_edi_ndd: recompute l10n_it_document_type for credit note #208654
Conversation
9da329a
to
b77f5bc
Compare
ef41812
to
1bf9283
Compare
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.
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() |
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.
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 ?
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.
The fix is linked to the ticket that Xavier has created.
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.
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() |
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.
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.
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.
Yes. It's working well. 👍
I've updated the fix.
Thanks for the review. 🙂
1bf9283
to
1b3af06
Compare
The ci/template fails looks like it needs a rebase to be fixed 🫤 |
1b3af06
to
beede87
Compare
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
beede87
to
dbd03b8
Compare
robodoo r+ My first ever r+ is for you, I hope you didn't break anything 😆 |
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>
Steps to reproduce:
=> Document Type (in "Electronic Invoicing" tab) is computed
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