diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py index 0f3679defea..89320a1a3ef 100644 --- a/addons/account/models/account_payment.py +++ b/addons/account/models/account_payment.py @@ -396,9 +396,7 @@ class AccountPayment(models.Model): else: pay.payment_method_line_id = False - @api.depends('payment_type', - 'journal_id.inbound_payment_method_line_ids', - 'journal_id.outbound_payment_method_line_ids') + @api.depends('payment_type', 'journal_id') def _compute_payment_method_line_fields(self): for pay in self: pay.available_payment_method_line_ids = pay.journal_id._get_available_payment_method_lines(pay.payment_type) diff --git a/addons/account/wizard/account_payment_register.py b/addons/account/wizard/account_payment_register.py index 7facfa8353a..5adf8e3876d 100644 --- a/addons/account/wizard/account_payment_register.py +++ b/addons/account/wizard/account_payment_register.py @@ -289,9 +289,7 @@ class AccountPaymentRegister(models.TransientModel): else: wizard.partner_bank_id = False - @api.depends('payment_type', - 'journal_id.inbound_payment_method_line_ids', - 'journal_id.outbound_payment_method_line_ids') + @api.depends('payment_type', 'journal_id') def _compute_payment_method_line_fields(self): for wizard in self: wizard.available_payment_method_line_ids = wizard.journal_id._get_available_payment_method_lines(wizard.payment_type) @@ -303,9 +301,7 @@ class AccountPaymentRegister(models.TransientModel): wizard.hide_payment_method_line = len(wizard.available_payment_method_line_ids) == 1 \ and wizard.available_payment_method_line_ids.code == 'manual' - @api.depends('payment_type', - 'journal_id.inbound_payment_method_line_ids', - 'journal_id.outbound_payment_method_line_ids') + @api.depends('payment_type', 'journal_id') def _compute_payment_method_line_id(self): for wizard in self: if wizard.payment_type == 'inbound': diff --git a/addons/payment/models/account_journal.py b/addons/payment/models/account_journal.py index ea02bc5a3c0..c0fcd74ef9c 100644 --- a/addons/payment/models/account_journal.py +++ b/addons/payment/models/account_journal.py @@ -13,6 +13,9 @@ class AccountJournal(models.Model): """ Check and ensure that the user do not remove a apml that is linked to an acquirer in the test or enabled state. """ + if not self.company_id: + return + self.env['account.payment.method'].flush(['code', 'payment_type']) self.env['account.payment.method.line'].flush(['payment_method_id']) self.env['payment.acquirer'].flush(['provider', 'state']) @@ -24,7 +27,8 @@ class AccountJournal(models.Model): LEFT JOIN account_payment_method_line apml ON apm.id = apml.payment_method_id WHERE acquirer.state IN ('enabled', 'test') AND apm.payment_type = 'inbound' AND apml.id IS NULL - ''') + AND acquirer.company_id IN %(company_ids)s + ''', {'company_ids': tuple(self.company_id.ids)}) ids = [r[0] for r in self._cr.fetchall()] acquirers = self.env['payment.acquirer'].browse(ids) if acquirers: