change module name

This commit is contained in:
Camilo Sarmiento 2019-09-04 15:32:21 -05:00
parent 6211c84d59
commit 97c5632e49
38 changed files with 853 additions and 77 deletions

View File

@ -12,8 +12,8 @@ def register():
server.Server,
server.Database,
server.PricePlan,
module='vps_management', type_='model')
module='vps', type_='model')
Pool.register(
module='vps_management', type_='wizard')
module='vps', type_='wizard')
Pool.register(
module='vps_management', type_='report')
module='vps', type_='report')

View File

@ -0,0 +1,19 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.pool import Pool
from . import configuration
from . import server
from . import supplier
def register():
Pool.register(
configuration.Configuration,
supplier.SupplierVps,
server.Server,
server.Database,
server.PricePlan,
module='vps', type_='model')
Pool.register(
module='vps', type_='wizard')
Pool.register(
module='vps', type_='report')

View File

@ -0,0 +1,17 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.model import ModelView, ModelSQL, fields, ModelSingleton
from trytond.pyson import Eval, If
__all__ = ['Configuration']
class Configuration(ModelSingleton, ModelSQL, ModelView):
'Vps manager Configuration'
__name__ = 'vps.configuration'
limit_days_expired = fields.Integer('Limit Days for Expired', required=True)
company = fields.Many2One('company.company', 'Company', required=True,
domain=[
('id', If(Eval('context', {}).contains('company'), '=', '!='),
Eval('context', {}).get('company', 0)),
])

View File

@ -0,0 +1,28 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data>
<record model="ir.ui.view" id="vps_configuration_view_form">
<field name="model">vps.configuration</field>
<field name="type">form</field>
<field name="name">configuration_form</field>
</record>
<record model="ir.action.act_window" id="act_vps_configuration_form">
<field name="name">Vps Management Configuration</field>
<field name="res_model">vps.configuration</field>
</record>
<record model="ir.action.act_window.view"
id="act_vps_management_configuration_view1">
<field name="sequence" eval="1"/>
<field name="view" ref="vps_configuration_view_form"/>
<field name="act_window" ref="act_vps_configuration_form"/>
</record>
<menuitem name="General Configuration" parent="menu_configuration"
action="act_vps_configuration_form" sequence="20"
id="menu_vps_configuration" icon="tryton-list"/>
</data>
</tryton>

View File

@ -0,0 +1 @@
<svg height="512pt" viewBox="0 0 512.08706 512" width="512pt" xmlns="http://www.w3.org/2000/svg"><path d="m504.085938 256.042969c0 136.96875-111.03125 248-248 248-136.964844 0-248-111.03125-248-248 0-136.964844 111.035156-248 248-248 136.96875 0 248 111.035156 248 248zm0 0" fill="#91e8ed"/><path d="m128.085938 320.042969-48-32v-40l16-24 32-16 16-28v-68l-32-24h-38.398438c-79.535156 86.277343-87.65625 216.511719-19.449219 312h33.847657l44-24 8-28zm0 0" fill="#9ccc65"/><path d="m404.6875 57.484375-40.601562 22.558594h-72l-36 20-20 80-20 16v32l24 48 56 16h205.367187c13.214844-90.023438-23.9375-180.054688-96.796875-234.558594zm0 0" fill="#9ccc65"/><path d="m240.085938 448.042969h-56l-44.71875 26.832031c74.421874 39.6875 163.910156 38.832031 237.558593-2.273438l-72.839843-48.558593zm0 0" fill="#9ccc65"/><path d="m296.085938 128.042969h208v256h-208zm0 0" fill="#00c3ff"/><g fill="#fff"><path d="m320.085938 344.042969h16v16h-16zm0 0"/><path d="m352.085938 344.042969h16v16h-16zm0 0"/><path d="m384.085938 344.042969h16v16h-16zm0 0"/><path d="m320.085938 280.042969h16v16h-16zm0 0"/><path d="m352.085938 280.042969h16v16h-16zm0 0"/><path d="m384.085938 280.042969h16v16h-16zm0 0"/><path d="m320.085938 216.042969h16v16h-16zm0 0"/><path d="m352.085938 216.042969h16v16h-16zm0 0"/><path d="m384.085938 216.042969h16v16h-16zm0 0"/><path d="m320.085938 152.042969h16v16h-16zm0 0"/><path d="m352.085938 152.042969h16v16h-16zm0 0"/><path d="m384.085938 152.042969h16v16h-16zm0 0"/></g><path d="m416.085938 344.042969h64v16h-64zm0 0"/><path d="m416.085938 280.042969h64v16h-64zm0 0"/><path d="m416.085938 216.042969h64v16h-64zm0 0"/><path d="m472.886719 120.042969c-65.382813-104.269531-195.707031-147.257813-310.292969-102.351563-114.589844 44.90625-181.003906 164.996094-158.132812 285.925782 22.867187 120.929687 128.554687 208.46875 251.625 208.425781 88.019531-.304688 169.777343-45.566407 216.753906-120h39.246094v-272zm-19.113281 0h-165.6875v161.390625l-42.398438-12.117188-21.601562-43.160156v-26.273438l19.105468-15.28125 19.816406-79.246093 31.152344-17.3125h72l37.816406-21.007813-.113281-.199218c19.25 15.09375 36.085938 33.035156 49.929688 53.207031zm-437.6875 136c-.039063-59.078125 21.796874-116.074219 61.304687-160h32l26.695313 20v61.871093l-13.742188 24.058594-31.738281 15.863282-18.519531 27.808593v46.703125l49.601562 33.054688 9.945312 23.199218-6.304687 22.042969-39.28125 21.398438h-27.558594c-27.65625-39.957031-42.449219-87.40625-42.402343-136zm240 240c-34.511719.019531-68.617188-7.449219-99.957032-21.894531l30.175782-18.105469h55.199218l61.527344-23.070313 58.015625 38.679688c-32.679687 16-68.574219 24.339844-104.960937 24.390625zm120.929687-33-71.90625-47.925781-66.46875 24.925781h-56.800781l-41.90625 25.144531.746094 1.230469c-26.894532-14.820313-50.71875-34.632813-70.191407-58.375h19.613281l48.738282-26.574219 9.695312-33.960938-14.054687-32.800781-46.394531-30.945312v-33.316407l13.480468-20.21875 32.265625-16.136718 18.253907-31.917969v-74.128906l-37.335938-28h-21.597656c81.523437-75.578125 204.277344-85.28125 296.664062-23.449219l-27.800781 15.449219h-72l-40.847656 22.6875-20.183594 80.753906-20.898437 16.71875v37.726563l26.402343 52.84375 53.597657 15.308593v93.960938h165.746093c-20.09375 29.011719-46.316406 53.25-76.816406 71zm119.070313-87h-192v-48h192zm0-64h-192v-48h192zm0-64h-192v-48h192zm0-64h-192v-48h192zm0 0"/><path d="m416.085938 152.042969h64v16h-64zm0 0"/></svg>

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -0,0 +1,200 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from datetime import datetime, timedelta, date
from trytond.model import Workflow, ModelView, ModelSQL, fields
from trytond.report import Report
from trytond.pyson import Eval, If, In, Get
from trytond.transaction import Transaction
from trytond.pool import Pool
from trytond.wizard import Wizard, StateTransition
import psycopg2
from psycopg2 import Error
import os
__all__ = ['Server', 'Database', 'PricePlan']
STATES = {
'readonly': Eval('state') != 'draft',
}
class Database(Workflow, ModelSQL, ModelView):
'Database'
__name__ = 'vps.databases'
_rec_name = 'name'
vps = fields.Many2One('vps.server', 'Server',
required=True, )
price_plan = fields.Many2One('vps.price_plan', 'Price Plan',)
name = fields.Char('Name Database', required=True,)
state = fields.Selection([
('enable', 'Enable'),
('disable', 'Disable'),
], 'State', readonly=True, required=True,)
customer = fields.Many2One('party.party', 'Customer')
invoices_expiration = fields.Function(fields.Integer('Invoices Expiration'),
'get_invoices_expiration')
@classmethod
def __setup__(cls):
super(Database, cls).__setup__()
cls._order = [
('name', 'DESC'),
]
cls._transitions |= set((
('disable', 'enable'),
('enable', 'disable'),
))
cls._buttons.update({
'disable': {
'invisible': Eval('state') != 'enable',
},
'enable': {
'invisible': Eval('state') != 'disable',
},
})
cls._error_messages.update({
'disable_warning': ('Sure you want to disable database!'),
})
@staticmethod
def default_state():
return 'enable'
@classmethod
@ModelView.button
@Workflow.transition('disable')
def disable(cls, records):
for record in records:
record.allow_connections_database(False)
pass
@classmethod
@ModelView.button
@Workflow.transition('enable')
def enable(cls, records):
for record in records:
record.allow_connections_database(True)
pass
def allow_connections_database(self, allow):
connection = None
try:
# connection = psycopg2.connect(user = "psk",
# password = "sion21",
# host = "45.63.106.42",
# port = "5432",
# database = "postgres")
connection = psycopg2.connect(user = self.vps.user,
password = self.vps.password,
host = self.vps.ip_address,
port = self.vps.port,
database = "postgres")
cursor = connection.cursor()
create_table_query_1 = ''
create_table_query_2 = ''
if allow:
create_table_query_1 = '''alter database "'''+self.name+'''" with allow_connections true; '''
create_table_query_2 = '''alter database "'''+self.name+'''" connection limit -1; '''
else:
create_table_query_1 = '''alter database "'''+self.name+'''" with allow_connections false; '''
create_table_query_2 = '''alter database "'''+self.name+'''" connection limit 0; '''
cursor.execute(create_table_query_1)
cursor.execute(create_table_query_2)
connection.commit()
print("process successfully in PostgreSQL ")
except (Exception, psycopg2.DatabaseError) as error:
print(("Error while executed process", error))
finally:
#closing database connection.
if(connection):
cursor.close()
connection.close()
print("PostgreSQL connection is closed")
# os.popen("sudo systemctl restart strytond.service", 'w').write('12345678')
def get_invoices_expiration(self, name):
Invoice = Pool().get('account.invoice')
Configuration = Pool().get('vps.configuration')
config = Configuration(1)
InvoicePaymentTermLineDelta = Pool().get('account.invoice.payment_term.line.delta')
invoices = Invoice.search([
('party', '=', self.customer),
('state', 'in', ['validated', 'posted']),
])
now = date.today()
invoices_expired = 0
if config and config.limit_days_expired:
for invoice in invoices:
invoice_payment_term_line_delta = InvoicePaymentTermLineDelta.search([
('line.payment', '=', invoice.payment_term),
])
if invoice.invoice_date and invoice_payment_term_line_delta:
d_expired = int((now - invoice.invoice_date).days)
d_expired = int(d_expired - invoice_payment_term_line_delta[0].days)
if d_expired <= 0:
invoices_expired += 0
else:
if d_expired >= config.limit_days_expired:
invoices_expired += 1
# setattr(invoice, 'days_expired', days_expired)
return invoices_expired
class Server(ModelSQL, ModelView):
'Vps Server'
__name__ = 'vps.server'
_rec_name = 'name'
supplier = fields.Many2One('vps.supplier', 'Supplier', ondelete='RESTRICT', required=True)
active = fields.Boolean('Active')
name = fields.Char('Name', required=True,)
user = fields.Char('User', required=True, )
ip_address = fields.Char('IP Address', required=True,)
port = fields.Char('Port', required=True,)
password = fields.Char('Password', required=True,)
# route = fields.Char('Route', states=STATES)
databases = fields.One2Many('vps.databases', 'vps', 'Databases',)
state = fields.Selection([
('stop', 'Stop'),
('execution', 'Execution'),
], 'State', required=True,)
location = fields.Char('Location')
@staticmethod
def default_state():
return 'draft'
@staticmethod
def default_active():
return True
@classmethod
def disable_databases(cls):
Database = Pool().get('vps.databases')
databases = Database.search([
('state', '=', 'enable'),
('vps.active', '=', True),
])
for db in databases:
if db.price_plan and db.price_plan.kind != 'free' and db.invoices_expiration >= 1:
db.allow_connections_database(False)
class PricePlan(ModelSQL, ModelView):
'Price Plan'
__name__ = 'vps.price_plan'
_rec_name = 'name'
name = fields.Char('Name', required=True,)
kind = fields.Selection([
('free', 'Free'),
('payment', 'Payment'),
], 'Kind', required=True,)

View File

@ -0,0 +1,80 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data>
<record model="ir.ui.view" id="vps_server_view_form">
<field name="model">vps.server</field>
<field name="type">form</field>
<field name="name">vps_server_view_form</field>
</record>
<record model="ir.ui.view" id="vps_server_view_tree">
<field name="model">vps.server</field>
<field name="type">tree</field>
<field name="name">vps_server_view_tree</field>
</record>
<record model="ir.action.act_window" id="act_vps_server_form">
<field name="name">VPS</field>
<field name="res_model">vps.server</field>
</record>
<record model="ir.action.act_window.view" id="act_vps_server_form_view1">
<field name="sequence" eval="1"/>
<field name="view" ref="vps_server_view_tree"/>
<field name="act_window" ref="act_vps_server_form"/>
</record>
<record model="ir.action.act_window.view" id="act_vps_server_form_view2">
<field name="sequence" eval="2"/>
<field name="view" ref="vps_server_view_form"/>
<field name="act_window" ref="act_vps_server_form"/>
</record>
<menuitem parent="menu_vps" sequence="30"
action="act_vps_server_form" id="menu_vps_management_form"/>
<record model="ir.ui.view" id="vps_management_price_plan_view_form">
<field name="model">vps.price_plan</field>
<field name="type">form</field>
<field name="name">price_plan_form</field>
</record>
<record model="ir.ui.view" id="vps_management_price_plan_view_tree">
<field name="model">vps.price_plan</field>
<field name="type">tree</field>
<field name="name">price_plan_tree</field>
</record>
<record model="ir.action.act_window" id="act_vps_management_price_plan_form">
<field name="name">Price Plan</field>
<field name="res_model">vps.price_plan</field>
</record>
<record model="ir.action.act_window.view" id="act_vps_price_plan_form_view1">
<field name="sequence" eval="1"/>
<field name="view" ref="vps_management_price_plan_view_tree"/>
<field name="act_window" ref="act_vps_management_price_plan_form"/>
</record>
<record model="ir.action.act_window.view" id="act_vps_management_price_plan_form_1">
<field name="sequence" eval="1"/>
<field name="view" ref="vps_management_price_plan_view_form"/>
<field name="act_window" ref="act_vps_management_price_plan_form"/>
</record>
<menuitem name="Price Plan" parent="menu_configuration"
action="act_vps_management_price_plan_form" sequence="30"
id="menu_vps_management_plan_price" icon="tryton-list"/>
<record model="ir.ui.view" id="database_reel_view_form">
<field name="model">vps.databases</field>
<field name="type">form</field>
<field name="name">database_reel_view_form</field>
</record>
<record model="ir.ui.view" id="database_reel_view_tree">
<field name="model">vps.databases</field>
<field name="type">tree</field>
<field name="name">database_reel_view_tree</field>
</record>
</data>
</tryton>

View File

@ -0,0 +1,64 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from datetime import datetime, timedelta, date
from trytond.model import Workflow, ModelView, ModelSQL, fields
from trytond.report import Report
from trytond.pyson import Eval, If, In, Get
from trytond.transaction import Transaction
from trytond.pool import Pool
from trytond.wizard import Wizard, StateTransition
import psycopg2
from psycopg2 import Error
import os
__all__ = ['SupplierVps']
STATES = {
'readonly': Eval('state') != 'draft',
}
class SupplierVps(ModelSQL, ModelView):
'Supplier Vps'
_rec_name = 'party.name'
__name__ = 'vps.supplier'
party = fields.Many2One('party.party', 'Party')
servers = fields.Function(fields.One2Many('vps.server', None,
'Servers', add_remove=[]), 'get_servers')
# @classmethod
# def __setup__(cls):
# super(SupplierVps, cls).__setup__()
# cls._order = [
# ('party', 'DESC'),
# ]
def get_servers(self, name):
Server = Pool().get('vps.server')
servers = Server.search([
('supplier.party', '=', self.party),
])
return [server.id for server in servers]
def get_rec_name(self, name):
rec_name = self.party.name
self._rec_name = rec_name
return (self._rec_name )
@classmethod
def search_rec_name(cls, name, clause):
if clause[1].startswith('!') or clause[1].startswith('not '):
bool_op = 'AND'
else:
bool_op = 'OR'
return [bool_op,
('party.name',) + tuple(clause[1:]),
('party.code',) + tuple(clause[1:]),
]

View File

@ -0,0 +1,35 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data>
<record model="ir.ui.view" id="vps_supplier_view_form">
<field name="model">vps.supplier</field>
<field name="type">form</field>
<field name="name">vps_supplier_view_form</field>
</record>
<record model="ir.ui.view" id="vps_supplier_view_tree">
<field name="model">vps.supplier</field>
<field name="type">tree</field>
<field name="name">vps_supplier_view_tree</field>
</record>
<record model="ir.action.act_window" id="act_vps_supplier_form">
<field name="name">VPS Suppliers</field>
<field name="res_model">vps.supplier</field>
</record>
<record model="ir.action.act_window.view" id="act_vps_supplier_form_view1">
<field name="sequence" eval="1"/>
<field name="view" ref="vps_supplier_view_tree"/>
<field name="act_window" ref="act_vps_supplier_form"/>
</record>
<record model="ir.action.act_window.view" id="act_vps_supplier_form_view2">
<field name="sequence" eval="2"/>
<field name="view" ref="vps_supplier_view_form"/>
<field name="act_window" ref="act_vps_supplier_form"/>
</record>
<menuitem parent="menu_vps" sequence="40"
action="act_vps_supplier_form" id="menu_vps_form_supplier"/>
</data>
</tryton>

View File

@ -0,0 +1,6 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from .test_vps_management import suite
__all__ = ['suite']

View File

@ -0,0 +1,12 @@
[tryton]
version=5.0.0
depends:
party
company
account
account_invoice
xml:
vps.xml
server.xml
configuration.xml
supplier.xml

View File

@ -0,0 +1,9 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<form>
<label name="company"/>
<field name="company"/>
<label name="limit_days_expired"/>
<field name="limit_days_expired"/>
</form>

View File

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<form>
<label name="name"/>
<field name="name"/>
<label name="state"/>
<field name="state"/>
<label name="customer"/>
<field name="customer"/>
<label name="price_plan"/>
<field name="price_plan"/>
<label name="invoices_expiration"/>
<field name="invoices_expiration"/>
<button name="disable" string="Disable"
icon="tryton-cancel"/>
<button name="enable" string="Enable"
icon="tryton-ok"/>
</form>

View File

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tree editable="bottom">
<field name="name"/>
<field name="state"/>
<field name="customer"/>
<field name="price_plan"/>
<field name="invoices_expiration"/>
<button name="disable" string="Disable" />
<button name="enable" string="Enable"/>
</tree>

View File

@ -0,0 +1,9 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<form>
<label name="name"/>
<field name="name"/>
<label name="kind"/>
<field name="kind"/>
</form>

View File

@ -0,0 +1,7 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tree>
<field name="name"/>
<field name="kind"/>
</tree>

View File

@ -0,0 +1,26 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<form>
<label name="name"/>
<field name="name"/>
<label name="active"/>
<field name="active"/>
<label name="ip_address"/>
<field name="ip_address"/>
<label name="supplier"/>
<field name="supplier" widget="selection"/>
<label name="user"/>
<field name="user"/>
<label name="password" />
<field name="password" widget="password"/>
<label name="port"/>
<field name="port"/>
<!-- <label name="route"/>
<field name="route"/> -->
<label name="state"/>
<field name="state"/>
<label name="location"/>
<field name="location"/>
<field name="databases" colspan="4"/>
</form>

View File

@ -0,0 +1,10 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tree>
<field name="name"/>
<field name="ip_address"/>
<field name="location"/>
<!-- <field name="route"/> -->
<field name="state"/>
</tree>

View File

@ -0,0 +1,9 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<form>
<label name="party"/>
<field name="party"/>
<newline />
<field name="servers" colspan="4"/>
</form>

View File

@ -0,0 +1,6 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tree>
<field name="party"/>
</tree>

View File

@ -3,72 +3,72 @@
this repository contains the full copyright notices and license terms. -->
<tryton>
<data>
<record model="res.group" id="group_vps_management">
<field name="name">Vps Management</field>
<record model="res.group" id="group_vps">
<field name="name">VPS</field>
</record>
<record model="res.group" id="group_vps_management_admin">
<field name="name">Vps Management Admin</field>
<record model="res.group" id="group_vps_admin">
<field name="name">VPS Admin</field>
</record>
<record model="res.user-res.group" id="user_admin_vps_management">
<record model="res.user-res.group" id="user_admin_vps">
<field name="user" ref="res.user_admin"/>
<field name="group" ref="group_vps_management"/>
<field name="group" ref="group_vps"/>
</record>
<record model="res.user-res.group" id="user_admin_group_vps_management">
<record model="res.user-res.group" id="user_admin_group_vps">
<field name="user" ref="res.user_admin"/>
<field name="group" ref="group_vps_management_admin"/>
<field name="group" ref="group_vps_admin"/>
</record>
<record model="res.user-res.group" id="user_trigger_group_vps_management">
<record model="res.user-res.group" id="user_trigger_group_vps">
<field name="user" ref="res.user_trigger"/>
<field name="group" ref="group_vps_management"/>
<field name="group" ref="group_vps"/>
</record>
<record model="res.user-res.group" id="user_trigger_group_vps_management_admin">
<record model="res.user-res.group" id="user_trigger_group_vps_admin">
<field name="user" ref="res.user_trigger"/>
<field name="group" ref="group_vps_management_admin"/>
<field name="group" ref="group_vps_admin"/>
</record>
<record model="ir.ui.icon" id="vps_management_icon">
<record model="ir.ui.icon" id="vps_icon">
<field name="name">tryton-vps</field>
<field name="path">icons/tryton-vps.svg</field>
</record>
<menuitem name="Vps Management" sequence="10" id="menu_vps_management"
<menuitem name="Vps Management" sequence="10" id="menu_vps"
icon="tryton-vps"/>
<record model="ir.ui.menu-res.group" id="menu_vps_management_group">
<field name="menu" ref="menu_vps_management"/>
<field name="group" ref="group_vps_management"/>
<record model="ir.ui.menu-res.group" id="menu_vps_group">
<field name="menu" ref="menu_vps"/>
<field name="group" ref="group_vps"/>
</record>
<menuitem name="Configuration" parent="menu_vps_management"
<menuitem name="Configuration" parent="menu_vps"
id="menu_configuration" sequence="10" />
<record model="ir.ui.menu-res.group"
id="menu_configuration_group_vps_management_admin">
id="menu_configuration_group_vps_admin">
<field name="menu" ref="menu_configuration"/>
<field name="group" ref="group_vps_management_admin"/>
<field name="group" ref="group_vps_admin"/>
</record>
<menuitem name="Reporting" parent="menu_vps_management"
<menuitem name="Reporting" parent="menu_vps"
id="menu_reporting" sequence="100" active="0"/>
<!-- Sequences -->
<record model="ir.sequence.type" id="sequence_type_vps_management">
<!-- <record model="ir.sequence.type" id="sequence_type_vps">
<field name="name">Vps Administration</field>
<field name="code">vps_management.server</field>
<field name="code">vps.server</field>
</record>
<record model="ir.sequence.type-res.group"
id="sequence_type_vps_management_group_admin">
<field name="sequence_type" ref="sequence_type_vps_management"/>
id="sequence_type_vps_group_admin">
<field name="sequence_type" ref="sequence_type_vps"/>
<field name="group" ref="res.group_admin"/>
</record>
<record model="ir.sequence.type-res.group"
id="sequence_type_vps_management_group_audiovisual_admin">
id="sequence_type_vps_group_admin">
<field name="sequence_type" ref="sequence_type_vps_management"/>
<field name="group" ref="vps_management.group_vps_management_admin"/>
<field name="group" ref="vps.group_vps_management_admin"/>
</record>
<record model="ir.sequence" id="sequence_vps_management">
<field name="name">Vps Administration</field>
<field name="code">vps_management.server</field>
</record>
</record> -->
</data>
</tryton>

View File

@ -8,7 +8,7 @@ __all__ = ['Configuration']
class Configuration(ModelSingleton, ModelSQL, ModelView):
'Vps manager Configuration'
__name__ = 'vps_management.configuration'
__name__ = 'vps.configuration'
limit_days_expired = fields.Integer('Limit Days for Expired', required=True)
company = fields.Many2One('company.company', 'Company', required=True,
domain=[

View File

@ -4,25 +4,25 @@ this repository contains the full copyright notices and license terms. -->
<tryton>
<data>
<record model="ir.ui.view" id="vps_management_configuration_view_form">
<field name="model">vps_management.configuration</field>
<record model="ir.ui.view" id="vps_configuration_view_form">
<field name="model">vps.configuration</field>
<field name="type">form</field>
<field name="name">configuration_form</field>
</record>
<record model="ir.action.act_window" id="act_vps_management_configuration_form">
<record model="ir.action.act_window" id="act_vps_configuration_form">
<field name="name">Vps Management Configuration</field>
<field name="res_model">vps_management.configuration</field>
<field name="res_model">vps.configuration</field>
</record>
<record model="ir.action.act_window.view"
id="act_vps_management_configuration_view1">
<field name="sequence" eval="1"/>
<field name="view" ref="vps_management_configuration_view_form"/>
<field name="act_window" ref="act_vps_management_configuration_form"/>
<field name="view" ref="vps_configuration_view_form"/>
<field name="act_window" ref="act_vps_configuration_form"/>
</record>
<menuitem name="General Configuration" parent="menu_configuration"
action="act_vps_management_configuration_form" sequence="20"
id="menu_vps_management_configuration" icon="tryton-list"/>
action="act_vps_configuration_form" sequence="20"
id="menu_vps_configuration" icon="tryton-list"/>
</data>
</tryton>

BIN
dist/trytonpsk_vps-5.0.0-py3.7.egg vendored Normal file

Binary file not shown.

View File

@ -23,11 +23,11 @@ STATES = {
class Database(Workflow, ModelSQL, ModelView):
'Database'
__name__ = 'vps_management.databases'
__name__ = 'vps.databases'
_rec_name = 'name'
vps_administration = fields.Many2One('vps_management.server', 'Server',
vps = fields.Many2One('vps.server', 'Server',
required=True, )
price_plan = fields.Many2One('vps_management.price_plan', 'Price Plan',)
price_plan = fields.Many2One('vps.price_plan', 'Price Plan',)
name = fields.Char('Name Database', required=True,)
state = fields.Selection([
('enable', 'Enable'),
@ -89,10 +89,10 @@ class Database(Workflow, ModelSQL, ModelView):
# host = "45.63.106.42",
# port = "5432",
# database = "postgres")
connection = psycopg2.connect(user = self.vps_administration.user,
password = self.vps_administration.password,
host = self.vps_administration.ip_address,
port = self.vps_administration.port,
connection = psycopg2.connect(user = self.vps.user,
password = self.vps.password,
host = self.vps.ip_address,
port = self.vps.port,
database = "postgres")
cursor = connection.cursor()
create_table_query_1 = ''
@ -122,7 +122,7 @@ class Database(Workflow, ModelSQL, ModelView):
def get_invoices_expiration(self, name):
Invoice = Pool().get('account.invoice')
Configuration = Pool().get('vps_management.configuration')
Configuration = Pool().get('vps.configuration')
config = Configuration(1)
InvoicePaymentTermLineDelta = Pool().get('account.invoice.payment_term.line.delta')
@ -152,16 +152,17 @@ class Database(Workflow, ModelSQL, ModelView):
class Server(ModelSQL, ModelView):
'Vps Server'
__name__ = 'vps_management.server'
__name__ = 'vps.server'
_rec_name = 'name'
supplier = fields.Many2One('vps_management.supplier', 'Supplier', ondelete='RESTRICT')
supplier = fields.Many2One('vps.supplier', 'Supplier', ondelete='RESTRICT', required=True)
active = fields.Boolean('Active')
name = fields.Char('Name', required=True,)
user = fields.Char('User', required=True, )
ip_address = fields.Char('IP Address', required=True,)
port = fields.Char('Port', required=True,)
password = fields.Char('Password', required=True,)
# route = fields.Char('Route', states=STATES)
databases = fields.One2Many('vps_management.databases', 'vps_administration', 'Databases',)
databases = fields.One2Many('vps.databases', 'vps', 'Databases',)
state = fields.Selection([
('stop', 'Stop'),
('execution', 'Execution'),
@ -172,11 +173,16 @@ class Server(ModelSQL, ModelView):
def default_state():
return 'draft'
@staticmethod
def default_active():
return True
def disable_databases(self):
Database = Pool().get('vps_management.databases')
@classmethod
def disable_databases(cls):
Database = Pool().get('vps.databases')
databases = Database.search([
('state', '=', 'enable'),
('vps.active', '=', True),
])
for db in databases:
if db.price_plan and db.price_plan.kind != 'free' and db.invoices_expiration >= 1:
@ -185,7 +191,7 @@ class Server(ModelSQL, ModelView):
class PricePlan(ModelSQL, ModelView):
'Price Plan'
__name__ = 'vps_management.price_plan'
__name__ = 'vps.price_plan'
_rec_name = 'name'
name = fields.Char('Name', required=True,)
kind = fields.Selection([

View File

@ -4,18 +4,18 @@ this repository contains the full copyright notices and license terms. -->
<tryton>
<data>
<record model="ir.ui.view" id="vps_server_view_form">
<field name="model">vps_management.server</field>
<field name="model">vps.server</field>
<field name="type">form</field>
<field name="name">vps_server_view_form</field>
</record>
<record model="ir.ui.view" id="vps_server_view_tree">
<field name="model">vps_management.server</field>
<field name="model">vps.server</field>
<field name="type">tree</field>
<field name="name">vps_server_view_tree</field>
</record>
<record model="ir.action.act_window" id="act_vps_server_form">
<field name="name">VPS</field>
<field name="res_model">vps_management.server</field>
<field name="res_model">vps.server</field>
</record>
<record model="ir.action.act_window.view" id="act_vps_server_form_view1">
<field name="sequence" eval="1"/>
@ -27,25 +27,25 @@ this repository contains the full copyright notices and license terms. -->
<field name="view" ref="vps_server_view_form"/>
<field name="act_window" ref="act_vps_server_form"/>
</record>
<menuitem parent="menu_vps_management" sequence="30"
<menuitem parent="menu_vps" sequence="30"
action="act_vps_server_form" id="menu_vps_management_form"/>
<record model="ir.ui.view" id="vps_management_price_plan_view_form">
<field name="model">vps_management.price_plan</field>
<field name="model">vps.price_plan</field>
<field name="type">form</field>
<field name="name">price_plan_form</field>
</record>
<record model="ir.ui.view" id="vps_management_price_plan_view_tree">
<field name="model">vps_management.price_plan</field>
<field name="model">vps.price_plan</field>
<field name="type">tree</field>
<field name="name">price_plan_tree</field>
</record>
<record model="ir.action.act_window" id="act_vps_management_price_plan_form">
<field name="name">Price Plan</field>
<field name="res_model">vps_management.price_plan</field>
<field name="res_model">vps.price_plan</field>
</record>
<record model="ir.action.act_window.view" id="act_vps_price_plan_form_view1">
<field name="sequence" eval="1"/>
@ -67,12 +67,12 @@ this repository contains the full copyright notices and license terms. -->
<record model="ir.ui.view" id="database_reel_view_form">
<field name="model">vps_management.databases</field>
<field name="model">vps.databases</field>
<field name="type">form</field>
<field name="name">database_reel_view_form</field>
</record>
<record model="ir.ui.view" id="database_reel_view_tree">
<field name="model">vps_management.databases</field>
<field name="model">vps.databases</field>
<field name="type">tree</field>
<field name="name">database_reel_view_tree</field>
</record>

View File

@ -11,7 +11,7 @@ try:
except ImportError:
from ConfigParser import ConfigParser
MODULE = 'vps_management'
MODULE = 'vps'
PREFIX = 'trytonpsk'
MODULE2PREFIX = {}

View File

@ -24,9 +24,9 @@ STATES = {
class SupplierVps(ModelSQL, ModelView):
'Supplier Vps'
_rec_name = 'party.name'
__name__ = 'vps_management.supplier'
__name__ = 'vps.supplier'
party = fields.Many2One('party.party', 'Party')
servers = fields.Function(fields.One2Many('vps_management.server', None,
servers = fields.Function(fields.One2Many('vps.server', None,
'Servers', add_remove=[]), 'get_servers')
# @classmethod
@ -37,7 +37,7 @@ class SupplierVps(ModelSQL, ModelView):
# ]
def get_servers(self, name):
Server = Pool().get('vps_management.server')
Server = Pool().get('vps.server')
servers = Server.search([
('supplier.party', '=', self.party),

View File

@ -4,18 +4,18 @@ this repository contains the full copyright notices and license terms. -->
<tryton>
<data>
<record model="ir.ui.view" id="vps_supplier_view_form">
<field name="model">vps_management.supplier</field>
<field name="model">vps.supplier</field>
<field name="type">form</field>
<field name="name">vps_supplier_view_form</field>
</record>
<record model="ir.ui.view" id="vps_supplier_view_tree">
<field name="model">vps_management.supplier</field>
<field name="model">vps.supplier</field>
<field name="type">tree</field>
<field name="name">vps_supplier_view_tree</field>
</record>
<record model="ir.action.act_window" id="act_vps_supplier_form">
<field name="name">VPS Suppliers</field>
<field name="res_model">vps_management.supplier</field>
<field name="res_model">vps.supplier</field>
</record>
<record model="ir.action.act_window.view" id="act_vps_supplier_form_view1">
<field name="sequence" eval="1"/>
@ -27,8 +27,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="view" ref="vps_supplier_view_form"/>
<field name="act_window" ref="act_vps_supplier_form"/>
</record>
<menuitem parent="menu_vps_management" sequence="40"
action="act_vps_supplier_form" id="menu_vps_management_form_supplier"/>
<menuitem parent="menu_vps" sequence="40"
action="act_vps_supplier_form" id="menu_vps_form_supplier"/>
</data>

View File

@ -6,7 +6,7 @@ depends:
account
account_invoice
xml:
vps_management.xml
vps.xml
server.xml
configuration.xml
supplier.xml

View File

@ -0,0 +1,78 @@
Metadata-Version: 1.1
Name: trytonpsk-vps
Version: 5.0.0
Summary: Module for Administration VPS.
Home-page: http://www.presik.com/
Author: Presik Technologies
Author-email: gerente@presik.com
License: GPL-3
Download-URL: https://bitbucket.org/presik/trytonpsk_vps
Description: trytond_audiovisual
===================
The Vps Management Administration module of the Tryton application platform.
See __tryton__.py
Installing
----------
See INSTALL
Support
-------
If you encounter any problems with Tryton, please don't hesitate to ask
questions on the Tryton bug tracker, mailing list, wiki or IRC channel:
http://bugs.tryton.org/
http://groups.tryton.org/
http://wiki.tryton.org/
irc://irc.freenode.net/tryton
License
-------
See LICENSE
Copyright
---------
See COPYRIGHT
For more information please visit the Tryton web site:
http://www.tryton.org/
Keywords: tryton vps
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Plugins
Classifier: Framework :: Tryton
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: Intended Audience :: Legal Industry
Classifier: License :: OSI Approved :: GNU General Public License (GPL)
Classifier: Natural Language :: Bulgarian
Classifier: Natural Language :: Catalan
Classifier: Natural Language :: Chinese (Simplified)
Classifier: Natural Language :: Czech
Classifier: Natural Language :: Dutch
Classifier: Natural Language :: English
Classifier: Natural Language :: French
Classifier: Natural Language :: German
Classifier: Natural Language :: Hungarian
Classifier: Natural Language :: Italian
Classifier: Natural Language :: Portuguese (Brazilian)
Classifier: Natural Language :: Russian
Classifier: Natural Language :: Slovenian
Classifier: Natural Language :: Spanish
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Office/Business
Classifier: Topic :: Office/Business :: Financial :: Accounting

View File

@ -0,0 +1,40 @@
CHANGELOG
COPYRIGHT
INSTALL
LICENSE
MANIFEST.in
README
TODO
configuration.xml
server.xml
setup.cfg
setup.py
supplier.xml
vps.xml
./__init__.py
./configuration.py
./configuration.xml
./server.py
./server.xml
./supplier.py
./supplier.xml
./tryton.cfg
./vps.xml
./icons/tryton-vps.svg
./tests/__init__.py
./view/configuration_form.xml
./view/database_reel_view_form.xml
./view/database_reel_view_tree.xml
./view/price_plan_form.xml
./view/price_plan_tree.xml
./view/vps_server_view_form.xml
./view/vps_server_view_tree.xml
./view/vps_supplier_view_form.xml
./view/vps_supplier_view_tree.xml
doc/index.rst
trytonpsk_vps.egg-info/PKG-INFO
trytonpsk_vps.egg-info/SOURCES.txt
trytonpsk_vps.egg-info/dependency_links.txt
trytonpsk_vps.egg-info/entry_points.txt
trytonpsk_vps.egg-info/not-zip-safe
trytonpsk_vps.egg-info/top_level.txt

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,4 @@
[trytond.modules]
vps = trytond.modules.vps

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@
trytond

View File

@ -2,18 +2,20 @@
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<form>
<label name="supplier"/>
<field name="supplier" widget="selection"/>
<label name="name"/>
<field name="name"/>
<label name="active"/>
<field name="active"/>
<label name="ip_address"/>
<field name="ip_address"/>
<label name="port"/>
<field name="port"/>
<label name="supplier"/>
<field name="supplier" widget="selection"/>
<label name="user"/>
<field name="user"/>
<label name="password" />
<field name="password" widget="password"/>
<label name="port"/>
<field name="port"/>
<!-- <label name="route"/>
<field name="route"/> -->
<label name="state"/>

74
vps.xml Normal file
View File

@ -0,0 +1,74 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tryton>
<data>
<record model="res.group" id="group_vps">
<field name="name">VPS</field>
</record>
<record model="res.group" id="group_vps_admin">
<field name="name">VPS Admin</field>
</record>
<record model="res.user-res.group" id="user_admin_vps">
<field name="user" ref="res.user_admin"/>
<field name="group" ref="group_vps"/>
</record>
<record model="res.user-res.group" id="user_admin_group_vps">
<field name="user" ref="res.user_admin"/>
<field name="group" ref="group_vps_admin"/>
</record>
<record model="res.user-res.group" id="user_trigger_group_vps">
<field name="user" ref="res.user_trigger"/>
<field name="group" ref="group_vps"/>
</record>
<record model="res.user-res.group" id="user_trigger_group_vps_admin">
<field name="user" ref="res.user_trigger"/>
<field name="group" ref="group_vps_admin"/>
</record>
<record model="ir.ui.icon" id="vps_icon">
<field name="name">tryton-vps</field>
<field name="path">icons/tryton-vps.svg</field>
</record>
<menuitem name="Vps Management" sequence="10" id="menu_vps"
icon="tryton-vps"/>
<record model="ir.ui.menu-res.group" id="menu_vps_group">
<field name="menu" ref="menu_vps"/>
<field name="group" ref="group_vps"/>
</record>
<menuitem name="Configuration" parent="menu_vps"
id="menu_configuration" sequence="10" />
<record model="ir.ui.menu-res.group"
id="menu_configuration_group_vps_admin">
<field name="menu" ref="menu_configuration"/>
<field name="group" ref="group_vps_admin"/>
</record>
<menuitem name="Reporting" parent="menu_vps"
id="menu_reporting" sequence="100" active="0"/>
<!-- Sequences -->
<!-- <record model="ir.sequence.type" id="sequence_type_vps">
<field name="name">Vps Administration</field>
<field name="code">vps.server</field>
</record>
<record model="ir.sequence.type-res.group"
id="sequence_type_vps_group_admin">
<field name="sequence_type" ref="sequence_type_vps"/>
<field name="group" ref="res.group_admin"/>
</record>
<record model="ir.sequence.type-res.group"
id="sequence_type_vps_group_admin">
<field name="sequence_type" ref="sequence_type_vps_management"/>
<field name="group" ref="vps.group_vps_management_admin"/>
</record>
<record model="ir.sequence" id="sequence_vps_management">
<field name="name">Vps Administration</field>
<field name="code">vps_management.server</field>
</record> -->
</data>
</tryton>