mirror of
https://github.com/bringout/oca-ocb-accounting.git
synced 2026-04-24 11:42:02 +02:00
19.0 vanilla
This commit is contained in:
parent
ba20ce7443
commit
768b70e05e
2357 changed files with 1057103 additions and 712486 deletions
|
|
@ -26,7 +26,11 @@ class PaymentRefundWizard(models.TransientModel):
|
|||
string="Refund Amount", compute='_compute_amount_to_refund', store=True, readonly=False
|
||||
)
|
||||
currency_id = fields.Many2one(string="Currency", related='transaction_id.currency_id')
|
||||
support_refund = fields.Selection(related='transaction_id.provider_id.support_refund')
|
||||
support_refund = fields.Selection(
|
||||
string="Refund",
|
||||
selection=[('none', "Unsupported"), ('full_only', "Full Only"), ('partial', "Partial")],
|
||||
compute='_compute_support_refund',
|
||||
)
|
||||
has_pending_refund = fields.Boolean(
|
||||
string="Has a pending refund", compute='_compute_has_pending_refund'
|
||||
)
|
||||
|
|
@ -51,6 +55,20 @@ class PaymentRefundWizard(models.TransientModel):
|
|||
for wizard in self:
|
||||
wizard.amount_to_refund = wizard.amount_available_for_refund
|
||||
|
||||
@api.depends('transaction_id.provider_id', 'transaction_id.payment_method_id')
|
||||
def _compute_support_refund(self):
|
||||
for wizard in self:
|
||||
tx_sudo = wizard.transaction_id.sudo() # needed for users without access to the provider
|
||||
p_support_refund = tx_sudo.provider_id.support_refund
|
||||
pm_sudo = tx_sudo.payment_method_id
|
||||
pm_support_refund = (pm_sudo.primary_payment_method_id or pm_sudo).support_refund
|
||||
if p_support_refund == 'none' or pm_support_refund == 'none':
|
||||
wizard.support_refund = 'none'
|
||||
elif p_support_refund == 'full_only' or pm_support_refund == 'full_only':
|
||||
wizard.support_refund = 'full_only'
|
||||
else: # Both support partial refunds.
|
||||
wizard.support_refund = 'partial'
|
||||
|
||||
@api.depends('payment_id') # To always trigger the compute
|
||||
def _compute_has_pending_refund(self):
|
||||
for wizard in self:
|
||||
|
|
@ -62,5 +80,5 @@ class PaymentRefundWizard(models.TransientModel):
|
|||
wizard.has_pending_refund = pending_refunds_count > 0
|
||||
|
||||
def action_refund(self):
|
||||
for wizard in self:
|
||||
wizard.transaction_id.action_refund(amount_to_refund=wizard.amount_to_refund)
|
||||
self.ensure_one()
|
||||
return self.transaction_id.action_refund(amount_to_refund=self.amount_to_refund)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue