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

@ -23,8 +23,8 @@ class ConfigAllInOnePT(Config):
'vat': False,
'vat_check_vies': True,
'logo': '../ext/custom-addons/dp_custom/static/src/img/logo.png',
#'favicon_backend': '../ext/custom-addons/dp_custom/static/src/img/favicon.ico',
#'favicon_backend_mimetype': 'image/x-icon'
# 'favicon_backend': '../ext/custom-addons/dp_custom/static/src/img/favicon.ico',
# 'favicon_backend_mimetype': 'image/x-icon'
}
# Nur für Lager
@ -86,3 +86,11 @@ class ConfigAllInOnePT(Config):
self.multi_company_settings = {
'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,
# },
}
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']
crm_team_obj = self.odoo.env['crm.team']
# if not ir_model_obj.search([('module', '=', 'website_multi_theme'), ('name', '=', 'clarico_multi')]):
# # 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')
websites = self.config.websites
# self.odoo.env.ref('website.default_website').multi_theme_reload()
# create salesteam
for idx, website in enumerate(websites):
cr_team = crm_team_obj.search([('name', '=', website['name'])])
if not cr_team:
crm_team_vals = {
'name': website['name'],
'team_type': 'website',
'company_id': self.odoo.env.ref(website['company_xml_id']).id,
}
cr_team = crm_team_obj.browse([crm_team_obj.create(crm_team_vals)])
else:
cr_team = crm_team_obj.browse(cr_team)
# create Salesteam for all websites
cr_team_ir_heizpaneel = crm_team_obj.search([('name', '=', 'IR Heizpaneele')])
if not cr_team_ir_heizpaneel:
crm_team_vals = {
'name': 'IR Heizpaneele',
'team_type': 'website',
'company_id': self.odoo.env.ref('base.main_company').id,
website_vals = {
'name': website['name'],
'domain': website['domain'],
'company_id': self.odoo.env.ref(website['company_xml_id']).id,
'salesteam_id': cr_team.id,
'multi_theme_id': self.odoo.env.ref('website_multi_theme.theme_default').id
}
cr_team_ir_heizpaneel = crm_team_obj.browse([crm_team_obj.create(crm_team_vals)])
else:
cr_team_ir_heizpaneel = crm_team_obj.browse(cr_team_ir_heizpaneel)
cr_team_heizpaneel = crm_team_obj.search([('name', '=', 'Heizpaneele')])
if not cr_team_heizpaneel:
crm_team_vals = {
'name': 'Heizpaneele',
'team_type': 'website',
'company_id': self.odoo.env.ref('base.main_company').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
default_website = self.odoo.env.ref('website.default_website')
default_website.write({
'name': 'IR Heizpaneele',
'domain': 'www.irheizpaneele.at',
'company_id': self.odoo.env.ref('base.main_company').id,
'salesteam_id': cr_team_ir_heizpaneel.id,
'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 = {
'model': 'website',
'module': 'dp_website',
'name': 'tz_heizpaneele',
'res_id': str(heizpaneele),
'noupdate': True,
}
ir_model_obj.create(vals)
else:
heizpaneele = self.odoo.env.ref('dp_website.tz_heizpaneele')
heizpaneele.write(heizpaneele_vals)
# Create and configure Websites
if idx == 0:
default_website = self.odoo.env.ref('website.default_website')
default_website.write(website_vals)
else:
website_id = website['name'].lower().replace('-', '_').replace(' ', '_').replace('.', '_')
if not ir_model_obj.search([('module', '=', 'dp_website'), ('name', '=', website_id)]):
created_website = self.odoo.env['website'].create(website_vals)
vals = {
'model': 'website',
'module': 'dp_website',
'name': website_id,
'res_id': str(created_website),
'noupdate': True,
}
ir_model_obj.create(vals)
else:
created_website = self.odoo.env.ref('dp_website.'+website_id)
created_website.write(website_vals)
res_settings = self.odoo.env['res.config.settings']
vals = res_settings.default_get([])
@ -349,7 +318,7 @@ class DatenpolFunctions(object):
wizard_id = res_settings.create(vals)
res_settings.execute(wizard_id)
#
# Make all pricelists not selectable
self.odoo.env['product.pricelist'].browse(self.odoo.env['product.pricelist'].search([])).write({
'selectable': False
})
@ -375,9 +344,16 @@ class DatenpolFunctions(object):
def configure_payment_providers(self):
"""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 = {
'website_ids': [(6, 0, [self.odoo.env.ref('dp_website.tz_heizpaneele').id,
self.odoo.env.ref('website.default_website').id])]
'website_ids': [(6, 0, website_ids)]
}
paypal = self.odoo.env.ref('payment.payment_acquirer_paypal')