Updated setup_website script

develop
Ahmed Aly 2018-09-25 10:42:46 +02:00
parent f546f09ef9
commit 60665a2738
3 changed files with 71 additions and 74 deletions

View File

@ -86,3 +86,11 @@ class ConfigAllInOnePT(Config):
self.multi_company_settings = { self.multi_company_settings = {
'chart_template_id': ('xmlid', 'l10n_at.austria_chart_template') 'chart_template_id': ('xmlid', 'l10n_at.austria_chart_template')
} }
self.websites = [
{
'name': 'Prosolutions Online',
'domain': 'www.prosolutions.online',
'company_xml_id': 'base.main_company'
},
]

View File

@ -89,3 +89,16 @@ class ConfigTZA(Config):
# 'padding': 5, # 'padding': 5,
# }, # },
} }
self.websites = [
{
'name': 'IR Heizpaneele',
'domain': 'www.irheizpaneele.at',
'company_xml_id': 'base.main_company'
},
{
'name': 'Heizpaneele',
'domain': 'www.heizpaneele.at',
'company_xml_id': 'base.main_company'
},
]

View File

@ -264,79 +264,48 @@ class DatenpolFunctions(object):
ir_model_obj = self.odoo.env['ir.model.data'] ir_model_obj = self.odoo.env['ir.model.data']
crm_team_obj = self.odoo.env['crm.team'] crm_team_obj = self.odoo.env['crm.team']
# if not ir_model_obj.search([('module', '=', 'website_multi_theme'), ('name', '=', 'clarico_multi')]): websites = self.config.websites
# # Create Theme
# clarico_theme = self.odoo.env['website.theme'].create({
# 'name': 'Multiwebsite Clarico Theme',
# 'converted_theme_addon': 'theme_clarico'
# })
#
# vals = {
# 'model': 'website.theme',
# 'module': 'website_multi_theme',
# 'name': 'clarico_multi',
# 'res_id': str(clarico_theme),
# 'noupdate': False,
# }
# ir_model_obj.create(vals)
#
# clarico_theme = self.odoo.env.ref('website_multi_theme.clarico_multi')
# self.odoo.env.ref('website.default_website').multi_theme_reload() # create salesteam
for idx, website in enumerate(websites):
# create Salesteam for all websites cr_team = crm_team_obj.search([('name', '=', website['name'])])
cr_team_ir_heizpaneel = crm_team_obj.search([('name', '=', 'IR Heizpaneele')]) if not cr_team:
if not cr_team_ir_heizpaneel:
crm_team_vals = { crm_team_vals = {
'name': 'IR Heizpaneele', 'name': website['name'],
'team_type': 'website', 'team_type': 'website',
'company_id': self.odoo.env.ref('base.main_company').id, 'company_id': self.odoo.env.ref(website['company_xml_id']).id,
} }
cr_team_ir_heizpaneel = crm_team_obj.browse([crm_team_obj.create(crm_team_vals)]) cr_team = crm_team_obj.browse([crm_team_obj.create(crm_team_vals)])
else: else:
cr_team_ir_heizpaneel = crm_team_obj.browse(cr_team_ir_heizpaneel) cr_team = crm_team_obj.browse(cr_team)
cr_team_heizpaneel = crm_team_obj.search([('name', '=', 'Heizpaneele')]) website_vals = {
if not cr_team_heizpaneel: 'name': website['name'],
crm_team_vals = { 'domain': website['domain'],
'name': 'Heizpaneele', 'company_id': self.odoo.env.ref(website['company_xml_id']).id,
'team_type': 'website', 'salesteam_id': cr_team.id,
'company_id': self.odoo.env.ref('base.main_company').id, 'multi_theme_id': self.odoo.env.ref('website_multi_theme.theme_default').id
} }
cr_team_heizpaneel = crm_team_obj.browse([crm_team_obj.create(crm_team_vals)])
else:
cr_team_heizpaneel = crm_team_obj.browse(cr_team_heizpaneel)
# Create and configure Websites # Create and configure Websites
if idx == 0:
default_website = self.odoo.env.ref('website.default_website') default_website = self.odoo.env.ref('website.default_website')
default_website.write({ default_website.write(website_vals)
'name': 'IR Heizpaneele', else:
'domain': 'www.irheizpaneele.at', website_id = website['name'].lower().replace('-', '_').replace(' ', '_').replace('.', '_')
'company_id': self.odoo.env.ref('base.main_company').id, if not ir_model_obj.search([('module', '=', 'dp_website'), ('name', '=', website_id)]):
'salesteam_id': cr_team_ir_heizpaneel.id, created_website = self.odoo.env['website'].create(website_vals)
'multi_theme_id': self.odoo.env.ref('website_multi_theme.theme_default').id
})
heizpaneele_vals = {
'name': 'Heizpaneele',
'domain': 'www.heizpaneele.at',
'company_id': self.odoo.env.ref('base.main_company').id,
'salesteam_id': cr_team_heizpaneel.id,
'multi_theme_id': self.odoo.env.ref('website_multi_theme.theme_default').id
}
if not ir_model_obj.search([('module', '=', 'dp_website'), ('name', '=', 'tz_heizpaneele')]):
heizpaneele = self.odoo.env['website'].create(heizpaneele_vals)
vals = { vals = {
'model': 'website', 'model': 'website',
'module': 'dp_website', 'module': 'dp_website',
'name': 'tz_heizpaneele', 'name': website_id,
'res_id': str(heizpaneele), 'res_id': str(created_website),
'noupdate': True, 'noupdate': True,
} }
ir_model_obj.create(vals) ir_model_obj.create(vals)
else: else:
heizpaneele = self.odoo.env.ref('dp_website.tz_heizpaneele') created_website = self.odoo.env.ref('dp_website.'+website_id)
heizpaneele.write(heizpaneele_vals) created_website.write(website_vals)
res_settings = self.odoo.env['res.config.settings'] res_settings = self.odoo.env['res.config.settings']
vals = res_settings.default_get([]) vals = res_settings.default_get([])
@ -349,7 +318,7 @@ class DatenpolFunctions(object):
wizard_id = res_settings.create(vals) wizard_id = res_settings.create(vals)
res_settings.execute(wizard_id) res_settings.execute(wizard_id)
# # Make all pricelists not selectable
self.odoo.env['product.pricelist'].browse(self.odoo.env['product.pricelist'].search([])).write({ self.odoo.env['product.pricelist'].browse(self.odoo.env['product.pricelist'].search([])).write({
'selectable': False 'selectable': False
}) })
@ -375,9 +344,16 @@ class DatenpolFunctions(object):
def configure_payment_providers(self): def configure_payment_providers(self):
"""Zahlungsmethoden konfigurieren""" """Zahlungsmethoden konfigurieren"""
websites = self.config.websites
website_ids = []
for idx, website in enumerate(websites):
if idx == 0:
website_ids.append(self.odoo.env.ref('website.default_website').id)
else:
website_xml_id = website['name'].lower().replace('-', '_').replace(' ', '_').replace('.', '_')
website_ids.append(self.odoo.env.ref('dp_website.'+website_xml_id).id)
vals = { vals = {
'website_ids': [(6, 0, [self.odoo.env.ref('dp_website.tz_heizpaneele').id, 'website_ids': [(6, 0, website_ids)]
self.odoo.env.ref('website.default_website').id])]
} }
paypal = self.odoo.env.ref('payment.payment_acquirer_paypal') paypal = self.odoo.env.ref('payment.payment_acquirer_paypal')