From 757ac884edbefb4a4447d05911f2241131329741 Mon Sep 17 00:00:00 2001 From: Ahmed Aly Date: Mon, 27 Nov 2017 14:12:31 +0100 Subject: [PATCH] multicompany dp_script functions fix --- setup/lib/environments.py | 3 ++- setup/lib/functions.py | 35 +++++++++++++++++++++-------------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/setup/lib/environments.py b/setup/lib/environments.py index 8c641f5f..2c831f95 100644 --- a/setup/lib/environments.py +++ b/setup/lib/environments.py @@ -31,7 +31,8 @@ ENVIRONMENTS = { 'br': Environment('http://localhost', '8080', 'tz-austria_1', 'tz-admin', 'x', 'admin', config=ConfigTZA()), 'br-glaser': Environment('http://localhost', '8080', 'tz-austria_1', 'glaser-admin', 'x', 'admin', config=ConfigGlaser()), - 'aa': Environment('http://localhost', '8080', 'tz-austria_1', 'tz-admin', 'x', 'admin', config=ConfigTZA()), + 'aa': Environment('http://localhost', '8080', 'tz-austria_1', 'admin', 'x', 'admin', config=ConfigTZA()), + 'aa-tz': Environment('http://localhost', '8080', 'tz-austria_1', 'tz-admin', 'x', 'admin', config=ConfigTZA()), 'aa-glaser': Environment('http://localhost', '8080', 'tz-austria_1', 'glaser-admin', 'x', 'admin', config=ConfigGlaser()), 'oa': Environment('http://localhost', '8080', 'tz-austria_1', 'admin', 'x', 'admin'), diff --git a/setup/lib/functions.py b/setup/lib/functions.py index 36077f76..6943e18b 100644 --- a/setup/lib/functions.py +++ b/setup/lib/functions.py @@ -97,25 +97,32 @@ class DatenpolFunctions: """Setze beim portal_template_user die Company als zulässiges Unternehmen""" portal_template_user = self.odoo.env.ref('auth_signup.default_template_user') vals = {} - if self.odoo.env.ref(self.config.company_xmlid) not in portal_template_user.company_ids: - vals = {'company_ids': [(4, self.odoo.env.ref(self.config.company_xmlid).id)]} + companies = self.odoo.env['res.company'].search([]) + vals_company = [] + for company in companies: + if company not in portal_template_user.company_ids.ids: + vals_company.append((4, company)) + + vals = {'company_ids': vals_company} return portal_template_user.write(vals) def set_multicompany_data(self): """Multicompany Systemeinstellungen konfigurieren""" - res_settings = self.odoo.env['res.config.settings'] - vals = res_settings.default_get([]) - newvals = {} - for key, value in self.config.multi_company_settings.items(): - if isinstance(value, tuple): - if value[0] == 'xmlid': - newvals.update({key: self.odoo.env.ref(value[1]).id}) - else: - newvals.update({key: value}) - vals.update(newvals) - wizard_id = res_settings.create(vals) - return res_settings.browse(wizard_id).execute() + if hasattr(self.config, 'multi_company_settings'): + res_settings = self.odoo.env['res.config.settings'] + vals = res_settings.default_get([]) + newvals = {} + for key, value in self.config.multi_company_settings.items(): + if isinstance(value, tuple): + if value[0] == 'xmlid': + newvals.update({key: self.odoo.env.ref(value[1]).id}) + else: + newvals.update({key: value}) + vals.update(newvals) + wizard_id = res_settings.create(vals) + return res_settings.browse(wizard_id).execute() + return True def load_languages(self): """Lade zusätzliche Sprachen"""