odex25_standard/odex25_takaful/odex_takaful/models/payment_machine.py

69 lines
2.0 KiB
Python

# -*- coding: utf-8 -*-
from odoo import models, fields, api, _
class PaymentMachine(models.Model):
"""Payment Machine Model for POS Terminals like Gidea, Neoleap, etc."""
_name = 'payment.machine'
_description = 'Payment Machine'
_order = 'name'
_rec_name = 'name'
name = fields.Char(
string='Machine Name',
required=True,
help='Name or identifier of the payment machine'
)
code = fields.Char(
string='Machine Code',
help='Serial number or code of the payment machine'
)
machine_type = fields.Selection([
('neoleap', 'Neoleap'),
('gidea', 'Gidea'),
('other', 'Other'),
], string='Machine Type', required=True, default='neoleap')
machine_type_other = fields.Char(
string='Other Machine Type',
help='Specify the machine type if not listed above'
)
branch_custom_id = fields.Many2one(
'branch.settings',
string='Branch',
required=True,
help='Branch where this payment machine is located'
)
journal_id = fields.Many2one(
'account.journal',
string='Journal',
required=True,
domain="[('type', '=', 'bank')]",
help='Bank journal associated with this payment machine'
)
active = fields.Boolean(
string='Active',
default=True,
help='If unchecked, the machine will be archived and hidden'
)
notes = fields.Text(
string='Notes',
help='Additional notes or information about the machine'
)
_sql_constraints = [
('code_unique', 'UNIQUE(code)', 'Machine code must be unique!'),
]
@api.depends('name', 'code')
def name_get(self):
"""Display name with code if available"""
result = []
for record in self:
if record.code:
name = f"{record.name} [{record.code}]"
else:
name = record.name
result.append((record.id, name))
return result