-
-
Notifications
You must be signed in to change notification settings - Fork 833
[FIX] report_csv: make it working if docids is False #962
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] report_csv: make it working if docids is False #962
Conversation
There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. |
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.
Indeed, as per code in controller, docids is None by default, and in this case you will get a TypeError.
See :
def report_routes(self, reportname, docids=None, converter=None, **data): |
Called from
reporting-engine/report_csv/controllers/main.py
Lines 80 to 82 in a224052
response = self.report_routes( | |
reportname, converter="csv", context=context, **data | |
) |
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.
could be nice to add unittest to avoid regressions !
other wise code looks good to me
6a52290
to
bd5cc62
Compare
len() is used on docids, but in some cases, docids is None wich raised a TypeError
bd5cc62
to
a70c672
Compare
@@ -55,7 +55,7 @@ def _render_csv(self, report_ref, docids, data): | |||
report_sudo = self._get_report(report_ref) | |||
report_model_name = "report.%s" % report_sudo.report_name | |||
report_model = self.env[report_model_name] | |||
res_id = len(docids) == 1 and docids[0] | |||
res_id = docids[0] if docids and len(docids) == 1 else None |
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.
just replaced
res_id = (len(docids) == 1 and docids[0]) if docids else False
with
res_id = docids[0] if docids and len(docids) == 1 else None
wich is more readable
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.
@petrus-v @remi-filament
Just added a test and the little change above
This PR has the |
/ocabot merge patch |
On my way to merge this fine PR! |
Congratulations, your PR was merged at 935eece. Thanks a lot for contributing to OCA. ❤️ |
len() is used on docids, but in some cases, docids is False wich raised a TypeError