<commit_before># -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import api, models, _
from odoo.exceptions import UserError


class PosInvoiceReport(models.AbstractModel):
    _name = 'report.point_of_sale.report_invoice'

    @api.multi
    def render_html(self, data=None):
        Report = self.env['report']
        PosOrder = self.env['pos.order']
        ids_to_print = []
        invoiced_posorders_ids = []
        selected_orders = PosOrder.browse(self.ids)
        for order in selected_orders.filtered(lambda o: o.invoice_id):
            ids_to_print.append(order.invoice_id.id)
            invoiced_posorders_ids.append(order.id)
        not_invoiced_orders_ids = list(set(self.ids) - set(invoiced_posorders_ids))
        if not_invoiced_orders_ids:
            not_invoiced_posorders = PosOrder.browse(not_invoiced_orders_ids)
            not_invoiced_orders_names = list(map(lambda a: a.name, not_invoiced_posorders))
            raise UserError(_('No link to an invoice for %s.') % ', '.join(not_invoiced_orders_names))

        return Report.sudo().render('account.report_invoice', {'docs': self.env['account.invoice'].browse(ids_to_print)})<commit_msg>[FIX] point_of_sale: re-print order invoice for pos users only<commit_after># -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import api, models, _
from odoo.exceptions import UserError


class PosInvoiceReport(models.AbstractModel):
    _name = 'report.point_of_sale.report_invoice'

    @api.multi
    def render_html(self, data=None):
        Report = self.env['report']
        PosOrder = self.env['pos.order']
        ids_to_print = []
        invoiced_posorders_ids = []
        selected_orders = PosOrder.browse(self.ids)
        for order in selected_orders.filtered(lambda o: o.invoice_id):
            ids_to_print.append(order.invoice_id.id)
            invoiced_posorders_ids.append(order.id)
        not_invoiced_orders_ids = list(set(self.ids) - set(invoiced_posorders_ids))
        if not_invoiced_orders_ids:
            not_invoiced_posorders = PosOrder.browse(not_invoiced_orders_ids)
            not_invoiced_orders_names = list(map(lambda a: a.name, not_invoiced_posorders))
            raise UserError(_('No link to an invoice for %s.') % ', '.join(not_invoiced_orders_names))

        return Report.sudo().render('account.report_invoice', {'docs': self.env['account.invoice'].sudo().browse(ids_to_print)})
{'fraction_non_alphanumeric': 0.10921366163621922, 'fraction_numerical': 0.0007942811755361397, 'mean_word_length': 3.4901960784313726, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5989449', 'n_tokens_mistral': 843, 'n_tokens_neox': 814, 'n_words': 153}