# -*- coding: utf-8 -*- # Copyright 2026 Nexa Systems Inc. # License OPL-1 (Odoo Proprietary License v1.0) # Part of the Fusion Plating product family. from odoo import fields, models class FpVehicle(models.Model): """Vehicle master for the plating shop's pickup & delivery fleet. A vehicle belongs to a facility (its home base), carries insurance, registration and service dates, and tracks its current driver and state. Vehicles flagged `tdg_certified` are approved to carry TDG (Transportation of Dangerous Goods) loads — e.g. stripped parts with residue, waste drums, spent chemistry. The module works without Odoo's Enterprise Fleet module: all fleet-level concerns are modelled here so that CE-only installations are fully supported. """ _name = 'fusion.plating.vehicle' _description = 'Fusion Plating — Vehicle' _inherit = ['mail.thread', 'mail.activity.mixin'] _order = 'name' name = fields.Char( string='Vehicle', required=True, tracking=True, help='Internal name — e.g. "Van 1" or "Box Truck 07".', ) license_plate = fields.Char( string='License Plate', required=True, tracking=True, ) make = fields.Char( string='Make', ) model_year = fields.Integer( string='Model Year', ) vehicle_type = fields.Selection( [ ('van', 'Van'), ('truck_box', 'Box Truck'), ('truck_pickup', 'Pickup Truck'), ('flatbed', 'Flatbed'), ('trailer', 'Trailer'), ('other', 'Other'), ], string='Type', default='van', required=True, tracking=True, ) capacity_kg = fields.Float( string='Capacity (kg)', help='Maximum payload capacity in kilograms.', ) facility_id = fields.Many2one( 'fusion.plating.facility', string='Home Facility', tracking=True, ) company_id = fields.Many2one( 'res.company', related='facility_id.company_id', store=True, readonly=True, ) active = fields.Boolean( default=True, ) insurance_expiry = fields.Date( string='Insurance Expiry', tracking=True, ) registration_expiry = fields.Date( string='Registration Expiry', tracking=True, ) next_service_date = fields.Date( string='Next Service', tracking=True, ) state = fields.Selection( [ ('available', 'Available'), ('in_use', 'In Use'), ('maintenance', 'Maintenance'), ('out_of_service', 'Out of Service'), ], string='Status', default='available', required=True, tracking=True, ) current_driver_id = fields.Many2one( 'hr.employee', string='Current Driver', tracking=True, domain=[('x_fc_is_driver', '=', True)], ) tdg_certified = fields.Boolean( string='TDG Certified', tracking=True, help='Vehicle is approved to carry Transportation of Dangerous ' 'Goods loads.', ) notes = fields.Text( string='Notes', ) _sql_constraints = [ ( 'fp_vehicle_license_plate_uniq', 'unique(license_plate)', 'License plate must be unique.', ), ] def action_mark_available(self): self.write({'state': 'available'}) def action_mark_in_use(self): self.write({'state': 'in_use'}) def action_mark_maintenance(self): self.write({'state': 'maintenance'}) def action_mark_out_of_service(self): self.write({'state': 'out_of_service'})