From 56bcfd662849b7c22cf0e2cdc82890b4856840b7 Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Mon, 12 Aug 2019 13:18:01 +0200 Subject: [PATCH] [IMP] Payment roommatik method --- hotel_roommatik/models/inherited_account_payment.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/hotel_roommatik/models/inherited_account_payment.py b/hotel_roommatik/models/inherited_account_payment.py index 67168671f..e6c2ef37e 100644 --- a/hotel_roommatik/models/inherited_account_payment.py +++ b/hotel_roommatik/models/inherited_account_payment.py @@ -11,8 +11,10 @@ class AccountPayment(models.Model): reservation = self.env['hotel.reservation'].search([ '|', ('localizator', '=', code), ('folio_id.name', '=', code)]) + if not reservation: + return False if reservation: - for cashpay in payment['PaymentTransaction']['CashPayments']: + for cashpay in payment['CashPayments']: vals = { 'journal_id': 7, # TODO:config setting 'partner_id': reservation.partner_invoice_id.id, @@ -25,8 +27,8 @@ class AccountPayment(models.Model): 'partner_type': 'customer', 'state': 'draft', } - self.update(vals) - for cashpay in payment['PaymentTransaction']['CreditCardPayments']: + pay = self.create(vals) + for cashpay in payment['CreditCardPayments']: vals = { 'journal_id': 15, # TODO:config setting 'partner_id': reservation.partner_invoice_id.id, @@ -39,5 +41,6 @@ class AccountPayment(models.Model): 'partner_type': 'customer', 'state': 'draft', } - self.update(vals) - self.with_context({'ignore_notification_post': True}).post() + pay = self.create(vals) + pay.post() + return True