[FIX] base: Cannot print multiple checks
Steps to reproduce:
1. Settings > Accounting > Vendor Payments > Checks > Enabled with
Print Check (Top) - US
2. Accounting / Vendors / Payments
3. Create at least 2 vendor payments using "Checks" as the payment method
4. In the list view select both payments and click action/print checks
5. Error
Bug:
in `_render_qweb_pdf_prepare_streams`, in the case of multiple
documents on multiple pages, we can only split them if the pdf has an
outline, and it will have an outline only with templates that have a
header tag. For the ones that don't have them like
`l10n_us_check_printing.print_check_top`, it is not possible with the
current logic to unambiguously split them. (maybe we can add a
heuristic like if number of pages = number of documents we can assume
1 document/page)
thus the streams returned by `_render_qweb_pdf_prepare_streams` don't
contain the record ids and
`safe_eval(report_sudo.attachment, {'object': record, 'time': time})`
might fail based on the expression to evaluate.
Fix:
It doesn't make sense to save the attachment if we can't split the
attachments clearly anyway, so we can just continue and skip the saving
if record is null
OPW-3124089
closes odoo/odoo#113863
X-original-commit: 1fac708bd335dce27eeb77e0a11e12883a83dac6
Signed-off-by: Quentin De Paoli <qdp@odoo.com>
Signed-off-by: Mohamed Megahed Abbas Megahed SALLAM (mome) <mome@odoo.com>
This commit is contained in:
@@ -807,6 +807,14 @@ class IrActionsReport(models.Model):
|
||||
if stream_data['attachment']:
|
||||
continue
|
||||
|
||||
# if res_id is false
|
||||
# we are unable to fetch the record, it won't be saved as we can't split the documents unambiguously
|
||||
if not res_id:
|
||||
_logger.warning(
|
||||
"These documents were not saved as an attachment because the template of %s doesn't "
|
||||
"have any headers seperating different instances of it. If you want it saved,"
|
||||
"please print the documents separately", report_sudo.report_name)
|
||||
continue
|
||||
record = self.env[report_sudo.model].browse(res_id)
|
||||
attachment_name = safe_eval(report_sudo.attachment, {'object': record, 'time': time})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user