from odoo import models, fields, api

class AllowedCountries(models.Model):
    _name = 'kyc.allowed.countries'
    _description = 'Allowed Countries for KYC'
    _order = 'country_id'

    country_id = fields.Many2one('res.country', string='Country', required=True)
    is_active = fields.Boolean(string='Active', default=True)
    created_date = fields.Datetime(string='Created Date', default=fields.Datetime.now)
    
    _sql_constraints = [
        ('unique_country', 'unique(country_id)', 'Country must be unique!')
    ]
    
    def name_get(self):
        result = []
        for record in self:
            name = f"{record.country_id.name} ({record.country_id.code})"
            result.append((record.id, name))
        return result