Skip to content

ADD Odoo development environment #332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ application with a Rust backend and a Postgres database.&nbsp;<a href="react-rus
with Spring framework and a Postgres database.&nbsp;<a href="spring-postgres"><img src="icon_devenvs.svg" alt="Use with Docker Dev Environments" height="30" align="top"/></a>
- [`WasmEdge / MySQL / Nginx`](wasmedge-mysql-nginx) - Sample Wasm-based web application with a static HTML frontend, using a MySQL (MariaDB) database. The frontend connects to a Wasm microservice written in Rust, that runs using the WasmEdge runtime.&nbsp;<a href="wasmedge-mysql-nginx"><img src="icon_wasm.svg" alt="Compatible with Docker+wasm" height="30" align="top"/></a>
- [`WasmEdge / Kafka / MySQL`](wasmedge-kafka-mysql) - Sample Wasm-based microservice that subscribes to a Kafka (Redpanda) queue topic, and transforms and saves any incoming message into a MySQL (MariaDB) database.&nbsp;<a href="wasmedge-kafka-mysql"><img src="icon_wasm.svg" alt="Compatible with Docker+wasm" height="30" align="top"/></a>
- [`Odoo / PostgreSQL`](odoo-postgres) - This sample provides a basic setup to start developing applications for Odoo, it also includes a simple demo module.

## Single service samples

Expand Down
117 changes: 117 additions & 0 deletions odoo-postgres/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
## Compose sample

Odoo is a suite of open source business apps including, for example, CRM,
eCommerce, accounting, etc. This example provides a basic setup to start
developing applications.

For more information about how to use Odoo with Docker or how to deploy Odoo
for production environment check the official Odoo [docker image](https://hub.docker.com/_/odoo/) page
or the official Odoo [documentation](https://www.odoo.com/documentation/16.0/administration/install/deploy.html)
page respectively.

Project structure:
```shell
odoo
├── compose.yaml
├── conf
│ └── odoo.conf
├── extra-addons
│ └── contact_birthdate
│ ├── __init__.py
│ ├── __manifest__.py
│ ├── models
│ │ ├── __init__.py
│ │ └── res_partner.py
│ ├── README.md
│ ├── static
│ │ └── description
│ │ └── icon.png
│ └── views
│ └── res_partner.xml
├── output.png
└── README.md
```

> The *contact_birthdate* folder is a simple demo module that enables the
> birthday date for individual type contacts.

[_compose.yaml_](compose.yaml)

```yml
services:
odoo:
image: odoo:16.0
platform: linux/amd64
container_name: odoo
...
```

The compose file defines two services called odoo and postgres. When
deploying, Docker Compose maps ports 8069 and 5432 of the odoo and
postgres service containers to host ports 8069 and 5432, so make sure
that both ports are not already being in use.

> The `tty: true` and `stdin_open: true` flags enable interactive mode,
> this is especially useful if you want to use a Python debugger such
> as `pdb`.

## Deploying with docker compose

```shell
$ docker compose up -d
[+] Running 5/5
⠿ Network odoo_default Created
⠿ Volume "odoo_odoo-data" Created
⠿ Volume "odoo_psql-data" Created
⠿ Container postgres Started
⠿ Container odoo Started
```

## Expected result

Listing containers must show two containers running and the port mapping as below:
```shell
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
374a18da3b63 odoo:16.0 "/entrypoint.sh odoo" 2 minutes ago Up 2 minutes 0.0.0.0:8069->8069/tcp, 8071-8072/tcp odoo
c3bbddf884d4 postgres:14.5 "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 0.0.0.0:5432->5432/tcp postgres
```

After the containers start, go to `http://localhost:8069` in your favorite web browser.

![page](output_01.png)

Once a new database is created, you will find the demo module along with all other
available applications in the Apps menu.

![page](output_02.png)

To stop and remove the containers execute:

```shell
$ docker compose down
```

To remove the volumes execute:

```shell
$ docker compose down -v
```

## Troubleshooting

If you are running docker on a Mac with an Apple chip you may get the
following error message when trying to pull the odoo image:

```shell
Using default tag: latest
latest: Pulling from library/odoo
no matching manifest for linux/arm64/v8 in the manifest list entries
```

This is because there is no *linux/arm64* image available yet, so to avoid
this problem you must explicitly specify in the compose file the platform
to use as follow: `platform: linux/amd64`.

There is an open [issue](https://github.com/odoo/docker/issues/349) related
to this subject on GitHub.
33 changes: 33 additions & 0 deletions odoo-postgres/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
services:
odoo:
image: odoo:16.0
platform: linux/amd64
container_name: odoo
depends_on:
- postgres
tty: true
stdin_open: true
ports:
- "8069:8069"
environment:
- HOST=postgres
volumes:
- odoo-data:/var/lib/odoo
- ./conf:/etc/odoo
- ./extra-addons:/mnt/extra-addons
postgres:
image: postgres:14.5
platform: linux/amd64
container_name: postgres
ports:
- "5432:5432"
environment:
- POSTGRES_DB=postgres
- POSTGRES_PASSWORD=odoo
- POSTGRES_USER=odoo
- PGDATA=/var/lib/postgresql/data/pgdata
volumes:
- psql-data:/var/lib/postgresql/data/pgdata
volumes:
odoo-data:
psql-data:
37 changes: 37 additions & 0 deletions odoo-postgres/conf/odoo.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[options]
addons_path = /mnt/extra-addons
data_dir = /var/lib/odoo
; admin_passwd = secretpass
; csv_internal_sep = ,
; db_maxconn = 64
; db_name = False
; db_template = template1
; dbfilter = .*
; debug_mode = False
; email_from = False
; limit_memory_hard = 2684354560
; limit_memory_soft = 2147483648
; limit_request = 8192
; limit_time_cpu = 60
; limit_time_real = 120
; list_db = True
; log_db = False
; log_handler = [':INFO']
; log_level = info
; logfile = None
; longpolling_port = 8072
; max_cron_threads = 2
; osv_memory_age_limit = 1.0
; osv_memory_count_limit = False
; smtp_password = False
; smtp_port = 25
; smtp_server = localhost
; smtp_ssl = False
; smtp_user = False
; workers = 0
; xmlrpc = True
; xmlrpc_interface =
; xmlrpc_port = 8069
; xmlrpcs = True
; xmlrpcs_interface =
; xmlrpcs_port = 8071
30 changes: 30 additions & 0 deletions odoo-postgres/extra-addons/contact_birthday/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
===================
Contact's birthday
===================

This module enables the birthday date for individual type contacts.

**Table of contents**

.. contents::
:local:

Configuration
=============

There is no need for any additional configuration to enable this feature.

Usage
=====

Go to Contacts, then select a contact and set the birthday date.

.. image:: static/description/image_01.png

Credits
=======

Authors
~~~~~~~

* Alexander Olivares <[email protected]>
3 changes: 3 additions & 0 deletions odoo-postgres/extra-addons/contact_birthday/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-

from . import models
19 changes: 19 additions & 0 deletions odoo-postgres/extra-addons/contact_birthday/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
{
"name": "Contact's birthday",

"author": "Alexander Olivares",
"website": "https://github.com/alxolivares",

"category": "Hidden",
"version": "0.1",

"depends": ["contacts"],

"data": ["views/res_partner.xml"],

"demo": ["demo/res_partner.xml"],

"installable": True,
"license": "AGPL-3",
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="base.res_partner_address_28" model="res.partner">
<field name="birthday_date" eval="DateTime.now()"/>
</record>
</odoo>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-

from . import res_partner
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# -*- coding: utf-8 -*-

from odoo import fields, models

class ResPartner(models.Model):
_inherit = 'res.partner'

birthday_date = fields.Date(
string="Birthday", help="Contact's birthday date")
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions odoo-postgres/extra-addons/contact_birthday/views/res_partner.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_partner_form" model="ir.ui.view">
<field name="name">view.partner.form.inherit</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="model">res.partner</field>
<field name="arch" type="xml">
<xpath expr="//field[@name='vat']" position="after">
<field name="birthday_date" attrs="{'invisible': [('is_company','=',True)]}"/>
</xpath>
</field>
</record>
</odoo>
Binary file added odoo-postgres/output_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added odoo-postgres/output_02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.