diff --git a/docker-compose.yml b/docker-compose.yml index 61f82e9..66241b2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,8 +20,6 @@ services: - ./odoo/extra-addons:${EXTRA_ADDONS} - ./odoo/custom-addons:${CUSTOM_ADDONS} - ./odoo/entrypoint.sh:/entrypoint.sh - - ./odoo/odoorc.sh:/odoorc.sh - - ./odoo/third-party-addons.sh:/third-party-addons.sh env_file: - ./.env networks: diff --git a/odoo/Dockerfile b/odoo/Dockerfile index 9111d0c..5c2cd50 100644 --- a/odoo/Dockerfile +++ b/odoo/Dockerfile @@ -76,6 +76,7 @@ RUN if [ -n "$GITHUB_USER" ] && [ -n "$GITHUB_ACCESS_TOKEN" ]; then \ RUN mkdir -p ${THIRD_PARTY_ADDONS} && \ chown odoo:odoo -R ${THIRD_PARTY_ADDONS} +COPY --chown=odoo:odoo ./odoo/fix-manifest.py / COPY --chown=odoo:odoo ./odoo/third-party-addons.sh / RUN /third-party-addons.sh && chown odoo:odoo ${THIRD_PARTY_ADDONS} diff --git a/odoo/fix-manifest.py b/odoo/fix-manifest.py new file mode 100644 index 0000000..5075e79 --- /dev/null +++ b/odoo/fix-manifest.py @@ -0,0 +1,34 @@ +import sys + +# Define the path to the manifest file +manifest_file_path = sys.argv[1] + +# Read the file content +with open(manifest_file_path, 'r') as file: + lines = file.readlines() + +# Find the start and end index of the manifest dictionary +start_index = next(i for i, line in enumerate(lines) if line.strip().startswith('{')) +end_index = next(i for i, line in enumerate(lines) if line.strip().endswith('}')) + +# Construct and evaluate the manifest dictionary +manifest_dict = eval(''.join(lines[start_index:end_index + 1])) + +# Modify the manifest dictionary +manifest_dict['installable'] = True +manifest_dict['auto_install'] = True + +# Construct the modified manifest string +modified_manifest_lines = ['{\n'] +for key, value in manifest_dict.items(): + modified_manifest_lines.append(f" '{key}': {repr(value)},\n") +modified_manifest_lines.append('}\n') + +# Replace the manifest dictionary string in the content +lines[start_index:end_index + 1] = modified_manifest_lines + +# Write the modified content back to the file +with open(manifest_file_path, 'w') as file: + file.writelines(lines) + +print(f"Modified {manifest_file_path}") diff --git a/odoo/third-party-addons.sh b/odoo/third-party-addons.sh index 4b1d3db..578ebcc 100755 --- a/odoo/third-party-addons.sh +++ b/odoo/third-party-addons.sh @@ -7,42 +7,7 @@ if [ ! -d "odoo-cloud-platform" ]; then fi # Define the path to the manifest file -manifest_file_path="${THIRD_PARTY_ADDONS}/attachment_s3/__manifest__.py" +s3_manifest="${THIRD_PARTY_ADDONS}/attachment_s3/__manifest__.py" -# Use Python to modify the manifest file -python3 -c " -filename = '${manifest_file_path}' - -# Read the file content -with open(filename, 'r') as file: - lines = file.readlines() - -# Find the start and end index of the manifest dictionary -start_index = next(i for i, line in enumerate(lines) if line.strip().startswith('{')) -end_index = next(i for i, line in enumerate(lines) if line.strip().endswith('}')) - -# Construct and evaluate the manifest dictionary -manifest_dict = eval(''.join(lines[start_index:end_index + 1])) - -# Modify the manifest dictionary -manifest_dict['installable'] = True -manifest_dict['auto_install'] = True - -# Construct the modified manifest string -modified_manifest_lines = ['{\n'] -for key, value in manifest_dict.items(): - modified_manifest_lines.append(f' \'{key}\': {repr(value)},\n') -modified_manifest_lines.append('}\n') - -# Replace the manifest dictionary string in the content -lines[start_index:end_index + 1] = modified_manifest_lines - -# Write the modified content back to the file -with open(filename, 'w') as file: - file.writelines(lines) -" - -echo "Modified $manifest_file_path" - -# Optional: Cat the file to verify changes -cat $manifest_file_path \ No newline at end of file +# Modify the manifest file +python3 /fix-manifest.py $s3_manifest