From 961d253f27f19d90db991ff82146f96f6f9b913b Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 1 Jun 2021 23:05:08 +0200 Subject: [PATCH] account_payment_sale: add payment_mode_id in sale.report --- account_payment_sale/models/__init__.py | 1 + account_payment_sale/models/sale_report.py | 27 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 account_payment_sale/models/sale_report.py diff --git a/account_payment_sale/models/__init__.py b/account_payment_sale/models/__init__.py index 6aacb753131f..6b9bbd7b5f33 100644 --- a/account_payment_sale/models/__init__.py +++ b/account_payment_sale/models/__init__.py @@ -1 +1,2 @@ from . import sale_order +from . import sale_report diff --git a/account_payment_sale/models/sale_report.py b/account_payment_sale/models/sale_report.py new file mode 100644 index 000000000000..690aaac014b8 --- /dev/null +++ b/account_payment_sale/models/sale_report.py @@ -0,0 +1,27 @@ +# Copyright 2021 Akretion France (http://www.akretion.com) +# @author Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class SaleReport(models.Model): + _inherit = "sale.report" + + payment_mode_id = fields.Many2one( + "account.payment.mode", + string="Payment Mode", + readonly=True, + ) + + def _query(self, with_clause="", fields=None, groupby="", from_clause=""): + if fields is None: + fields = {} + fields["payment_mode_id"] = ", s.payment_mode_id as payment_mode_id" + groupby += ", s.payment_mode_id" + return super()._query( + with_clause=with_clause, + fields=fields, + groupby=groupby, + from_clause=from_clause, + )