Skip to content

Commit

Permalink
Install only new Odoo modules (#53)
Browse files Browse the repository at this point in the history
Co-Authored-By: raneq <46573858+raneq@users.noreply.github.com>

Solve data initialization problem (overwrite) for modules, and speed up operations, by init'ing only modules not already installed, and by updating only one token module (base) in order to "update all modules list"
  • Loading branch information
enricostano authored and raneq committed Jun 12, 2019
1 parent f70a253 commit 8c84378
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 12 deletions.
11 changes: 0 additions & 11 deletions tasks/community-modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,3 @@
pip:
requirements: "{{ odoo_role_odoo_modules_path }}/requirements.txt"
virtualenv: "{{ odoo_role_odoo_venv_path }}"

- name: Update Odoo modules list
become: yes
become_user: "{{ odoo_role_odoo_user }}"
command: "{{ odoo_role_odoo_python_path }} {{ odoo_role_odoo_bin_path }} -c {{ odoo_role_odoo_config_path }}/odoo.conf -d {{ odoo_role_odoo_db_name }} --update all --stop-after-init --without-demo=all --logfile=/dev/stdout --log-level=warn"

- name: Install community Odoo roles
become: yes
become_user: "{{ odoo_role_odoo_user }}"
command: "{{ odoo_role_odoo_python_path }} {{ odoo_role_odoo_bin_path }} -c {{ odoo_role_odoo_config_path }}/odoo.conf -d {{ odoo_role_odoo_db_name }} --init {{ odoo_role_community_odoo_modules }} --stop-after-init --without-demo=all --logfile=/dev/stdout --log-level=warn"
notify: restart odoo
52 changes: 51 additions & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,62 @@
group: "{{ odoo_role_odoo_group }}"
notify: restart odoo

- name: Check if Odoo database has been initialized ("0" false, "1" true)
become: yes
become_user: "{{ odoo_role_odoo_user }}"
shell: >
psql {{ odoo_role_odoo_db_name }} -tAc
"SELECT COUNT(*)
FROM information_schema.tables
WHERE table_name='ir_module_module';"
register: db_initialized

- name: Init Odoo database
become: yes
become_user: "{{ odoo_role_odoo_user }}"
command: "{{ odoo_role_odoo_python_path }} {{ odoo_role_odoo_bin_path }} -c {{ odoo_role_odoo_config_path }}/odoo.conf -d {{ odoo_role_odoo_db_name }} --init {{ odoo_role_odoo_core_modules }} --stop-after-init --without-demo=all --logfile=/dev/stdout --log-level=warn"
command: >
{{ odoo_role_odoo_python_path }} {{ odoo_role_odoo_bin_path }}
-c {{ odoo_role_odoo_config_path }}/odoo.conf
-d {{ odoo_role_odoo_db_name }}
--init base
--stop-after-init
--without-demo=all
--logfile=/dev/stdout
--log-level=warn
when: db_initialized.stdout == "0"
notify: restart odoo

- import_tasks: community-modules.yml

- name: Build the list of new modules to install
become: yes
become_user: "{{ odoo_role_odoo_user }}"
shell: >
psql {{ odoo_role_odoo_db_name }} -tAc
"SELECT name
FROM (VALUES ('{{ (odoo_role_odoo_core_modules + ',' + odoo_role_community_odoo_modules).split(',') | join(separator) }}'))
AS t (name)
EXCEPT
SELECT name
FROM ir_module_module
WHERE state = 'installed';"
register: modules_to_install
vars:
- separator: "'), ('"

- name: Install only new Odoo modules
become: yes
become_user: "{{ odoo_role_odoo_user }}"
command: >
{{ odoo_role_odoo_python_path }} {{ odoo_role_odoo_bin_path }}
-c {{ odoo_role_odoo_config_path }}/odoo.conf
-d {{ odoo_role_odoo_db_name }}
--init {{ modules_to_install.stdout_lines | join(',') }}
--stop-after-init
--without-demo=all
--logfile=/dev/stdout
--log-level=warn
when: modules_to_install.stdout
notify: restart odoo

- import_tasks: add-service.yml

0 comments on commit 8c84378

Please sign in to comment.