From 2889cb91dc8d3542bb0b06d4a8759e91bd5e43d3 Mon Sep 17 00:00:00 2001 From: Pierre Masereel Date: Fri, 13 Dec 2019 09:34:54 +0000 Subject: [PATCH] [FIX] point_of_sale: payment in sale details When you are printing the sale details report in point_of_sale, there are no payment method shown. It is caused by the changing of model from statement lines to pos payment. So we ar now checking the pos payment instead of the statement lines. ISSUE_ID: 41815 closes odoo/odoo#41867 X-original-commit: 2adce8b01cc19ae2bc0f3236d80d94b9725b32df Signed-off-by: pimodoo --- addons/point_of_sale/models/pos_order.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py index 4ec1285dfa3..f4f3b103609 100644 --- a/addons/point_of_sale/models/pos_order.py +++ b/addons/point_of_sale/models/pos_order.py @@ -796,18 +796,16 @@ class ReportSaleDetails(models.AbstractModel): taxes.setdefault(0, {'name': _('No Taxes'), 'tax_amount':0.0, 'base_amount':0.0}) taxes[0]['base_amount'] += line.price_subtotal_incl - st_line_ids = self.env["account.bank.statement.line"].search([('pos_statement_id', 'in', orders.ids)]).ids - if st_line_ids: + payment_ids = self.env["pos.payment"].search([('pos_order_id', 'in', orders.ids)]).ids + if payment_ids: self.env.cr.execute(""" - SELECT aj.name, sum(amount) total - FROM account_bank_statement_line AS absl, - account_bank_statement AS abs, - account_journal AS aj - WHERE absl.statement_id = abs.id - AND abs.journal_id = aj.id - AND absl.id IN %s - GROUP BY aj.name - """, (tuple(st_line_ids),)) + SELECT method.name, sum(amount) total + FROM pos_payment AS payment, + pos_payment_method AS method + WHERE payment.payment_method_id = method.id + AND payment.id IN %s + GROUP BY method.name + """, (tuple(payment_ids),)) payments = self.env.cr.dictfetchall() else: payments = []