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] account: log error in chatter when importing xml #163849
base: 17.0
Are you sure you want to change the base?
Conversation
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 idea is noble, and this is an open pain-point (IMHO).
Yet, this bit of code is quite complicated, and re-instating the error like in your PR has several consequences:
-
There might be more than one decoder per attachment (see the
unwrap_attachments
function).
Every decoder has a check function that just looks at the filename, so let's suppose that an XML file is both checked as "OK I can handle that" byPEPPOL decoder
,French EDI decoder
andItalian EDI decoder
. TheFrench EDI decoder
will always fail and have a traceback on all Italian invoices. This is mitigated because the "check" methods for decoders rely on having different filename patterns, but it's still possible. Furthermore, that may change in the future. We got partners asking that we look into the the structure of any XML file imported to say that it's an Italian invoice or not, so that they can import invoices with any given filename. That would require compute time and developer time. -
In case the input file is wrong, we would have a (server language!) traceback in the chatter, moving the attention of the client from his own file to "there's an error in the system". Maybe he uploaded a base64-ed XML file. It happens, even by mistake.
-
We're not sure that an empty invoice created by
get_edi_creation
with errors in the chatter is the correct way to handle a failed import. Maybe we can have exception logs on the server and a UserError appearing: "Cannot import this file." -
On the side - The
try..except
is too large, it also involves the link between the file and the Purchase Order, while it should be limited to the failing decoder. I'd like this to be addressed when touching this bit.
To rework all this, we thought with @jco-odoo and @antoine162 about opening a task and discussing about it, but no one had time to follow that.
|
No need to rework "all this" imo. What's the interest of doing at? 🤔 |
Don't use an aggressive tone, please, I'm a very sensitive person, and might go defensive. The Italian EDI doesn't actually get a decoded We can actually change in the Italian EDI and make it work normally:
There will be people complaining anyway, since I guess this "feature" was exactly made for the reason that people were trying to import signed misnamed files.
The main point of the PR was to give user feedback. Before that change, the user would upload a file and get a totally blank invoice because the error was just logged. It happened a lot and tickets were opened. We can simply do both!
Anyway, please take the time to conform the
Me, @antoine162, @jco-odoo, the people involved in the discussion when the "no-user-feedback in the EDI when an exception occurs" problem arose.
By no means I want the traceback in the chatter. If we both post and log, the customer support will then know that in the server logs of the instance there is the exception text, and the user won't get too scared and maybe look inside the file to see that he's uploaded something appropriate before opening a ticket. |
@lordkrandel Understand me well: I just discover you merged things with @jco-odoo like
I don't want to be aggressive but I don't like the way you are doing things. You are talking much about opening a task and discuss nicely about it but it's already merged and I guess I'm just supposed to deal with it. |
You're correct on the first two, the idea was clearly to have more work on it... but didn't happen, so I'm sorry for that. I'll make sure that from now on every part that it's not directly
I thought the reviewer was Josse, it was very clear to him what I was doing. Please talk to @qdp-odoo to state it clearly if the process is different for EDI matters and it has some kind of hierarchy or process I didn't know of.
Neither did I like the entire
What? I didn't make the code that had no user feedback at all, and I had to put something there in the first place. If the patch is not good or not enough, we are just discussing and making it better. I can do the (other) task myself soon, if you don't have time. |
except Exception as e: | ||
message = _( | ||
"Error importing attachment '%s' as invoice (decoder=%s): %s", | ||
file_data['filename'], | ||
decoder.__name__, | ||
str(e), | ||
) | ||
invoice.sudo().message_post(body=message) | ||
_logger.exception(message) |
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.
except Exception as e: | |
message = _( | |
"Error importing attachment '%s' as invoice (decoder=%s): %s", | |
file_data['filename'], | |
decoder.__name__, | |
str(e), | |
) | |
invoice.sudo().message_post(body=message) | |
_logger.exception(message) | |
except Exception as e: | |
chatter_message = _( | |
"Error importing attachment '%s' as invoice (decoder=%s)." | |
" Check the file itself, or read the application logs" | |
" for more information.", | |
file_data['filename'], | |
decoder.__name__ | |
) | |
invoice.sudo().message_post(body=chatter_message) | |
_logger.exception( | |
"Error importing attachment '%s' as invoice (decoder=%s): %s", | |
file_data['filename'], | |
decoder.__name__, | |
str(e) | |
) |
Would this do?
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.
Sorry, I made a few edits after post ^^.
Still re-reading, but I hope you get what I mean with the suggestion.
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.
@lordkrandel I'm still not convinced by the invoice chatter message. The user doesn't know what a decoder is. Do we really need to log something in that case? :(
(the _logger
is better yes)
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.
Look, let's say I'm a user.
- I upload an invoice XML.
- It appears a blank invoices with no lines, no quantities, no errors at all. Blank draft and the invoice attached. Almost like I pressed the "new" button.
- I think I did something wrong, so I retry.
- Another new invoice completely blank.
- I don't know what's wrong, but there's a header on top (totally unrelated ofc but he doesn't know) saying "you have no credits to do OCR"
- I open a ticket about l10n_it_edi and OCR
- Support knows nothing about this. They don't even know that in the logs there might be an import exception. And they ask... PGI about the ticket.
This happened many times.
What is hard to understand from "We need user feedback somewhere"?
It's a concept that in other contexts I think we well cover with UserErrors, ValidationErrors, warnings... (tracebacks even!) We have user feedback when we send, we have all kinds of warnings and "Rejected" states.
But if the user imports a file, and it goes wrong, it gets a blank invoice.
I don't care if he knows what a decoder is, but somehow he needs to know there was an error somewhere.
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.
@lordkrandel OK then if you insist
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.
If find this really painful for a user having errors, if he doesn't have access to the logs, he will have to wait for 3 weeks to get an answer from the support... but I see you're not convinced 🤷♂️
59d160b
to
c65a13b
Compare
Chiming in:
I'm not a super fan of just putting that just in the logs, as almost nobody will be able to access that. The chatter is good, but I also agree that random technical error messages in the chatter is bad.
|
If there's one (or more) deity/ies, thanks for Product Owners. |
Modify the error message to state that the exception can be found in the logs. NB: Before c02d8b1, an error occuring during the import was logged in the chatter, but we don't want to show it to the user. For instance: opw-3874857
c65a13b
to
fe17810
Compare
Italian EDI used to look at the filename to determine whether the uploaded attachment is related to it or not. With this change we look at the structure of the XML file, making it more standard - it's what all other EDIs do. CADES signed files (.xml.p7m) have their signature removed and then they are treated like normal XML files. In order to be able to do this, we have to move the code that specially handles the account_predictive_bills for Italy to the `account` level. Related PR: odoo#163849 Related issue: odoo#150382
Before c02d8b1, an error occuring during the import was logged in the chatter. This commit restores this behaviour, as it is highly helpful to have the error message (it could probably avoid customers to open tickets in some cases).
Ticket link: https://www.odoo.com/web#model=project.task&id=3874857
opw-3874857