Metadata-Version: 2.4
Name: mangono-addon-odoo_custom_server
Version: 1.8.3
Project-URL: Homepage, https://mangono.fr/
Author-Email: mangono <opensource+odoo@mangono.fr>
License-Expression: AGPL-3.0
Classifier: Framework :: Odoo
Classifier: Framework :: Odoo :: 14.0
Classifier: Framework :: Odoo :: 15.0
Classifier: Framework :: Odoo :: 16.0
Classifier: Framework :: Odoo :: 17.0
Classifier: Framework :: Odoo :: 18.0
Classifier: Framework :: Odoo :: 19.0
Classifier: Framework :: Odoo :: 20.0
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Dist: environ-odoo-config<1.0,>=0.9.0
Requires-Dist: addons-installer~=3.7
Requires-Dist: typing_extensions
Requires-Dist: wrapt~=1.17
Requires-Dist: manifestoo-core<2,>=1.16
Requires-Dist: tomli<3,>=1.1; python_version < "3.11"
Description-Content-Type: text/markdown

# mangono-addon-odoo_custom_server

[![PyPI](https://img.shields.io/pypi/v/mangono-addon-odoo_custom_server)](https://pypi.org/project/mangono-addon-odoo_custom_server/)
[![Python](https://img.shields.io/pypi/pyversions/mangono-addon-odoo_custom_server)](https://pypi.org/project/mangono-addon-odoo_custom_server/)
[![License: AGPL-3](https://img.shields.io/badge/license-AGPL--3-blue)](https://www.gnu.org/licenses/agpl-3.0.html)

`odoo-bin` commands to run Odoo in a cloud environment: web server behind an integrated reverse proxy, automatic
module update on deployment, database neutralization, assets regeneration, interactive shell. The configuration
comes from the environment variables, through [environ-odoo-config](https://pypi.org/project/environ-odoo-config/),
without an `odoo.conf` file.

The package ships the Odoo module `odoo_custom_server`. It is not installed on a database: it only provides the
commands and the patches of the Odoo core they apply at startup. Odoo itself is not modified.

- Source code: [gitlab.mangono.io/odoo-cloud/server-command](https://gitlab.mangono.io/odoo-cloud/server-command)
- Documentation: [odoo-cloud.docs.mangono.io/server-command](https://odoo-cloud.docs.mangono.io/server-command/index.html)
  (Mangono account required)

## Installation

```shell
pip install mangono-addon-odoo_custom_server
```

Install it in the Python environment of Odoo. The commands are then available as `odoo-bin <command>`.

Supported versions: Odoo 14 to 20, tested in CI on each of them.

## Commands

| Command             | Role                                                                                                                                   |
|---------------------|----------------------------------------------------------------------------------------------------------------------------------------|
| `cloud_server`      | Odoo web server behind a Caddy reverse proxy started and stopped with Odoo: static files, `X-Sendfile`, database manager blocking.     |
| `cloud_auto_update` | Installs and updates the modules, then stops. Detects the installed modules that changed (manifest version or content hash).          |
| `generate_assets`   | Removes the asset bundles of a database (rebuilt by Odoo at the next request) and computes the missing menu icons.                    |
| `db_neutralize`     | Neutralizes a database like `odoo-bin neutralize`, then runs the `dump-cleaner.sql` of each addons path.                               |
| `cloud_shell`       | Interactive shell with the options of the Odoo 20 `odoo-bin shell` (`--shell-interface`, `--shell-file`), on Odoo 14 to 20.            |
| `front_proxy`       | Starts or stops the Caddy reverse proxy apart from the Odoo process (`start` / `stop`).                                               |

Deprecated, removed in 2.0.0: `generic_server`, `web_server` (replaced by `cloud_server`), `update_server` (replaced
by `cloud_auto_update`).

## Usage

```shell
# Web server on $HTTP_PORT, Odoo listens on 127.0.0.1:8069 behind Caddy
DB_NAME=my_db odoo-bin cloud_server

# Install $INSTALL, update $UPDATE and the modules changed since the last update, then stop
DB_NAME=my_db odoo-bin cloud_auto_update

# Other commands
DB_NAME=my_db odoo-bin generate_assets
DB_NAME=my_db odoo-bin db_neutralize
DB_NAME=my_db odoo-bin cloud_shell --shell-interface ipython
```

`cloud_auto_update` takes a PostgreSQL advisory lock per database: several instances started together do not update
the same database in parallel.

## Odoo core patches

Applied at startup by the commands of this package, through runtime wrappers ([wrapt](https://pypi.org/project/wrapt/)):

- Database allow-list: Odoo connects only to the databases of `$DB_NAME`. A connection to `postgres` is redirected to
  the first configured database, any other database is refused.
- PostgreSQL `application_name`: `odoo-<pid>` by default, or `PGAPPNAME` / `db_app_name` (`{pid}` is replaced).
- Reverse proxy: `X-Forwarded-Host` is set from `Host` when the proxy sends only `X-Forwarded-Proto` (case of Clever
  Cloud), so that Odoo stays in proxy mode.
- Garbage collector: the thresholds of Odoo 19 on Odoo 14 to 18 (`GC_THRESHOLD` to override), `gc.freeze()` before
  each worker fork in prefork mode (`GC_FREEZE=False` to disable).
- HTTP `Server` header: `Odoo` instead of the Werkzeug and Python versions.

## Security

- The database allow-list applies only when `$DB_NAME` is set. Without it, Odoo connects to any database, as usual.
- With `cloud_server`, Odoo listens on `127.0.0.1` only; only the proxy is exposed.
- With `cloud_server`, the `/web/database/*` routes are redirected to `/web/login` by the proxy when `list_db` is off
  (`LIST_DB`). When it is on, the database manager is reachable, protected by the Odoo master password only.
- The other commands (`odoo-bin` without proxy) do not block the database manager.

## License

[AGPL-3](https://www.gnu.org/licenses/agpl-3.0.html), [Mangono](https://mangono.fr/).
