<commit_before>from datetime import datetime
from osv import osv, fields
from operator import mod

def _get_vehicle_year():
    present_year=datetime.now().year
    years=[]
    for i in range(1970,present_year+2):
        this=(str(i),str(i))
        years.append(this)
    return years


class models(osv.osv):
    _name = "mttl.models"
    _description = "Models"
    _columns = {
        'name': fields.char('Model', size=50, required=True),
        'code':fields.char('Code', size=2, required=True)
    }


class years(osv.osv):
    _name = "mttl.years"
    _description = "Years"
    _columns = {
        'name': fields.char('Year', size=4, required=True),
        'code':fields.char('Code', size=1, required=True)
    }


class location(osv.osv):
    _name = "mttl.locations"
    _description = "Location"
    _columns = {
        'name': fields.char('Location', size=50, required=True),
        'code':fields.char('Code', size=1, required=True)
    }


class country(osv.osv):
    _name = "mttl.countries"
    _description = "Country"
    _rec_name="country_id"
    _columns = {
        'country_id': fields.char('Country', size=50, required=True),
        'code':fields.char('Code', size=1, required=True)
    }


class chassis(osv.osv):
    _name = "mttl.chassis"
    _description = "Chassis"
    _columns = {
        'name': fields.char('Chassiss', size=50, required=True),
        'code':fields.char('Code', size=1, required=True)
    }

class VehicleModel(osv.osv):
    _name = "mttl.vehicle.model"
    _description = "Vehicle Model"
    _columns = {
            'name':fields.char('Model', size=50,required=True),
            'make':fields.many2one('mttl.vehicle.make','Make',required=True)
    }

class VehicleMake(osv.osv):
    _name = "mttl.vehicle.make"
    _description = "Vehicle Make"
    _columns = {
        'name':fields.char('Make', size=20,required=True)
    }

class WarrantyHistory(osv.osv):
    _name = "mttl.warranty.history"
    _description = "Warranty History"
    _columns = {
        'serial_id':fields.many2one('mttl.serials', 'Serial', ondelete='cascade', select=True),
        'date':fields.date('Date'),
        'incident':fields.text('Incident'),
        'action_taken':fields.text('Action Taken'),
        'status':fields.selection([
                   ('in_progress','In Progress'),
                   ('complete','Complete'),
                   ('on_hold','On Hold')], 'Status'),
    }

class partner(osv.osv):
    _inherit="res.partner"
    _columns = {
        'dealer':fields.boolean('Dealer'),
    }
    
class ir_attachment(osv.osv):
    _inherit = "ir.attachment"
    _columns = {
        'mttl_serials_id': fields.many2one('mttl.serials', 'Serial'),
    }
    def create(self, cr, uid, vals, context=None):
        if context is None:
            context = {}
        if vals.get('mttl_serials_id'):
            vals['mttl_serials_id'] = vals['mttl_serials_id']
            vals['res_model'] = 'mttl.serials'             
            
        return super(ir_attachment, self).create(cr, uid, vals, context)
            
class mttl_serials(osv.osv):
    
    def _generate_serial_number(self, cursor, user, *args):
        try:
            cursor.execute("select serial_number from mttl_serials where id=(select max(id) from mttl_serials)")
            for item in cursor.dictfetchall():
                serial_number = int(item["serial_number"]) + 1
            return serial_number
        except Exception, ex:
            return False
    
    _name = "mttl.serials"
    _description = "Serials"
    _rec_name="serial"
    _order = 'create_date'
    _columns = {
        'serial':fields.char('Serial', size=50, help="Add text here"),
        <commit_msg>Make order by create date<commit_after>from datetime import datetime
from osv import osv, fields
from operator import mod

def _get_vehicle_year():
    present_year=datetime.now().year
    years=[]
    for i in range(1970,present_year+2):
        this=(str(i),str(i))
        years.append(this)
    return years


class models(osv.osv):
    _name = "mttl.models"
    _description = "Models"
    _columns = {
        'name': fields.char('Model', size=50, required=True),
        'code':fields.char('Code', size=2, required=True)
    }


class years(osv.osv):
    _name = "mttl.years"
    _description = "Years"
    _columns = {
        'name': fields.char('Year', size=4, required=True),
        'code':fields.char('Code', size=1, required=True)
    }


class location(osv.osv):
    _name = "mttl.locations"
    _description = "Location"
    _columns = {
        'name': fields.char('Location', size=50, required=True),
        'code':fields.char('Code', size=1, required=True)
    }


class country(osv.osv):
    _name = "mttl.countries"
    _description = "Country"
    _rec_name="country_id"
    _columns = {
        'country_id': fields.char('Country', size=50, required=True),
        'code':fields.char('Code', size=1, required=True)
    }


class chassis(osv.osv):
    _name = "mttl.chassis"
    _description = "Chassis"
    _columns = {
        'name': fields.char('Chassiss', size=50, required=True),
        'code':fields.char('Code', size=1, required=True)
    }

class VehicleModel(osv.osv):
    _name = "mttl.vehicle.model"
    _description = "Vehicle Model"
    _columns = {
            'name':fields.char('Model', size=50,required=True),
            'make':fields.many2one('mttl.vehicle.make','Make',required=True)
    }

class VehicleMake(osv.osv):
    _name = "mttl.vehicle.make"
    _description = "Vehicle Make"
    _columns = {
        'name':fields.char('Make', size=20,required=True)
    }

class WarrantyHistory(osv.osv):
    _name = "mttl.warranty.history"
    _description = "Warranty History"
    _columns = {
        'serial_id':fields.many2one('mttl.serials', 'Serial', ondelete='cascade', select=True),
        'date':fields.date('Date'),
        'incident':fields.text('Incident'),
        'action_taken':fields.text('Action Taken'),
        'status':fields.selection([
                   ('in_progress','In Progress'),
                   ('complete','Complete'),
                   ('on_hold','On Hold')], 'Status'),
    }

class partner(osv.osv):
    _inherit="res.partner"
    _columns = {
        'dealer':fields.boolean('Dealer'),
    }
    
class ir_attachment(osv.osv):
    _inherit = "ir.attachment"
    _columns = {
        'mttl_serials_id': fields.many2one('mttl.serials', 'Serial'),
    }
    def create(self, cr, uid, vals, context=None):
        if context is None:
            context = {}
        if vals.get('mttl_serials_id'):
            vals['mttl_serials_id'] = vals['mttl_serials_id']
            vals['res_model'] = 'mttl.serials'             
            
        return super(ir_attachment, self).create(cr, uid, vals, context)
            
class mttl_serials(osv.osv):
    
    def _generate_serial_number(self, cursor, user, *args):
        try:
            cursor.execute("select serial_number from mttl_serials where id=(select max(id) from mttl_serials)")
            for item in cursor.dictfetchall():
                serial_number = int(item["serial_number"]) + 1
            return serial_number
        except Exception, ex:
            return False
    
    _name = "mttl.serials"
    _description = "Serials"
    _rec_name="serial"
    _order = "id desc"
    _columns = {
        'serial':fields.char('Serial', size=50, help="Add text here"),
        
{'fraction_non_alphanumeric': 0.1478987068965517, 'fraction_numerical': 0.0078125, 'mean_word_length': 2.6940298507462686, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6787527', 'n_tokens_mistral': 2534, 'n_tokens_neox': 2457, 'n_words': 445}