<commit_before># -*- coding: utf-8 -*-

from openerp import models, fields


class computer(models.Model):

    _name = 'it_infrastructure.computer'
    _description = 'Computer'
    _inherit = [
        'it_infrastructure.equipment',
    ]

    hostname = fields.Char(
        string='Hostname',
        required=True
    )

    user_id = fields.Many2one(
        'res.partner',
        string='User'
    )

    username = fields.Char(
        string='Username',
        required=True
    )

    ip_address = fields.Char(
        string='IP Address',
        required=True
    )

    netmask = fields.Char(
        string='Network Mask',
        default='255.255.255.0',
        required=True
    )

    os_id = fields.Many2one(
        'it_infrastructure.software',
        string='Operating System',
        domain=[('category_id.parent_id', 'ilike', 'Operating System')],
        required=True
    )

    hardware_data = fields.Html(
        string='Hardware Data'
    )

    hardware_specs = fields.Binary(
        string='Hardware Specifications'
    )

    note = fields.Html(
        string='Note'
    )

    change_ids = fields.One2many(
        'it_infrastructure.computer_change',
        'computer_id',
        string='Changes'
    )

    _sql_constraints = [
        ('name_uniq', 'unique(name)',
            'Computer name must be unique!'),
    ]<commit_msg>[ADD] Unique hostname and IP address constraints<commit_after># -*- coding: utf-8 -*-

from openerp import models, fields


class computer(models.Model):

    _name = 'it_infrastructure.computer'
    _description = 'Computer'
    _inherit = [
        'it_infrastructure.equipment',
    ]

    hostname = fields.Char(
        string='Hostname',
        required=True
    )

    user_id = fields.Many2one(
        'res.partner',
        string='User'
    )

    username = fields.Char(
        string='Username',
        required=True
    )

    ip_address = fields.Char(
        string='IP Address',
        required=True
    )

    netmask = fields.Char(
        string='Network Mask',
        default='255.255.255.0',
        required=True
    )

    os_id = fields.Many2one(
        'it_infrastructure.software',
        string='Operating System',
        domain=[('category_id.parent_id', 'ilike', 'Operating System')],
        required=True
    )

    hardware_data = fields.Html(
        string='Hardware Data'
    )

    hardware_specs = fields.Binary(
        string='Hardware Specifications'
    )

    note = fields.Html(
        string='Note'
    )

    change_ids = fields.One2many(
        'it_infrastructure.computer_change',
        'computer_id',
        string='Changes'
    )

    _sql_constraints = [
        ('name_unique', 'unique(name)', 'Computer name must be unique!'),
        ('ip_address_unique', 'unique(ip_address)', 'Computer IP address must be unique!'),
        ('hostname_unique', 'unique(hostname)', 'Computer hostname must be unique!')
    ]
{'fraction_non_alphanumeric': 0.1217774762550882, 'fraction_numerical': 0.009497964721845319, 'mean_word_length': 2.2406593406593407, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '5423292', 'n_tokens_mistral': 926, 'n_tokens_neox': 872, 'n_words': 167}