setup function for odoo11

develop
Ahmed Aly 2017-10-09 16:36:27 +02:00
parent efbf71d577
commit 89c7ff574b
5 changed files with 97 additions and 100 deletions

View File

@ -1,4 +1,4 @@
import cli from . import cli
import config_at from . import config_at
import environments from . import environments
import functions from . import functions

View File

@ -1,33 +1,33 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import sys import sys
import urlparse from urllib.parse import urlparse
from config_at import Config from .config_at import Config
from environments import ENVIRONMENTS, Environment from .environments import ENVIRONMENTS, Environment
from functions import DatenpolFunctions from .functions import DatenpolFunctions
def main(): def main():
def _usage(): def _usage():
print 'Verwendung: dp <environment> <command> [<module_name>/<setup_function>]' print('Verwendung: dp <environment> <command> [<module_name>/<setup_function>]')
print ' dp list-envs\n' print(' dp list-envs\n')
print 'Commands:' print('Commands:')
print ' create Neue Datenbank erstellen' print(' create Neue Datenbank erstellen')
print ' create_from_dump Neue Datenbank von Dump erstellen' print(' create_from_dump Neue Datenbank von Dump erstellen')
print ' setup Modulinstallation, Konfigurationen' print(' setup Modulinstallation, Konfigurationen')
print ' setup_part setup_function Aufruf eines einzelnen Setup-Schrittes' print(' setup_part setup_function Aufruf eines einzelnen Setup-Schrittes')
print ' "setup_part info" listet die verfügbaren' print(' "setup_part info" listet die verfügbaren')
print ' Setup-Schritte auf' print(' Setup-Schritte auf')
print ' rollout Setzt Dokumentnummern, importiert Benutzer,' print(' rollout Setzt Dokumentnummern, importiert Benutzer,')
print ' setzt dp_dmi auf noupdate, ...' print(' setzt dp_dmi auf noupdate, ...')
print ' update modul1 modul2 ... Module updaten' print(' update modul1 modul2 ... Module updaten')
print ' install module_name Modul installieren' print(' install module_name Modul installieren')
print ' uninstall module_name Modul deinstallieren' print(' uninstall module_name Modul deinstallieren')
print ' cancel_upgrade module_name Abbruch Modulinstallation' print(' cancel_upgrade module_name Abbruch Modulinstallation')
print ' update_modules Update aller Module in der config-Modulliste' print(' update_modules Update aller Module in der config-Modulliste')
print ' update_all Update aller verfügbaren Module' print(' update_all Update aller verfügbaren Module')
print ' anonym Daten anonymisieren (Namen, Adresse, E-Mail, ...)' print(' anonym Daten anonymisieren (Namen, Adresse, E-Mail, ...)')
print ' invalidate_email E-Mail Adressen invalidieren (@ > #)' print(' invalidate_email E-Mail Adressen invalidieren (@ > #)')
sys.exit(3) sys.exit(3)
argv = sys.argv[1:] argv = sys.argv[1:]
@ -49,10 +49,10 @@ def main():
env = Environment('http://localhost', port, db, 'admin', 'admin', 'admin') env = Environment('http://localhost', port, db, 'admin', 'admin', 'admin')
os.chdir(setup_path) os.chdir(setup_path)
elif argv[0] == 'list-envs': elif argv[0] == 'list-envs':
print 'name: host:port dbname username' print('name: host:port dbname username')
for env_name in sorted(ENVIRONMENTS): for env_name in sorted(ENVIRONMENTS):
env = ENVIRONMENTS[env_name] env = ENVIRONMENTS[env_name]
print '%s: %s:%s %s %s' % (env_name, env.host, env.port, env.dbname, env.username) print('%s: %s:%s %s %s' % (env_name, env.host, env.port, env.dbname, env.username))
return return
else: else:
if len(argv) != 2: if len(argv) != 2:
@ -67,7 +67,7 @@ def main():
env = ENVIRONMENTS.get(argv[0]) env = ENVIRONMENTS.get(argv[0])
if not env: if not env:
print 'Unbekannte Umgebung' print('Unbekannte Umgebung')
_usage() _usage()
instance = DatenpolFunctions(env, config) instance = DatenpolFunctions(env, config)
@ -185,7 +185,7 @@ def main():
if cmd == 'setup_part': if cmd == 'setup_part':
if (argv[2] == 'info') or (argv[2] not in setup_methods): if (argv[2] == 'info') or (argv[2] not in setup_methods):
print 'Verfügbare Setup-Schritte:', ', '.join(setup_methods) print('Verfügbare Setup-Schritte:', ', '.join(setup_methods))
return return
methods = [ methods = [
@ -205,49 +205,43 @@ def main():
'invalidate_email', 'invalidate_email',
] ]
if cmd == 'remove_standard_translations':
methods = [
'login',
'remove_standard_translations'
]
if not methods: if not methods:
print 'Unbekanntes Kommando' print('Unbekanntes Kommando')
_usage() _usage()
print env print(env)
local_netlocs = [ local_netlocs = [
'localhost', 'localhost',
'127.0.0.1', '127.0.0.1',
'::1', '::1',
] ]
netloc = urlparse.urlparse(env.host).netloc netloc = urlparse(env.host).netloc
if (netloc not in local_netlocs) or (env.pwd is None): if (netloc not in local_netlocs) or (env.pwd is None):
print '\nAchtung, diese Umgebung ist nicht lokal!\n' print('\nAchtung, diese Umgebung ist nicht lokal!\n')
print cmd, print(cmd)
print instance.config.module_name if instance.config.module_name else '' print(instance.config.module_name if instance.config.module_name else '')
print print()
env.pwd = raw_input('Passwort: ') env.pwd = input('Passwort: ')
if cmd in ['create','create_dump','create_from_dump']: if cmd in ['create','create_dump','create_from_dump']:
env.super_admin_pw = raw_input('Super-Admin-Passwort: ') env.super_admin_pw = input('Super-Admin-Passwort: ')
print print()
for method in methods: for method in methods:
doc = getattr(instance, method).__doc__ doc = getattr(instance, method).__doc__
print doc, # print(doc)
sys.stdout.flush() sys.stdout.flush()
res = getattr(instance, method)() res = getattr(instance, method)()
print '\r%s: %s' % (res and 'OK ' or 'ERROR ', doc) print('\r%s: %s' % (res and 'OK ' or 'ERROR ', doc))
if not res: if not res:
print 'Abbruch wegen Fehler' print('Abbruch wegen Fehler')
return return
print '\nAbgeschlossen.' print('\nAbgeschlossen.')
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View File

@ -14,18 +14,18 @@ class Config():
self.uom_decimals = 3 # Nachkommastellen Mengeneinheiten self.uom_decimals = 3 # Nachkommastellen Mengeneinheiten
self.company_data = { self.company_data = {
'name': 'datenpol gmbh', 'name': 'TZ Tischlerzentrum GesmbH',
'street': 'Lederergasse 32', 'street': 'Neugasse 36',
'street2': False, 'street2': False,
'city': 'Linz', 'city': 'Spannberg',
'zip': '4020', 'zip': '2244',
'phone': '+43 732 997 035-0', 'phone': '+43 2538/8628 0',
'fax': False, 'fax': '+43 2538/8628 400',
'email': 'office@datenpol.at', 'email': 'office@tzaustria.com',
'website': 'http://www.datenpol.at/', 'website': 'https://www.tzaustria.com/',
'company_registry': '359270p', 'company_registry': 'FN 224119m',
'country_id': 'at', # 'de' für Deutschland 'country_id': 'at', # 'de' für Deutschland
'vat': 'ATU 66309611', 'vat': 'ATU 54619104',
'rml_header1': False, 'rml_header1': False,
'vat_check_vies': True, 'vat_check_vies': True,
'tax_calculation_rounding_method': 'round_globally', 'tax_calculation_rounding_method': 'round_globally',
@ -46,8 +46,8 @@ class Config():
# Nur für Lager # Nur für Lager
# Wenn nicht gesetzt, dann wird der Firmenname genommen # Wenn nicht gesetzt, dann wird der Firmenname genommen
self.warehouse_name = False self.warehouse_name = 'TZA'
self.warehouse_code = False self.warehouse_code = 'TZA'
# Anzahl der Schritte beim Ausliefern # Anzahl der Schritte beim Ausliefern
# [ship_only] Direkt vom Lager liefern # [ship_only] Direkt vom Lager liefern
@ -141,15 +141,13 @@ class Config():
# 'number_next_actual': 1, # 'number_next_actual': 1,
'prefix': '%(y)s', 'prefix': '%(y)s',
'padding': 4, 'padding': 4,
'use_date_range': True, 'use_date_range': True
'monthly_date_range': False
}, },
'account.invoice': { 'account.invoice': {
# 'number_next_actual': 0001, # 'number_next_actual': 0001,
'prefix': '%(y)s%(month)s', 'prefix': '%(y)s%(month)s',
'padding': 4, 'padding': 4,
'use_date_range': True, 'use_date_range': True
'monthly_date_range': False
}, },
# Wenn 'account.invoice_refund' auskommentiert ist, dann wird # Wenn 'account.invoice_refund' auskommentiert ist, dann wird
# für die Gutschrift der selbe Nummernkreis verwendet # für die Gutschrift der selbe Nummernkreis verwendet
@ -159,8 +157,7 @@ class Config():
'implementation': 'no_gap', 'implementation': 'no_gap',
'prefix': '%(y)s', 'prefix': '%(y)s',
'padding': 4, 'padding': 4,
'use_date_range': True, 'use_date_range': True
'monthly_date_range': False
}, },
#'picking.out': { #'picking.out': {
# # 'number_next_actual': 1, # # 'number_next_actual': 1,
@ -205,29 +202,32 @@ class Config():
self.modules = [ self.modules = [
'base_iban', 'base_iban',
'document', 'document',
'knowledge', 'knowledge', # not found
'auth_crypt', 'auth_crypt',
'auth_admin_passkey', # 'auth_admin_passkey',
'auth_brute_force', # 'auth_brute_force',
'auth_session_timeout', # 'auth_session_timeout',
'disable_odoo_online', # 'disable_odoo_online',
'mass_editing', # 'mass_editing',
'password_security', # 'password_security',
'res_config_settings_enterprise_remove', # 'res_config_settings_enterprise_remove',
'scheduler_error_mailer', # 'scheduler_error_mailer',
'web_dialog_size', # 'web_dialog_size',
'web_environment_ribbon', # 'web_environment_ribbon',
'web_favicon', # 'web_favicon',
'web_responsive', # 'web_responsive',
'web_searchbar_full_width', # 'web_searchbar_full_width',
'web_sheet_full_width', # 'web_sheet_full_width',
'web_shortcut', # 'web_shortcut',
'web_translate_dialog', # 'web_translate_dialog',
'web_tree_many2one_clickable', # 'web_tree_many2one_clickable',
#'website_no_crawler', #'website_no_crawler',
#'website_odoo_debranding', #'website_odoo_debranding',
'dp_custom', 'dp_custom',
'dp_reports', # 'dp_reports_account',
# 'dp_reports_purchase',
# 'dp_reports_sale',
# 'dp_reports_stock',
'account_cancel', 'account_cancel',
] ]

View File

@ -24,9 +24,10 @@ Port: %s
ENVIRONMENTS = { ENVIRONMENTS = {
# Local environments are listed with passwords # Local environments are listed with passwords
'br': Environment('http://localhost', '8080', 'INSTANCE_1', 'admin', 'x', 'admin'), 'br': Environment('http://localhost', '8080', 'demo11c_1', 'admin', 'x', 'admin'),
'aa': Environment('http://localhost', '8080', 'demo11c_1', 'admin', 'x', 'admin'),
# Remote environments are always listed without passwords! # Remote environments are always listed without passwords!
# Do not store them here, you have to type them anyway! # Do not store them here, you have to type them anyway!
'test': Environment('https://INSTANCE.datenpol.at', '443', 'INSTANCE_1', 'admin'), 'test': Environment('https://demo11c_1.datenpol.at', '443', 'demo11c_1', 'admin'),
} }

View File

@ -4,12 +4,13 @@ import base64
import json import json
import pprint import pprint
import sys import sys
import xmlrpclib from xmlrpc import client as xmlrpclib
import requests import requests
import ssl import ssl
class DatenpolFunctions():
class DatenpolFunctions:
def __init__(self, environment, config): def __init__(self, environment, config):
self.env = environment self.env = environment
self.config = config self.config = config
@ -62,11 +63,11 @@ class DatenpolFunctions():
} }
url = '%s:%s/web/database/restore?restore_pwd=%s&new_db=%s&mode=restore' url = '%s:%s/web/database/restore?restore_pwd=%s&new_db=%s&mode=restore'
url %= (self.env.host, self.env.port, self.env.super_admin_pw, self.env.dbname) url %= (self.env.host, self.env.port, self.env.super_admin_pw, self.env.dbname)
print 'Request: ' + url print('Request: ' + url)
res = requests.post(url, files=files, verify=False) res = requests.post(url, files=files, verify=False)
if (res.status_code != 200): if (res.status_code != 200):
return False return False
print "\nACHTUNG: Nicht vergessen './cam [env] anonym' auszuführen, sodass es zu keiner Kommunikation mit dem Produktivsystem kommt" print("\nACHTUNG: Nicht vergessen './cam [env] anonym' auszuführen, sodass es zu keiner Kommunikation mit dem Produktivsystem kommt")
return True return True
def login(self): def login(self):
@ -84,12 +85,13 @@ class DatenpolFunctions():
return self.sock.execute(self.env.dbname, self.uid, self.env.pwd, *args) return self.sock.execute(self.env.dbname, self.uid, self.env.pwd, *args)
def _readAndReturnFile(self, filename, encode=''): def _readAndReturnFile(self, filename, encode=''):
fi = open(filename, 'r') fi = open(filename, 'rb')
content = '' content = ''
if encode == '': if encode == '':
content = fi.read() content = fi.read()
elif encode == 'base64': elif encode == 'base64':
content = base64.b64encode(fi.read()) content = base64.b64encode(fi.read())
content = content.decode()
else: else:
sys.exit(-1) sys.exit(-1)
fi.close() fi.close()
@ -652,7 +654,7 @@ class DatenpolFunctions():
if wizard_id: if wizard_id:
messages = self._execute('base_import.import', 'do', wizard_id, fields, options) messages = self._execute('base_import.import', 'do', wizard_id, fields, options)
if messages: if messages:
print messages print(messages)
return False return False
return True return True
@ -771,9 +773,9 @@ class DatenpolFunctions():
"""Systemparameter entfernen""" """Systemparameter entfernen"""
for key, value in self.config.system_parameters_remove_on_rollout.items(): for key, value in self.config.system_parameters_remove_on_rollout.items():
print key print(key)
param_ids = self._execute('ir.config_parameter', 'search', [('key', '=', key)]) param_ids = self._execute('ir.config_parameter', 'search', [('key', '=', key)])
print param_ids print(param_ids)
if param_ids: if param_ids:
self._execute('ir.config_parameter', 'unlink', param_ids) self._execute('ir.config_parameter', 'unlink', param_ids)
return True return True
@ -828,9 +830,9 @@ class DatenpolFunctions():
try: try:
getattr(self, func_name)() getattr(self, func_name)()
print '.............. ' + func_name + ': OK' print('.............. ' + func_name + ': OK')
except: except:
print '.............. ' + func_name + ': ERROR!!!' print('.............. ' + func_name + ': ERROR!!!')
return False return False
return True return True