This commit is contained in:
gsinghpal
2026-03-26 15:16:51 -04:00
parent bd7275881f
commit 2563208f53
13 changed files with 329 additions and 15 deletions

View File

@@ -2,7 +2,7 @@
import logging
from odoo import _, models
from odoo import _, api, fields, models
from odoo.exceptions import UserError
_logger = logging.getLogger(__name__)
@@ -11,6 +11,37 @@ _logger = logging.getLogger(__name__)
class SaleOrder(models.Model):
_inherit = 'sale.order'
poynt_transaction_count = fields.Integer(
string="Poynt Transactions",
compute='_compute_poynt_transaction_count',
)
def _compute_poynt_transaction_count(self):
for order in self:
order.poynt_transaction_count = self.env['payment.transaction'].sudo().search_count([
('sale_order_ids', 'in', order.id),
('provider_code', '=', 'poynt'),
])
def action_view_poynt_transactions(self):
self.ensure_one()
transactions = self.env['payment.transaction'].sudo().search([
('sale_order_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_poynt_collect_payment(self):
"""Create an invoice (if needed) and open the Poynt payment wizard.