Aufgaben aus der Dev-Session 10. 2. 2016:

* cam warnt bei nicht lokalen Umgebungen und fragt nach dem Passwort
* Passwörter für nicht lokale Umgebungen nicht im environments speichern
* cam list-envs zum Auflisten aller Umgebungen

Allgemein:
* Mich hinzufügen, Kumar entfernen
* Überflüssigen Leerraum entfernen
develop
Christian Hattemer 2016-02-19 18:02:25 +01:00
parent a1d621ee8a
commit a9d0bb2b59
6 changed files with 429 additions and 407 deletions

View File

@ -1,19 +1,23 @@
# -*- coding: utf-8 -*-
import urlparse
import sys
from functions import CamadeusFunctions
from config_at import Config
from environments import ENVIRONMENTS, Environment
import sys, getopt
from functions import CamadeusFunctions
def main():
def _usage():
print 'cam.py <environment> [create|setup|rollout|update] [<module_name>]'
print 'cam.py list-envs'
sys.exit(3)
argv = sys.argv[1:]
config = Config()
if not argv:
_usage()
# RUNBOT
# ./cam runbot create [db] [port] [working-dir]
@ -26,22 +30,30 @@ 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'
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)
return
else:
if not len(argv) == 2:
if len(argv) == 3 and argv[1] in ['update','install']: # 'update' requires additional param 'module_name'
if len(argv) != 2:
if len(argv) == 3 and argv[1] in ['update', 'install']:
# 'update' requires additional param 'module_name'
pass
else:
_usage()
cmd = argv[1]
env = ENVIRONMENTS.get(argv[0],False)
env = ENVIRONMENTS.get(argv[0])
if not env:
print 'Unbekannte Umgebung'
_usage()
instance = CamadeusFunctions(env, config)
methods = False
methods = None
if cmd == 'test':
methods = [
@ -126,17 +138,42 @@ def main():
]
if not methods:
print 'Unbekanntes Kommando'
_usage()
print env
local_netlocs = [
'localhost',
'127.0.0.1',
'::1',
]
netloc = urlparse.urlparse(env.host).netloc
if netloc not in local_netlocs:
print '\nAchtung, diese Umgebung ist nicht lokal!\n'
print cmd,
print instance.config.module_name if instance.config.module_name else ''
print
env.pwd = raw_input('Passwort: ')
if cmd == 'create':
env.super_admin_pw = raw_input('Super-Admin-Passwort: ')
print
for method in methods:
doc = getattr(instance, method).__doc__
print doc,
sys.stdout.flush()
res = getattr(instance, method)()
print "%s: %s" % (res and "OK " or "ERROR ", getattr(instance, method).__doc__)
print '\r%s: %s' % (res and 'OK ' or 'ERROR ', doc)
if not res:
return False
print 'Abbruch wegen Fehler'
return
print "\nAbgeschlossen."
print '\nAbgeschlossen.'
if __name__ == "__main__":
if __name__ == '__main__':
main()

View File

@ -1,9 +1,7 @@
# -*- coding: utf-8 -*-
class Config():
def __init__(self):
self.module_name = None
self.lang = 'de_DE' # de_DE, en_US
self.chart_of_accounts = 'l10n_at'
self.sales_tax = '20% MwSt'
@ -14,16 +12,16 @@ class Config():
self.company_data = {
'name': 'Camadeus GmbH',
'street': 'Kriehubergasse 16',
'street': 'Wiedner Hauptstraße 135/B3',
'street2': False,
'city': 'Wien',
'zip': '1050',
'phone': '+43 1 78910 96 70',
'fax': False,
'email': 'office@camadeus.at',
'website': 'http://www.camadeus.at',
'website': 'http://www.camadeus.at/',
'company_registry': '280076b',
'country_id': 'at', # "de" für deutschland
'country_id': 'at', # 'de' für Deutschland
'logo': False,
'vat': 'ATU 62991855',
'rml_header1': False,
@ -78,7 +76,7 @@ class Config():
# Allgemeine Einstellungen
self.base_config = {
'module_portal': False, # Kundenportal
'alias_domain': False, # False: keine Domainbezogenen E-Mails (wie zB. Reply-To zur alias-Adresse)
'alias_domain': False, # False: keine Domainbezogenen E-Mails (wie z. B. Reply-To zur Alias-Adresse)
}
# Einstellungen Verkauf
@ -105,7 +103,6 @@ class Config():
'module_hr_expense': True, # Spesen der Mitarbeiter verwalten
'module_hr_timesheet': False, # Verwalten Sie Ihre Studenzettel
'group_hr_attendance': True, # Zuweisung der Berechtigung zur Arbeitszeiteingabe für alle Benutzer
}
#Einstellungen Lager
@ -209,7 +206,7 @@ class Config():
#'sale_order_reminder',
]
# Setzen das Feld "Attachment" im Report (wenn gesetzt, wird das PDF in den Anhängen gespeichert)
# Setze das Feld "Attachment" im Report (wenn gesetzt wird das PDF in den Anhängen gespeichert)
timestamp = " + '_' + time.strftime('%Y-%m-%d-%H%M') + '.pdf')"
self.reports = {
'sale.report_saleorder': "((object.state in ('draft','sent') and 'KV_' or 'AB_') + object.name" + timestamp,
@ -225,10 +222,10 @@ class Config():
'cam_reports.report_purchaseorder_ohne': "('B_' + object.name" + timestamp,
}
self.users_file = "res.users.csv"
self.users_file = 'res.users.csv'
self.translation_files = [
"ir.translation.csv"
'ir.translation.csv'
]
self.default_values = [ # ir.values

View File

@ -1,15 +1,17 @@
# -*- coding: utf-8 -*-
class Environment():
def __init__(self, host, port, dbname, username, pwd, admin_pw=False, basic_auth=False):
self.admin_pw = admin_pw
def __init__(self, host, port, dbname, username, pwd=None, super_admin_pw=None, basic_auth=None):
self.host = host
self.port = port
self.dbname = dbname
self.username = username
# The password for the user named username
# During create the user is created with this password,
# otherwise it's used to authenticate during login.
self.pwd = pwd
self.port = port
self.host = host
self.basic_auth = basic_auth or ('user', 'pass') # HTTP authentification
self.super_admin_pw = super_admin_pw
# HTTP authentication
self.basic_auth = basic_auth or ('user', 'pass')
def __str__(self):
return """==============================
@ -21,9 +23,13 @@ Port: %s
ENVIRONMENTS = {
# Local environments are listed with passwords
'br': Environment('http://localhost', '8080', 'INSTANCE_1', 'admin', 'x', 'admin'),
'sk': Environment('http://localhost', '8080', 'INSTANCE_1', 'admin', 'x', 'admin'),
'ka': Environment('http://localhost', '8080', 'INSTANCE_1', 'admin', 'x', 'admin'),
'test': Environment('https://INSTANCE.camadeus.at', '443', 'INSTANCE_1', 'admin', '141kcal', 'asdfasdf'),
'ha': Environment('http://localhost', '8080', 'INSTANCE_1', 'admin', 'x', 'admin'),
'jb': Environment('http://localhost', '8080', 'INSTANCE_1', 'admin', 'x', 'admin'),
'uk': Environment('http://localhost', '8080', 'INSTANCE_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.camadeus.at', '443', 'INSTANCE_1', 'admin'),
}

View File

@ -1,17 +1,13 @@
# -*- coding: utf-8 -*-
import xmlrpclib
import base64
import os
import sys
import datetime
import json
import pprint
import sys
import xmlrpclib
import requests
from config_at import Config
from environments import ENVIRONMENTS
class CamadeusFunctions():
def __init__(self, environment, config):
self.env = environment
self.config = config
@ -19,7 +15,7 @@ class CamadeusFunctions():
def create_db(self):
"""Neue Datenbank erstellen"""
payload = {'fields': [ {'name': 'super_admin_pwd', 'value': self.env.admin_pw},
payload = {'fields': [ {'name': 'super_admin_pwd', 'value': self.env.super_admin_pw},
{'name': 'db_name', 'value': self.env.dbname},
{'name': 'demo_data', 'value': False},
{'name': 'db_lang', 'value': self.config.lang},
@ -29,28 +25,29 @@ class CamadeusFunctions():
payload = {'params': payload}
json_data = json.dumps(payload)
headers = {'content-type': 'application/json'}
r = requests.post('%s:%s/web/database/create' % (self.env.host,self.env.port), data=json_data, headers=headers, auth=self.env.basic_auth, verify=False)
if r and r.json().get('result',False):
r = requests.post('%s:%s/web/database/create' % (self.env.host, self.env.port), data=json_data, headers=headers, auth=self.env.basic_auth, verify=False)
if r and r.json().get('result', False):
return True
else:
print "Error occured: %s" % r.json().get('error', '????')
msg = pprint.pformat(r.json().get('error', '????'))
print 'Error occured: %s' % msg
return False
def login(self):
"""Login"""
# Get the uid
sock_common = xmlrpclib.ServerProxy ('%s:%s/xmlrpc/common' % (self.env.host,self.env.port))
sock_common = xmlrpclib.ServerProxy ('%s:%s/xmlrpc/common' % (self.env.host, self.env.port))
self.uid = sock_common.login(self.env.dbname, self.env.username, self.env.pwd)
if not self.uid:
raise "Authentication Error"
self.sock = xmlrpclib.ServerProxy('%s:%s/xmlrpc/object' % (self.env.host,self.env.port))
raise Exception('Authentication Error')
self.sock = xmlrpclib.ServerProxy('%s:%s/xmlrpc/object' % (self.env.host, self.env.port))
return True
def _execute(self, *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')
content = ''
if encode=='':
@ -66,28 +63,24 @@ class CamadeusFunctions():
"""Setze Unternehmensdaten (Allgemein, RML, Logo)"""
vals = self.config.company_data
dummy,country_id = self._execute('ir.model.data', 'get_object_reference', 'base',vals['country_id'])
dummy,country_id = self._execute('ir.model.data', 'get_object_reference', 'base', vals['country_id'])
# RML-Header ist nun ein function-Feld
#if vals.get('rml_header',False):
# vals['rml_header'] = self._readAndReturnFile(vals['rml_header'])
if vals.get('logo',False):
vals['logo'] = self._readAndReturnFile(vals['logo'], encode = 'base64')
if vals.get('logo', False):
vals['logo'] = self._readAndReturnFile(vals['logo'], encode='base64')
vals['country_id'] = country_id
c_ids = self._execute('res.company', 'search', [], )
c_ids = self._execute('res.company', 'search', [])
return self._execute('res.company', 'write', c_ids, vals)
def set_taxes(self):
"""Setze nicht benötigte Steuern auf inaktiv"""
tax_ids = self._execute('account.tax', 'search', [('description','not in', self.config.valid_taxes)])
tax_ids = self._execute('account.tax', 'search', [('description', 'not in', self.config.valid_taxes)])
return self._execute('account.tax', 'write', tax_ids, {'active': False})
def set_date_format(self):
"""Setzen des Datumsformats """
lang_ids = self._execute('res.lang', 'search', [('code','=',self.config.lang)])
lang_ids = self._execute('res.lang', 'search', [('code', '=', self.config.lang)])
if lang_ids:
vals = {
'date_format': '%d.%m.%Y',
@ -100,7 +93,7 @@ class CamadeusFunctions():
else:
return False
lang_ids = self._execute('res.lang', 'search', [('code','=','en_US')])
lang_ids = self._execute('res.lang', 'search', [('code', '=', 'en_US')])
if lang_ids:
vals = {
'grouping': '[3,3]',
@ -111,17 +104,6 @@ class CamadeusFunctions():
return True
# def set_report_types(self):
# """Setzen der Report Types auf RML (PDF)"""
#
# report_names = ['purchase.report_purchaseorder',
# 'purchase.report_purchasequotation',
# 'account.report_invoice',
# 'sale.report_saleorder',
# 'stock.report_picking']
# report_ids = self._execute('ir.actions.report.xml', 'search', [('report_name','in',report_names)])
# return self._execute('ir.actions.report.xml', 'write', report_ids, {'report_type': 'pdf'})
def purchase_config(self):
"""Basiskonfiguration für Einkauf laden"""
@ -154,7 +136,7 @@ class CamadeusFunctions():
"""Basiskonfiguration für Fertigung laden"""
if hasattr(self.config, 'mrp_config'):
vals = {}#self._execute('mrp.config.settings', 'default_get', self.config.mrp_config.keys())
vals = {}
vals.update(self.config.mrp_config)
wizard_id = self._execute('mrp.config.settings', 'create', vals)
return self._execute('mrp.config.settings', 'execute', [wizard_id])
@ -176,9 +158,8 @@ class CamadeusFunctions():
if hasattr(self.config, 'incoterms'):
terms = self.config.incoterms
for name,code in terms:
existing_ids = self._execute('stock.incoterms', 'search', ['|',('active','=',True),('active','=',False),('code','=',code)])
existing_ids = self._execute('stock.incoterms', 'search', ['|', ('active', '=', True), ('active', '=', False), ('code', '=', code)])
if existing_ids:
vals = {
'active': True,
@ -193,10 +174,9 @@ class CamadeusFunctions():
self._execute('stock.incoterms', 'create', vals)
codes = [code for name,code in terms]
inactive_ids = self._execute('stock.incoterms', 'search', [('code','not in',codes)])
inactive_ids = self._execute('stock.incoterms', 'search', [('code', 'not in', codes)])
self._execute('stock.incoterms', 'write', inactive_ids, {'active': False})
return True
def base_config(self):
@ -210,7 +190,7 @@ class CamadeusFunctions():
def install_module_sale(self):
"""Modul 'Sale' installieren"""
modules_to_install = self._execute('ir.module.module', 'search', [('name','=','sale'),('state','!=','installed')])
modules_to_install = self._execute('ir.module.module', 'search', [('name', '=', 'sale'), ('state', '!=', 'installed')])
res = self._execute('ir.module.module', 'button_install', modules_to_install)
res = self._execute('base.module.upgrade', 'upgrade_module', modules_to_install)
return True
@ -218,7 +198,7 @@ class CamadeusFunctions():
def install_modules(self):
"""Module installieren"""
modules_to_install = self._execute('ir.module.module', 'search', [('name','in',self.config.modules),('state','!=','installed')])
modules_to_install = self._execute('ir.module.module', 'search', [('name', 'in', self.config.modules), ('state', '!=', 'installed')])
res = self._execute('ir.module.module', 'button_install', modules_to_install)
res = self._execute('base.module.upgrade', 'upgrade_module', modules_to_install)
return True
@ -226,15 +206,15 @@ class CamadeusFunctions():
def _set_picking_sequence_prefix(self, code, value):
seq_dict = self.config.sequences
#Hauptsequenz des Picking Types mit diesem code anpassen
picking_type_id = self._execute('stock.picking.type', 'search', [('code','=',code)], 0, 1, 'id')[0]
# Hauptsequenz des Picking Types mit diesem code anpassen
picking_type_id = self._execute('stock.picking.type', 'search', [('code', '=', code)], 0, 1, 'id')[0]
picking_type = self._execute('stock.picking.type', 'read', picking_type_id, ['sequence_id'])
s_id = picking_type['sequence_id'][0]
if not self._execute('ir.sequence', 'write', s_id, seq_dict.get(value)):
return False
#Allen Picking Types mit diesem code die Haupsequenz geben
picking_type_ids = self._execute('stock.picking.type', 'search', [('code','=',code)])
# Allen Picking Types mit diesem code die Haupsequenz geben
picking_type_ids = self._execute('stock.picking.type', 'search', [('code', '=', code)])
if not self._execute('stock.picking.type', 'write', picking_type_ids, {'sequence_id': s_id}):
return False
@ -253,7 +233,7 @@ class CamadeusFunctions():
# Angebot
if seq_dict.get('sale.order',False):
s_ids = self._execute('ir.sequence', 'search', [('code','=','sale.order')])
s_ids = self._execute('ir.sequence', 'search', [('code', '=', 'sale.order')])
if len(s_ids) != 1:
return False
if not self._execute('ir.sequence', 'write', s_ids, seq_dict.get('sale.order')):
@ -261,7 +241,7 @@ class CamadeusFunctions():
# Arbeitsschein
if seq_dict.get('work.order',False):
s_ids = self._execute('ir.sequence', 'search', [('code','=','work.order')])
s_ids = self._execute('ir.sequence', 'search', [('code', '=', 'work.order')])
if len(s_ids) != 1:
return False
if not self._execute('ir.sequence', 'write', s_ids, seq_dict.get('work.order')):
@ -269,7 +249,7 @@ class CamadeusFunctions():
# EK-Angebot
if seq_dict.get('purchase.order',False):
s_ids = self._execute('ir.sequence', 'search', [('code','=','purchase.order')])
s_ids = self._execute('ir.sequence', 'search', [('code', '=', 'purchase.order')])
if len(s_ids) != 1:
return False
if not self._execute('ir.sequence', 'write', s_ids, seq_dict.get('purchase.order')):
@ -277,7 +257,7 @@ class CamadeusFunctions():
# Rechnungsnummer
if seq_dict.get('account.invoice',False):
j_ids = self._execute('account.journal', 'search', [('code','=','VK')])
j_ids = self._execute('account.journal', 'search', [('code', '=', 'VK')])
if len(j_ids) != 1:
return False
journals = self._execute('account.journal', 'read', j_ids, ['sequence_id'])
@ -287,19 +267,19 @@ class CamadeusFunctions():
# Setzen Gutschriftenkreis
if self.config.refund_invoice_sequence:
j_ids = self._execute('account.journal', 'search', [('code','=','VK')])
j_ids = self._execute('account.journal', 'search', [('code', '=', 'VK')])
if len(j_ids) != 1:
return False
journals = self._execute('account.journal', 'read', j_ids, ['sequence_id'])
s_id = journals[0]['sequence_id'][0]
gj_ids = self._execute('account.journal', 'search', [('code','=','GSV')])
gj_ids = self._execute('account.journal', 'search', [('code', '=', 'GSV')])
if len(gj_ids) != 1:
return False
vals = {
'sequence_id': s_id,
}
self._execute('account.journal', 'write', gj_ids,vals)
self._execute('account.journal', 'write', gj_ids, vals)
return True
@ -311,11 +291,11 @@ class CamadeusFunctions():
# Technische Eigenschaften
dummy,group_id = self._execute('ir.model.data', 'get_object_reference', 'base', 'group_no_one')
groups.append((4,group_id))
groups.append((4, group_id))
# Finanzmanager
dummy,group_id = self._execute('ir.model.data', 'get_object_reference', 'account', 'group_account_manager')
groups.append((4,group_id))
groups.append((4, group_id))
vals = {
'groups_id': groups,
@ -337,14 +317,14 @@ class CamadeusFunctions():
"""Konfiguration Kontenplan"""
c = self.config
sales_tax_ids = self._execute('account.tax.template', 'search', [('description','=', c.sales_tax),('parent_id','=',False)])
sales_tax_ids = self._execute('account.tax.template', 'search', [('description', '=', c.sales_tax), ('parent_id', '=', False)])
if not sales_tax_ids:
return False
purchase_tax_ids = self._execute('account.tax.template', 'search', [('description','=', c.purchase_tax),('parent_id','=',False)])
purchase_tax_ids = self._execute('account.tax.template', 'search', [('description', '=', c.purchase_tax), ('parent_id', '=', False)])
if not purchase_tax_ids:
return False
#Set Your Accounting Options
# Set Your Accounting Options
dummy,currency_id = self._execute('ir.model.data', 'get_object_reference', 'base', 'EUR')
vals = {}
vals['chart_template_id'] = c.chart_template_id
@ -362,13 +342,13 @@ class CamadeusFunctions():
c = self.config
# Set all currencies to active
ids = self._execute('res.currency', 'search', ['|',('active','=',True),('active','=',False)])
ids = self._execute('res.currency', 'search', ['|', ('active', '=', True), ('active', '=', False)])
res = self._execute('res.currency', 'write', ids, {'active': True})
if not res:
return False
# Set all other UOMs to inactive
inactive_ids = self._execute('res.currency', 'search', [('name','not in',c.valid_currencies)])
inactive_ids = self._execute('res.currency', 'search', [('name', 'not in', c.valid_currencies)])
res = self._execute('res.currency', 'write', inactive_ids, {'active': False})
if not res:
return False
@ -378,8 +358,8 @@ class CamadeusFunctions():
def uninstall_chat(self):
"""Chat-Modul deinstallieren """
modules = ['im_chat','im_odoo_support','bus']
modules_to_install = self._execute('ir.module.module', 'search', [('name','in',modules)])
modules = ['im_chat', 'im_odoo_support', 'bus']
modules_to_install = self._execute('ir.module.module', 'search', [('name', 'in', modules)])
res = self._execute('ir.module.module', 'button_uninstall', modules_to_install)
res = self._execute('base.module.upgrade', 'upgrade_module', modules_to_install)
return True
@ -397,13 +377,13 @@ class CamadeusFunctions():
active_ids.append(uom_id)
# Set all UOMs to active
ids = self._execute('product.uom', 'search', ['|',('active','=',True),('active','=',False)])
ids = self._execute('product.uom', 'search', ['|', ('active', '=', True), ('active', '=', False)])
res = self._execute('product.uom', 'write', ids, {'active': True})
if not res:
return False
# Set all other UOMs to inactive
inactive_ids = self._execute('product.uom', 'search', [('id','not in',active_ids)])
inactive_ids = self._execute('product.uom', 'search', [('id', 'not in', active_ids)])
res = self._execute('product.uom', 'write', inactive_ids, {'active': False})
if not res:
return False
@ -422,23 +402,24 @@ class CamadeusFunctions():
c = self.config
# Ungültige Steuerzuordnungen auf inaktiv setzen
invalid_ids = self._execute('account.fiscal.position', 'search', [('name','not in',c.valid_fiscal_positions)])
invalid_ids = self._execute('account.fiscal.position', 'search', [('name', 'not in', c.valid_fiscal_positions)])
self._execute('account.fiscal.position', 'write', invalid_ids, {'active': False})
# Mappings inaktiver Steuern löschen (also wenn rechte Seite eine inaktive Steuer ist, wie z.B "strf. i.g.L"))
valid_position_ids = self._execute('account.fiscal.position', 'search', [('name','in',c.valid_fiscal_positions)])
valid_tax_ids = self._execute('account.tax', 'search', [('parent_id','=',False)])
valid_position_ids = self._execute('account.fiscal.position', 'search', [('name', 'in', c.valid_fiscal_positions)])
valid_tax_ids = self._execute('account.tax', 'search', [('parent_id', '=', False)])
position_tax_line_ids = self._execute('account.fiscal.position.tax', 'search', [('position_id','in',valid_position_ids),('tax_dest_id','not in',valid_tax_ids)])
position_tax_line_ids = self._execute('account.fiscal.position.tax', 'search', [('position_id', 'in', valid_position_ids), ('tax_dest_id', 'not in', valid_tax_ids)])
vals = {'tax_dest_id': False}
return self._execute('account.fiscal.position.tax', 'write', position_tax_line_ids, vals)
def update_module(self):
"""Aktualisiere Modul"""
module_name = self.config.module_name
mod_ids = self._execute('ir.module.module', 'search', [('name','=',module_name),('state','=','installed')])
mod_ids = self._execute('ir.module.module', 'search', [('name', '=', module_name),('state', '=', 'installed')])
if not len(mod_ids) == 1:
raise "Module '%s' not found or ist not installed." % module_name
raise Exception('Module "%s" not found or not installed.' % module_name)
res = self._execute('ir.module.module', 'button_upgrade', mod_ids)
res = self._execute('base.module.upgrade', 'upgrade_module', [])
@ -446,10 +427,11 @@ class CamadeusFunctions():
def install_module(self):
"""Installiere Modul"""
module_name = self.config.module_name
mod_ids = self._execute('ir.module.module', 'search', [('name','=',module_name),('state','=','uninstalled')])
mod_ids = self._execute('ir.module.module', 'search', [('name', '=', module_name), ('state', '=', 'uninstalled')])
if not len(mod_ids) == 1:
raise "Module '%s' not found or is not in state 'uninstalled'." % module_name
raise Exception('Module "%s" not found or is not in state "uninstalled".' % module_name)
res = self._execute('ir.module.module', 'button_install', mod_ids)
res = self._execute('base.module.upgrade', 'upgrade_module', [])
@ -464,8 +446,9 @@ class CamadeusFunctions():
def setup_journals(self):
"""Update journals"""
# Verkauf- und Gutschriftenjournal
j_ids = self._execute('account.journal', 'search', [('code','in',['VK','GSV','SAJ','SCNJ'])])
j_ids = self._execute('account.journal', 'search', [('code', 'in', ['VK', 'GSV', 'SAJ', 'SCNJ'])])
if len(j_ids) != 2:
return False
vals = {
@ -477,10 +460,11 @@ class CamadeusFunctions():
def update_all(self):
"""Aktualisiere Modul"""
for module_name in self.config.modules:
mod_ids = self._execute('ir.module.module', 'search', [('name','=',module_name),('state','=','installed')])
mod_ids = self._execute('ir.module.module', 'search', [('name', '=', module_name), ('state', '=', 'installed')])
if not len(mod_ids) == 1:
raise Exception("Module '%s' not found or ist not installed." % module_name)
raise Exception('Module "%s" not found or ist not installed.' % module_name)
res = self._execute('ir.module.module', 'button_upgrade', mod_ids)
res = self._execute('base.module.upgrade', 'upgrade_module', [])
@ -489,15 +473,15 @@ class CamadeusFunctions():
def set_warehouse(self):
"""Name des Zentrallagers setzen"""
is_installed = self._execute('ir.module.module', 'search', [('name','=','stock'),('state','=','installed')])
is_installed = self._execute('ir.module.module', 'search', [('name', '=', 'stock'), ('state', '=', 'installed')])
if is_installed:
vals = {
'name': self.config.warehouse_name or self.config.company_data.get('name','Mein Unternehmen'),
'name': self.config.warehouse_name or self.config.company_data.get('name', 'Mein Unternehmen'),
'delivery_steps': self.config.delivery_steps,
}
if self.config.warehouse_code:
vals.update({'code': self.config.warehouse_code})
warehouse_ids = self._execute('stock.warehouse', 'search', [('id','=',1)])
warehouse_ids = self._execute('stock.warehouse', 'search', [('id', '=', 1)])
return self._execute('stock.warehouse', 'write', warehouse_ids, vals)
else:
return True
@ -505,7 +489,7 @@ class CamadeusFunctions():
def set_dmi_noupdate(self):
"""DMI: Einträge auf 'no update' setzen"""
domain = [('module','=','cam_dmi'),('noupdate','=',False)]
domain = [('module','=','cam_dmi'), ('noupdate', '=', False)]
data_ids = self._execute('ir.model.data', 'search', domain)
vals = {'noupdate': True}
@ -518,7 +502,7 @@ class CamadeusFunctions():
inventory = self._execute('stock.inventory', 'read', inventory_id, ['state'])
if inventory.get('state','') == 'confirm':
if inventory.get('state', '') == 'confirm':
return self._execute('stock.inventory', 'action_done', [inventory_id])
return True
@ -545,7 +529,7 @@ class CamadeusFunctions():
return False
# Product Price
ids = self._execute('decimal.precision', 'search', [('name','=','Product Price')])
ids = self._execute('decimal.precision', 'search', [('name', '=', 'Product Price')])
res = self._execute('decimal.precision', 'write', ids, {'digits': self.config.price_decimals})
if not res:
return False
@ -583,7 +567,7 @@ class CamadeusFunctions():
wizard_id = self._execute('base_import.import', 'create', vals)
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:
print messages
return False
@ -596,7 +580,7 @@ class CamadeusFunctions():
if hasattr(self.config, 'translation_files') and self.config.lang != 'en_US':
for file in self.config.translation_files:
data = self._readAndReturnFile(file,encode='base64')
data = self._readAndReturnFile(file, encode='base64')
vals = {
'name': 'test',
'code': self.config.lang,
@ -618,9 +602,10 @@ class CamadeusFunctions():
def set_default_removal_strategy(self):
"""Default Entnahmestrategie für Lager setzen"""
if hasattr(self.config, 'removal_strategy'):
method = self.config.removal_strategy
strategy_ids = self._execute('product.removal', 'search', [('method','=',method)])
strategy_ids = self._execute('product.removal', 'search', [('method', '=', method)])
if not strategy_ids:
return False
@ -628,11 +613,12 @@ class CamadeusFunctions():
if not stock_id:
return False
return self._execute('stock.location', 'write', stock_id,{'removal_strategy_id':strategy_ids[0]})
return self._execute('stock.location', 'write', stock_id, {'removal_strategy_id': strategy_ids[0]})
return True
def set_default_values(self):
"""Defaultwerte für Dokumente setzen"""
for model,field,value in self.config.default_values:
vals = {
'name': field,
@ -641,7 +627,7 @@ class CamadeusFunctions():
'key': 'default',
'key2': False,
}
domain = [('name','=',field),('model','=',model)]
domain = [('name', '=', field), ('model', '=', model)]
val_ids = self._execute('ir.values', 'search', domain)
if val_ids:
self._execute('ir.values', 'write', val_ids, vals)
@ -662,9 +648,11 @@ class CamadeusFunctions():
"""Systemparameter setzen"""
for key,value in self.config.system_parameters.items():
param_ids = self._execute('ir.config_parameter', 'search', [('key','=',key)])
vals = {'key': key,
'value': value}
param_ids = self._execute('ir.config_parameter', 'search', [('key', '=', key)])
vals = {
'key': key,
'value': value,
}
if param_ids:
self._execute('ir.config_parameter', 'write', param_ids, vals)
else:
@ -675,7 +663,7 @@ class CamadeusFunctions():
"""Berichte konfigurieren"""
for report, attachment in self.config.reports.items():
r_ids = self._execute('ir.actions.report.xml', 'search', [('report_name','=',report)])
r_ids = self._execute('ir.actions.report.xml', 'search', [('report_name', '=', report)])
if r_ids:
self._execute('ir.actions.report.xml', 'write', r_ids, {'attachment': attachment})
else:

View File

@ -139,7 +139,6 @@ class odoo {
ensure => installed,
provider => 'pip',
require => Package['python-pip'],
}
# Update python lib distribute if required ("sudo easy_install -U distribute")
@ -157,7 +156,6 @@ class odoo {
ensure => present,
provider => 'pip',
require => [Package['python-pip'],Package['python-psycopg2'],Exec['upgrade_distribute'], Class['postgresql::server']],
}
# main directory for odoo backups
@ -206,7 +204,6 @@ class odoo {
}
define odoo::instance ($db_pw,$ssl = false, $servername, $odooport, $odooport_longpolling) {
$instance = $title
include odoo
@ -270,7 +267,6 @@ define odoo::instance ($db_pw,$ssl = false, $servername, $odooport, $odooport_lo
target => "/var/log/odoo/$instance/odoo-server.log",
}
$require_log = "file[/var/log/odoo/$instance]"
file { "/var/log/odoo/$instance/odoo-server.log":
owner => $instance,
@ -347,7 +343,6 @@ git --work-tree=/home/$instance/ext --git-dir=/home/$instance/ext.git checkout -
}
# backup
file { "/home/$instance/odoo-backup.sh":
owner => $instance,
@ -357,7 +352,6 @@ git --work-tree=/home/$instance/ext --git-dir=/home/$instance/ext.git checkout -
content => template('odoo/odoo-backup.sh.erb'),
}
$cron_cmd = "/home/$instance/odoo-backup.sh"
$cron_require = "file[/home/$instance/odoo-backup.sh]"
$odoo_backup = "odoo-backup-$instance"
@ -391,7 +385,7 @@ git --work-tree=/home/$instance/ext --git-dir=/home/$instance/ext.git checkout -
postgresql::server::role { "$instance":
password_hash => postgresql_password($instance, $db_pw),
createdb => true,
# require => Exec['utf8 postgres'],
#require => Exec['utf8 postgres'],
}
# NGINX