From 029ee8dc0d9ab9c89cbd91279e1e8a7d36faad8e Mon Sep 17 00:00:00 2001 From: Antoine Prieels <anp@odoo.com> Date: Mon, 20 Jan 2020 10:25:46 +0000 Subject: [PATCH] [FIX] point_of_sale: Lost payment info Payment information for terminal transactions (payment_status, transaction_id & card_type) was lost when going back to the floor plan in pos_restaurant. Validated transactions were then considered as not processed yet. closes odoo/odoo#43550 Signed-off-by: pimodoo <pimodoo@users.noreply.github.com> --- addons/point_of_sale/models/pos_order.py | 1 + addons/point_of_sale/models/pos_payment.py | 1 + addons/pos_restaurant/models/pos_order.py | 18 ++++++++++++------ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py index f5372a833b99..91850acbb14f 100644 --- a/addons/point_of_sale/models/pos_order.py +++ b/addons/point_of_sale/models/pos_order.py @@ -61,6 +61,7 @@ class PosOrder(models.Model): 'payment_method_id': ui_paymentline['payment_method_id'], 'card_type': ui_paymentline.get('card_type'), 'transaction_id': ui_paymentline.get('transaction_id'), + 'payment_status': ui_paymentline.get('payment_status'), 'pos_order_id': order.id, } diff --git a/addons/point_of_sale/models/pos_payment.py b/addons/point_of_sale/models/pos_payment.py index 1bfe9f351b0a..a87762f501a6 100644 --- a/addons/point_of_sale/models/pos_payment.py +++ b/addons/point_of_sale/models/pos_payment.py @@ -26,6 +26,7 @@ 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') + payment_status = fields.Char('Payment Status') @api.model def name_get(self): diff --git a/addons/pos_restaurant/models/pos_order.py b/addons/pos_restaurant/models/pos_order.py index b4c2ef669238..8f160c799176 100644 --- a/addons/pos_restaurant/models/pos_order.py +++ b/addons/pos_restaurant/models/pos_order.py @@ -87,6 +87,17 @@ class PosOrder(models.Model): for order_id, order_lines in groupby(extended_order_lines, key=lambda x:x[2]['order_id']): next(order for order in orders if order['id'] == order_id[0])['lines'] = list(order_lines) + def _get_fields_for_payment_lines(self): + return [ + 'id', + 'amount', + 'pos_order_id', + 'payment_method_id', + 'card_type', + 'transaction_id', + 'payment_status' + ] + def _get_payment_lines(self, orders): """Add account_bank_statement_lines to the orders. @@ -97,12 +108,7 @@ class PosOrder(models.Model): """ payment_lines = self.env['pos.payment'].search_read( domain = [('pos_order_id', 'in', [po['id'] for po in orders])], - fields = [ - 'id', - 'amount', - 'pos_order_id', - 'payment_method_id', - ]) + fields = self._get_fields_for_payment_lines()) extended_payment_lines = [] for payment_line in payment_lines: -- GitLab