trytond-network /

Full commit
#This file is part of network module for Tryton.
#The COPYRIGHT file at the top level of this repository contains 
#the full copyright notices and license terms.

from trytond.model import ModelSQL, ModelView, fields

__all__ = [

class Network(ModelSQL, ModelView):
    __name__ = ''

    name = fields.Char('Network name', required=True)
    party = fields.Many2One('', 'Party', required=True)
    hardwares = fields.One2Many('network.hardware', 'network', 'Hardwares')
    domain = fields.Char('Domain')
    ip_address = fields.Char('IP Address')
    note = fields.Text('Notes')

    def __setup__(cls):
        super(Network, cls).__setup__()
        cls._constraints += [
            ('check_domain_or_ip_address', 'domain_or_ip_address_needed'),
                    'You must set at least the domain or IP address.',

    def check_domain_or_ip_address(self):
        if not self.domain and not self.ip_address:
            return False
        return True

class NetworkHardwareType(ModelSQL, ModelView):
    __name__ = 'network.hardware.type'

    name = fields.Char('Type of hardware', required=True, translate=True)

    def default_networkable():
        return False

class NetworkHardware(ModelSQL, ModelView):
    'Network Hardware'
    __name__ = 'network.hardware'

    name = fields.Char('Device Name', required=True)
    network = fields.Many2One('', 'Network', required=True)
    type = fields.Many2One('network.hardware.type', 'Hardware type',
    note = fields.Text('Notes')
    softwares = fields.One2Many('', 'hardware', 'Softwares')
    party = fields.Function(fields.Many2One('', 'Party'),

    def get_party(self, name):

class NetworkSoftwareType(ModelSQL, ModelView):
    'Network Software Type'
    __name__ = ''

    name = fields.Char('Software Type Name', required=True)

class NetworkSoftware(ModelSQL, ModelView):
    'Network Software'
    __name__ = ''

    name = fields.Char('Software name', required=True)
    hardware = fields.Many2One('network.hardware', 'Hardware', required=True)
    type = fields.Many2One('', 'Software Type')
    note = fields.Text('Notes')
    network = fields.Function(fields.Many2One('', 'Network'),
    party = fields.Function(fields.Many2One('', 'Party'),
    logins = fields.One2Many('', 'software',
        'Login Users')

    def get_network(self, name):

    def get_party(self, name):

class NetworkSoftwareLogin(ModelSQL, ModelView):
    'Network Software Login'
    __name__ = ''
    _rec_name = 'login'

    login = fields.Char('User', required=True)
    password = fields.Char('Password', required=True)
    software = fields.Many2One('', 'Software', required=True)
    note = fields.Text('Notes')
    hardware = fields.Function(fields.Many2One('network.hardware', 'Hardware'),
    superuser = fields.Boolean('Super User')
    protocols = fields.One2Many('network.protocol', 'software_login',
        'Connection Protocols')

    def get_hardware(self, login):

class NetworkProtocolType(ModelSQL, ModelView):
    'Network Protocol Type'
    __name__ = 'network.protocol.type'

    name = fields.Char('Protocol Name', required=True)

    def __setup__(cls):
        super(NetworkProtocolType, cls).__setup__()
        cls._order.insert(0, ('name', 'ASC'))

class NetworkProtocol(ModelSQL, ModelView):
    'Network Protocol'
    __name__ = 'network.protocol'

    name = fields.Many2One('network.protocol.type', 'Protocol', required=True)
    note = fields.Text('Notes')
    port = fields.Integer('Port', required=True)
    software_login = fields.Many2One('',
            'Software Login', required=True)