-
Notifications
You must be signed in to change notification settings - Fork 23.1k
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: select generated pdf streams from invoices without attachments #160670
[FIX] account: select generated pdf streams from invoices without attachments #160670
Conversation
9e44b56
to
1d65467
Compare
1d65467
to
6759c9b
Compare
6759c9b
to
a15ec77
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.
looks good to me
f56dfcc
to
4bb5f24
Compare
5fecf05
to
10bb54d
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.
Always better to use recordsets instead of lists of records.
Since it's a test, I'll 🙈 but try to remember that in the future 😉
(Same for the creation, better to do it in batch)
@robodoo r+
}) for i in range(50)] # Make this a multipage invoice. | ||
}) | ||
|
||
self.assert_invoice_creation([first_invoice, second_invoice, third_invoice], second_invoice) |
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.
self.assert_invoice_creation([first_invoice, second_invoice, third_invoice], second_invoice) | |
self.assert_invoice_creation((first_invoice + second_invoice + third_invoice), second_invoice) |
self.assertTrue( | ||
invoice_to_report.id in [invoice.id for invoice in invoices], "Invoice to report must be in invoices list") |
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.
self.assertTrue( | |
invoice_to_report.id in [invoice.id for invoice in invoices], "Invoice to report must be in invoices list") | |
self.assertIn(invoice_to_report, invoices, "Invoice to report must be in invoices list") |
for invoice in invoices: | ||
invoice.action_post() |
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.
for invoice in invoices: | |
invoice.action_post() | |
invoices.action_post() |
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.
Neat!
aggregate_report_content, content_type = reports._render_qweb_pdf(invoices_report_ref, | ||
res_ids=[invoice.id for invoice in invoices]) |
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.
aggregate_report_content, content_type = reports._render_qweb_pdf(invoices_report_ref, | |
res_ids=[invoice.id for invoice in invoices]) | |
aggregate_report_content, content_type = reports._render_qweb_pdf(invoices_report_ref, | |
res_ids=invoices.ids) |
Neat suggestions. I'll keep that in mind, thank you! |
…achments Issue ----- Report creation for multiple invoices fails (e.g. with <AttributeError: "NoneType" object has no attribute "getvalue">) when some, but not all, of the invoices across the selection have a previously generated report as an attachment, and the 'Reload from attachment' option is enabled for the report action. Steps ----- - Enable 'Reload from attachment' from Settings -> Techical -> Actions -> Reports -> invoices. - Create 3 invoices without any previous reports as attachments. - Select the middle invoice and generate a report (Print -> Invoices). An attachment will be created for the invoice. - Select the 3 invoices then generate a report (Print -> Invoices). Cause ----- When "Reload from attachment" is enabled, the algorithm for creating aggregate reports for a number of invoices selects only those that don't have an attachment to generate a pdf for. These are copied into a separate list "res_ids_wo_stream". When the pdfs streams are generated, they're put back into the return value "collected_streams. However, this was done from the original ids list "res_ids" rather than the selected one, which resulted in an indexing issue. opw-3827700 Closes #157975 closes #160670 Signed-off-by: William André (wan) <wan@odoo.com>
@mizosoft @william-andre this pull request has forward-port PRs awaiting action (not merged or closed): |
1 similar comment
@mizosoft @william-andre this pull request has forward-port PRs awaiting action (not merged or closed): |
Issue ----- Make `test_ir_actions_report.py` configure the invoices report to create attachments if it is not configured to do so. Previously (in odoo#160670) it was assumed that this is the case, so the test failed otherwise. Also, the portion of the test concerned with \odoo#160670 is moved to `base` instead of `account`.
@mizosoft @william-andre this pull request has forward-port PRs awaiting action (not merged or closed): |
5 similar comments
@mizosoft @william-andre this pull request has forward-port PRs awaiting action (not merged or closed): |
@mizosoft @william-andre this pull request has forward-port PRs awaiting action (not merged or closed): |
@mizosoft @william-andre this pull request has forward-port PRs awaiting action (not merged or closed): |
@mizosoft @william-andre this pull request has forward-port PRs awaiting action (not merged or closed): |
@mizosoft @william-andre this pull request has forward-port PRs awaiting action (not merged or closed): |
Issue ----- Make `test_ir_actions_report.py` configure the invoices report to create attachments if it is not configured to do so. Previously (in odoo#160670) it was assumed that this is the case, so the test failed otherwise. Also, the portion of the test concerned with \odoo#160670 is moved to `base` instead of `account`.
Issue ----- Make `test_ir_actions_report.py` configure the invoices report to create attachments if it is not configured to do so. Previously (in odoo#160670) it was assumed that this is the case, so the test failed otherwise. Also, the portion of the test concerned with \odoo#160670 is moved to `base` instead of `account`.
Issue
Report creation for multiple invoices fails (e.g. with <AttributeError: "NoneType" object has no attribute "getvalue">)
when some, but not all, of the invoices across the selection have a previously generated report
as an attachment, and the 'Reload from attachment' option is enabled for the report action.
Steps
for the invoice.
Cause
When "Reload from attachment" is enabled, the algorithm for creating aggregate reports for a number
of invoices selects only those that don't have an attachment to generate a pdf for. These are copied
into a separate list "res_ids_wo_stream". When the pdfs streams are generated, they're put back into
the return value "collected_streams. However, this was done from the original ids list "res_ids" rather
than the selected one, which resulted in an indexing issue.
opw-3827700
Closes #157975