From 8054a0956d28835e656977e44e387b673be46980 Mon Sep 17 00:00:00 2001 From: Florian du Garage Num Date: Sat, 28 Oct 2023 13:53:51 +0200 Subject: [PATCH] odoo devenv --- docs/divers/devops/odoo/devenv.md | 11 ++++- docs/divers/devops/odoo/devmodule.md | 66 ++++++++++++++++++++++++++++ docs/divers/devops/odoo/index.md | 3 +- 3 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 docs/divers/devops/odoo/devmodule.md diff --git a/docs/divers/devops/odoo/devenv.md b/docs/divers/devops/odoo/devenv.md index 9342bfe5..81e365da 100644 --- a/docs/divers/devops/odoo/devenv.md +++ b/docs/divers/devops/odoo/devenv.md @@ -103,7 +103,7 @@ Go to extensions views by clicking on the square icon in the sidebar or pressing } ``` -## Access Odoo +## Finalize installation ### Access @@ -119,3 +119,12 @@ You need to use the master password defined in `etc/odoo.conf` ![ScreenShot for first access to odoo instance, with a form for db configuration](img/odoo-dbconfig.png) +Vous pouvez maintenant décommenter les 2 dernières lignes du fichier __odoo.conf__, et redémarrer votre instance avec `docker-compose restart`. + +### Installation des modules + +Une fois les modules communautaires téléchargés dans le dossier des addons, il faut entrer dans le conteneur pour lancer l'installation des modules: +``` +user@host:~$ docker-compose exec -u odoo web bash +odoo@odoo-container:/$ find /mnt/extra-addons/ -mindepth 1 -maxdepth 1 -type d -printf "%f," | sed -E 's/(.*),/\1/' |xargs odoo -d odoo -i +``` \ No newline at end of file diff --git a/docs/divers/devops/odoo/devmodule.md b/docs/divers/devops/odoo/devmodule.md new file mode 100644 index 00000000..dd461cd0 --- /dev/null +++ b/docs/divers/devops/odoo/devmodule.md @@ -0,0 +1,66 @@ +# Créer son module pour Odoo + +## Créer un script d'installation automatisée + +Ce script python va permettre d'automatiser l'installation des modules de base + +??? note "init.py" + ``` + import odoorpc + + # Configuration + ODOO_URL = 'http://localhost:10014' + ODOO_DB = 'odoo' + ODOO_USERNAME = 'garagenum@gmail.com' + ODOO_PASSWORD = 'bellinux@dm!' + + # Modules to install + MODULES_TO_INSTALL = [ + 'account', + 'sale_management', + 'purchase', + 'hr', + 'contacts', + 'hr_expense', + 'project', + 'stock', + 'membership', + 'website', + 'mass_mailing', + 'partner_autocomplete', + 'hr_recruitment', + 'survey', + 'board', + 'mass_mailing_sms', + 'note', + 'website_forum', + 'hr_skills', + 'hr_holidays', + 'website_hr_recruitment', + 'hr_contract', + 'website_slides', + 'board', + 'base_automation', + 'delivery', + ] + + # Connect to the Odoo server + odoo = odoorpc.ODOO('localhost', port=10014) + odoo.login(ODOO_DB, ODOO_USERNAME, ODOO_PASSWORD) + + # Check if each module is installed or not + for module_name in MODULES_TO_INSTALL: + module_id = odoo.env['ir.module.module'].search([('name', '=', module_name)]) + if module_id: + module = odoo.env['ir.module.module'].browse(module_id)[0] + if module.state not in ['installed', 'to upgrade']: + module.button_immediate_install() + print(f"Module {module_name} has been installed.") + else: + print(f"Module {module_name} is already installed.") + else: + print(f"Module {module_name} not found.") + + print("Script execution finished!") + + ``` \ No newline at end of file diff --git a/docs/divers/devops/odoo/index.md b/docs/divers/devops/odoo/index.md index 46f1b351..70e4f756 100644 --- a/docs/divers/devops/odoo/index.md +++ b/docs/divers/devops/odoo/index.md @@ -1,3 +1,4 @@ # Guide de développement pour Odoo -- [ Mettre en place son environnement de développement](devenv.md) \ No newline at end of file +- [ Mettre en place son environnement de développement](devenv.md) +- [Développer un module](devmodule.md) \ No newline at end of file