# -*- coding: utf-8 -*- from odoo import models, fields, api, _ from odoo.exceptions import UserError class AccountPaymentRegister(models.TransientModel): _inherit = 'account.payment.register' def _create_payment_vals_from_wizard(self): payment_vals = { 'date': self.payment_date, 'amount': self.amount, 'payment_type': self.payment_type, 'partner_type': self.partner_type, 'ref': self.communication, 'journal_id': self.journal_id.id, 'is_hr': True, 'currency_id': self.currency_id.id, 'partner_id': self.partner_id.id, 'partner_bank_id': self.partner_bank_id.id, 'payment_method_id': self.payment_method_id.id, 'destination_account_id': self.line_ids[0].account_id.id } if not self.currency_id.is_zero(self.payment_difference) and self.payment_difference_handling == 'reconcile': payment_vals['write_off_line_vals'] = { 'name': self.writeoff_label, 'amount': self.payment_difference, 'account_id': self.writeoff_account_id.id, } return payment_vals def _create_payment_vals_from_batch(self, batch_result): batch_values = self._get_wizard_values_from_batch(batch_result) return { 'date': self.payment_date, 'amount': batch_values['source_amount_currency'], 'payment_type': batch_values['payment_type'], 'partner_type': batch_values['partner_type'], 'ref': self._get_batch_communication(batch_result), 'journal_id': self.journal_id.id, 'is_hr': True, 'currency_id': batch_values['source_currency_id'], 'partner_id': batch_values['partner_id'], 'partner_bank_id': batch_result['key_values']['partner_bank_id'], 'payment_method_id': self.payment_method_id.id, 'destination_account_id': batch_result['lines'][0].account_id.id }