-
Notifications
You must be signed in to change notification settings - Fork 2
/
odoo.sysparams
executable file
·41 lines (31 loc) · 1.08 KB
/
odoo.sysparams
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#! /usr/bin/env python2
"""Manage Odoo system parameters.
"""
import sys
import argparse
from oekit.oe_client_env import OEClientEnv
def main(options):
"""Main program."""
options.func(options)
def set_param(options):
peek = OEClientEnv().get_erppeek_client()
ConfigParameter = peek.model('ir.config_parameter')
param = ConfigParameter.get([('key', '=', options.key)])
if param:
param.write(dict(value=options.value))
else:
ConfigParameter.create(dict(key=options.key, value=options.value))
def get_options():
"""Get options for the script."""
parser = argparse.ArgumentParser(
description="Manage Odoo system parameters",
)
subparsers = parser.add_subparsers(title='action')
set_parser = subparsers.add_parser('set', help='set a parameter\'s value')
set_parser.add_argument('key', help='key to set')
set_parser.add_argument('value', help='value to set the parameter to')
set_parser.set_defaults(func=set_param)
options = parser.parse_args()
return options
if __name__ == "__main__":
main(get_options())