Skip to Content
Menu
This question has been flagged
1 Reply
653 Views

how to automatically create a unique chassis number, consisting of

1️⃣ VIN (Vehicle Identification Number) Structure

General Format:

MG3-VDS-VIS (17 characters in total)

________________________________________

1.1 WMI (World Manufacturer Identifier)

- 3 characters

MG3

- M = Asia

- G = Indonesia

- 3 = PT Marlip Indo Mandiri

________________________________________

1.2 VDS (Vehicle Descriptor Section)

- 6 characters

Format: V-K-MMM

- V = Vehicle Type Code

- K = Battery Capacity Code

- MMM = Vehicle Model Code

V/VEHICLE TYPE CODE:

L1 = 2 Wheel Max speed 50km/h

L2 = 3 Wheel max speed 50km/h

L3 = Wheel 2 Speed More than 50km / hour

L4 = 3 Wheel Speed More than 50km/hour

L5 = Custom 2 Wheel & 3 Wheel

M1 = Passenger Car Max 8 seats

M2 = Passenger Car 8-23 seats

M3 = Passenger Car More than 23 seats

N1 = Goods Car GVW Max 3500kg

N2 = Goods Car GVW More than 3500kg & Max 12000kg

N3 = Goods Car GVW Over 12000kg

D/Code Battery Capacity:

S = 1 - 6 kWh

M = 6.1 - 20 kWh

L = 20.1 - 120 kWh

H = More than 120kWh

S/Vehicle Model Code:

MSP = Motor Sport

MSK = Motor Scooter

MTR = Trail Motorcycle

MCS = Custom Motorcycle

M3K = Cargo 3 Wheel Motorcycle

M3P = Passenger 3 Wheel Motorcycle

M3S = Multipurpose 3 Wheel Motorcycle

MCC = City Car

MSH = Sedan & Hatchback Car

MPV = Multy Purpose Car

MSU = Sport Utility Car

MBS = Micro Bus Shuttle

MBL = Micro Bus Ramp

MBM = Medium Bus Car

MBB = Large Bus Car

UCP = Urban Cargo Pickup

UCL = Urban Cargo Platform

TR1 = Light Truck Platform

TR4 = 4x4 Truck Platform

Example:

- M2LMBM = 8-23 seat passenger car, 20.1-120kWh Battery, Medium Bus Model

________________________________________

1.3 VIS (Vehicle Identifier Section) - 8 characters

Format: Y-L-SSSSS

- Y = Year of Production (S = 2025)

- L = Production Location (J = West Java)

- SSSSS = Production Serial Number (00001 to 99999)

Example VIS: SJ00001

Complete VIN Example: MG3M2LMBMSJ00001


Avatar
Discard
Best Answer
  1. Fixed WMI: "MG3" (constant).
  2. VDS: Built from three input fields:
    • Vehicle Type Code (e.g. "M2")
    • Battery Capacity Code (e.g. "L")
    • Vehicle Model Code (e.g. "MBM")
  3. VIS: Constructed as:
    • Year code "S" for 2025 (map your production year to letter)
    • Location code (e.g. "J")
    • Serial number: a 5-digit zero-padded sequence, unique per year+location.


Sample Python code (inside your Odoo model):

from odoo import models, fields, api

from datetime import datetime


class Vehicle(models.Model):

    _name = 'your_module.vehicle'

    _description = 'Vehicle'


    vehicle_type_code = fields.Selection([...], string="Vehicle Type Code")  # e.g. 'M2'

    battery_capacity_code = fields.Selection([...], string="Battery Capacity Code")  # e.g. 'L'

    vehicle_model_code = fields.Selection([...], string="Vehicle Model Code")  # e.g. 'MBM'

    production_year = fields.Integer(string="Production Year", default=lambda self: datetime.now().year)

    production_location_code = fields.Char(string="Production Location Code")  # e.g. 'J'


    vin = fields.Char(string="VIN", compute="_compute_vin", store=True, readonly=True)


    @api.depends('vehicle_type_code', 'battery_capacity_code', 'vehicle_model_code', 'production_year', 'production_location_code')

    def _compute_vin(self):

        for record in self:

            # Map production year to letter, example: 2025 = 'S'

            year_map = {2025: 'S'}  # Extend as needed

            year_code = year_map.get(record.production_year, 'X')  # Default 'X' if unknown


            # Serial number generation - find max serial for same year + location

            domain = [

                ('production_year', '=', record.production_year),

                ('production_location_code', '=', record.production_location_code),

            ]

            existing_vins = self.search(domain)

            max_serial = 0

            for v in existing_vins:

                if v.vin and len(v.vin) >= 17:

                    serial_str = v.vin[-5:]

                    if serial_str.isdigit():

                        max_serial = max(max_serial, int(serial_str))

            new_serial = str(max_serial + 1).zfill(5)  # zero padded 5 digit


            # Compose VIN

            wmi = "MG3"

            vds = (record.vehicle_type_code or '') + (record.battery_capacity_code or '') + (record.vehicle_model_code or '')

            vis = year_code + (record.production_location_code or '') + new_serial


            record.vin = wmi + vds + vis

The VIN is automatically computed combining WMI + VDS + VIS.

Serial numbers increment uniquely per production year and location.

Extend year_map as needed for other years.

Use dropdowns for the codes (Selection fields) to restrict inputs.

Avatar
Discard
Related Posts Replies Views Activity
0
Apr 25
684
0
Jul 22
2217
6
Mar 18
5873
3
Mar 15
45704
1
Mar 15
7020