66 lines
3.5 KiB
Python
66 lines
3.5 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 ('127.0.0.1','1025','Lokale mailcatcher','login','name','t');
|
|
INSERT INTO ir_mail_server(smtp_host,smtp_port,name,smtp_authentication,smtp_encryption,active) VALUES ('192.168.78.199','1025','Algemene mailcatcher','login','name','t');
|
|
""" %(db_id))
|
|
if self.env['ir.config_parameter'].search([('key','=','web.base.url.freeze')]):
|
|
self.env.cr.execute("""DELETE FROM ir_config_parameter WHERE key = 'web.base.url.freeze';""")
|
|
if not self.env['ir.config_parameter'].search([('key','=','report.url')]):
|
|
self.env.cr.execute("""INSERT INTO ir_config_parameter(key,value) VALUES ('report.url','http://127.0.0.1:8069');""")
|
|
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;""")
|
|
model = self.env['ir.model'].search([('model','=','account.online.link')])
|
|
if model:
|
|
field = self.env['ir.model.fields'].search([('id','>',0),('model_id','=',model.id)])
|
|
if field:
|
|
self.env.cr.execute("""DELETE FROM account_online_link 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)))
|