From 9d8266f02a986b38a8de3fc2e041c22e249caf1b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20-=20Le=20Filament?= <remi@le-filament.com>
Date: Wed, 10 Jul 2024 14:01:40 +0200
Subject: [PATCH] [UPD] add variables for server_wide and auto_install

---
 defaults/main.yml      | 14 +++++++++++++-
 templates/odoo.conf.j2 | 27 +++------------------------
 2 files changed, 16 insertions(+), 25 deletions(-)

diff --git a/defaults/main.yml b/defaults/main.yml
index 67bcbdb..c73def4 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -4,12 +4,18 @@ odoo_setup_version: 16
 odoo_setup_conf:
   17:
     odoo_version: '17.0'
-    postgres_version: '15'
+    postgres_version: '16'
+    modules_auto_install_disabled: google_gmail,l10_fr_invoice_addr,mail_bot,snailmail,sms,web_unsplash
+    modules_auto_install_enabled: account_move_name_sequence,account_usability,mail_debrand,partner_firstname,web_no_bubble,web_responsive,web_theme_classic
+    server_wide_modules: base,web,module_change_auto_install
     websocket_uri: 'websocket'
     websocket_uri_trailing: ''
   16:
     odoo_version: '16.0'
     postgres_version: '15'
+    modules_auto_install_disabled: google_gmail,l10_fr_invoice_addr,mail_bot,web_unsplash
+    modules_auto_install_enabled: account_move_name_sequence,account_usability,disable_odoo_online,lefilament_release_agent,mail_debrand,partner_disable_gravatar,partner_firstname,password_security,portal_odoo_debranding,remove_login_links,remove_odoo_enterprise,web_no_bubble,web_responsive,web_theme_classic
+    server_wide_modules: base,web,module_change_auto_install
     websocket_uri: 'websocket'
     websocket_uri_trailing: ''
   15:
@@ -20,11 +26,17 @@ odoo_setup_conf:
   14:
     odoo_version: '14.0'
     postgres_version: '13'
+    modules_auto_install_disabled: mail_bot,web_unsplash
+    modules_auto_install_enabled: account_move_name_sequence,account_reconcile_show_boolean,account_reconciliation_widget,disable_odoo_online,lefilament_release_agent,mail_debrand,partner_disable_gravatar,partner_firstname,password_security,remove_login_links,remove_odoo_enterprise,web_responsive,web_no_bubble
+    server_wide_modules: base,web,module_change_auto_install
     websocket_uri: 'longpolling'
     websocket_uri_trailing: '/'
   12:
     odoo_version: '12.0'
     postgres_version: '10'
+    modules_auto_install_disabled: mail_bot,web_unsplash
+    modules_auto_install_enabled: disable_odoo_online,lefilament_release_agent,mail_debrand,partner_disable_gravatar,partner_firstname,password_security,remove_odoo_enterprise,web_responsive,web_no_bubble
+    server_wide_modules: base,web,module_change_auto_install
     websocket_uri: 'longpolling'
     websocket_uri_trailing: '/'
   10:
diff --git a/templates/odoo.conf.j2 b/templates/odoo.conf.j2
index a916fdd..e63c123 100644
--- a/templates/odoo.conf.j2
+++ b/templates/odoo.conf.j2
@@ -3,9 +3,7 @@
 addons_path = /opt/odoo/odoo/addons,/opt/odoo/additional_addons,/opt/odoo/private_addons
 admin_passwd = {{ odoo_instances[item.value.prod_instance | default(item.key )].master_pass | pbkdf2_passwd(65534 | random(seed=inventory_hostname) | string) }}
 data_dir = /opt/odoo/data
-{% if instance_odoo_setup.odoo_version == '12.0' or instance_odoo_setup.odoo_version == '14.0' or instance_odoo_setup.odoo_version == '16.0' %}
-server_wide_modules = base,web,module_change_auto_install{% if item.value.odoo_server_wide_modules is defined %},{{ item.value.odoo_server_wide_modules }}{% endif %}
-{% endif %}
+server_wide_modules = {{ odoo_setup_conf[item.value.odoo_setup_version | default(odoo_setup_version)].server_wide_modules }}{% if item.value.odoo_server_wide_modules is defined %},{{ item.value.odoo_server_wide_modules }}{% endif %}
 
 without_demo = all
 
@@ -76,31 +74,12 @@ workers = {{ (ansible_processor_vcpus * 2 - 1) | int | abs }}
 ; max_cron_threads = 2
 ; workers = 0
 {% endif %}
-{% if instance_odoo_setup.odoo_version == '12.0' %}
-
-;; Autoinstall options
-modules_auto_install_disabled = mail_bot,web_unsplash{% if item.value.modules_auto_install_disabled is defined %},{{ item.value.modules_auto_install_disabled }}{% endif %}
-
-modules_auto_install_enabled = disable_odoo_online,lefilament_release_agent,mail_debrand,partner_disable_gravatar,partner_firstname,password_security,remove_odoo_enterprise,web_responsive,web_no_bubble{% if item.value.modules_auto_install_enabled is defined %},{{ item.value.modules_auto_install_enabled }}{% endif %}
-
-{% endif %}
-{% if instance_odoo_setup.odoo_version == '14.0' %}
 
 ;; Autoinstall options
-modules_auto_install_disabled = mail_bot,web_unsplash{% if item.value.modules_auto_install_disabled is defined %},{{ item.value.modules_auto_install_disabled }}{% endif %}
+modules_auto_install_disabled = {{ odoo_setup_conf[item.value.odoo_setup_version | default(odoo_setup_version)].modules_auto_install_disabled | default("mail_bot") }}{% if item.value.modules_auto_install_disabled is defined %},{{ item.value.modules_auto_install_disabled }}{% endif %}
 
-modules_auto_install_enabled = account_move_name_sequence,account_reconcile_show_boolean,account_reconciliation_widget,disable_odoo_online,lefilament_release_agent,mail_debrand,partner_disable_gravatar,partner_firstname,password_security,remove_login_links,remove_odoo_enterprise,web_responsive,web_no_bubble{% if item.value.modules_auto_install_enabled is defined %},{{ item.value.modules_auto_install_enabled }}{% endif %}
+modules_auto_install_enabled = {{ odoo_setup_conf[item.value.odoo_setup_version | default(odoo_setup_version)].modules_auto_install_enabled | default("web") }}{% if item.value.modules_auto_install_enabled is defined %},{{ item.value.modules_auto_install_enabled }}{% endif %}
 
-{% endif %}
-{% if instance_odoo_setup.odoo_version == '16.0' %}
-
-;; Autoinstall options
-modules_auto_install_disabled = google_gmail,mail_bot,web_unsplash{% if item.value.modules_auto_install_disabled is defined %},{{ item.value.modules_auto_install_disabled }}{% endif %}
-
-; to be updated once all modules are available
-modules_auto_install_enabled = account_move_name_sequence,account_usability,disable_odoo_online,lefilament_release_agent,mail_debrand,partner_disable_gravatar,partner_firstname,password_security,portal_odoo_debranding,remove_login_links,remove_odoo_enterprise,web_no_bubble,web_responsive,web_theme_classic{% if item.value.modules_auto_install_enabled is defined %},{{ item.value.modules_auto_install_enabled }}{% endif %}
-
-{% endif %}
 {% if item.value.odoo_extra_conf is defined %}
 
 ;; Extra options
-- 
GitLab