Debian Codegraph @

addons/point_of_sale/report/pos_invoice.py

raw
1 # -*- coding: utf-8 -*-
2 # Part of Odoo. See LICENSE file for full copyright and licensing details.
3
4 from odoo import api, models, _
5 from odoo.exceptions import UserError
6
7
8 class ReportPoint_Of_SaleReport_Invoice(models.AbstractModel):
9 _name = 'report.point_of_sale.report_invoice'
10 _description = 'Point of Sale Invoice Report'
11
12 @api.model
13 def _get_report_values(self, docids, data=None):
14 PosOrder = self.env['pos.order']
15 ids_to_print = []
16 invoiced_posorders_ids = []
17 selected_orders = PosOrder.browse(docids)
18 for order in selected_orders.filtered(lambda o: o.account_move):
19 ids_to_print.append(order.account_move.id)
20 invoiced_posorders_ids.append(order.id)
21 not_invoiced_orders_ids = list(set(docids) - set(invoiced_posorders_ids))
22 if not_invoiced_orders_ids:
23 not_invoiced_posorders = PosOrder.browse(not_invoiced_orders_ids)
24 not_invoiced_orders_names = [a.name for a in not_invoiced_posorders]
25 raise UserError(_('No link to an invoice for %s.', ', '.join(not_invoiced_orders_names)))
26
27 return {
28 'docs': self.env['account.move'].sudo().browse(ids_to_print),
29 'qr_code_urls': self.env['report.account.report_invoice'].sudo()._get_report_values(ids_to_print)['qr_code_urls']
30 }