Skip to content

[ADD] utils: Util to launch an industry easily #689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: saas-18.3
Choose a base branch
from

Conversation

arthurrrm
Copy link
Contributor

@arthurrrm arthurrrm commented Jun 12, 2025

Usage: ./industry/run_industry.sh -i <industry-name> [-d] [-t] [-r]
  -i <industry-name>   (re)Install this industry
  -d                   Enable demo data when installing
  -t                   Run tests for the installed industry
  -r                   Reset the database before running

@robodoo
Copy link
Collaborator

robodoo commented Jun 12, 2025

Pull request status dashboard

@arthurrrm arthurrrm force-pushed the saas-18.3-utils-zip-import-modules-amer branch 4 times, most recently from 9d9aea3 to e0b0b07 Compare June 17, 2025 15:05
zip_industry.py Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rename it utils.py?

zip_industry.py Outdated
output = BytesIO()
zf = ZipFile(output, "w")
external_modules = get_external_dependencies('industry/' + module_name, env)
dirs = ['industry/' + module_name] + ['industry/' + module for module in external_modules]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you check the runbot code as well? I think the path is different, and we'd need to find an unified way

zip_industry.py Outdated
for filename in files:
zf.write(os.path.join(dirname, filename), os.path.join(zip_dirname, filename))
zf.close()
output.seek(0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need this?

zip_industry.py Outdated
Comment on lines 24 to 26
if not os.path.exists(manifest_file):
print(f"Manifest not found: {manifest_file}")
return set()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is no manifest, nothing will be installed anyway. I wonder if this shouldn't raise instead of failing silently... Other solution is to replace the print by a warning in the log

zip_industry.py Outdated
Comment on lines 27 to 28
with open(manifest_file, mode='r') as f:
manifest = ast.literal_eval(f.read())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe more secure to use file_open(..., env=env)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

problem is that industry/ is not in the addons path so we cant use this

def file_open(name: str, mode: str = "r", filter_ext: tuple[str, ...] = (), env: Environment | None = None):
    """Open a file from within the addons_path directories, as an absolute or relative path.

run_industry.sh Outdated
from zip_industry import get_zip
def main():
zip = get_zip('$INDUSTRY_NAME', env)
res = env['ir.module.module'].sudo()._import_zipfile(zip, force=False, with_demo=True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to be able to select if we add demo data or not + I'd force a fresh install

Suggested change
res = env['ir.module.module'].sudo()._import_zipfile(zip, force=False, with_demo=True)
res = env['ir.module.module'].sudo()._import_zipfile(zip, force=True, with_demo=with_demo)

cat <<EOF > "$TMP_INSTALL_PY"
import sys

sys.path.append('industry/')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get why you need this

@vava-odoo
Copy link
Collaborator

You'll also have to edit the test so that these new files are not considered as industry modules

@vava-odoo
Copy link
Collaborator

@frva-odoo would you mind having a look at this?

@frva-odoo
Copy link
Contributor

@frva-odoo would you mind having a look at this?

I have nothing to add after reading your comments, everything looks good to me 🙂

@arthurrrm arthurrrm force-pushed the saas-18.3-utils-zip-import-modules-amer branch 2 times, most recently from 7543855 to 2430a0c Compare June 18, 2025 12:58
@arthurrrm arthurrrm requested a review from vava-odoo June 19, 2025 14:41
@arthurrrm arthurrrm force-pushed the saas-18.3-utils-zip-import-modules-amer branch from 2430a0c to 256484e Compare June 20, 2025 13:50
Usage: ./industry/run_industry.sh -i <industry-name> [-d] [-t] [-r]
  -i <industry-name>   (re)Install this industry
  -d                   Enable demo data when installing
  -t                   Run tests for the installed industry
  -r                   Reset the database before running
@arthurrrm arthurrrm force-pushed the saas-18.3-utils-zip-import-modules-amer branch from 256484e to 361b922 Compare June 23, 2025 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants