from odoo import models, fields


class LogisticsContainerType(models.Model):
    _name = 'logistics.container.type'
    _description = 'Logistics Container Type'
    _order = 'container_category, name'

    name = fields.Char(
        string='Container Type Name',
        required=True,
        help='Name of the container type (e.g., 20ft Dry Container, 40ft Refrigerated)'
    )
    
    container_category = fields.Selection([
        ('dry', 'Dry Container'),
        ('reefer', 'Refrigerated'),
        ('tank', 'Tank Container'),
        ('bulk', 'Bulk Container'),
        ('flat', 'Flat Rack'),
        ('open', 'Open Top'),
        ('special', 'Special Purpose'),
    ], string='Container Category', required=True)
    
    max_payload = fields.Float(
        string='Max Payload (kg)',
        help='Maximum cargo weight'
    )
    
    active = fields.Boolean(
        string='Active',
        default=True
    )

    def name_get(self):
        result = []
        for record in self:
            category = dict(record._fields['container_category'].selection)[record.container_category]
            name = f"{record.name} ({category})"
            result.append((record.id, name))
        return result