[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.
This commit is contained in:
Gert Pellin
2019-09-13 10:05:44 +00:00
committed by Pierre Masereel
parent 2d36eb8baa
commit d61be86bf0
+12 -1
View File
@@ -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