From 89c7ff574b44f79b366c64ed5f4fbaa8a6802b9a Mon Sep 17 00:00:00 2001 From: Ahmed Aly Date: Mon, 9 Oct 2017 16:36:27 +0200 Subject: [PATCH] setup function for odoo11 --- setup/lib/__init__.py | 8 ++-- setup/lib/cli.py | 88 ++++++++++++++++++--------------------- setup/lib/config_at.py | 74 ++++++++++++++++---------------- setup/lib/environments.py | 5 ++- setup/lib/functions.py | 22 +++++----- 5 files changed, 97 insertions(+), 100 deletions(-) diff --git a/setup/lib/__init__.py b/setup/lib/__init__.py index 5bea60ea..6354a6f1 100644 --- a/setup/lib/__init__.py +++ b/setup/lib/__init__.py @@ -1,4 +1,4 @@ -import cli -import config_at -import environments -import functions \ No newline at end of file +from . import cli +from . import config_at +from . import environments +from . import functions diff --git a/setup/lib/cli.py b/setup/lib/cli.py index 59591da0..b496afe9 100755 --- a/setup/lib/cli.py +++ b/setup/lib/cli.py @@ -1,33 +1,33 @@ # -*- coding: utf-8 -*- import sys -import urlparse +from urllib.parse import urlparse -from config_at import Config -from environments import ENVIRONMENTS, Environment -from functions import DatenpolFunctions +from .config_at import Config +from .environments import ENVIRONMENTS, Environment +from .functions import DatenpolFunctions def main(): def _usage(): - print 'Verwendung: dp [/]' - print ' dp list-envs\n' - print 'Commands:' - print ' create Neue Datenbank erstellen' - print ' create_from_dump Neue Datenbank von Dump erstellen' - print ' setup Modulinstallation, Konfigurationen' - print ' setup_part setup_function Aufruf eines einzelnen Setup-Schrittes' - print ' "setup_part info" listet die verfügbaren' - print ' Setup-Schritte auf' - print ' rollout Setzt Dokumentnummern, importiert Benutzer,' - print ' setzt dp_dmi auf noupdate, ...' - print ' update modul1 modul2 ... Module updaten' - print ' install module_name Modul installieren' - print ' uninstall module_name Modul deinstallieren' - print ' cancel_upgrade module_name Abbruch Modulinstallation' - print ' update_modules Update aller Module in der config-Modulliste' - print ' update_all Update aller verfügbaren Module' - print ' anonym Daten anonymisieren (Namen, Adresse, E-Mail, ...)' - print ' invalidate_email E-Mail Adressen invalidieren (@ > #)' + print('Verwendung: dp [/]') + print(' dp list-envs\n') + print('Commands:') + print(' create Neue Datenbank erstellen') + print(' create_from_dump Neue Datenbank von Dump erstellen') + print(' setup Modulinstallation, Konfigurationen') + print(' setup_part setup_function Aufruf eines einzelnen Setup-Schrittes') + print(' "setup_part info" listet die verfügbaren') + print(' Setup-Schritte auf') + print(' rollout Setzt Dokumentnummern, importiert Benutzer,') + print(' setzt dp_dmi auf noupdate, ...') + print(' update modul1 modul2 ... Module updaten') + print(' install module_name Modul installieren') + print(' uninstall module_name Modul deinstallieren') + print(' cancel_upgrade module_name Abbruch Modulinstallation') + print(' update_modules Update aller Module in der config-Modulliste') + print(' update_all Update aller verfügbaren Module') + print(' anonym Daten anonymisieren (Namen, Adresse, E-Mail, ...)') + print(' invalidate_email E-Mail Adressen invalidieren (@ > #)') sys.exit(3) argv = sys.argv[1:] @@ -49,10 +49,10 @@ def main(): env = Environment('http://localhost', port, db, 'admin', 'admin', 'admin') os.chdir(setup_path) elif argv[0] == 'list-envs': - print 'name: host:port dbname username' + print('name: host:port dbname username') for env_name in sorted(ENVIRONMENTS): 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 else: if len(argv) != 2: @@ -67,7 +67,7 @@ def main(): env = ENVIRONMENTS.get(argv[0]) if not env: - print 'Unbekannte Umgebung' + print('Unbekannte Umgebung') _usage() instance = DatenpolFunctions(env, config) @@ -185,7 +185,7 @@ def main(): if cmd == 'setup_part': 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 methods = [ @@ -205,49 +205,43 @@ def main(): 'invalidate_email', ] - if cmd == 'remove_standard_translations': - methods = [ - 'login', - 'remove_standard_translations' - ] - if not methods: - print 'Unbekanntes Kommando' + print('Unbekanntes Kommando') _usage() - print env + print(env) local_netlocs = [ 'localhost', '127.0.0.1', '::1', ] - netloc = urlparse.urlparse(env.host).netloc + netloc = urlparse(env.host).netloc 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 instance.config.module_name if instance.config.module_name else '' - print + print(cmd) + print(instance.config.module_name if instance.config.module_name else '') + print() - env.pwd = raw_input('Passwort: ') + env.pwd = input('Passwort: ') 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: doc = getattr(instance, method).__doc__ - print doc, + # print(doc) sys.stdout.flush() 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: - print 'Abbruch wegen Fehler' + print('Abbruch wegen Fehler') return - print '\nAbgeschlossen.' + print('\nAbgeschlossen.') if __name__ == '__main__': main() diff --git a/setup/lib/config_at.py b/setup/lib/config_at.py index 6f5c17e0..1db4d4c8 100644 --- a/setup/lib/config_at.py +++ b/setup/lib/config_at.py @@ -14,18 +14,18 @@ class Config(): self.uom_decimals = 3 # Nachkommastellen Mengeneinheiten self.company_data = { - 'name': 'datenpol gmbh', - 'street': 'Lederergasse 32', + 'name': 'TZ Tischlerzentrum GesmbH', + 'street': 'Neugasse 36', 'street2': False, - 'city': 'Linz', - 'zip': '4020', - 'phone': '+43 732 997 035-0', - 'fax': False, - 'email': 'office@datenpol.at', - 'website': 'http://www.datenpol.at/', - 'company_registry': '359270p', + 'city': 'Spannberg', + 'zip': '2244', + 'phone': '+43 2538/8628 – 0', + 'fax': '+43 2538/8628 – 400', + 'email': 'office@tzaustria.com', + 'website': 'https://www.tzaustria.com/', + 'company_registry': 'FN 224119m', 'country_id': 'at', # 'de' für Deutschland - 'vat': 'ATU 66309611', + 'vat': 'ATU 54619104', 'rml_header1': False, 'vat_check_vies': True, 'tax_calculation_rounding_method': 'round_globally', @@ -46,8 +46,8 @@ class Config(): # Nur für Lager # Wenn nicht gesetzt, dann wird der Firmenname genommen - self.warehouse_name = False - self.warehouse_code = False + self.warehouse_name = 'TZA' + self.warehouse_code = 'TZA' # Anzahl der Schritte beim Ausliefern # [ship_only] Direkt vom Lager liefern @@ -141,15 +141,13 @@ class Config(): # 'number_next_actual': 1, 'prefix': '%(y)s', 'padding': 4, - 'use_date_range': True, - 'monthly_date_range': False + 'use_date_range': True }, 'account.invoice': { # 'number_next_actual': 0001, 'prefix': '%(y)s%(month)s', 'padding': 4, - 'use_date_range': True, - 'monthly_date_range': False + 'use_date_range': True }, # Wenn 'account.invoice_refund' auskommentiert ist, dann wird # für die Gutschrift der selbe Nummernkreis verwendet @@ -159,8 +157,7 @@ class Config(): 'implementation': 'no_gap', 'prefix': '%(y)s', 'padding': 4, - 'use_date_range': True, - 'monthly_date_range': False + 'use_date_range': True }, #'picking.out': { # # 'number_next_actual': 1, @@ -205,29 +202,32 @@ class Config(): self.modules = [ 'base_iban', 'document', - 'knowledge', + 'knowledge', # not found 'auth_crypt', - 'auth_admin_passkey', - 'auth_brute_force', - 'auth_session_timeout', - 'disable_odoo_online', - 'mass_editing', - 'password_security', - 'res_config_settings_enterprise_remove', - 'scheduler_error_mailer', - 'web_dialog_size', - 'web_environment_ribbon', - 'web_favicon', - 'web_responsive', - 'web_searchbar_full_width', - 'web_sheet_full_width', - 'web_shortcut', - 'web_translate_dialog', - 'web_tree_many2one_clickable', + # 'auth_admin_passkey', + # 'auth_brute_force', + # 'auth_session_timeout', + # 'disable_odoo_online', + # 'mass_editing', + # 'password_security', + # 'res_config_settings_enterprise_remove', + # 'scheduler_error_mailer', + # 'web_dialog_size', + # 'web_environment_ribbon', + # 'web_favicon', + # 'web_responsive', + # 'web_searchbar_full_width', + # 'web_sheet_full_width', + # 'web_shortcut', + # 'web_translate_dialog', + # 'web_tree_many2one_clickable', #'website_no_crawler', #'website_odoo_debranding', 'dp_custom', - 'dp_reports', + # 'dp_reports_account', + # 'dp_reports_purchase', + # 'dp_reports_sale', + # 'dp_reports_stock', 'account_cancel', ] diff --git a/setup/lib/environments.py b/setup/lib/environments.py index 97575844..b108107f 100644 --- a/setup/lib/environments.py +++ b/setup/lib/environments.py @@ -24,9 +24,10 @@ Port: %s ENVIRONMENTS = { # 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! # 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'), } diff --git a/setup/lib/functions.py b/setup/lib/functions.py index 22504e09..e483d470 100644 --- a/setup/lib/functions.py +++ b/setup/lib/functions.py @@ -4,12 +4,13 @@ import base64 import json import pprint import sys -import xmlrpclib +from xmlrpc import client as xmlrpclib import requests import ssl -class DatenpolFunctions(): + +class DatenpolFunctions: def __init__(self, environment, config): self.env = environment self.config = config @@ -62,11 +63,11 @@ class DatenpolFunctions(): } 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) - print 'Request: ' + url + print('Request: ' + url) res = requests.post(url, files=files, verify=False) if (res.status_code != 200): 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 def login(self): @@ -84,12 +85,13 @@ class DatenpolFunctions(): return self.sock.execute(self.env.dbname, self.uid, self.env.pwd, *args) def _readAndReturnFile(self, filename, encode=''): - fi = open(filename, 'r') + fi = open(filename, 'rb') content = '' if encode == '': content = fi.read() elif encode == 'base64': content = base64.b64encode(fi.read()) + content = content.decode() else: sys.exit(-1) fi.close() @@ -652,7 +654,7 @@ class DatenpolFunctions(): if wizard_id: messages = self._execute('base_import.import', 'do', wizard_id, fields, options) if messages: - print messages + print(messages) return False return True @@ -771,9 +773,9 @@ class DatenpolFunctions(): """Systemparameter entfernen""" 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)]) - print param_ids + print(param_ids) if param_ids: self._execute('ir.config_parameter', 'unlink', param_ids) return True @@ -828,9 +830,9 @@ class DatenpolFunctions(): try: getattr(self, func_name)() - print '.............. ' + func_name + ': OK' + print('.............. ' + func_name + ': OK') except: - print '.............. ' + func_name + ': ERROR!!!' + print('.............. ' + func_name + ': ERROR!!!') return False return True