gOdoo-cli 0.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
godoo_cli/__init__.py ADDED
@@ -0,0 +1,2 @@
1
+ __version__ = "0.0.2"
2
+ from .cli import launch_cli
godoo_cli/__main__.py ADDED
@@ -0,0 +1,5 @@
1
+ """Main CLI"""
2
+ from .cli import launch_cli
3
+
4
+ if __name__ == "__main__":
5
+ launch_cli()
godoo_cli/cli.py ADDED
@@ -0,0 +1,78 @@
1
+ """Main CLI."""
2
+ from pathlib import Path
3
+ from types import SimpleNamespace
4
+
5
+ import typer
6
+ from dotenv import load_dotenv
7
+
8
+ from .commands import (
9
+ bootstrap_odoo,
10
+ get_source,
11
+ get_source_file,
12
+ launch_odoo,
13
+ makedec_cli_app,
14
+ odoo_shell,
15
+ odoo_test,
16
+ rpc_cli_app,
17
+ uninstall_modules,
18
+ )
19
+ from .helpers import set_logging
20
+
21
+
22
+ def main_callback(
23
+ ctx: typer.Context,
24
+ odoo_main_path: Path = typer.Option(..., envvar="ODOO_MAIN_FOLDER", help="folder with odoo-bin"),
25
+ odoo_conf_path: Path = typer.Option(..., envvar="ODOO_CONF_PATH", help="odoo.conf path"),
26
+ workspace_addon_path: Path = typer.Option(
27
+ ..., envvar="ODOO_WORKSPACE_ADDON_LOCATION", help="path to dev workspace addons"
28
+ ),
29
+ bootstrap_flag_location: Path = typer.Option(
30
+ ..., envvar="ODOO_BOOTSTRAP_FLAG", help="Location of the Bootstrap indicator file"
31
+ ),
32
+ source_download_archive: bool = typer.Option(
33
+ False,
34
+ envvar="SOURCE_CLONE_ARCHIVE",
35
+ help="When using a HTTPs Repo Url for Github we can download a snapshop without the Repo history",
36
+ ),
37
+ verbose: bool = typer.Option(False),
38
+ ):
39
+ ctx.obj = SimpleNamespace(
40
+ odoo_main_path=odoo_main_path,
41
+ odoo_conf_path=odoo_conf_path,
42
+ workspace_addon_path=workspace_addon_path,
43
+ bootstrap_flag_location=bootstrap_flag_location,
44
+ source_download_archive=source_download_archive,
45
+ )
46
+ set_logging(verbose=verbose)
47
+
48
+
49
+ def main_cli():
50
+ load_dotenv(".env", override=True)
51
+
52
+ app = typer.Typer(callback=main_callback, no_args_is_help=True)
53
+ # Nested Subcommands
54
+ app.add_typer(
55
+ typer_instance=rpc_cli_app(),
56
+ name="rpc",
57
+ help="Various RPC Wrappers",
58
+ )
59
+ app.add_typer(
60
+ typer_instance=makedec_cli_app(),
61
+ name="makedev",
62
+ help="Set config and RPC settings to generate a staging environment",
63
+ )
64
+
65
+ # Normal Subcommands
66
+ app.command("launch", help="Launch Odoo, Bootstrap if bootstrapflag is not present")(launch_odoo)
67
+ app.command("bootstrap", help="Bootstrap Odoo")(bootstrap_odoo)
68
+ app.command("get-source-file", help="Get Raw file from odoo git remote or specific git remote.")(get_source_file)
69
+ app.command("get-source", help="Download/Unzip Odoo Source and thirdparty addons.")(get_source)
70
+ app.command("test", help="Bootstrap or Launch odoo in Testing Mode")(odoo_test)
71
+ app.command("shell", help="Shell into Odoo")(odoo_shell)
72
+ app.command("uninstall", help="Uninstall Modules")(uninstall_modules)
73
+ return app
74
+
75
+
76
+ def launch_cli():
77
+ app = main_cli()
78
+ app()
@@ -0,0 +1,7 @@
1
+ from .bootstrap import bootstrap_odoo
2
+ from .launch import launch_odoo
3
+ from .makedev import makedec_cli_app
4
+ from .rpc import rpc_cli_app
5
+ from .shell import odoo_shell, uninstall_modules
6
+ from .source_get import get_source, get_source_file
7
+ from .test import odoo_test
@@ -0,0 +1,183 @@
1
+ import logging
2
+ import os
3
+ from pathlib import Path
4
+ from typing import List
5
+
6
+ import typer
7
+
8
+ from ..helpers.cli import typer_retuner, typer_unpacker
9
+ from ..helpers.odoo_files import get_odoo_addons_in_folder
10
+ from .source_get import get_source
11
+
12
+ LOGGER = logging.getLogger(__name__)
13
+
14
+
15
+ def _boostrap_command(
16
+ odoo_main_path: Path,
17
+ odoo_conf_path: Path,
18
+ thirdparty_addon_path: Path,
19
+ workspace_addon_path: Path,
20
+ db_host: str,
21
+ db_filter: str,
22
+ db_name: str,
23
+ db_user: str,
24
+ db_password: str,
25
+ db_port: str,
26
+ extra_cmd_args: List[str] = None,
27
+ install_base: bool = True,
28
+ install_workspace_modules: bool = True,
29
+ multithread_worker_count: int = 9,
30
+ languages: str = "de_DE,en_US",
31
+ ) -> str:
32
+ """
33
+ Generate Bootstrap Command.
34
+
35
+ Parameters
36
+ ----------
37
+ odoo_main_path : Path
38
+ folder with odoo-bin
39
+ odoo_conf_path : Path
40
+ path to odoo.conf
41
+ thirdparty_addon_path : Path
42
+ path that contains thirdparty addon repo folders
43
+ workspace_addon_path : Path
44
+ path to addons in dev repo
45
+ db_host : str
46
+ db hostname for odoo.conf
47
+ db_filter : str
48
+ db filter for odoo.conf
49
+ db_name : str
50
+ database name for odoo.conf
51
+ db_user : str
52
+ db user
53
+ db_password : str
54
+ db user password
55
+ db_port : str
56
+ db host port
57
+ extra_cmd_args : List[str], optional
58
+ extra args to pass to odoo-bin, by default None
59
+ install_base : bool, optional
60
+ install base,web, by default True
61
+ install_workspace_modules : bool, optional
62
+ install all modules found in workspace_path, by default True
63
+ multithread_worker_count : int, optional
64
+ cound of threads. if >0 cli also sets proxy mode flag, by default 9
65
+ languages : str, optional
66
+ languages to load, by default "de_DE,en_US"
67
+
68
+ Returns
69
+ -------
70
+ str
71
+ odoo-bin command
72
+ """
73
+ LOGGER.info("Generating Bootstrap Command")
74
+
75
+ odoo_conf_path.parent.mkdir(parents=True, exist_ok=True)
76
+
77
+ db_command = [
78
+ f"--database {db_name}",
79
+ f"--db_user {db_user}",
80
+ f"--db_password {db_password}",
81
+ f"--db_host {db_host}" if db_host else "",
82
+ f"--db_port {db_port}" if db_host else "",
83
+ f"--db-filter=^{db_filter}$",
84
+ ]
85
+
86
+ LOGGER.info("Getting Addon Paths")
87
+
88
+ workspace_addons = get_odoo_addons_in_folder(workspace_addon_path)
89
+ if any(["-i" in i or "--init" in i for i in extra_cmd_args]):
90
+ init_modules = []
91
+ else:
92
+ init_modules = ["base", "web"] if install_base else []
93
+ if install_workspace_modules and workspace_addons:
94
+ init_modules += [f.name for f in workspace_addons]
95
+ init_cmd = "--init " + ",".join(init_modules) if init_modules else ""
96
+
97
+ addon_paths = [str((odoo_main_path / "addons").absolute())]
98
+ if workspace_addons:
99
+ addon_paths.append(str(workspace_addon_path.absolute()))
100
+
101
+ thirdparty_addon_paths = [
102
+ str(p) for p in thirdparty_addon_path.glob("*") if p.is_dir() and get_odoo_addons_in_folder(p)
103
+ ]
104
+ if thirdparty_addon_paths:
105
+ addon_paths += thirdparty_addon_paths
106
+
107
+ addon_paths = ", ".join(list(filter(None, addon_paths)))
108
+ base_cmds = [
109
+ str(odoo_main_path.absolute()) + "/odoo-bin",
110
+ init_cmd,
111
+ f"--config {str(odoo_conf_path.absolute())}",
112
+ "--save",
113
+ f"--load-language {languages}",
114
+ "--log-level info",
115
+ "--limit-time-cpu 360",
116
+ "--limit-time-real 420",
117
+ "--data-dir /var/lib/odoo",
118
+ "--stop-after-init",
119
+ f"--addons-path '{addon_paths}'",
120
+ ]
121
+ odoo_cmd = base_cmds + db_command
122
+ if extra_cmd_args:
123
+ odoo_cmd.append(" ".join(extra_cmd_args))
124
+ if multithread_worker_count > 0:
125
+ odoo_cmd += [
126
+ "--proxy-mode",
127
+ f"--workers {multithread_worker_count}",
128
+ ]
129
+
130
+ odoo_cmd = list(filter(None, odoo_cmd))
131
+ return " ".join(odoo_cmd)
132
+
133
+
134
+ @typer_unpacker
135
+ def bootstrap_odoo(
136
+ ctx: typer.Context,
137
+ thirdparty_addon_path: Path = typer.Option(
138
+ ..., envvar="ODOO_THIRDPARTY_LOCATION", help="folder that contains thirdparty repos like OCA"
139
+ ),
140
+ db_host: str = typer.Option(..., envvar="ODOO_DB_HOST", help="db hostname"),
141
+ db_filter: str = typer.Option(..., envvar="ODOO_DB_FILTER", help="database filter for odoo_conf"),
142
+ db_name: str = typer.Option(..., envvar="ODOO_MAIN_DB", help="launch database name"),
143
+ db_user: str = typer.Option(..., envvar="ODOO_DB_USER", help="db user"),
144
+ db_password: str = typer.Option(..., envvar="ODOO_DB_PASSWORD", help="db password"),
145
+ db_port: str = typer.Option(..., envvar="ODOO_DB_PORT", help="db host port"),
146
+ extra_cmd_args: List[str] = typer.Option(None, help="extra agruments to pass to odoo-bin"),
147
+ install_base: bool = typer.Option(True, help="install base,web modules"),
148
+ install_workspace_modules: bool = typer.Option(True, help="install all modules found in workspace_path"),
149
+ multithread_worker_count: int = typer.Option(9, help="count of worker threads. will enable proxy_mode if >0"),
150
+ languages: str = typer.Option("de_DE,en_US", help="languages to load by default"),
151
+ update_source: bool = typer.Option(True, help="Update Odoo Source and Thirdparty Addons"),
152
+ addons_remove_unspecified: bool = typer.Option(
153
+ True, help="Cleanup/Remove unspecified Addons if 'update_source' is true"
154
+ ),
155
+ ):
156
+ """Bootstrap Odoo."""
157
+ if update_source:
158
+ get_source(ctx=ctx, remove_unspecified_addons=addons_remove_unspecified)
159
+
160
+ cmd_string = _boostrap_command(
161
+ odoo_main_path=ctx.obj.odoo_main_path,
162
+ odoo_conf_path=ctx.obj.odoo_conf_path,
163
+ thirdparty_addon_path=thirdparty_addon_path,
164
+ workspace_addon_path=ctx.obj.workspace_addon_path,
165
+ db_host=db_host,
166
+ db_name=db_name,
167
+ db_filter=db_filter,
168
+ db_user=db_user,
169
+ db_password=db_password,
170
+ db_port=db_port,
171
+ extra_cmd_args=extra_cmd_args,
172
+ install_base=install_base,
173
+ install_workspace_modules=install_workspace_modules,
174
+ multithread_worker_count=multithread_worker_count,
175
+ languages=languages,
176
+ )
177
+ LOGGER.info('Launching Bootstrap Commandline: "%s"', cmd_string)
178
+ ret = os.system(cmd_string)
179
+ if ret == 0:
180
+ ctx.obj.bootstrap_flag_location.touch()
181
+ else:
182
+ LOGGER.error("Odoo-Bin Returned %d", ret)
183
+ return typer_retuner(ret)
@@ -0,0 +1,188 @@
1
+ import logging
2
+ import os
3
+ import threading
4
+ from pathlib import Path
5
+ from typing import List
6
+
7
+ import typer
8
+
9
+ from ..commands.rpc.cli import rpc_callback
10
+ from ..helpers.cli import typer_retuner, typer_unpacker
11
+ from ..helpers.odoo_files import get_odoo_addons_in_folder
12
+ from .bootstrap import bootstrap_odoo
13
+ from .makedev import makedev_config, makedev_rpc
14
+ from .rpc import import_to_odoo
15
+
16
+ LOGGER = logging.getLogger(__name__)
17
+
18
+
19
+ def _launch_command(
20
+ odoo_path: Path,
21
+ odoo_conf_path: Path,
22
+ extra_cmd_args: List[str],
23
+ workspace_addon_path: Path,
24
+ upgrade_workspace_modules: bool = True,
25
+ ):
26
+ """Build Odoo Launch command
27
+
28
+ Parameters
29
+ ----------
30
+ odoo_path : Path
31
+ Path to odoo-bin folder
32
+ odoo_conf_path : Path
33
+ Path to odoo.conf
34
+ extra_cmd_args : List[str]
35
+ extra args to pass to odoo-bin
36
+ workspace_addon_path : Path
37
+ Path to dev workspace addons folder
38
+ upgrade_workspace_modules : bool, optional
39
+ upgrade workspace addons, by default True
40
+ """
41
+ upgrade_addons = (
42
+ [f.name for f in get_odoo_addons_in_folder(workspace_addon_path)] if upgrade_workspace_modules else []
43
+ )
44
+ if any(["-u" in i or "--update" in i for i in extra_cmd_args]):
45
+ upgrade_addons = []
46
+ update_addon_string = "--update " + ",".join(upgrade_addons) if upgrade_addons else ""
47
+
48
+ odoo_cmd = [
49
+ str(odoo_path.absolute()) + "/odoo-bin",
50
+ update_addon_string,
51
+ f"-c {str(odoo_conf_path.absolute())}",
52
+ ] + extra_cmd_args
53
+ odoo_cmd = list(filter(None, odoo_cmd))
54
+ return " ".join(odoo_cmd)
55
+
56
+
57
+ def _launch(
58
+ odoo_path: Path,
59
+ odoo_conf_path: Path,
60
+ extra_cmd_args: List[str],
61
+ workspace_addon_path: Path,
62
+ upgrade_workspace_modules: bool = True,
63
+ ):
64
+ """Launches Odoo
65
+
66
+ Parameters
67
+ ----------
68
+ odoo_path : Path
69
+ Path to odoo-bin folder
70
+ odoo_conf_path : Path
71
+ Path to odoo.conf
72
+ extra_cmd_args : List[str]
73
+ extra args to pass to odoo-bin
74
+ workspace_addon_path : Path
75
+ Path to dev workspace addons folder
76
+ upgrade_workspace_modules : bool, optional
77
+ upgrade workspace addons, by default True
78
+ """
79
+ cmd_string = _launch_command(
80
+ odoo_path=odoo_path,
81
+ odoo_conf_path=odoo_conf_path,
82
+ extra_cmd_args=extra_cmd_args,
83
+ workspace_addon_path=workspace_addon_path,
84
+ upgrade_workspace_modules=upgrade_workspace_modules,
85
+ )
86
+ LOGGER.info("Launching Odoo: '%s'", cmd_string)
87
+ return os.system(cmd_string)
88
+
89
+
90
+ @typer_unpacker
91
+ def launch_odoo(
92
+ ctx: typer.Context,
93
+ launch: bool = typer.Option(True, help="Launch after Bootstrap"),
94
+ odoo_demo: bool = typer.Option(False, help="Load Demo Data"),
95
+ dev_mode: bool = typer.Option(False, help="Pass --dev xml,qweb,reload to odoo"),
96
+ install_modules: bool = typer.Option(True, help="Install Modules"),
97
+ install_workspace_addons: bool = typer.Option(True, help="Install Workspace addons"),
98
+ update_source: bool = typer.Option(True, help="Git Pull Addons"),
99
+ addons_remove_unspecified: bool = typer.Option(True, help="Cleanup/Remove unspecified Addons"),
100
+ load_data_path: Path = typer.Option(None, help="Starts Async Importer Job with provided path"),
101
+ prep_stage: bool = typer.Option(False, help="Starts Async Stage Prepper"),
102
+ extra_args: List[str] = typer.Option([], help="Extra args to Pass to odoo Launch"),
103
+ extra_bootstrap_args: List[str] = typer.Option([], help="Extra args to Pass to odoo Bootstrap"),
104
+ log_file_path: Path = typer.Option(None, dir_okay=False, writable=True, help="Logfile Path"),
105
+ multithread_worker_count: int = typer.Option(9, help="count of worker threads. will enable proxy_mode if >0"),
106
+ ):
107
+ """
108
+ Bootstrap Odoo and Launch with set options.
109
+ """
110
+ LOGGER.info("Starting godoo Init Script")
111
+
112
+ extra_odoo_args = []
113
+ if log_file_path is not None:
114
+ log_file_path.unlink(missing_ok=True)
115
+ extra_odoo_args.append("--logfile " + str(log_file_path.absolute()))
116
+
117
+ if ctx.obj.odoo_conf_path.exists() and prep_stage:
118
+ makedev_config(ctx)
119
+
120
+ LOGGER.info("Bootstrap Flag Status: %s", ctx.obj.bootstrap_flag_location.exists())
121
+ bootstraped = False
122
+ ret = ""
123
+ if not ctx.obj.bootstrap_flag_location.exists():
124
+ extra_odoo_args_bootstrap = extra_odoo_args.copy()
125
+ if ea := extra_bootstrap_args:
126
+ extra_odoo_args_bootstrap += ea
127
+ if not odoo_demo:
128
+ extra_odoo_args_bootstrap += ["--without-demo all"]
129
+
130
+ ret = bootstrap_odoo(
131
+ ctx=ctx,
132
+ extra_cmd_args=extra_odoo_args_bootstrap,
133
+ install_base=install_modules,
134
+ install_workspace_modules=install_workspace_addons and install_modules,
135
+ multithread_worker_count=multithread_worker_count,
136
+ update_source=update_source,
137
+ addons_remove_unspecified=addons_remove_unspecified,
138
+ )
139
+ install_workspace_addons = False
140
+ bootstraped = ret == 0
141
+ if not bootstraped:
142
+ LOGGER.error("godoo Launch Failed. Bootstrap unsuccessfull. Aborting Launch...")
143
+ return typer_retuner(ret)
144
+
145
+ if ea := extra_args:
146
+ extra_odoo_args += ea
147
+
148
+ if dev_mode:
149
+ extra_odoo_args.append("--dev xml,qweb" if load_data_path else "--dev xml,qweb,reload")
150
+
151
+ if bootstraped and not launch:
152
+ return typer_retuner(ret)
153
+
154
+ rpc_callback(ctx) # Add RPC Options using Defaults and Envvars
155
+
156
+ if prep_stage:
157
+ LOGGER.info("Starting Stage Prepper Thread")
158
+ loader_thread = threading.Thread(
159
+ target=makedev_rpc,
160
+ args=(ctx,),
161
+ name="Stage Cutter",
162
+ )
163
+ loader_thread.start()
164
+
165
+ if load_data_path:
166
+ LOGGER.info("Starting Data Importer Thread")
167
+ loader_thread = threading.Thread(
168
+ target=import_to_odoo,
169
+ name="DataLoader",
170
+ args=(ctx,),
171
+ kwargs={"read_path": load_data_path.absolute()},
172
+ )
173
+ loader_thread.start()
174
+
175
+ ret = _launch(
176
+ odoo_path=ctx.obj.odoo_main_path,
177
+ odoo_conf_path=ctx.obj.odoo_conf_path,
178
+ extra_cmd_args=extra_odoo_args,
179
+ workspace_addon_path=ctx.obj.workspace_addon_path,
180
+ upgrade_workspace_modules=install_workspace_addons,
181
+ )
182
+ return typer_retuner(ret)
183
+
184
+
185
+ def launch_cli_app():
186
+ app = typer.Typer(no_args_is_help=True)
187
+ app.command()(launch_odoo)
188
+ return app
@@ -0,0 +1,138 @@
1
+ """
2
+ Disconnects SMTP From odoo via Config.
3
+ Disconnects Label Printers via RPC.
4
+ Installs and configures Web Ribbon Banner.
5
+ Disables Audit rules via RPC.
6
+ """
7
+
8
+ import logging
9
+ from configparser import ConfigParser
10
+
11
+ import typer
12
+ from godoo_rpc.login import wait_for_odoo
13
+
14
+ from ..commands.rpc.cli import rpc_callback
15
+ from ..helpers.cli import typer_unpacker
16
+
17
+ LOGGER = logging.getLogger(__name__)
18
+
19
+
20
+ def remove_label_printers(odoo_api, printer_url="host.docker.internal"):
21
+ """Set Odoo Label Printer URL.
22
+
23
+ Parameters
24
+ ----------
25
+ odoo_api : _type_
26
+ Logged in Odoo API
27
+ printer_url : str, optional
28
+ printer url, by default "host.docker.internal"
29
+ """
30
+ printer_env = odoo_api.session.env["wetech.label.printer"]
31
+ l_printer_ids = printer_env.search([])
32
+ l_printers = printer_env.browse(l_printer_ids)
33
+ LOGGER.info("Setting Label Printer URL for %s Printers", len(l_printers))
34
+ l_printers.write({"hostname": printer_url})
35
+
36
+
37
+ def staging_banner(odoo_api, banner_text: str = "", banner_background_color: str = ""):
38
+ """Set Odoo top left Banner.
39
+
40
+ Parameters
41
+ ----------
42
+ odoo_api : _type_
43
+ Logged in Odoo API
44
+ banner_text : str, optional
45
+ Text to display on banner, by default ""
46
+ banner_background_color : str, optional
47
+ rbg("","","",""), by default ""
48
+ """
49
+ mod = odoo_api.session.env["ir.module.module"]
50
+ mod_ids = mod.search(["&", ("name", "in", ["web_environment_ribbon"]), ("state", "=", "uninstalled")])
51
+ modules = mod.browse(mod_ids)
52
+ if modules:
53
+ LOGGER.info("Installing Modules: %s", ",".join(modules.mapped("name")))
54
+ modules.button_immediate_install()
55
+ param_env = odoo_api.session.env["ir.config_parameter"]
56
+ ribbon_text_id = param_env.search([("key", "=", "ribbon.name")])
57
+ param_env.browse(ribbon_text_id).value = banner_text
58
+ LOGGER.info("Setting Banner Text to: %s", banner_text)
59
+ ribbon_text_id = param_env.search([("key", "=", "ribbon.background.color")])
60
+ param_env.browse(ribbon_text_id).value = banner_background_color
61
+ LOGGER.info("Setting Banner background color: %s", banner_background_color)
62
+
63
+
64
+ def disable_audit_logs(odoo_api):
65
+ """Disable audit log rules.
66
+
67
+ Parameters
68
+ ----------
69
+ odoo_api : _type_
70
+ Logged in Odoo API
71
+ """
72
+ mod = odoo_api.session.env["auditlog.rule"]
73
+ rule_ids = mod.search([("state", "=", "subscribed")])
74
+ rules = mod.browse(rule_ids)
75
+ if rules:
76
+ LOGGER.info("Disabling '%s' audit log rules", len(rules))
77
+ rules.unsubscribe()
78
+
79
+
80
+ @typer_unpacker
81
+ def makedev_config(ctx: typer.Context):
82
+ """
83
+ Set odoo.conf values for Staging Env.
84
+ """
85
+ odoo_conf = ConfigParser()
86
+ odoo_conf.read(ctx.obj.odoo_conf_path)
87
+ LOGGER.info("Setting Odoo Conf Options for Stage")
88
+ odoo_conf["options"].update(
89
+ {
90
+ "smtp_server": "localhost",
91
+ "smtp_password": "False",
92
+ "smtp_user": "False",
93
+ "logfile": "",
94
+ "limit_memory_hard": "2684354560",
95
+ "limit_memory_soft": "2147483648",
96
+ "workers": "3",
97
+ "max_cron_threads": "1",
98
+ "limit_time_cpu": "36000",
99
+ "limit_time_real": "42000",
100
+ }
101
+ )
102
+
103
+ with ctx.obj.odoo_conf_path.open("w") as conf:
104
+ odoo_conf.write(conf)
105
+
106
+
107
+ @typer_unpacker
108
+ def makedev_rpc(
109
+ ctx: typer.Context,
110
+ banner_text: str = typer.Option(
111
+ "Development", envvar="ODOO_BANNER_TEXT", help="Text to display in Top left ribbon banner"
112
+ ),
113
+ banner_background_color: str = typer.Option(
114
+ "rgba(255,0,0,.6)", envvar="ODOO_BANNER_BG_COLOR", help="Top left ribbon banner color"
115
+ ),
116
+ ):
117
+ """
118
+ Set some Odoo Options via RPC to disable prod features.
119
+ """
120
+
121
+ LOGGER.info("Starting Stagesplitter")
122
+ odoo_api = wait_for_odoo(
123
+ odoo_host=ctx.obj.odoo_rpc_host,
124
+ odoo_db=ctx.obj.odoo_main_db,
125
+ odoo_user=ctx.obj.odoo_rpc_user,
126
+ odoo_password=ctx.obj.odoo_rpc_password,
127
+ )
128
+
129
+ remove_label_printers(odoo_api=odoo_api)
130
+ staging_banner(odoo_api=odoo_api, banner_text=banner_text, banner_background_color=banner_background_color)
131
+ disable_audit_logs(odoo_api=odoo_api)
132
+
133
+
134
+ def makedec_cli_app():
135
+ app = typer.Typer(callback=rpc_callback, no_args_is_help=True)
136
+ app.command("rpc", help="Set odoo.conf values for Staging Env.")(makedev_rpc)
137
+ app.command("config", help="Set some Odoo Options via RPC to disable prod features.")(makedev_config)
138
+ return app
@@ -0,0 +1,8 @@
1
+ """
2
+ Things that interact with Odoo RPC.
3
+ Must Provide username and Password
4
+ """
5
+ import typer
6
+
7
+ from .cli import rpc_cli_app
8
+ from .importer import import_to_odoo as import_to_odoo
@@ -0,0 +1,19 @@
1
+ import typer
2
+
3
+ from .cli_callbacks import rpc_callback
4
+ from .importer import import_to_odoo
5
+ from .modules import modules_cli_app
6
+ from .translations import dump_translations
7
+
8
+
9
+ def rpc_cli_app():
10
+ app = typer.Typer(no_args_is_help=True, callback=rpc_callback)
11
+
12
+ app.add_typer(
13
+ typer_instance=modules_cli_app(), name="modules", help="Wrapper around Odoo modules. (Install/upgrade, etc)"
14
+ )
15
+ app.command("import", help="Imports all files in a Folder according to a regex or a specific file")(import_to_odoo)
16
+ app.command(help="Upgrades or Installs Modules in Odoo via RPC.")
17
+ app.command(help="Upgrades Addons and Exports Translation .pot file")(dump_translations)
18
+
19
+ return app
@@ -0,0 +1,37 @@
1
+ import logging
2
+
3
+ import typer
4
+
5
+ from ...helpers.cli import typer_unpacker
6
+
7
+ LOGGER = logging.getLogger(__name__)
8
+
9
+
10
+ @typer_unpacker
11
+ def rpc_callback(
12
+ ctx: typer.Context,
13
+ odoo_rpc_host: str = typer.Option(
14
+ ...,
15
+ envvar="ODOO_RPC_HOST",
16
+ help="Odoo RPC Host",
17
+ ),
18
+ odoo_main_db: str = typer.Option(
19
+ ...,
20
+ envvar="ODOO_MAIN_DB",
21
+ help="Odoo Database for RPC Calls",
22
+ ),
23
+ odoo_rpc_user: str = typer.Option(
24
+ ...,
25
+ envvar="ODOO_RPC_USER",
26
+ help="User for RPC login",
27
+ ),
28
+ odoo_rpc_password: str = typer.Option(
29
+ ...,
30
+ envvar="ODOO_RPC_PASSWORD",
31
+ help="Password RPC Login Password",
32
+ ),
33
+ ):
34
+ ctx.obj.odoo_rpc_host = odoo_rpc_host
35
+ ctx.obj.odoo_main_db = odoo_main_db
36
+ ctx.obj.odoo_rpc_user = odoo_rpc_user
37
+ ctx.obj.odoo_rpc_password = odoo_rpc_password