From 261aa927b679b7e84a28b8b4e149d5625bfe4afd Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 14 Jun 2017 16:13:22 +0200 Subject: [PATCH] [FIX] point_of_sale: add_payment Ease the extension of `add_payment`. From work of @benwillig Closes #17598 opw-747348 --- addons/point_of_sale/models/pos_order.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py index 0454cbf203c..2742e708790 100644 --- a/addons/point_of_sale/models/pos_order.py +++ b/addons/point_of_sale/models/pos_order.py @@ -703,7 +703,7 @@ class PosOrder(models.Model): qty_done = pack_operation.product_qty pack_operation.write({'pack_lot_ids': map(lambda x: (0, 0, x), pack_lots), 'qty_done': qty_done}) - def add_payment(self, data): + def _prepare_bank_statement_line_payment_values(self, data): """Create a new payment for the order""" args = { 'amount': data['amount'], @@ -748,8 +748,16 @@ class PosOrder(models.Model): 'journal_id': journal_id, 'ref': self.session_id.name, }) + + return args + + def add_payment(self, data): + """Create a new payment for the order""" + args = self._prepare_bank_statement_line_payment_values(data) + context = dict(self.env.context) + context.pop('pos_session_id', False) self.env['account.bank.statement.line'].with_context(context).create(args) - return statement_id + return args.get('statement_id', False) @api.multi def refund(self):