diff --git a/setup/lib/cli.py b/setup/lib/cli.py index d4a3e31b..10ca01e7 100755 --- a/setup/lib/cli.py +++ b/setup/lib/cli.py @@ -1,12 +1,17 @@ # -*- coding: utf-8 -*- +from __future__ import print_function import sys -from urllib.parse import urlparse +try: + from urllib.parse import urlparse +except ImportError: + from urlparse import urlparse from .config import Config from .environments import ENVIRONMENTS, Environment from .functions import DatenpolFunctions + def main(): def _usage(): print('Verwendung: dp [/]') @@ -145,7 +150,7 @@ def main(): if cmd == 'rollout': methods = [ 'login', - #'set_sequences', + 'set_sequences', #'set_dmi_noupdate', #'dmi_confirm_inventory', #'import_users', @@ -234,7 +239,7 @@ def main(): env.pwd = input('Passwort: ') - if cmd in ['create','dump','restore']: + if cmd in ['create', 'dump', 'restore']: env.super_admin_pw = input('Super-Admin-Passwort: ') print() diff --git a/setup/lib/config_glaser.py b/setup/lib/config_glaser.py index 106ab879..35c81f0a 100644 --- a/setup/lib/config_glaser.py +++ b/setup/lib/config_glaser.py @@ -2,6 +2,7 @@ from .config import Config + class ConfigGlaser(Config): def __init__(self): super(ConfigGlaser, self).__init__() @@ -35,29 +36,28 @@ class ConfigGlaser(Config): self.sequences = { 'sale.order': { # 'number_next_actual': 1, - 'prefix': 'GL%(y)s', - 'padding': 4, + 'prefix': 'ATOC%(range_y)s-', + 'padding': 6, 'use_date_range': True, 'monthly_date_range': False }, 'account.invoice': { # 'number_next_actual': 0001, - 'prefix': 'GL%(y)s%(month)s', - 'padding': 4, + 'prefix': '%(range_year)s-', + 'padding': 6, 'use_date_range': True, - 'monthly_date_range': False }, # Wenn 'account.invoice_refund' auskommentiert ist, dann wird # für die Gutschrift der selbe Nummernkreis verwendet - 'account.invoice_refund': { - # 'number_next_actual': 0001, - 'name': 'Gutschriften', - 'implementation': 'no_gap', - 'prefix': 'GL%(y)s', - 'padding': 4, - 'use_date_range': True, - 'monthly_date_range': False - }, + # 'account.invoice_refund': { + # # 'number_next_actual': 0001, + # 'name': 'Gutschriften', + # 'implementation': 'no_gap', + # 'prefix': 'GL%(y)s', + # 'padding': 4, + # 'use_date_range': True, + # 'monthly_date_range': False + # }, # 'picking.out': { # # 'number_next_actual': 1, # 'prefix': 'LS-', @@ -83,4 +83,3 @@ class ConfigGlaser(Config): self.multi_company_settings = { 'chart_template_id': ('xmlid', 'l10n_at.austria_chart_template') } - diff --git a/setup/lib/config_tza.py b/setup/lib/config_tza.py index f70f1c93..367ae74c 100644 --- a/setup/lib/config_tza.py +++ b/setup/lib/config_tza.py @@ -2,6 +2,7 @@ from .config import Config + class ConfigTZA(Config): def __init__(self): super(ConfigTZA, self).__init__() @@ -35,29 +36,28 @@ class ConfigTZA(Config): self.sequences = { 'sale.order': { # 'number_next_actual': 1, - 'prefix': '%(y)s', - 'padding': 4, + 'prefix': 'ATOC%(range_y)s-', + 'padding': 6, 'use_date_range': True, 'monthly_date_range': False }, 'account.invoice': { # 'number_next_actual': 0001, - 'prefix': '%(y)s%(month)s', - 'padding': 4, + 'prefix': '%(range_year)s-', + 'padding': 6, 'use_date_range': True, - 'monthly_date_range': False }, # Wenn 'account.invoice_refund' auskommentiert ist, dann wird # für die Gutschrift der selbe Nummernkreis verwendet - 'account.invoice_refund': { - # 'number_next_actual': 0001, - 'name': 'Gutschriften', - 'implementation': 'no_gap', - 'prefix': '%(y)s', - 'padding': 4, - 'use_date_range': True, - 'monthly_date_range': False - }, + # 'account.invoice_refund': { + # # 'number_next_actual': 0001, + # 'name': 'Gutschriften', + # 'implementation': 'no_gap', + # 'prefix': '%(y)s', + # 'padding': 4, + # 'use_date_range': True, + # 'monthly_date_range': False + # }, # 'picking.out': { # # 'number_next_actual': 1, # 'prefix': 'LS-', @@ -79,4 +79,3 @@ class ConfigTZA(Config): # 'padding': 5, # }, } - diff --git a/setup/lib/functions.py b/setup/lib/functions.py index 5f6d6d98..add55c19 100644 --- a/setup/lib/functions.py +++ b/setup/lib/functions.py @@ -1,13 +1,16 @@ # -*- coding: utf-8 -*- - +from __future__ import print_function import base64 import sys import odoorpc -from urllib.parse import urlparse +try: + from urllib.parse import urlparse +except ImportError: + from urlparse import urlparse -class DatenpolFunctions: +class DatenpolFunctions(object): def __init__(self, environment, config): self.env = environment self.config = config @@ -252,9 +255,19 @@ class DatenpolFunctions: # Angebot if seq_dict.get('sale.order', False): - s_ids = ir_seq.search([('code', '=', 'sale.order')]) + s_ids = ir_seq.search([('code', '=', 'sale.order'), ('company_id', '=', self.company_id.id)]) + if not s_ids: + s_ids = ir_seq.search([('code', '=', 'sale.order'), ('company_id', '=', False)]) if len(s_ids) != 1: - return False + s_ids = ir_seq.search([('code', '=', 'sale.order')], limit=1) + if not s_ids: + return False + ir_seq_id = ir_seq.browse(s_ids) + if ir_seq_id.company_id and ir_seq_id.company_id.id != self.company_id.id: + seq_dict['sale.order']['company_id'] = self.company_id.id + s_ids = [ir_seq_id.copy()] + if not ir_seq_id.company_id: + seq_dict['sale.order']['company_id'] = self.company_id.id if not ir_seq.write(s_ids, seq_dict.get('sale.order')): return False @@ -275,7 +288,9 @@ class DatenpolFunctions: return False # Hole Journal für Ausgangsrechnungen - j_ids = self.odoo.env['account.journal'].search([('code', '=', 'Re.:')]) + j_ids = self.odoo.env['account.journal'].search([('code', '=', 'Re.:'), ('company_id', '=', self.company_id.id)]) + if not j_ids: + j_ids = self.odoo.env['account.journal'].search([('code', '=', 'Re.:')]) if len(j_ids) != 1: return False journals = self.odoo.env['account.journal'].read(j_ids, @@ -727,7 +742,7 @@ class DatenpolFunctions: self.odoo.env['res.partner'].write([id], vals) def make_anonymous_project(self): - if (self.odoo.env['ir.module.module'].search([('name', '=', 'project'), ('state', '=', 'installed')])): + if self.odoo.env['ir.module.module'].search([('name', '=', 'project'), ('state', '=', 'installed')]): ids = self.odoo.env['project.project'].search([]) for id in ids: vals = { @@ -744,7 +759,7 @@ class DatenpolFunctions: self.odoo.env['project.task'].write([id], vals) def make_anonymous_employee(self): - if (self.odoo.env['ir.module.module'].search([('name', '=', 'hr'), ('state', '=', 'installed')])): + if self.odoo.env['ir.module.module'].search([('name', '=', 'hr'), ('state', '=', 'installed')]): ids = self.odoo.env['hr.employee'].search([]) for id in ids: vals = { @@ -754,7 +769,7 @@ class DatenpolFunctions: self.odoo.env['hr.employee'].write([id], vals) def make_anonymous_leads(self): - if (self.odoo.env['ir.module.module'].search([('name', '=', 'crm'), ('state', '=', 'installed')])): + if self.odoo.env['ir.module.module'].search([('name', '=', 'crm'), ('state', '=', 'installed')]): ids = self.odoo.env['crm.lead'].search([]) for id in ids: vals = {