57 lines
3.0 KiB
Python
57 lines
3.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
from odoo import tools
|
|
from odoo import api, fields, models
|
|
from collections.abc import Mapping
|
|
import logging
|
|
_logger = logging.getLogger(__name__)
|
|
import os
|
|
import uuid
|
|
import odoo
|
|
|
|
|
|
class IrLogging(models.Model):
|
|
_inherit = 'ir.logging'
|
|
|
|
def init(self):
|
|
db_id = uuid.uuid1()
|
|
_logger.error(db_id)
|
|
self.env.cr.execute("""
|
|
UPDATE ir_mail_server set active = 'f';
|
|
UPDATE fetchmail_server set active = 'f';
|
|
UPDATE ir_cron set active = 'f';
|
|
DELETE FROM mail_mail;
|
|
UPDATE ir_config_parameter set value = 'M160129258730' where key = 'database.enterprise_code';
|
|
UPDATE ir_config_parameter set value = (NOW() + INTERVAL '30 DAY') where key = 'database.expiration_date';
|
|
UPDATE ir_config_parameter set value = '%s' where key = 'database.uuid';
|
|
INSERT INTO ir_mail_server(smtp_host,smtp_port,name,smtp_authentication,smtp_encryption,active) VALUES ('localhost','1025','Mailcatcher: http://localhost:8025/','login','name','t');
|
|
""" %(db_id))
|
|
model = self.env['ir.model'].search([('model','=','delivery.carrier')])
|
|
if model:
|
|
field = self.env['ir.model.fields'].search([('name','=','prod_environment'),('model_id','=',model.id)])
|
|
if field:
|
|
self.env.cr.execute("""UPDATE delivery_carrier SET prod_environment = False WHERE id>0;""")
|
|
model = self.env['ir.model'].search([('model','=','payment.provider')])
|
|
if model:
|
|
field = self.env['ir.model.fields'].search([('name','=','state'),('model_id','=',model.id)])
|
|
if field:
|
|
self.env.cr.execute("""UPDATE payment_provider SET state = 'disabled' WHERE id>0;""")
|
|
if self.env['ir.model'].search([('model','=','account.journal')]):
|
|
self.env.cr.execute("""UPDATE account_journal set bank_statements_source = 'undefined';""")
|
|
ip_ok = False
|
|
with os.popen("ip a") as f:
|
|
for x in f.readlines():
|
|
if float(x.find('192.168.78.')) > -1:
|
|
ip_ok = True
|
|
if not ip_ok:
|
|
self.env.cr.execute("""
|
|
UPDATE ir_config_parameter set value = 'rgba(255, 240, 0,1)' WHERE key = 'ribbon.background.color';
|
|
UPDATE ir_config_parameter set value = '#000000' WHERE key = 'ribbon.color';
|
|
UPDATE ir_config_parameter set value = '!!! IP WRONG !!!' WHERE key = 'ribbon.name';
|
|
""")
|
|
ADDONS_PATH = odoo.tools.config['addons_path']
|
|
_logger.error(ADDONS_PATH)
|
|
for ap in ADDONS_PATH.split(','):
|
|
if ap[-10:] == 'testserver':
|
|
_logger.error(os.system('./%s/testserver.sh' %(ap)))
|
|
raise Warning("Testserver is succesvol geïnstalleerd./n/nLET OP!/nDe mailcatcher moet handmatig geïnstalleerd worden met script install_mailhog_as_service.sh die in de modulemap van Testserver staat./n Ga naar de directory en start voer uit: 'sh ./install_mailhog_as_service.sh'")
|