2017-01-19 01:59:38 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
import sys
|
|
|
|
|
|
|
|
dbname = sys.argv[1]
|
|
|
|
config_file = sys.argv[2]
|
|
|
|
from trytond.config import config as CONFIG
|
|
|
|
CONFIG.update_etc(config_file)
|
|
|
|
|
|
|
|
from trytond.pool import Pool
|
2020-05-11 19:52:59 +02:00
|
|
|
from trytond.transaction import Transaction
|
2017-01-19 01:59:38 +01:00
|
|
|
import logging
|
2019-10-08 12:36:32 +02:00
|
|
|
from trytond.pyson import PYSONEncoder, Eval
|
|
|
|
|
|
|
|
# Avoid pyflakes warnings and use Eval which may be needed by 'eval()'
|
|
|
|
Eval
|
2017-01-19 01:59:38 +01:00
|
|
|
|
|
|
|
Pool.start()
|
|
|
|
pool = Pool(dbname)
|
|
|
|
pool.init()
|
|
|
|
|
|
|
|
context = {'company': 1}
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
logger.setLevel(logging.DEBUG)
|
|
|
|
ch = logging.StreamHandler(sys.stdout)
|
|
|
|
ch.setLevel(logging.DEBUG)
|
|
|
|
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
|
|
|
ch.setFormatter(formatter)
|
|
|
|
logger.addHandler(ch)
|
|
|
|
|
|
|
|
with Transaction().start(dbname, 0, context=context):
|
|
|
|
user_obj = pool.get('res.user')
|
|
|
|
user = user_obj.search([('login', '=', 'admin')], limit=1)[0]
|
|
|
|
user_id = user.id
|
|
|
|
|
|
|
|
|
|
|
|
with Transaction().start(dbname, 0, context=context) as transaction:
|
|
|
|
|
|
|
|
pool = Pool()
|
|
|
|
Rule = pool.get('ir.rule.group')
|
|
|
|
|
|
|
|
groups = Rule.search([('create_uid', '>', 0)])
|
|
|
|
for group in groups:
|
|
|
|
for rule in group.rules:
|
|
|
|
rule.domain = PYSONEncoder().encode(eval(rule.domain))
|
|
|
|
rule.save()
|
2018-01-03 15:27:41 +01:00
|
|
|
|
2018-05-30 12:52:10 +02:00
|
|
|
|
|
|
|
with Transaction().start(dbname, 0, context=context) as transaction:
|
|
|
|
|
2018-01-03 15:27:41 +01:00
|
|
|
pool = Pool()
|
2018-05-30 12:52:10 +02:00
|
|
|
ActWindow = pool.get('ir.action.act_window')
|
|
|
|
|
2018-11-02 09:20:06 +01:00
|
|
|
actions = ActWindow.search([])
|
2018-05-30 12:52:10 +02:00
|
|
|
for action in actions:
|
2019-02-09 07:31:40 +01:00
|
|
|
|
|
|
|
if action.domain and 'null' in action.domain:
|
|
|
|
action.domain = action.domain.replace('null', "None")
|
|
|
|
if action.context and 'true' in action.context:
|
|
|
|
action.context = action.context.replace('true', "True")
|
2018-11-02 09:20:06 +01:00
|
|
|
if action.domain:
|
|
|
|
domain = action.domain.replace('null', 'None').replace(
|
|
|
|
'true', 'True').replace('false', 'False')
|
2019-10-08 12:36:32 +02:00
|
|
|
action.domain = PYSONEncoder().encode(eval(domain, {'Eval': Eval}))
|
2018-11-02 09:20:06 +01:00
|
|
|
if action.context:
|
2018-11-19 14:50:49 +01:00
|
|
|
context_ = action.context.replace('null', 'None').replace('true',
|
2018-11-02 09:20:06 +01:00
|
|
|
'True').replace('false', 'False')
|
2018-11-19 14:50:49 +01:00
|
|
|
action.context = PYSONEncoder().encode(eval(context_, {}))
|
2018-05-30 12:52:10 +02:00
|
|
|
action.save()
|
2018-06-12 16:30:06 +02:00
|
|
|
|
|
|
|
with Transaction().start(dbname, 0, context=context) as transaction:
|
|
|
|
|
|
|
|
pool = Pool()
|
|
|
|
ActWindowDomain = pool.get('ir.action.act_window.domain')
|
|
|
|
|
|
|
|
actions = ActWindowDomain.search([('create_uid', '>', 0)])
|
|
|
|
for action in actions:
|
2019-07-05 13:26:07 +02:00
|
|
|
if not action.domain or action.domain.strip() == '':
|
2018-06-12 16:30:06 +02:00
|
|
|
continue
|
|
|
|
action.domain = PYSONEncoder().encode(eval(action.domain))
|
|
|
|
action.save()
|
2018-11-19 14:50:49 +01:00
|
|
|
|
|
|
|
with Transaction().start(dbname, 0, context=context) as transaction:
|
|
|
|
|
|
|
|
pool = Pool()
|
|
|
|
Trigger = pool.get('ir.trigger')
|
|
|
|
triggers = Trigger.search([])
|
|
|
|
for trigger in triggers:
|
2019-04-03 15:44:05 +02:00
|
|
|
print("Update Manaualy:", trigger.id, trigger.condition)
|
2018-11-19 14:50:49 +01:00
|
|
|
if not trigger.condition and trigger.condition.strip() == '':
|
|
|
|
continue
|
|
|
|
trigger.condition = PYSONEncoder().encode(eval(trigger.condition))
|
|
|
|
trigger.save()
|