Uso de doodba para desarrollo de aplicaciones en Odoo

¿Para qué?

El propósito de doodba es servirle de base para construir su propio proyecto para desarrollar módulos y aplicaciones para Odoo de forma rápida, ya que la mayoría de los desarrollos terminan requiriendo una gran cantidad de parches, fusiones, repositorios personalizados, etc. Doodba genera imágenes con dockers, estas imagenes, tienen una colección de buenas prácticas y herramientas para permitir que su equipo tenga una estructura de proyecto estándar de Odoo.


¿Por qué Doodba?

Porque desarrollar para Odoo es difícil. Necesita muchas personalizaciones, dependencias, y si desea pasar de una versión a otra, es un dolor de muelas.

Además, debido a que nadie quiere ir contra corriente, ya que Odoo siempre está en constante evolución y lo más probable es que necesite agregar parches y complementos personalizados, al menos, cada vez que se trata de instalar un Odoo siempre necesitamos una forma de armar todo y hacer que funcione en cualquier lugar rápidamente.


Instalar requisitos

Dockers

Copier

doodba

Instalar docker

El manejador de contenedoores

Dockers

sudo apt install docker.io

Instalar Copier

Es el programa que nos va a permitir crear las plantillas de proyectos

pipx install copier

Doodba

sudo apt install python3-pip

sudo pip3 install docker-compose

sudo pip3 install plumbum

sudo pip3 install pre-commit

sudo apt-get install python3-venv

Crear Template de proyecto

copier copy gh:Tecnativa/doodba-copier-template ~/path/to/your/subproject

Inicializar proyecto

vi repo.yaml

vi addons.yaml

invoke git-aggregate

invoke img-build --pull

Arrancar

invoke start

Requisitos

Dockers

sudo apt install docker.io

o de https://get.docker.com/

curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh


Copier

Este proyecto en sí mismo es solo la plantilla para generar proyectos con dockers, pero necesita instalar estas herramientas para usarlo:

  • copier v3.0.6 or newer

  • git 2.24 or newer

  • invoke installed in Python 3.6+ (and the binary must be called invoke — beware if your distro installs it as invoke3 or similar).

  • pre-commit

  • python 3.6+

  • Install non-python apps with your distro's recommended package manager. The recommended way to install Python CLI apps is pipx:

Con tu usuario normal:

python3 -m pip install --user pipx
pipx install copier
pipx install invoke
pipx install pre-commit
pipx ensurepath

Crear un proyecto de desarrollo para Odoo de 0 con doodba

Usar el templete de doodba

copier copy gh:Tecnativa/doodba-copier-template ~/ruta/a/mi/nuevo/proyecto

Contestar preguntas clave:

  • Autor

  • Nombre del Proyecto (Creará un directorio con ese nombre y todas la imagenes docker tendrán este nombre como prefijo)

  • Licencia

  • Versión de Odoo

  • Lenguaje inicial de Odoo

  • Proxy de Odoo (Dejar el de default Traefik)

  • Versión de PostgreSQL


Tell me who you are.
If private modules do not include this author, pylint will warn you.
project_author? Format: str
 [RealSystems]:

What's your project name?
Do not use dots or spaces in the name; just "A-Za-z0-9-_" please.
project_name? Format: str
 [proyecto13]:

project_license? Format: yaml
 
(1) No license
(2) Apache License 2.0
(3) Boost Software License 1.0
(4) GNU Affero General Public License (AGPL) 3.0 or later
(5) GNU Library or "Lesser" General Public License (LGPL) 3.0 or later
(6) MIT license
(7) Odoo Enterprise Edition License v1.0
(8) Odoo Proprietary License v1.0
Choice [4]:
gitlab_url? Format: str
 [None]:
Write the main production domain for this project. Only the domain, no protocol or things like that.
Example: www.example.com
domain_prod? Format: str
 [None]:
domain_prod_alternatives? Format: yaml
 [None]:
domain_test? Format: str
 [None]:
paths_without_crawlers? Format: yaml
 [['/web', '/website/info']]:
cidr_whitelist? Format: yaml
[None]:
On which odoo version is it based?
odoo_version? Format: float

 
(1) 7.0
(2) 8.0
(3) 9.0
(4) 10.0
(5) 11.0
(6) 12.0
(7) 13.0
Choice [7]:
If you want to initialize Odoo automatically in a specific language, write it here. The format must be ll_CC where ll is the language code and CC is the country code.
Examples: en_US, es_ES, es_VE...
odoo_initial_lang? Format: str
 [en_US]:

If you are using an OCI/Docker image registry (such as the Docker Hub, Quay or Gitlab registry) to publish the Odoo images that will be built with this Doodba project, specify here the path to the odoo image built with it. Leave it empty if you are not using a registry.
Example: docker.io/myteam/example-odoo
odoo_oci_image? Format: str
 [None]:
Do you want to list databases publicly?
odoo_listdb? Format: bool
? [Y/n]
bulb To auto-generate strong passwords, see https://ddg.gg/?q=password+64+strong
warning This password is critical for security, especially if you have set odoo_listdb to true, so keep it safe.
What will be your odoo admin password?
odoo_admin_password? Format: str
 [example-admin-password]:
Set your Odoo db filter. It must be a regexp that matches the domain name being visited. It is useful if you use Odoo in SaaS mode.
odoo_dbfilter? Format: str
 [.*]:
warning Using a misconfigured proxy for production can create a security hole. Using none can create performance problems.
Which proxy will you use to deploy odoo?
odoo_proxy? Format: yaml
 
(1) No proxy (dangerous for production)
(2) Traefik
(3) Other proxy (it's up to you!)
Choice [2]:
Which PostgreSQL version do you want to deploy?
postgres_version? Format: yaml

(1) I will use an external PostgreSQL server
(2) 9.6
(3) 10
(4) 11
(5) 12
Choice [5]:
Which user name will be used to connect to the postgres server?
postgres_username? Format: str
 [odoo13]:
bulb If database names differ among environments, operations like restoring a database from an alien environment will be harder to maintain, but can provide additional security. It's up to you. We default to "prod" for historical reasons.
What is going to be the main database name?
postgres_dbname? Format: str
 [dev13]:
What will be your postgres user password?
postgres_password? Format: str
 [example-db-password]:
Now, let's start configuring outgoing mail.
In case an email coming out from odoo doesn't have a valid From: header address, which address should be the default one that sends the email?
smtp_default_from? Format: str
 [None]:
warning If you leave this answer empty, all next SMTP settings will be ignored.
If you supply a valid SMTP host, production Odoo will be able to send emails without needing to configure any ir.mail_server record, because Doodba will configure it to use a mail relay that will manage a local mail queue before sending it to the real SMTP endpoint (saving your mails from bad network conditions). The same relay will be used to send backup reports.
So, what is your SMTP host?
Example: mail.example.com
smtp_relay_host? Format: str
 [None]:
Indicate the port to connect in the SMTP server you just defined.
warning NEVER use port 465 point_right tomav/docker-mailserver#1428
smtp_relay_port? Format: int
 [587]:
Indicate the user to connect in the SMTP server you just defined.
For Odoo to work fine, this user needs to be able to do mail spoofing.
smtp_relay_user? Format: str
 [None]:
What is your SMTP password?
smtp_relay_password? Format: str
 [example-smtp-password]:
Usually, if you send mails like "user@example.com", the canonical domain would be "example.com".
This canonical domain should have correct SPF, DKIM and DMARC settings that allow the SMTP host to send mails in its name.
When Odoo tries to send a mail that does not come from a canonical domain, the domain you indicate here will be used when rewriting the address with SRS (https://en.wikipedia.org/wiki/SRS).
What's your canonical domain?
smtp_canonical_default? Format: str
 [None]:
Supply a list of other domains authorized to send email from this Odoo instance and SMTP host. They will not be affected by SRS. They also must have valid SPF, DKIM and DMARC settings.
You do not need to repeat the canonical domain you indicated above.
Example: [examplemail.com, example.org]
smtp_canonical_domains? Format: yaml
 [None]:
If you want to use an Amazon S3 bucket, write its URL like s3://s3.amazonaws.com/example-bucket/example/path to make sure it works fine.
If you want to use any other backend, supply any URL supported by Duplicity (our choice backup engine; read http://duplicity.nongnu.org/vers8/duplicity.1.html#sect7 for those URL formats).
If you don't want bakcups, leave this empty.
Where should the backups be stored?
backup_dst? Format: str
 [None]:
The backup container will send email reports if the SMTP relay is properly configured.
What email address should it use to send them?
backup_email_from? Format: str
 [None]:
Where to send those backup reports?
backup_email_to? Format: str
 [None]:
If you're using S3, you probably want to delete outdated backups using bucket lifecycle rules. If you use other storage backend, then you probably want to enable outdated backups deletion using duplicity itself.
So, do you want to enable duplicity backup deletion via cron?
backup_deletion? Format: bool
? [y/N]
Set the timezone used by the backup cron for reports.
Visit https://www.cyberciti.biz/faq/linux-unix-set-tz-environment-variable/ to know how to obtain a valid value for this variable.
backup_tz? Format: str
 [UTC]:
If you're using AWS S3 to store backups, provide here your access key ID.
backup_aws_access_key_id? Format: str
 [None]:
If you're using AWS S3 to store backups, provide here your secret access key.
backup_aws_secret_access_key? Format: str
 [None]:
warning This passphrase is critical for security, so keep it safe. You will need it to restore backups.
Which will be your backups passphrase?
backup_passphrase? Format: str
 [example-backup-passphrase]:

Después agregar repositorios y códigos privados editando

vi proyecto/odoo/custom/src/repos.yaml 

Agregar módulos para que estén disponibles en el Odoo

vi proyecto/odoo/custom/src/addons.yaml

Descargar y agregar repositorios

invoke git-aggregate

Reconstruir la imagen docker de odoo

invoke img-build --pull

Iniciar el odoo

invoke start

Ver en el navegador web

http://localhost:$ODOO_VERSION069/

Donde:

$ODOO_VERSION es la versión descargada de Odoo elegida en el cuestionario de coupier



Parece que se creó una base de datos en blanco, eliminamos la base de datos y debería funcionar
Incluyendo información demo:

docker-compose run --rm odoo --stop-after-init -i base

ó si no se quiere que cargue información demo:

docker-compose run --rm odoo --without-demo=true --stop-after-init -i base


Después

invoke restart

 

Guía ultra rápida para contribuir a un proyecto en github 1/2