<commit_before># -*- coding: utf-8 -*-
# © 2014-2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, api


class OmrAwareReport(models.Model):

    _inherit = 'report'

    @api.multi
    def get_pdf(self, docids, report_name, html=None, data=None):
        pdf_data = super(OmrAwareReport, self) \
            .get_pdf(docids, report_name, html=html, data=data)
        job = self.env['partner.communication.job'].browse(docids)
        if job.omr_enable_marks:
            is_latest_document = not job.attachment_ids.filtered(
                'attachment_id.enable_omr'
            )
            return job.add_omr_marks(
                pdf_data, is_latest_document
            )
        return pdf_data
<commit_msg>Co 1885 FIX get_pdf - make sure job actually exists<commit_after># -*- coding: utf-8 -*-
# © 2014-2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, api


class OmrAwareReport(models.Model):

    _inherit = 'report'

    @api.multi
    def get_pdf(self, docids, report_name, html=None, data=None):
        pdf_data = super(OmrAwareReport, self) \
            .get_pdf(docids, report_name, html=html, data=data)
        job = self.env['partner.communication.job'].browse(docids).exists()
        if job.omr_enable_marks:
            is_latest_document = not job.attachment_ids.filtered(
                'attachment_id.enable_omr'
            )
            return job.add_omr_marks(
                pdf_data, is_latest_document
            )
        return pdf_data

{'fraction_non_alphanumeric': 0.10909090909090909, 'fraction_numerical': 0.016300940438871474, 'mean_word_length': 2.41025641025641, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5317621', 'n_tokens_mistral': 546, 'n_tokens_neox': 509, 'n_words': 106}