Changing the name of model payment.acquirer to payment.provider and everything that it touches. It is technically incorrect to use the term "acquirer" for systems that only provide a service of payment. After this commit the model payment.acquirer and all related to it will be renamed to payment.provider. Task - 2842088 closes odoo/odoo#90899 Related: odoo/upgrade#3542 Related: odoo/documentation#1981 Related: odoo/enterprise#27131 Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
65 lines
2.2 KiB
Python
65 lines
2.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import api, fields, models, _
|
|
from odoo.osv import expression
|
|
|
|
|
|
class AccountPaymentMethodLine(models.Model):
|
|
_inherit = "account.payment.method.line"
|
|
|
|
payment_provider_id = fields.Many2one(
|
|
comodel_name='payment.provider',
|
|
compute='_compute_payment_provider_id',
|
|
store=True
|
|
)
|
|
payment_provider_state = fields.Selection(
|
|
related='payment_provider_id.state'
|
|
)
|
|
|
|
@api.depends('payment_method_id')
|
|
def _compute_payment_provider_id(self):
|
|
providers = self.env['payment.provider'].sudo().search([
|
|
('code', 'in', self.mapped('code')),
|
|
('company_id', 'in', self.journal_id.company_id.ids),
|
|
])
|
|
|
|
# Make sure to pick the active provider, if any.
|
|
providers_map = dict()
|
|
for provider in providers:
|
|
current_value = providers_map.get((provider.code, provider.company_id), False)
|
|
if current_value and current_value.state != 'disabled':
|
|
continue
|
|
|
|
providers_map[(provider.code, provider.company_id)] = provider
|
|
|
|
for line in self:
|
|
code = line.payment_method_id.code
|
|
company = line.journal_id.company_id
|
|
line.payment_provider_id = providers_map.get((code, company), False)
|
|
|
|
@api.model
|
|
def _get_payment_method_domain(self, code):
|
|
# OVERRIDE
|
|
domain = super()._get_payment_method_domain(code)
|
|
information = self._get_payment_method_information().get(code)
|
|
|
|
unique = information.get('mode') == 'unique'
|
|
if unique:
|
|
company_ids = self.env['payment.provider'].sudo().search([('code', '=', code)]).mapped('company_id')
|
|
if company_ids:
|
|
domain = expression.AND([domain, [('company_id', 'in', company_ids.ids)]])
|
|
|
|
return domain
|
|
|
|
def action_open_provider_form(self):
|
|
self.ensure_one()
|
|
return {
|
|
'type': 'ir.actions.act_window',
|
|
'name': _('Provider'),
|
|
'view_mode': 'form',
|
|
'res_model': 'payment.provider',
|
|
'target': 'current',
|
|
'res_id': self.payment_provider_id.id
|
|
}
|