From 17ee7c81266eb7b963a0f396b8f0b60b28c89472 Mon Sep 17 00:00:00 2001 From: Ahmed Aly Date: Wed, 27 Jun 2018 16:49:08 +0200 Subject: [PATCH] update setup_website script --- setup/lib/config.py | 4 +- setup/lib/functions.py | 110 ++++++++++++++++++++++++++--------------- 2 files changed, 73 insertions(+), 41 deletions(-) diff --git a/setup/lib/config.py b/setup/lib/config.py index 7bb58f6b..68c623f1 100644 --- a/setup/lib/config.py +++ b/setup/lib/config.py @@ -157,12 +157,12 @@ class Config(object): self.multi_website_modules = [ 'website_multi_company_sale', - 'dp_website', 'clarico_cart', 'clarico_contact', 'theme_clarico', 'payment_paypal', - 'payment_stripe' + 'payment_stripe', + 'dp_website' ] # Setze das Feld "Attachment" im Report (wenn gesetzt wird das PDF in den Anhängen gespeichert) diff --git a/setup/lib/functions.py b/setup/lib/functions.py index 5af2e52a..436b7dda 100644 --- a/setup/lib/functions.py +++ b/setup/lib/functions.py @@ -260,37 +260,49 @@ class DatenpolFunctions(object): def setup_websites(self): """Setup 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, - } - self.odoo.env['ir.model.data'].create(vals) + if not self.odoo.env['ir.model.data'].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, + } + self.odoo.env['ir.model.data'].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 all websites - crm_team_vals = { - 'name': 'IR Heizpaneele', - 'team_type': 'website', - 'company_id': self.odoo.env.ref('base.main_company').id, - } - cr_team_ir_heizpaneel = self.odoo.env['crm.team'].create(crm_team_vals) + # create Salesteam for all websites + cr_team_ir_heizpaneel = self.odoo.env['crm.team'].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, + } + cr_team_ir_heizpaneel = self.odoo.env['crm.team'].create(crm_team_vals) + else: + cr_team_ir_heizpaneel = self.odoo.env['crm.team'].browse(cr_team_ir_heizpaneel) - crm_team_vals = { - 'name': 'Heizpaneele', - 'team_type': 'website', - 'company_id': self.odoo.env.ref('base.main_company').id, - } - cr_team_heizpaneel = self.odoo.env['crm.team'].create(crm_team_vals) + cr_team_heizpaneel = self.odoo.env['crm.team'].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 = self.odoo.env['crm.team'].create(crm_team_vals) + else: + cr_team_heizpaneel = self.odoo.env['crm.team'].browse(cr_team_heizpaneel) # Create and configure Websites default_website = self.odoo.env.ref('website.default_website') @@ -298,25 +310,31 @@ class DatenpolFunctions(object): 'name': 'IR Heizpaneele', 'domain': 'www.irheizpaneele.at', 'company_id': self.odoo.env.ref('base.main_company').id, - 'salesteam_id': cr_team_ir_heizpaneel, - 'multi_theme_id': clarico_theme + 'salesteam_id': cr_team_ir_heizpaneel.id, + 'multi_theme_id': clarico_theme.id }) - heizpaneele = self.odoo.env['website'].create({ + + heizpaneele_vals = { 'name': 'Heizpaneele', 'domain': 'www.heizpaneele.at', 'company_id': self.odoo.env.ref('base.main_company').id, - 'salesteam_id': cr_team_heizpaneel, - 'multi_theme_id': clarico_theme - }) - vals = { - 'model': 'website', - 'module': 'dp_website', - 'name': 'tz_heizpaneele', - 'res_id': str(heizpaneele), - 'noupdate': False, + 'salesteam_id': cr_team_heizpaneel.id, + 'multi_theme_id': clarico_theme.id } - self.odoo.env['ir.model.data'].create(vals) + if not self.odoo.env['ir.model.data'].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': False, + } + self.odoo.env['ir.model.data'].create(vals) + else: + heizpaneele = self.odoo.env.ref('dp_website.tz_heizpaneele') + heizpaneele.write(heizpaneele_vals) res_settings = self.odoo.env['res.config.settings'] vals = res_settings.default_get([]) @@ -328,6 +346,20 @@ class DatenpolFunctions(object): wizard_id = res_settings.create(vals) res_settings.execute(wizard_id) + # + self.odoo.env['product.pricelist'].browse(self.odoo.env['product.pricelist'].search([])).write({ + 'selectable': False + }) + + # create Cart Menu + if not self.odoo.env['website.menu'].search([('name', '=', 'Cart')]): + self.odoo.env['website.menu'].create({ + 'website_id': False, + 'name': 'Cart', + 'url': '/shop/cart', + 'parent_id': self.odoo.env.ref('website.main_menu').id, + }) + return True def configure_payment_providers(self):