From d61be86bf0581ee6fa1badc66c2afc08fdb5ffc1 Mon Sep 17 00:00:00 2001 From: Gert Pellin Date: Mon, 9 Sep 2019 09:19:01 +0000 Subject: [PATCH] [FIX] point_of_sale: pos_paiment breadcrumb when consulting a pos.payment record, in form view, you get a "False" in the breadcrumbs = the label is empty. Anything we could do about it ? https://nimb.ws/sB7GEQ (NB : it works for returns (=negative amounts) https://nimb.ws/M6QHJm ) This fix sets the breadcrumb to show the payment_id, the only field that is unique for every payment and always has a value. --- addons/point_of_sale/models/pos_payment.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/models/pos_payment.py b/addons/point_of_sale/models/pos_payment.py index 28913dd8a55..7f34d01f4d4 100644 --- a/addons/point_of_sale/models/pos_payment.py +++ b/addons/point_of_sale/models/pos_payment.py @@ -1,4 +1,5 @@ -from odoo import api, fields, models +from odoo import api, fields, models, _ +from odoo.tools import formatLang class PosPayment(models.Model): @@ -25,3 +26,13 @@ class PosPayment(models.Model): company_id = fields.Many2one('res.company', string='Company', related='pos_order_id.company_id') card_type = fields.Char('Type of card used') transaction_id = fields.Char('Payment Transaction ID') + + @api.model + def name_get(self): + res = [] + for payment in self: + if payment.name: + res.append((payment.id, _('%s %s') % (payment.name, formatLang(self.env, payment.amount, currency_obj=payment.currency_id)))) + else: + res.append((payment.id, formatLang(self.env, payment.amount, currency_obj=payment.currency_id))) + return res