mirror of
https://github.com/bringout/oca-ocb-accounting.git
synced 2026-04-26 12:22:05 +02:00
19.0 vanilla
This commit is contained in:
parent
ba20ce7443
commit
768b70e05e
2357 changed files with 1057103 additions and 712486 deletions
|
|
@ -25,8 +25,6 @@ class AccountPaymentRegister(models.TransientModel):
|
|||
use_electronic_payment_method = fields.Boolean(
|
||||
compute='_compute_use_electronic_payment_method',
|
||||
)
|
||||
payment_method_code = fields.Char(
|
||||
related='payment_method_line_id.code')
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# COMPUTE METHODS
|
||||
|
|
@ -35,21 +33,18 @@ class AccountPaymentRegister(models.TransientModel):
|
|||
@api.depends('payment_method_line_id')
|
||||
def _compute_suitable_payment_token_ids(self):
|
||||
for wizard in self:
|
||||
wizard.suitable_payment_token_ids = [Command.clear()]
|
||||
if wizard.can_edit_wizard and wizard.use_electronic_payment_method:
|
||||
related_partner_ids = (
|
||||
wizard.partner_id
|
||||
| wizard.partner_id.commercial_partner_id
|
||||
| wizard.partner_id.commercial_partner_id.child_ids
|
||||
)._origin
|
||||
|
||||
token_partners = wizard.partner_id
|
||||
lines_partners = wizard.batches[0]['lines'].move_id.partner_id
|
||||
if len(lines_partners) == 1:
|
||||
token_partners |= lines_partners
|
||||
wizard.suitable_payment_token_ids = self.env['payment.token'].sudo().search([
|
||||
('company_id', '=', wizard.company_id.id),
|
||||
*self.env['payment.token']._check_company_domain(wizard.company_id),
|
||||
('partner_id', 'in', token_partners.ids),
|
||||
('provider_id.capture_manually', '=', False),
|
||||
('partner_id', 'in', related_partner_ids.ids),
|
||||
('provider_id', '=', wizard.payment_method_line_id.payment_provider_id.id),
|
||||
])
|
||||
else:
|
||||
wizard.suitable_payment_token_ids = [Command.clear()]
|
||||
|
||||
@api.depends('payment_method_line_id')
|
||||
def _compute_use_electronic_payment_method(self):
|
||||
|
|
@ -59,28 +54,17 @@ class AccountPaymentRegister(models.TransientModel):
|
|||
codes = [key for key in dict(self.env['payment.provider']._fields['code']._description_selection(self.env))]
|
||||
wizard.use_electronic_payment_method = wizard.payment_method_code in codes
|
||||
|
||||
@api.onchange('can_edit_wizard', 'payment_method_line_id', 'journal_id')
|
||||
@api.depends('can_edit_wizard', 'suitable_payment_token_ids', 'journal_id')
|
||||
def _compute_payment_token_id(self):
|
||||
codes = [key for key in dict(self.env['payment.provider']._fields['code']._description_selection(self.env))]
|
||||
for wizard in self:
|
||||
related_partner_ids = (
|
||||
wizard.partner_id
|
||||
| wizard.partner_id.commercial_partner_id
|
||||
| wizard.partner_id.commercial_partner_id.child_ids
|
||||
)._origin
|
||||
if wizard.can_edit_wizard \
|
||||
and wizard.payment_method_line_id.code in codes \
|
||||
and wizard.journal_id \
|
||||
and related_partner_ids:
|
||||
|
||||
wizard.payment_token_id = self.env['payment.token'].sudo().search([
|
||||
('company_id', '=', wizard.company_id.id),
|
||||
('partner_id', 'in', related_partner_ids.ids),
|
||||
('provider_id.capture_manually', '=', False),
|
||||
('provider_id', '=', wizard.payment_method_line_id.payment_provider_id.id),
|
||||
], limit=1)
|
||||
else:
|
||||
if wizard.payment_method_line_id and wizard.payment_method_line_id.code not in codes:
|
||||
wizard.payment_token_id = False
|
||||
elif wizard.payment_token_id in wizard.suitable_payment_token_ids:
|
||||
# The selected payment token is still valid.
|
||||
continue
|
||||
else:
|
||||
wizard.payment_token_id = wizard.suitable_payment_token_ids[:1]
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# BUSINESS METHODS
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue