[ADD] configuration: can generate config file repo odoo import from group

- Add feature git repo filter by group
- Makefile support configuration
- Can generate config import path with code_generator dependencies
- Base group is erplibre_base dependencies
This commit is contained in:
Mathieu Benoit 2021-01-14 16:26:36 -05:00
parent 461a2584ef
commit 22384a5126
5 changed files with 119 additions and 22 deletions

View file

@ -29,6 +29,26 @@ else
endif
endif
###################
# Configuration #
###################
# generate new config.conf
.PHONY: config_install
config_install:
./script/install_locally.sh
# generate config all repo
.PHONY: config_gen_all
config_gen_all:
./script/git_repo_update_group.py
./script/install_locally.sh
# generate config repo code_generator
.PHONY: config_gen_code_generator
config_gen_code_generator:
./script/git_repo_update_group.py --group base,code_generator
./script/install_locally.sh
###################
# Documentation #
###################

View file

@ -102,6 +102,19 @@ Check if manifest contains "auto_install" and change the value to False.
./script/repo_remove_auto_install.py
```
# Execution
## Config file
You can limit your addons in ERPlibre config file depending on a group of your actual manifest.
```bash
./script/git_repo_update_group.py --group base,code_generator
./script/install_locally.sh
```
Or go back to normal
```bash
./script/git_repo_update_group.py
./script/install_locally.sh
```
# Coding
## Create module scaffold
```bash

View file

@ -58,18 +58,18 @@
<project name="ddmrp.git" path="addons/OCA_ddmrp" remote="OCA" groups="addons"/>
<project name="delivery-carrier.git" path="addons/OCA_delivery-carrier" remote="OCA" groups="addons"/>
<project name="deltatech.git" path="addons/dhongu_deltatech" remote="dhongu" groups="addons"/>
<project name="development.git" path="addons/MathBenTech_development" remote="MathBenTech" groups="addons"/>
<project name="development.git" path="addons/MathBenTech_development" remote="MathBenTech" groups="addons,base"/>
<project name="documentation-user.git" path="doc/odoo_documentation-user" remote="odoo" groups="odoo"/>
<project name="donation.git" path="addons/OCA_donation" remote="OCA" revision="12.0_module_donation_website" groups="addons"/>
<project name="e-commerce.git" path="addons/OCA_e-commerce" remote="OCA" groups="addons"/>
<project name="edi.git" path="addons/OCA_edi" remote="OCA" groups="addons"/>
<project name="erplibre_addons.git" path="addons/ERPLibre_erplibre_addons" remote="ERPLibre" groups="addons"/>
<project name="erplibre_addons.git" path="addons/ERPLibre_erplibre_addons" remote="ERPLibre" groups="addons,base"/>
<project name="erplibre_theme_addons.git" path="addons/ERPLibre_erplibre_theme_addons" remote="ERPLibre" groups="addons"/>
<project name="event.git" path="addons/OCA_event" remote="OCA" groups="addons"/>
<project name="field-service.git" path="addons/OCA_field-service" remote="OCA" groups="addons"/>
<project name="fleet.git" path="addons/OCA_fleet" remote="OCA" groups="addons"/>
<project name="geospatial.git" path="addons/OCA_geospatial" remote="OCA" groups="addons"/>
<project name="helpdesk.git" path="addons/OCA_helpdesk" remote="OCA" revision="12.0_dev" groups="addons"/>
<project name="geospatial.git" path="addons/OCA_geospatial" remote="OCA" groups="addons,code_generator"/>
<project name="helpdesk.git" path="addons/OCA_helpdesk" remote="OCA" revision="12.0_dev" groups="addons,code_generator"/>
<project name="hr.git" path="addons/OCA_hr" remote="OCA" groups="addons"/>
<project name="interface-github.git" path="addons/OCA_interface-github" remote="OCA" groups="addons"/>
<project name="knowledge.git" path="addons/OCA_knowledge" remote="OCA" groups="addons"/>
@ -80,18 +80,18 @@
<project name="margin-analysis.git" path="addons/OCA_margin-analysis" remote="OCA" revision="12.0_sale_margin_editor" groups="addons"/>
<project name="medical-fhir.git" path="addons/tegin_medical-fhir" remote="tegin" groups="addons"/>
<project name="mis-builder.git" path="addons/OCA_mis-builder" remote="OCA" groups="addons"/>
<project name="muk_base.git" path="addons/muk-it_muk_base" remote="muk-it" revision="12.0_dev" groups="addons"/>
<project name="muk_base.git" path="addons/muk-it_muk_base" remote="muk-it" revision="12.0_dev" groups="addons,base"/>
<project name="muk_dms.git" path="addons/muk-it_muk_dms" remote="muk-it" groups="addons"/>
<project name="muk_docs.git" path="addons/muk-it_muk_docs" remote="muk-it" groups="addons"/>
<project name="muk_misc.git" path="addons/muk-it_muk_misc" remote="muk-it" groups="addons"/>
<project name="muk_misc.git" path="addons/muk-it_muk_misc" remote="muk-it" groups="addons,base"/>
<project name="muk_quality.git" path="addons/muk-it_muk_quality" remote="muk-it" groups="addons"/>
<project name="muk_web.git" path="addons/muk-it_muk_web" remote="muk-it" revision="12.0_fix_web_conflict_menu" groups="addons"/>
<project name="muk_website.git" path="addons/muk-it_muk_website" remote="muk-it" revision="12.0_remove_autoinstall" groups="addons"/>
<project name="muk_web.git" path="addons/muk-it_muk_web" remote="muk-it" revision="12.0_fix_web_conflict_menu" groups="addons,base"/>
<project name="muk_website.git" path="addons/muk-it_muk_website" remote="muk-it" revision="12.0_remove_autoinstall" groups="addons,base"/>
<project name="multi-company.git" path="addons/OCA_multi-company" remote="OCA" groups="addons"/>
<project name="odoo-base-addons.git" path="addons/Numigi_odoo-base-addons" remote="Numigi" revision="12.0_dev" groups="addons"/>
<project name="odoo-business-spending-management-quebec-canada.git" path="addons/MathBenTech_odoo-business-spending-management-quebec-canada" remote="MathBenTech" revision="12.0_sale_order_line_timesheet_attribution" groups="addons"/>
<project name="odoo-cloud-platform.git" path="addons/camptocamp_odoo-cloud-platform" remote="camptocamp" groups="addons"/>
<project name="odoo-code-generator.git" path="addons/TechnoLibre_odoo-code-generator" remote="TechnoLibre" revision="12.0" groups="addons"/>
<project name="odoo-business-spending-management-quebec-canada.git" path="addons/MathBenTech_odoo-business-spending-management-quebec-canada" remote="MathBenTech" revision="12.0_sale_order_line_timesheet_attribution" groups="addons,base"/>
<project name="odoo-cloud-platform.git" path="addons/camptocamp_odoo-cloud-platform" remote="camptocamp" groups="addons,base"/>
<project name="odoo-code-generator.git" path="addons/TechnoLibre_odoo-code-generator" remote="TechnoLibre" revision="12.0" groups="addons,code_generator"/>
<project name="odoo-development.git" path="doc/itpp-labs_odoo-development" remote="itpp-labs" revision="master" groups="odoo"/>
<project name="odoo-entertainment-addons.git" path="addons/Numigi_odoo-entertainment-addons" remote="Numigi" revision="12.0_dev" groups="addons"/>
<project name="odoo-git-addons.git" path="addons/Numigi_odoo-git-addons" remote="Numigi" revision="12.0_dev" groups="addons"/>
@ -109,7 +109,7 @@
<project name="odoo-test-docs.git" path="doc/itpp-labs_odoo-test-docs" remote="itpp-labs" revision="master" groups="odoo"/>
<project name="odoo-timesheet-addons.git" path="addons/Numigi_odoo-timesheet-addons" remote="Numigi" revision="12.0_dev" groups="addons"/>
<project name="odoo-web-addons.git" path="addons/Numigi_odoo-web-addons" remote="Numigi" groups="addons"/>
<project name="odoo.git" path="odoo" remote="odoo" revision="ERPLibre/12.0" clone-depth="10" groups="odoo"/>
<project name="odoo.git" path="odoo" remote="odoo" revision="ERPLibre/12.0" clone-depth="10" groups="odoo,base,code_generator"/>
<project name="odoo_addons.git" path="addons/Smile-SA_odoo_addons" remote="Smile-SA" revision="12.0_remote_autoinstall" groups="addons"/>
<project name="odoo_dhtmlxgantt.git" path="addons/obayit_odoo_dhtmlxgantt" remote="obayit" groups="addons"/>
<project name="odooapps.git" path="addons/odoomates_odooapps" remote="odoomates" groups="addons"/>
@ -133,11 +133,11 @@
<project name="scrummer.git" path="addons/MathBenTech_scrummer" remote="MathBenTech" revision="12.0_dev" groups="addons"/>
<project name="server-auth.git" path="addons/OCA_server-auth" remote="OCA" groups="addons"/>
<project name="server-backend.git" path="addons/OCA_server-backend" remote="OCA" groups="addons"/>
<project name="server-brand.git" path="addons/OCA_server-brand" remote="OCA" groups="addons"/>
<project name="server-brand.git" path="addons/OCA_server-brand" remote="OCA" groups="addons,base"/>
<project name="server-env.git" path="addons/OCA_server-env" remote="OCA" groups="addons"/>
<project name="server-tools.git" path="addons/OCA_server-tools" remote="OCA" revision="12.0_dev" groups="addons"/>
<project name="server-tools.git" path="addons/OCA_server-tools" remote="OCA" revision="12.0_dev" groups="addons,base"/>
<project name="server-ux.git" path="addons/OCA_server-ux" remote="OCA" groups="addons"/>
<project name="social.git" path="addons/OCA_social" remote="OCA" groups="addons"/>
<project name="social.git" path="addons/OCA_social" remote="OCA" groups="addons,base"/>
<project name="stock-logistics-warehouse.git" path="addons/OCA_stock-logistics-warehouse" remote="OCA" groups="addons"/>
<project name="storage.git" path="addons/OCA_storage" remote="OCA" groups="addons"/>
<project name="timesheet.git" path="addons/OCA_timesheet" remote="OCA" revision="12.0_support_project_agile_timesheet" groups="addons"/>
@ -145,9 +145,9 @@
<project name="vertical-hotel.git" path="addons/OCA_vertical-hotel" remote="OCA" groups="addons"/>
<project name="vertical-isp.git" path="addons/OCA_vertical-isp" remote="OCA" groups="addons"/>
<project name="vertical-travel.git" path="addons/OCA_vertical-travel" remote="OCA" groups="addons"/>
<project name="web.git" path="addons/OCA_web" remote="OCA" revision="12.0_dev" groups="addons"/>
<project name="web.git" path="addons/OCA_web" remote="OCA" revision="12.0_dev" groups="addons,base"/>
<project name="website-addons.git" path="addons/itpp-labs_website-addons" remote="itpp-labs" revision="12.0_dev" groups="addons"/>
<project name="website-cms.git" path="addons/OCA_website-cms" remote="OCA" groups="addons"/>
<project name="website.git" path="addons/OCA_website" remote="OCA" revision="12.0_dev" groups="addons"/>
<project name="website.git" path="addons/OCA_website" remote="OCA" revision="12.0_dev" groups="addons,code_generator"/>
<project name="wms.git" path="addons/OCA_wms" remote="OCA" groups="addons"/>
</manifest>

50
script/git_repo_update_group.py Executable file
View file

@ -0,0 +1,50 @@
#!./.venv/bin/python
import os
import sys
import argparse
import logging
from git import Repo
import git
new_path = os.path.normpath(os.path.join(os.path.dirname(__file__), '..'))
sys.path.append(new_path)
from script.git_tool import GitTool
_logger = logging.getLogger(__name__)
def get_config():
"""Parse command line arguments, extracting the config file name,
returning the union of config file and command line arguments
:return: dict of config file settings and command line arguments
"""
config = GitTool.get_project_config()
# TODO update description
parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter,
description='''\
Update config.conf file with group specified in manifest file.
''',
epilog='''\
'''
)
parser.add_argument('--group', default="",
help="Prod by default, use 'dev' for manifest/default.dev.xml")
args = parser.parse_args()
return args
def main():
config = get_config()
git_tool = GitTool()
filter_group = config.group if config.group else None
git_tool.generate_install_locally(filter_group=filter_group)
if __name__ == '__main__':
main()

View file

@ -133,10 +133,10 @@ class GitTool:
return d
def get_repo_info(self, repo_path: str = "./",
add_root: bool = False, is_manifest: bool = True):
add_root: bool = False, is_manifest: bool = True, filter_group=None):
if is_manifest:
return self.get_repo_info_manifest_xml(repo_path=repo_path,
add_root=add_root)
add_root=add_root, filter_group=filter_group)
return self.get_repo_info_submodule(repo_path=repo_path, add_root=add_root)
def get_repo_info_submodule(self, repo_path: str = "./",
@ -221,11 +221,12 @@ class GitTool:
return lst_repo
def get_repo_info_manifest_xml(self, repo_path: str = "./",
add_root: bool = False) -> list:
add_root: bool = False, filter_group=None) -> list:
"""
Get information about manifest of Repo from repo_path
:param repo_path: path of repo to get information about submodule
:param add_root: add information about root repository
:param filter_group: filter manifest by group if exist, separate by comma for multiple group
:return:
[{
"url": original_url,
@ -236,6 +237,7 @@ class GitTool:
"name": name of the submodule
}]
"""
lst_filter_group = filter_group.split(",") if filter_group else []
manifest_file = self.get_manifest_file(repo_path=repo_path)
filename = f"{repo_path}{manifest_file}"
lst_repo = []
@ -252,6 +254,17 @@ class GitTool:
lst_project = [lst_project]
dct_remote = {a.get("@name"): a.get("@fetch") for a in lst_remote}
for project in lst_project:
groups = project.get("@groups")
lst_group = groups.split(',') if groups else []
# Continue if lst_filter exist and group in filter
for group in lst_group:
if lst_filter_group and group not in lst_filter_group:
continue
else:
break
else:
continue
# get name and remote .git
path = project.get("@path")
name = path
@ -268,6 +281,7 @@ class GitTool:
"path": path,
"relative_path": f"{repo_path}/{path}",
"name": name,
"group": group,
}
lst_repo.append(data)
@ -350,9 +364,9 @@ class GitTool:
if url:
webbrowser.open_new_tab(url)
def generate_install_locally(self, repo_path="./"):
def generate_install_locally(self, repo_path="./", filter_group=None):
filename_locally = f"{repo_path}script/install_locally.sh"
lst_repo = self.get_repo_info(repo_path=repo_path)
lst_repo = self.get_repo_info(repo_path=repo_path, filter_group=filter_group)
lst_result = []
for repo in lst_repo:
# Exception, ignore addons/OCA_web and root