summaryrefslogtreecommitdiff
path: root/addons/point_of_sale/report/pos_invoice.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/point_of_sale/report/pos_invoice.py
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/point_of_sale/report/pos_invoice.py')
-rw-r--r--addons/point_of_sale/report/pos_invoice.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/addons/point_of_sale/report/pos_invoice.py b/addons/point_of_sale/report/pos_invoice.py
new file mode 100644
index 00000000..bc85f273
--- /dev/null
+++ b/addons/point_of_sale/report/pos_invoice.py
@@ -0,0 +1,30 @@
+# -*- 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'
+ _description = 'Point of Sale Invoice Report'
+
+ @api.model
+ def _get_report_values(self, docids, data=None):
+ PosOrder = self.env['pos.order']
+ ids_to_print = []
+ invoiced_posorders_ids = []
+ selected_orders = PosOrder.browse(docids)
+ for order in selected_orders.filtered(lambda o: o.account_move):
+ ids_to_print.append(order.account_move.id)
+ invoiced_posorders_ids.append(order.id)
+ not_invoiced_orders_ids = list(set(docids) - set(invoiced_posorders_ids))
+ if not_invoiced_orders_ids:
+ not_invoiced_posorders = PosOrder.browse(not_invoiced_orders_ids)
+ not_invoiced_orders_names = [a.name for a in not_invoiced_posorders]
+ raise UserError(_('No link to an invoice for %s.') % ', '.join(not_invoiced_orders_names))
+
+ return {
+ 'docs': self.env['account.move'].sudo().browse(ids_to_print),
+ 'qr_code_urls': self.env['report.account.report_invoice'].sudo()._get_report_values(ids_to_print)['qr_code_urls']
+ }