[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 <pimodoo@users.noreply.github.com>
This commit is contained in:
Pierre Masereel
2019-12-13 09:34:54 +00:00
parent 238a28c515
commit 2889cb91dc
+9 -11
View File
@@ -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 = []