Skip to content

Commit

Permalink
[IMP] payment_multic_ux: avoid inverse if running tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cav-adhoc committed Aug 1, 2024
1 parent e836e90 commit e4ac2fa
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions payment_multic_ux/models/payment_provider.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import fields, models

from odoo import fields, models, tools


class PaymentProvider(models.Model):
_inherit = 'payment.provider'

journal_id = fields.Many2one(compute=False, inverse='_inverse_journal_id', domain="[('type', 'in', ('bank', 'cash'))]", check_company=False,)
journal_id = fields.Many2one(compute='_compute_journal_id', inverse='_inverse_journal_id', domain="[('type', 'in', ('bank', 'cash'))]", check_company=False,)

def _compute_journal_id(self):
# Caso de test de odoo account_payment
if tools.config['test_enable']:
super()._compute_journal_id()

def _inverse_journal_id(self):
""" Reemplazamos método original """
for provider in self:
code = provider._get_code()
payment_method_line = self.env['account.payment.method.line'].search([
*self.env['account.payment.method.line']._check_company_domain(provider.company_id),
('code', '=', code),
], limit=1)
if provider.journal_id:
self._link_payment_method_to_journal(provider)
elif payment_method_line:
payment_method_line.unlink()
# Caso de test de odoo account_payment
if tools.config['test_enable']:
super()._inverse_journal_id()
else:
for provider in self:
code = provider._get_code()
payment_method_line = self.env['account.payment.method.line'].search([
*self.env['account.payment.method.line']._check_company_domain(provider.company_id),
('code', '=', code),
], limit=1)
if provider.journal_id:
self._link_payment_method_to_journal(provider)
elif payment_method_line:
payment_method_line.unlink()

def _link_payment_method_to_journal(self, provider):
""" Reemplazamos método original """
Expand Down

0 comments on commit e4ac2fa

Please sign in to comment.