changes
This commit is contained in:
@@ -23,6 +23,10 @@ class AccountMove(models.Model):
|
||||
string="Has Poynt Receipt",
|
||||
compute='_compute_has_poynt_receipt',
|
||||
)
|
||||
poynt_transaction_count = fields.Integer(
|
||||
string="Poynt Transactions",
|
||||
compute='_compute_poynt_transaction_count',
|
||||
)
|
||||
|
||||
@api.depends('reversal_move_ids')
|
||||
def _compute_poynt_refund_count(self):
|
||||
@@ -38,6 +42,33 @@ class AccountMove(models.Model):
|
||||
for move in self:
|
||||
move.has_poynt_receipt = bool(move._get_poynt_transaction_for_receipt())
|
||||
|
||||
def _compute_poynt_transaction_count(self):
|
||||
for move in self:
|
||||
move.poynt_transaction_count = self.env['payment.transaction'].sudo().search_count([
|
||||
('invoice_ids', 'in', move.id),
|
||||
('provider_code', '=', 'poynt'),
|
||||
])
|
||||
|
||||
def action_view_poynt_transactions(self):
|
||||
"""Open payment transactions linked to this invoice/credit note."""
|
||||
self.ensure_one()
|
||||
transactions = self.env['payment.transaction'].sudo().search([
|
||||
('invoice_ids', 'in', self.id),
|
||||
('provider_code', '=', 'poynt'),
|
||||
])
|
||||
action = {
|
||||
'name': _("Poynt Transactions"),
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': 'payment.transaction',
|
||||
'domain': [('id', 'in', transactions.ids)],
|
||||
}
|
||||
if len(transactions) == 1:
|
||||
action['view_mode'] = 'form'
|
||||
action['res_id'] = transactions.id
|
||||
else:
|
||||
action['view_mode'] = 'list,form'
|
||||
return action
|
||||
|
||||
def action_view_poynt_refunds(self):
|
||||
"""Open the credit notes linked to this invoice that were refunded via Poynt."""
|
||||
self.ensure_one()
|
||||
|
||||
Reference in New Issue
Block a user