From b63dd7b0106a406953a25c0203629dc05f86e11c Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Mon, 6 Jul 2020 01:31:21 -0400 Subject: [PATCH 01/18] [ADD] DOC: Update RELEASE.md to do a release - Adapt repo manifest to release 1.0.0 - move prod manifest at root of project, default path of git-repo --- manifest/default.xml => default.xml | 0 doc/GIT_REPO.md | 4 ++-- doc/RELEASE.md | 11 +++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) rename manifest/default.xml => default.xml (100%) diff --git a/manifest/default.xml b/default.xml similarity index 100% rename from manifest/default.xml rename to default.xml diff --git a/doc/GIT_REPO.md b/doc/GIT_REPO.md index a2608c1..702c17c 100644 --- a/doc/GIT_REPO.md +++ b/doc/GIT_REPO.md @@ -10,7 +10,7 @@ curl https://storage.googleapis.com/git-repo-downloads/repo > ./venv/repo ## prod ```bash -./venv/repo init -u http://git.erplibre.ca/ERPLibre -b 12.0_repo +./venv/repo init -u http://git.erplibre.ca/ERPLibre -b master ./venv/repo sync ``` @@ -37,7 +37,7 @@ Freezes all repo, from dev to prod. This will add revision git hash in the Manifest. ```bash -./venv/repo manifest -r -o ./manifest/default.xml +./venv/repo manifest -r -o ./default.xml ``` Do your commit. ```bash diff --git a/doc/RELEASE.md b/doc/RELEASE.md index 9e21f25..ec91d48 100644 --- a/doc/RELEASE.md +++ b/doc/RELEASE.md @@ -3,7 +3,7 @@ A guide on how to do a release. ## Generate new prod ```bash -./venv/repo manifest -r -o ./manifest/default.xml +./venv/repo manifest -r -o ./default.xml ``` Do your commit. ```bash @@ -11,7 +11,14 @@ git commit -am "[#ticket] subject: short sentence" ``` ## Merge release -Merge your feature to master. Generate a new tag. Fill CHANGELOG.md +When ready to make a release, create a branch release/#.#.# and create a pull request to master. +Update file CHANGELOG.md and create a section with new version. +Merge it when maintener accept it. + +Add a tag on the commit on branch master with your release. +> git tag v#.#.# +Push your tag +> git push --tags # TIPS ## Compare diff repo with another ERPLibre project From cc2e0497db405b203d8b8e9e1d1badab9f0fae7e Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Mon, 6 Jul 2020 23:08:05 -0400 Subject: [PATCH 02/18] [FIX] manifest guide discover --- doc/DEVELOPMENT.md | 13 ++++++++++++- doc/DISCOVER.md | 3 ++- env_var.sh | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/doc/DEVELOPMENT.md b/doc/DEVELOPMENT.md index 2e45e18..d0554d5 100644 --- a/doc/DEVELOPMENT.md +++ b/doc/DEVELOPMENT.md @@ -19,6 +19,17 @@ cd ERPLibre ./run.sh ``` +## Develop in Odoo repository +You need to remove +> clone-depth="1" + +from +> ./manifest/default.dev.xml + +file to be able to commit and push. +Commit temporary and regenerate with +> ./script/install_locally_dev.sh + ## Fork project to create a new project independent of ERPLibre (deprecated) ERPLibre was created by this script. It's now deprecated. Use this script when you need to fork directly from the original source. @@ -64,7 +75,7 @@ This will update all urls in git format: ## Diff repo with another project Tools to display the differences between the repo and another project. ```bash -./venv/bin/python ./script/list_repo_diff.py --sync_to /path/to/project/erplibre --dyr_sync +./venv/bin/python ./script/list_repo_diff.py --sync_to /path/to/project/erplibre --dry_sync ``` ## Sync repo with another project diff --git a/doc/DISCOVER.md b/doc/DISCOVER.md index 7a1fc0f..aa93a3b 100644 --- a/doc/DISCOVER.md +++ b/doc/DISCOVER.md @@ -25,7 +25,8 @@ Access to a new repo, add your URL to file [source_repo_addons.csv](../source_re Execute script: ```bash ./venv/bin/python ./script/git_repo_manifest.py -./script/install_locally_dev.sh +git checkout -b new_branch git commit -am "Add new repo" +./script/install_locally_dev.sh ``` [Update your repo.](./GIT_REPO.md) diff --git a/env_var.sh b/env_var.sh index d919be9..5c913df 100755 --- a/env_var.sh +++ b/env_var.sh @@ -19,5 +19,5 @@ EL_INSTALL_NGINX="True" # Set the website name EL_WEBSITE_NAME="_" EL_GITHUB_TOKEN="" -EL_MANIFEST_PROD="./manifest/default.xml" +EL_MANIFEST_PROD="./default.xml" EL_MANIFEST_DEV="./manifest/default.dev.xml" From 4579fdc8f4ccca84b4bd227f1d905c537c907df0 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Wed, 8 Jul 2020 14:42:59 -0400 Subject: [PATCH 03/18] [FIX] prod install locally --- script/install_debian_dependancy.sh | 2 +- script/install_locally_prod.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/script/install_debian_dependancy.sh b/script/install_debian_dependancy.sh index 333a5d9..41b9b1f 100755 --- a/script/install_debian_dependancy.sh +++ b/script/install_debian_dependancy.sh @@ -19,7 +19,7 @@ WKHTMLTOX_X32=https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12. echo -e "\n---- Update Server ----" # add-apt-repository can install add-apt-repository Ubuntu 18.x -sudo apt-get install software-properties-common -y +sudo apt-get install software-properties-common curl -y # universe package is for Ubuntu 18.x sudo add-apt-repository universe # libpng12-0 dependency for wkhtmltopdf diff --git a/script/install_locally_prod.sh b/script/install_locally_prod.sh index 77f158d..6cc9b62 100755 --- a/script/install_locally_prod.sh +++ b/script/install_locally_prod.sh @@ -19,7 +19,7 @@ EL_CONFIG_FILE="${EL_HOME}/config.conf" ./script/install_locally.sh # Update git-repo -./venv/repo init -u http://git.erplibre.ca/ERPLibre -b 12.0_repo +./venv/repo init -u http://git.erplibre.ca/ERPLibre -b master #./venv/repo sync --force-sync ./venv/repo sync From 1c479f082fac365054f6b164c945178f7537b2e2 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 10 Jul 2020 13:44:15 -0400 Subject: [PATCH 04/18] [FIX] Missing repo version - Update missing branch - Add limit_time in run.sh --- doc/GIT_REPO.md | 8 +++++++- manifest/default.dev.xml | 26 +++++++++++++------------- run.sh | 3 ++- script/install_daemon.sh | 2 +- source_repo_addons.csv | 26 +++++++++++++------------- 5 files changed, 36 insertions(+), 29 deletions(-) diff --git a/doc/GIT_REPO.md b/doc/GIT_REPO.md index 702c17c..743a5c5 100644 --- a/doc/GIT_REPO.md +++ b/doc/GIT_REPO.md @@ -51,4 +51,10 @@ git commit -am "[#ticket] subject: short sentence" Do your commit. ```bash git commit -am "[#ticket] subject: short sentence" -``` \ No newline at end of file +``` + +## Useful command +### Search all repo with specific branch name +```bash +./venv/repo forall -pc "git branch -a|grep BRANCH" +``` diff --git a/manifest/default.dev.xml b/manifest/default.dev.xml index 51c95b1..6766ad6 100644 --- a/manifest/default.dev.xml +++ b/manifest/default.dev.xml @@ -22,7 +22,7 @@ - + @@ -38,34 +38,34 @@ - + - + - + - - + + - + - + @@ -74,7 +74,7 @@ - + @@ -82,11 +82,11 @@ - + - + @@ -96,8 +96,8 @@ - + - + diff --git a/run.sh b/run.sh index 28b1df3..a4600ea 100755 --- a/run.sh +++ b/run.sh @@ -1,2 +1,3 @@ #!/usr/bin/env bash -./venv/bin/python ./odoo/odoo-bin -c ./config.conf $@ +source ./venv/bin/activate +python3 ./odoo/odoo-bin -c ./config.conf --limit-time-real 99999 --limit-time-cpu 99999 $@ diff --git a/script/install_daemon.sh b/script/install_daemon.sh index 586d95c..2311c04 100755 --- a/script/install_daemon.sh +++ b/script/install_daemon.sh @@ -52,7 +52,7 @@ cat < /tmp/${EL_USER}run.sh #!/usr/bin/env bash cd ${EL_HOME_ERPLIBRE} source ./venv/bin/activate -python3 ${EL_HOME_ERPLIBRE}/odoo/odoo-bin -c ${EL_HOME_ERPLIBRE}/config.conf $@ +python3 ${EL_HOME_ERPLIBRE}/odoo/odoo-bin -c ${EL_HOME_ERPLIBRE}/config.conf --limit-time-real 99999 --limit-time-cpu 99999 $@ EOF echo -e "* Security Run File" diff --git a/source_repo_addons.csv b/source_repo_addons.csv index 2f64738..a98b03d 100644 --- a/source_repo_addons.csv +++ b/source_repo_addons.csv @@ -1,20 +1,20 @@ url,path,revision,clone-depth https://github.com/ERPLibre/erplibre_addons.git,addons,, https://github.com/MathBenTech/development.git,addons,, -https://github.com/MathBenTech/odoo-business-spending-management-quebec-canada.git,addons,stable_prod_12.0, +https://github.com/MathBenTech/odoo-business-spending-management-quebec-canada.git,addons,12.0_sale_order_line_timesheet_attribution, https://github.com/MathBenTech/scrummer.git,addons,, https://github.com/muk-it/muk_base.git,addons,, https://github.com/muk-it/muk_dms.git,addons,, https://github.com/muk-it/muk_docs.git,addons,, https://github.com/muk-it/muk_misc.git,addons,, https://github.com/muk-it/muk_quality.git,addons,, -https://github.com/muk-it/muk_web.git,addons,, -https://github.com/muk-it/muk_website.git,addons,, +https://github.com/muk-it/muk_web.git,addons,12.0_fix_web_conflict_menu, +https://github.com/muk-it/muk_website.git,addons,12.0_remove_autoinstall, https://github.com/Numigi/odoo-base-addons.git,addons,, https://github.com/Numigi/odoo-entertainment-addons.git,addons,, https://github.com/Numigi/odoo-git-addons.git,addons,, https://github.com/Numigi/odoo-hr-addons.git,addons,, -https://github.com/Numigi/odoo-partner-addons.git,addons,, +https://github.com/Numigi/odoo-partner-addons.git,addons,12.0_partner_no_vat_improve_no_vat, https://github.com/Numigi/odoo-product-addons.git,addons,, https://github.com/Numigi/odoo-project-addons.git,addons,, https://github.com/Numigi/odoo-purchase-addons.git,addons,, @@ -29,7 +29,7 @@ https://github.com/OCA/account-consolidation.git,addons,, https://github.com/OCA/account-financial-reporting.git,addons,, https://github.com/OCA/account-financial-tools.git,addons,, https://github.com/OCA/account-fiscal-rule.git,addons,, -https://github.com/OCA/account-invoicing.git,addons,, +https://github.com/OCA/account-invoicing.git,addons,12.0_account_invoice_approbation, https://github.com/OCA/account-invoice-reporting.git,addons,, https://github.com/OCA/account-payment.git,addons,, https://github.com/OCA/account-reconcile.git,addons,, @@ -45,18 +45,18 @@ https://github.com/OCA/contract.git,addons,, https://github.com/OCA/credit-control.git,addons,, https://github.com/OCA/currency.git,addons,, https://github.com/OCA/data-protection.git,addons,, -https://github.com/OCA/donation.git,addons,, +https://github.com/OCA/donation.git,addons,12.0_module_donation_website, https://github.com/OCA/e-commerce.git,addons,, https://github.com/OCA/edi.git,addons,, https://github.com/OCA/event.git,addons,, -https://github.com/OCA/helpdesk.git,addons,, +https://github.com/OCA/helpdesk.git,addons,12.0_dev, https://github.com/OCA/hr.git,addons,, https://github.com/OCA/knowledge.git,addons,, https://github.com/OCA/l10n-canada.git,addons,, https://github.com/OCA/maintenance.git,addons,, https://github.com/OCA/management-system.git,addons,, https://github.com/OCA/manufacture.git,addons,, -https://github.com/OCA/margin-analysis.git,addons,, +https://github.com/OCA/margin-analysis.git,addons,12.0_sale_margin_editor, https://github.com/OCA/mis-builder.git,addons,, https://github.com/OCA/multi-company.git,addons,, https://github.com/OCA/partner-contact.git,addons,, @@ -64,12 +64,12 @@ https://github.com/OCA/pos.git,addons,, https://github.com/OCA/product-attribute.git,addons,, https://github.com/OCA/product-pack.git,addons,, https://github.com/OCA/product-variant.git,addons,, -https://github.com/OCA/project.git,addons,, +https://github.com/OCA/project.git,addons,12.0_fix_conflict_project_key, https://github.com/OCA/project-reporting.git,addons,, https://github.com/OCA/purchase-workflow.git,addons,, https://github.com/OCA/queue.git,addons,, https://github.com/OCA/reporting-engine.git,addons,, -https://github.com/OCA/sale-workflow.git,addons,, +https://github.com/OCA/sale-workflow.git,addons,12.0_modules_sale_order_line, https://github.com/OCA/server-auth.git,addons,, https://github.com/OCA/server-brand.git,addons,, https://github.com/OCA/server-env.git,addons,, @@ -77,12 +77,12 @@ https://github.com/OCA/server-tools.git,addons,, https://github.com/OCA/server-ux.git,addons,, https://github.com/OCA/social.git,addons,, https://github.com/OCA/stock-logistics-warehouse.git,addons,, -https://github.com/OCA/timesheet.git,addons,, +https://github.com/OCA/timesheet.git,addons,12.0_support_project_agile_timesheet, https://github.com/OCA/web.git,addons,, -https://github.com/OCA/website.git,addons,, +https://github.com/OCA/website.git,addons,12.0_dev, https://github.com/OCA/wms.git,addons,, https://github.com/odoo/odoo.git,.,12.0_feature_5_star_CRM,1 https://github.com/odooaktiv/QuotationRevision.git,addons,, https://github.com/openeducat/openeducat_erp.git,addons,, https://github.com/SanteLibre/santelibre_addons.git,addons,master, -https://github.com/Smile-SA/odoo_addons.git,addons,, +https://github.com/Smile-SA/odoo_addons.git,addons,12.0_remote_autoinstall, From ac530f70d20abafa508833bad18542ecd0060552 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Mon, 6 Jul 2020 13:15:59 -0400 Subject: [PATCH 05/18] [ADD] Support manifest default.staged.xml - Stage is a version between dev and prod, to update future prod with dev - Add doc how to generate default.staged.xml - Fix generate manifest when missing default remote - Fix generate manifest path --- doc/GIT_REPO.md | 12 ++++++ script/fork_project_ERPLibre.py | 3 +- script/git_merge_repo_manifest.py | 68 +++++++++++++++++++++++++++++++ script/git_repo_manifest.py | 7 ++-- script/git_tool.py | 51 +++++++++++++++++------ 5 files changed, 125 insertions(+), 16 deletions(-) create mode 100644 script/git_merge_repo_manifest.py diff --git a/doc/GIT_REPO.md b/doc/GIT_REPO.md index 743a5c5..c58348b 100644 --- a/doc/GIT_REPO.md +++ b/doc/GIT_REPO.md @@ -43,7 +43,19 @@ Do your commit. ```bash git commit -am "[#ticket] subject: short sentence" ``` +### Mix prod and dev to do a stage +When dev contain specific revision with default revision, you want to replace default revision by prod revision and keep specific version, do: +```bash +./venv/bin/python ./script/git_merge_repo_manifest.py --input1 ./manifest/default.dev.xml --input2 ./default.xml --output ./manifest/default.staged.xml +git commit -am "Updated manifest/default.staged.xml" +git daemon --base-path=. --export-all --reuseaddr --informative-errors --verbose & + +./venv/repo init -u git://127.0.0.1:9418/ -b $(git rev-parse --abbrev-ref HEAD) -m ./manifest/default.staged.xml +./venv/repo sync -m ./manifest/default.staged.xml + +./venv/repo manifest -r -o ./default.xml +``` ## Create a dev version ```bash ./venv/repo manifest -o ./manifest/default.dev.xml diff --git a/script/fork_project_ERPLibre.py b/script/fork_project_ERPLibre.py index fb25b19..ee22908 100644 --- a/script/fork_project_ERPLibre.py +++ b/script/fork_project_ERPLibre.py @@ -127,7 +127,8 @@ def main(): # Update origin to new repo # git_tool.generate_git_modules(lst_repo_organization, repo_path=config.dir) - git_tool.generate_repo_manifest(lst_repo_organization, repo_path=config.dir) + git_tool.generate_repo_manifest(lst_repo_organization, + output=f"{config.dir}manifest/default.dev.xml") git_tool.generate_install_locally() diff --git a/script/git_merge_repo_manifest.py b/script/git_merge_repo_manifest.py new file mode 100644 index 0000000..8db3d12 --- /dev/null +++ b/script/git_merge_repo_manifest.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python +import os +import sys +import argparse +import logging +import copy + +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 + """ + # TODO update description + parser = argparse.ArgumentParser( + formatter_class=argparse.RawDescriptionHelpFormatter, + description="""Replace revision field in input2 from input1 if existing, create an output of new manifest.""", + epilog='''\ +''' + ) + parser.add_argument('--input1', required=True, + help="First manifest to merge into input2.") + parser.add_argument('--input2', required=True, + help="Second manifest, overwrite by input1.") + parser.add_argument('--output', required=True, + help="Output of new manifest") + # parser.add_argument('--clear', action="store_true", + # help="Create a new manifest and clear old configuration.") + args = parser.parse_args() + return args + + +def main(): + config = get_config() + git_tool = GitTool() + + dct_remote_1, dct_project_1, default_remote_1 = git_tool.get_manifest_xml_info( + filename=config.input1, add_root=True) + dct_remote_2, dct_project_2, default_remote_2 = git_tool.get_manifest_xml_info( + filename=config.input2, add_root=True) + + dct_remote_3 = copy.deepcopy(dct_remote_2) + dct_project_3 = copy.deepcopy(dct_project_2) + + for key, value in dct_project_1.items(): + revision = value.get("@revision") + if revision: + dct_project_3[key]["@revision"] = revision + else: + dct_project_3[key]["@upstream"] = "12.0" + dct_project_3[key]["@dest-branch"] = "12.0" + + # Update origin to new repo + git_tool.generate_repo_manifest(dct_remote=dct_remote_3, dct_project=dct_project_3, + output=config.output, + default_remote=default_remote_2) + + +if __name__ == '__main__': + main() diff --git a/script/git_repo_manifest.py b/script/git_repo_manifest.py index e2b634a..87c7daa 100644 --- a/script/git_repo_manifest.py +++ b/script/git_repo_manifest.py @@ -47,12 +47,13 @@ def main(): # Update origin to new repo if not config.clear: - dct_remote, dct_project = git_tool.get_manifest_xml_info(repo_path=config.dir, - add_root=True) + dct_remote, dct_project, _ = git_tool.get_manifest_xml_info( + repo_path=config.dir, add_root=True) else: dct_remote = {} dct_project = {} - git_tool.generate_repo_manifest(lst_repo_organization, repo_path=config.dir, + git_tool.generate_repo_manifest(lst_repo_organization, + output=f"{config.dir}manifest/default.dev.xml", dct_remote=dct_remote, dct_project=dct_project) git_tool.generate_install_locally() diff --git a/script/git_tool.py b/script/git_tool.py index 8bec5d2..07cc7f0 100644 --- a/script/git_tool.py +++ b/script/git_tool.py @@ -269,17 +269,19 @@ class GitTool: lst_repo = sorted(lst_repo, key=lambda k: k.get("name")) return lst_repo - def get_manifest_xml_info(self, repo_path: str = "./", + def get_manifest_xml_info(self, repo_path: str = "./", filename=None, add_root: bool = False) -> list: """ Get contain of manifest :param repo_path: path of repo to get information about submodule + :param filename: manifest filename. Default none, or use this instead use repo_path :param add_root: add information about root repository - :return: dct_remote, dct_project + :return: dct_remote, dct_project, default_remote """ - manifest_file = self.get_manifest_file(repo_path=repo_path) - filename = f"{repo_path}/manifest/{manifest_file}" + if filename is None: + manifest_file = self.get_manifest_file(repo_path=repo_path) + filename = f"{repo_path}/{manifest_file}" with open(filename) as xml: xml_as_string = xml.read() xml_dict = xmltodict.parse(xml_as_string, dict_constructor=dict) @@ -289,7 +291,7 @@ class GitTool: lst_project = dct_manifest.get("project") dct_remote = {a.get("@name"): a for a in lst_remote} dct_project = {a.get("@name"): a for a in lst_project} - return dct_remote, dct_project + return dct_remote, dct_project, default_remote @staticmethod def get_project_config(repo_path="./"): @@ -362,8 +364,19 @@ class GitTool: def str_insert(source_str, insert_str, pos): return source_str[:pos] + insert_str + source_str[pos:] - def generate_repo_manifest(self, lst_repo: List[Struct], repo_path: str = "./", - dct_remote={}, dct_project={}): + def generate_repo_manifest(self, lst_repo: List[Struct] = [], output: str = "", + dct_remote={}, dct_project={}, default_remote=None): + """ + Generate repo manifest + :param lst_repo: optional, update manifest with list_repo + :param output: filename to write output + :param dct_remote: dict of remote information + :param dct_project: dict of project information + :param default_remote: name of default remote, optional + :return: + """ + if not output: + raise Exception("Cannot generate manifest with missing output filename.") lst_remote = [] lst_remote_name = [] lst_project = [] @@ -381,14 +394,20 @@ class GitTool: lst_project_info = [ ('@name', dct_value.get("@name")), ('@path', dct_value.get("@path")), - ('@remote', dct_value.get("@remote")) ] + if "@remote" in dct_value.keys(): + lst_project_info.append(('@remote', dct_value.get("@remote"))) if "@revision" in dct_value.keys(): lst_project_info.append(('@revision', dct_value.get("@revision"))) if "@clone-depth" in dct_value.keys(): lst_project_info.append(('@clone-depth', dct_value.get("@clone-depth"))) if "@groups" in dct_value.keys(): lst_project_info.append(('@groups', dct_value.get("@groups"))) + if "@upstream" in dct_value.keys(): + lst_project_info.append(('@upstream', dct_value.get("@upstream"))) + if "@dest-branch" in dct_value.keys(): + lst_project_info.append(('@dest-branch', dct_value.get("@dest-branch"))) + lst_project.append(OrderedDict(lst_project_info)) lst_project_name.append(dct_value.get("@name")) @@ -430,6 +449,14 @@ class GitTool: lst_project_info.append(('@groups', "odoo")) lst_project.append(OrderedDict(lst_project_info)) + if default_remote and not lst_default: + lst_default.append(OrderedDict([ + ('@remote', default_remote), + ('@revision', "12.0"), + ('@sync-j', "4"), + ('@sync-c', "true"), + ])) + # Order in alphabetic lst_order_remote = sorted(lst_remote, key=lambda key: key.get("@name")) lst_order_default = sorted(lst_default, key=lambda key: key.get("@remote")) @@ -444,14 +471,14 @@ class GitTool: str_xml_text = xmltodict.unparse(dct_repo, pretty=True) pos_insert = str_xml_text.rfind("") - if pos_insert: + if pos_insert >= 0: pos_insert += len("") str_xml_text = self.str_insert(str_xml_text, "\n ", pos_insert) pos_insert = str_xml_text.rfind("") - if pos_insert: + if pos_insert >= 0: pos_insert += len("") - str_xml_text = self.str_insert(str_xml_text, "\n ", pos_insert) + str_xml_text = self.str_insert(str_xml_text, "\n ", pos_insert) # pos_insert = str_xml_text.rfind("") # if pos_insert: @@ -465,7 +492,7 @@ class GitTool: str_xml_text = str_xml_text.replace("\t", " ") # create file - with open(f"{repo_path}manifest/default.dev.xml", mode="w") as file: + with open(output, mode="w") as file: file.writelines(str_xml_text + "\n") def generate_git_modules(self, lst_repo: List[Struct], repo_path: str = "./"): From f32b5bf7f76360e8c9c38bd1db977ad34ba9dd3e Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Mon, 6 Jul 2020 01:34:58 -0400 Subject: [PATCH 06/18] [UPD] manifest from staged to update prod. - Add draft account invoice approbation in portal - Add muk theme in erplibre_base - New module sale_fix_update_price_unit_when_update_qty - New module account_invoice_approbation WIP - New module sale_margin_editor --- default.xml | 32 +++++----- manifest/default.dev.xml | 6 +- manifest/default.experimental.xml | 103 ++++++++++++++++++++++++++++++ manifest/default.staged.xml | 103 ++++++++++++++++++++++++++++++ 4 files changed, 225 insertions(+), 19 deletions(-) create mode 100644 manifest/default.experimental.xml create mode 100644 manifest/default.staged.xml diff --git a/default.xml b/default.xml index bc968b9..1396a65 100644 --- a/default.xml +++ b/default.xml @@ -22,7 +22,7 @@ - + @@ -37,35 +37,35 @@ - - + + - + - + - + - - + + - + - + @@ -73,8 +73,8 @@ - - + + @@ -82,11 +82,11 @@ - + - + @@ -96,8 +96,8 @@ - + - + diff --git a/manifest/default.dev.xml b/manifest/default.dev.xml index 6766ad6..c4493a2 100644 --- a/manifest/default.dev.xml +++ b/manifest/default.dev.xml @@ -37,11 +37,11 @@ - + - + @@ -73,7 +73,7 @@ - + diff --git a/manifest/default.experimental.xml b/manifest/default.experimental.xml new file mode 100644 index 0000000..4450cfc --- /dev/null +++ b/manifest/default.experimental.xml @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/manifest/default.staged.xml b/manifest/default.staged.xml new file mode 100644 index 0000000..5a83766 --- /dev/null +++ b/manifest/default.staged.xml @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From c30ad4163457f92be2777be8d36da1d22873bbcf Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Sat, 11 Jul 2020 04:41:22 -0400 Subject: [PATCH 07/18] [FIX] support multi empty line at end of source_repo_addons.csv --- script/git_tool.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/script/git_tool.py b/script/git_tool.py index 07cc7f0..03e2c36 100644 --- a/script/git_tool.py +++ b/script/git_tool.py @@ -550,7 +550,10 @@ class GitTool: for line in all_lines: # Separate information with path in tuple - line_split = line[:-1].split(',') + line = line.strip() + if not line: + continue + line_split = line.split(',') if len(line_split) != 4: print(f"Error with line {line}, suppose to have only 4 ','.") exit(1) From 1589979d2d1d5e2438ec9d9cc4a3752dd7784401 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Sat, 11 Jul 2020 05:10:04 -0400 Subject: [PATCH 08/18] [FIX] support git_change_remote_https_to_git missing.py git remote origin --- script/git_tool.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/script/git_tool.py b/script/git_tool.py index 03e2c36..ddad05f 100644 --- a/script/git_tool.py +++ b/script/git_tool.py @@ -15,6 +15,9 @@ from typing import List CST_FILE_SOURCE_REPO_ADDONS = "source_repo_addons.csv" CST_EL_GITHUB_TOKEN = "EL_GITHUB_TOKEN" +DEFAULT_PROJECT_NAME = "ERPLibre" +DEFAULT_WEBSITE = "erplibre.ca" +DEFAULT_REMOTE_URL = "https://github.com/ERPLibre/ERPLibre.git" class Struct(object): @@ -254,7 +257,13 @@ class GitTool: if add_root: repo_root = Repo(repo_path) - url = repo_root.git.remote("get-url", "origin") + try: + url = repo_root.git.remote("get-url", "origin") + except Exception as e: + print(f"WARNING: Missing origin remote, use default url " + f"{DEFAULT_REMOTE_URL}. Suggest to add a remote origin: \n" + f"> git remote add origin {DEFAULT_REMOTE_URL}") + url = DEFAULT_REMOTE_URL url, url_https, url_git = self.get_url(url) data = { From 0c94c2d507f48c7b2cbb61198a1642ed4f2e34aa Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Sat, 11 Jul 2020 05:12:47 -0400 Subject: [PATCH 09/18] [FIX] script git_ venv bin update hasbang with environment --- doc/DEVELOPMENT.md | 18 +++++++++--------- doc/DISCOVER.md | 2 +- doc/GIT_REPO.md | 2 +- doc/HOWTO.md | 2 +- doc/RELEASE.md | 11 ++++++----- script/fork_project.py | 2 +- script/fork_project_ERPLibre.py | 2 +- script/git_change_remote.py | 2 +- script/git_change_remote_https_to_git.py | 2 +- script/git_merge_repo_manifest.py | 2 +- script/git_repo_manifest.py | 2 +- script/git_tool.py | 2 +- 12 files changed, 25 insertions(+), 24 deletions(-) mode change 100644 => 100755 script/git_merge_repo_manifest.py mode change 100644 => 100755 script/git_repo_manifest.py diff --git a/doc/DEVELOPMENT.md b/doc/DEVELOPMENT.md index d0554d5..a0b36c7 100644 --- a/doc/DEVELOPMENT.md +++ b/doc/DEVELOPMENT.md @@ -35,7 +35,7 @@ ERPLibre was created by this script. It's now deprecated. Use this script when you need to fork directly from the original source. Don't use this script if you want to update from ERPLibre and follow mainstream development. ```bash -./venv/bin/python ./script/fork_project.py --github_token GITHUB_KEY --organization NAME +./script/fork_project.py --github_token GITHUB_KEY --organization NAME ``` # Fork all repo for you own organization @@ -43,7 +43,7 @@ Go to your github account and generate a token to access fork option with your u This command will fork all repos and ERPLibre to your own organization. It keeps track to ERPLibre. ```bash -./venv/bin/python ./script/fork_project_ERPLibre.py --github_token GITHUB_KEY --organization NAME +./script/fork_project_ERPLibre.py --github_token GITHUB_KEY --organization NAME ``` ## Generate manifest from csv repo @@ -51,7 +51,7 @@ Add repo in file [./source_repo_addons.csv](./source_repo_addons.csv) Execute to generate manifest of Repo ```bash -./venv/bin/python ./script/fork_project_ERPLibre.py --skip_fork +./script/fork_project_ERPLibre.py --skip_fork ``` ## Move database prod to dev @@ -63,25 +63,25 @@ Run: # TODO ```bash -./venv/bin/python ./script/git_change_remote.py +./script/git_change_remote.py ``` ## Change git url https to git This will update all urls in git format: ```bash -./venv/bin/python ./script/git_change_remote_https_to_git.py +./script/git_change_remote_https_to_git.py ``` ## Diff repo with another project Tools to display the differences between the repo and another project. ```bash -./venv/bin/python ./script/list_repo_diff.py --sync_to /path/to/project/erplibre --dry_sync +./script/git_change_remote.py --sync_to /path/to/project/erplibre --dry_sync ``` ## Sync repo with another project Tools to synchronise the repo with another project. This will show differences and try to checkout on the same commit in all repo. ```bash -./venv/bin/python ./script/git_change_remote.py --sync_to /path/to/project/erplibre +./script/git_change_remote.py --sync_to /path/to/project/erplibre ``` ## Add repo @@ -89,10 +89,10 @@ Access to a new repo, add your URL to file [source_repo_addons.csv](../source_re Fork the repo to be able to push new code: ```bash -./venv/bin/python ./script/fork_project_ERPLibre.py +./script/fork_project_ERPLibre.py ``` To regenerate only manifest.xml. ```bash -./venv/bin/python ./script/fork_project_ERPLibre.py --skip_fork +./script/fork_project_ERPLibre.py --skip_fork ``` diff --git a/doc/DISCOVER.md b/doc/DISCOVER.md index aa93a3b..7e5ca0e 100644 --- a/doc/DISCOVER.md +++ b/doc/DISCOVER.md @@ -24,7 +24,7 @@ Access to a new repo, add your URL to file [source_repo_addons.csv](../source_re Execute script: ```bash -./venv/bin/python ./script/git_repo_manifest.py +./script/git_repo_manifest.py git checkout -b new_branch git commit -am "Add new repo" ./script/install_locally_dev.sh diff --git a/doc/GIT_REPO.md b/doc/GIT_REPO.md index c58348b..d4d8603 100644 --- a/doc/GIT_REPO.md +++ b/doc/GIT_REPO.md @@ -46,7 +46,7 @@ git commit -am "[#ticket] subject: short sentence" ### Mix prod and dev to do a stage When dev contain specific revision with default revision, you want to replace default revision by prod revision and keep specific version, do: ```bash -./venv/bin/python ./script/git_merge_repo_manifest.py --input1 ./manifest/default.dev.xml --input2 ./default.xml --output ./manifest/default.staged.xml +./script/git_merge_repo_manifest.py --input1 ./manifest/default.dev.xml --input2 ./default.xml --output ./manifest/default.staged.xml git commit -am "Updated manifest/default.staged.xml" git daemon --base-path=. --export-all --reuseaddr --informative-errors --verbose & diff --git a/doc/HOWTO.md b/doc/HOWTO.md index b337e76..8588b44 100644 --- a/doc/HOWTO.md +++ b/doc/HOWTO.md @@ -1,3 +1,3 @@ # HOW TO ## Update changelog -Please, read documentation (keepachangelog.com)[https://keepachangelog.com] \ No newline at end of file +Please, read documentation [keepachangelog.com](https://keepachangelog.com) \ No newline at end of file diff --git a/doc/RELEASE.md b/doc/RELEASE.md index ec91d48..fe8acbe 100644 --- a/doc/RELEASE.md +++ b/doc/RELEASE.md @@ -16,13 +16,14 @@ Update file CHANGELOG.md and create a section with new version. Merge it when maintener accept it. Add a tag on the commit on branch master with your release. -> git tag v#.#.# -Push your tag -> git push --tags - +```bash +git tag v#.#.# +# Push your tags +git push --tags +``` # TIPS ## Compare diff repo with another ERPLibre project To generate a list of differences between repo git commit, do ```bash -./venv/bin/python ./script/git_change_remote.py --sync_to /path/to/directory +./script/git_change_remote.py --sync_to /path/to/directory ``` \ No newline at end of file diff --git a/script/fork_project.py b/script/fork_project.py index c2396a7..b761d83 100644 --- a/script/fork_project.py +++ b/script/fork_project.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!./venv/bin/python import os import sys import argparse diff --git a/script/fork_project_ERPLibre.py b/script/fork_project_ERPLibre.py index ee22908..3a292cc 100644 --- a/script/fork_project_ERPLibre.py +++ b/script/fork_project_ERPLibre.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!./venv/bin/python import os import sys import argparse diff --git a/script/git_change_remote.py b/script/git_change_remote.py index 91b1282..9dbf4f0 100755 --- a/script/git_change_remote.py +++ b/script/git_change_remote.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!./venv/bin/python import os import sys import argparse diff --git a/script/git_change_remote_https_to_git.py b/script/git_change_remote_https_to_git.py index ebdbeec..134177b 100755 --- a/script/git_change_remote_https_to_git.py +++ b/script/git_change_remote_https_to_git.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!./venv/bin/python # © 2020 TechnoLibre (http://www.technolibre.ca) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/script/git_merge_repo_manifest.py b/script/git_merge_repo_manifest.py old mode 100644 new mode 100755 index 8db3d12..877b836 --- a/script/git_merge_repo_manifest.py +++ b/script/git_merge_repo_manifest.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!./venv/bin/python import os import sys import argparse diff --git a/script/git_repo_manifest.py b/script/git_repo_manifest.py old mode 100644 new mode 100755 index 87c7daa..9076d64 --- a/script/git_repo_manifest.py +++ b/script/git_repo_manifest.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!./venv/bin/python import os import sys import argparse diff --git a/script/git_tool.py b/script/git_tool.py index ddad05f..6fc7bb0 100644 --- a/script/git_tool.py +++ b/script/git_tool.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!./venv/bin/python # © 2020 TechnoLibre (http://www.technolibre.ca) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). import os From d5bd432d59d67d75c1584fc9070b92f1c4af0586 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Sat, 11 Jul 2020 21:13:44 -0400 Subject: [PATCH 10/18] [FIX] add git_diff_repo_manifest to show diff code between 2 manifests --- doc/DEVELOPMENT.md | 6 ++ doc/RELEASE.md | 8 ++- script/git_diff_repo_manifest.py | 95 ++++++++++++++++++++++++++++++++ script/git_tool.py | 22 +++++++- 4 files changed, 127 insertions(+), 4 deletions(-) create mode 100755 script/git_diff_repo_manifest.py diff --git a/doc/DEVELOPMENT.md b/doc/DEVELOPMENT.md index a0b36c7..b298926 100644 --- a/doc/DEVELOPMENT.md +++ b/doc/DEVELOPMENT.md @@ -84,6 +84,12 @@ Tools to synchronise the repo with another project. This will show differences a ./script/git_change_remote.py --sync_to /path/to/project/erplibre ``` +## Diff code between manifest +To show diff between commits in different manifest +```bash +./script/git_diff_repo_manifest.py --input1 ./manifest/MANIFEST1.xml --input2 ./manifest/MANIFEST2.xml +``` + ## Add repo Access to a new repo, add your URL to file [source_repo_addons.csv](../source_repo_addons.csv) diff --git a/doc/RELEASE.md b/doc/RELEASE.md index fe8acbe..e73a371 100644 --- a/doc/RELEASE.md +++ b/doc/RELEASE.md @@ -15,12 +15,18 @@ When ready to make a release, create a branch release/#.#.# and create a pull re Update file CHANGELOG.md and create a section with new version. Merge it when maintener accept it. -Add a tag on the commit on branch master with your release. +Add a tag on the commit on branch master with your release. When adding tag, be sure to update default.xml ```bash git tag v#.#.# # Push your tags git push --tags +# Add tags for all repo +./venv/repo forall -pc "git tag ERPLibre/v#.#.#" +./venv/repo forall -pc "git push ERPLibre --tags" +# Get all difference between a tag and HEAD, to update the CHANGELOG.md +./venv/repo forall -pc "git diff ERPLibre/v#.#.#..HEAD" ``` + # TIPS ## Compare diff repo with another ERPLibre project To generate a list of differences between repo git commit, do diff --git a/script/git_diff_repo_manifest.py b/script/git_diff_repo_manifest.py new file mode 100755 index 0000000..b969bd4 --- /dev/null +++ b/script/git_diff_repo_manifest.py @@ -0,0 +1,95 @@ +#!./venv/bin/python +import os +import sys +import argparse +import logging +from git import Repo + +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 + """ + # TODO update description + parser = argparse.ArgumentParser( + formatter_class=argparse.RawDescriptionHelpFormatter, + description="""Get git diff between manifest repo revision, + diff revision input1 to input2 """, + epilog='''\ +''' + ) + parser.add_argument('--input1', required=True, + help="Compare input1 to input2. Input1 is older config.") + parser.add_argument('--input2', required=True, + help="Compare input1 to input2. Input2 is newer config.") + # parser.add_argument('--clear', action="store_true", + # help="Create a new manifest and clear old configuration.") + args = parser.parse_args() + return args + + +def main(): + config = get_config() + git_tool = GitTool() + + dct_remote_1, dct_project_1, default_remote_1 = git_tool.get_manifest_xml_info( + filename=config.input1, add_root=True) + dct_remote_2, dct_project_2, default_remote_2 = git_tool.get_manifest_xml_info( + filename=config.input2, add_root=True) + + set_project_1 = set(dct_project_1.keys()) + set_project_2 = set(dct_project_2.keys()) + lst_same_name_normalize = set_project_1.intersection(set_project_2) + lst_missing_name_normalize = set_project_2.difference(set_project_1) + lst_over_name_normalize = set_project_1.difference(set_project_2) + + i = 0 + total = len(lst_same_name_normalize) + for key in lst_missing_name_normalize: + i += 1 + print(f"{i}/{total} - {key} from input1 not in input2.") + + i = 0 + total = len(lst_over_name_normalize) + for key in lst_over_name_normalize: + i += 1 + print(f"{i}/{total} - {key} from input2 not in input1.") + + i = 0 + total = len(lst_same_name_normalize) + for key in lst_same_name_normalize: + value1 = dct_project_1.get(key) + value2 = dct_project_2.get(key) + old_revision = value1.get("@revision", git_tool.default_branch) + new_revision = value2.get("@revision", git_tool.default_branch) + + path1 = value1.get("@path") + path2 = value2.get("@path") + if path1 != path2: + print(f"WARNING id {i}, path of git are different. " + f"Input1 {path1}, input2 {path2}") + continue + + i += 1 + result = "same" if old_revision == new_revision else "diff" + print(f"{i}/{total} - {result} - " + f"{path1} {key} old {old_revision} new {new_revision}") + default_arg = [f"{old_revision}..{new_revision}"] + if old_revision != new_revision: + # get git diff + repo = Repo(path1) + status = repo.git.diff(*default_arg) + print(status) + + +if __name__ == '__main__': + main() diff --git a/script/git_tool.py b/script/git_tool.py index 6fc7bb0..f9e9e37 100644 --- a/script/git_tool.py +++ b/script/git_tool.py @@ -18,6 +18,7 @@ CST_EL_GITHUB_TOKEN = "EL_GITHUB_TOKEN" DEFAULT_PROJECT_NAME = "ERPLibre" DEFAULT_WEBSITE = "erplibre.ca" DEFAULT_REMOTE_URL = "https://github.com/ERPLibre/ERPLibre.git" +DEFAULT_BRANCH = "12.0" class Struct(object): @@ -26,6 +27,22 @@ class Struct(object): class GitTool: + @property + def default_project_name(self): + return DEFAULT_PROJECT_NAME + + @property + def default_website(self): + return DEFAULT_WEBSITE + + @property + def default_remote_url(self): + return DEFAULT_REMOTE_URL + + @property + def default_branch(self): + return DEFAULT_BRANCH + @staticmethod def get_url(url: str) -> object: """ @@ -128,7 +145,6 @@ class GitTool: Get information about submodule from repo_path :param repo_path: path of repo to get information about submodule :param add_root: add information about root repository - :param upstream: Use this upstream of root :return: [{ "url": original_url, @@ -428,7 +444,7 @@ class GitTool: "Validate why 2 or more is not submodule.") lst_default.append(OrderedDict([ ('@remote', repo.original_organization), - ('@revision', "12.0"), + ('@revision', DEFAULT_BRANCH), ('@sync-j', "4"), ('@sync-c', "true"), ])) @@ -461,7 +477,7 @@ class GitTool: if default_remote and not lst_default: lst_default.append(OrderedDict([ ('@remote', default_remote), - ('@revision', "12.0"), + ('@revision', DEFAULT_BRANCH), ('@sync-j', "4"), ('@sync-c', "true"), ])) From c202107f1bb25d3e4d2444635fa5e08e1b97635a Mon Sep 17 00:00:00 2001 From: Gael Date: Sun, 12 Jul 2020 15:01:57 -0400 Subject: [PATCH 11/18] [ADD] doc development create module scaffold --- doc/DEVELOPMENT.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/DEVELOPMENT.md b/doc/DEVELOPMENT.md index b298926..01c43de 100644 --- a/doc/DEVELOPMENT.md +++ b/doc/DEVELOPMENT.md @@ -102,3 +102,10 @@ To regenerate only manifest.xml. ```bash ./script/fork_project_ERPLibre.py --skip_fork ``` + +# Coding +## Create module scaffold (run in the venv) +```bash +source ./venv/bin/activate +python odoo/odoo-bin scaffold MODULE_NAME addons/REPO_NAME/ +``` From 4c0ed94f8b87a2a5c0621cc3c3c1300b5caaf246 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Sun, 12 Jul 2020 15:20:39 -0400 Subject: [PATCH 12/18] [UPD] run.md improve guide for testing --- doc/RUN.md | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/doc/RUN.md b/doc/RUN.md index c1e1d0b..545af32 100644 --- a/doc/RUN.md +++ b/doc/RUN.md @@ -20,22 +20,30 @@ With arguments ### Method 2 Execute your own python script: ```bash -source ./venv/bin/activate -python odoo/odoo-bin -c config.conf --log-level debug +./run.sh --log-level debug ``` ### Update all Great idea to run it when updating Odoo, it updates database of each modules. ```bash -python odoo/odoo-bin -c config.conf -d [DATABASE] -u all --log-level debug +./run.sh -d [DATABASE] -u all --log-level debug ``` ### Update module ```bash -python odoo/odoo-bin -c config.conf -d [DATABASE] -u [module] --log-level debug +./run.sh -d [DATABASE] -u [module] --log-level debug ``` ### Test +First execution, install you requirements, choose a new database. ```bash -python odoo/odoo-bin -c config.conf -d [DATABASE] -i [module to test] --test-enable --stop-after-init --log-level=test --test-tags [module_name][tags] +./run.sh -d [DATABASE] -i [module to test] --test-enable --stop-after-init --log-level=test +``` +Execute your test on specific module. +```bash +./run.sh -d [DATABASE] -u [module to test] --test-enable --stop-after-init --log-level=test +``` +Execute your test on specific module with tags. +```bash +./run.sh -d [DATABASE] -u [module to test] --test-enable --stop-after-init --log-level=test --test-tags [module_name][tags] ``` \ No newline at end of file From 7b9a4e4345ab63f5448476a08c1abd2f378f2b7c Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Sun, 12 Jul 2020 18:24:00 -0400 Subject: [PATCH 13/18] [UPD] create script to run repo sync on manifest - Add guide to search branch in all repo - Add experimental manifest - Add script to clean all repo --- env_var.sh | 1 + script/clean_repo_manifest.sh | 4 ++++ script/install_locally_dev.sh | 8 +------- script/install_locally_prod.sh | 4 +--- script/update_manifest_dev.sh | 11 +++++++++++ script/update_manifest_local_dev.sh | 15 +++++++++++++++ script/update_manifest_local_experimental.sh | 16 ++++++++++++++++ script/update_manifest_local_prod.sh | 15 +++++++++++++++ script/update_manifest_prod.sh | 11 +++++++++++ 9 files changed, 75 insertions(+), 10 deletions(-) create mode 100755 script/clean_repo_manifest.sh create mode 100755 script/update_manifest_dev.sh create mode 100755 script/update_manifest_local_dev.sh create mode 100755 script/update_manifest_local_experimental.sh create mode 100755 script/update_manifest_local_prod.sh create mode 100755 script/update_manifest_prod.sh diff --git a/env_var.sh b/env_var.sh index 5c913df..072a4de 100755 --- a/env_var.sh +++ b/env_var.sh @@ -21,3 +21,4 @@ EL_WEBSITE_NAME="_" EL_GITHUB_TOKEN="" EL_MANIFEST_PROD="./default.xml" EL_MANIFEST_DEV="./manifest/default.dev.xml" +EL_MANIFEST_EXP="./manifest/default.experimental.xml" diff --git a/script/clean_repo_manifest.sh b/script/clean_repo_manifest.sh new file mode 100755 index 0000000..b0833d0 --- /dev/null +++ b/script/clean_repo_manifest.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +rm -rf ./odoo ./addons/* +mkdir -p addons/addons diff --git a/script/install_locally_dev.sh b/script/install_locally_dev.sh index 671f74d..af55c91 100755 --- a/script/install_locally_dev.sh +++ b/script/install_locally_dev.sh @@ -19,13 +19,7 @@ EL_CONFIG_FILE="${EL_HOME}/config.conf" ./script/install_locally.sh # Update git-repo -git daemon --base-path=. --export-all --reuseaddr --informative-errors --verbose & -DAEMON_PID=$! - -./venv/repo init -u git://127.0.0.1:9418/ -b $(git rev-parse --abbrev-ref HEAD) -m ${EL_MANIFEST_DEV} -./venv/repo sync -m ${EL_MANIFEST_DEV} - -kill ${DAEMON_PID} +./script/update_manifest_local_dev.sh echo -e "\n---- Install python packages/requirements ----" ${EL_HOME}/venv/bin/pip3 install --upgrade pip diff --git a/script/install_locally_prod.sh b/script/install_locally_prod.sh index 6cc9b62..dd61b2e 100755 --- a/script/install_locally_prod.sh +++ b/script/install_locally_prod.sh @@ -19,9 +19,7 @@ EL_CONFIG_FILE="${EL_HOME}/config.conf" ./script/install_locally.sh # Update git-repo -./venv/repo init -u http://git.erplibre.ca/ERPLibre -b master -#./venv/repo sync --force-sync -./venv/repo sync +./script/update_manifest_prod.sh echo -e "\n---- Install python packages/requirements ----" ${EL_HOME}/venv/bin/pip3 install --upgrade pip diff --git a/script/update_manifest_dev.sh b/script/update_manifest_dev.sh new file mode 100755 index 0000000..7af5f61 --- /dev/null +++ b/script/update_manifest_dev.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +. ./env_var.sh + +#EL_MANIFEST_PROD="./default.xml" +#EL_MANIFEST_DEV="./manifest/default.dev.xml" + +# Update git-repo +./venv/repo init -u http://git.erplibre.ca/ERPLibre -b $(git rev-parse --abbrev-ref HEAD) -m ${EL_MANIFEST_DEV} +#./venv/repo sync --force-sync +./venv/repo sync --force-sync -v diff --git a/script/update_manifest_local_dev.sh b/script/update_manifest_local_dev.sh new file mode 100755 index 0000000..8e09e0a --- /dev/null +++ b/script/update_manifest_local_dev.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +. ./env_var.sh + +#EL_MANIFEST_PROD="./default.xml" +#EL_MANIFEST_DEV="./manifest/default.dev.xml" + +# Update git-repo +git daemon --base-path=. --export-all --reuseaddr --informative-errors --verbose & +DAEMON_PID=$! + +./venv/repo init -u git://127.0.0.1:9418/ -b $(git rev-parse --abbrev-ref HEAD) -m ${EL_MANIFEST_DEV} +./venv/repo sync -v --force-sync -m ${EL_MANIFEST_DEV} + +kill ${DAEMON_PID} diff --git a/script/update_manifest_local_experimental.sh b/script/update_manifest_local_experimental.sh new file mode 100755 index 0000000..c41027e --- /dev/null +++ b/script/update_manifest_local_experimental.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +. ./env_var.sh + +#EL_MANIFEST_PROD="./default.xml" +#EL_MANIFEST_DEV="./manifest/default.dev.xml" +#EL_MANIFEST_EXP="./manifest/default.experimental.xml" + +# Update git-repo +git daemon --base-path=. --export-all --reuseaddr --informative-errors --verbose & +DAEMON_PID=$! + +./venv/repo init -u git://127.0.0.1:9418/ -b $(git rev-parse --abbrev-ref HEAD) -m ${EL_MANIFEST_EXP} +./venv/repo sync -v --force-sync -m ${EL_MANIFEST_EXP} + +kill ${DAEMON_PID} diff --git a/script/update_manifest_local_prod.sh b/script/update_manifest_local_prod.sh new file mode 100755 index 0000000..c8efb1b --- /dev/null +++ b/script/update_manifest_local_prod.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +. ./env_var.sh + +#EL_MANIFEST_PROD="./default.xml" +#EL_MANIFEST_DEV="./manifest/default.dev.xml" + +# Update git-repo +git daemon --base-path=. --export-all --reuseaddr --informative-errors --verbose & +DAEMON_PID=$! + +./venv/repo init -u git://127.0.0.1:9418/ -b $(git rev-parse --abbrev-ref HEAD) -m ${EL_MANIFEST_PROD} +./venv/repo sync -v -m ${EL_MANIFEST_PROD} + +kill ${DAEMON_PID} diff --git a/script/update_manifest_prod.sh b/script/update_manifest_prod.sh new file mode 100755 index 0000000..b8d5b0c --- /dev/null +++ b/script/update_manifest_prod.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +. ./env_var.sh + +#EL_MANIFEST_PROD="./default.xml" +#EL_MANIFEST_DEV="./manifest/default.dev.xml" + +# Update git-repo +./venv/repo init -u http://git.erplibre.ca/ERPLibre -b $(git rev-parse --abbrev-ref HEAD) +#./venv/repo sync --force-sync +./venv/repo sync -v From 11ebb7a208686a99a6ec13deec4d48a155572cc1 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Sun, 12 Jul 2020 22:49:25 -0400 Subject: [PATCH 14/18] [ADD] doc to search branch, empty branch and script to clean manifest --- doc/GIT_REPO.md | 16 ++++++++++++++++ doc/PRODUCTION.md | 7 ++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/doc/GIT_REPO.md b/doc/GIT_REPO.md index d4d8603..95a6991 100644 --- a/doc/GIT_REPO.md +++ b/doc/GIT_REPO.md @@ -70,3 +70,19 @@ git commit -am "[#ticket] subject: short sentence" ```bash ./venv/repo forall -pc "git branch -a|grep BRANCH" ``` + +### Search missing branch in all repo +```bash +./venv/repo forall -pc 'git branch -a|(grep /BRANCH$||echo "no match")|grep "no match"' +``` + +### Search change file in all repo +```bash +./venv/repo forall -pc "git status -s" +``` + +### Clean all +Maybe, some version diverge from your manifest. Simply clean all and relaunch your installation. +```bash +./script/clean_repo_manifest.sh +``` \ No newline at end of file diff --git a/doc/PRODUCTION.md b/doc/PRODUCTION.md index 880dfc3..636ebfc 100644 --- a/doc/PRODUCTION.md +++ b/doc/PRODUCTION.md @@ -24,9 +24,14 @@ cd /[EL_USER]/erplibre ``` ## Move database prod to dev - When moving database prod to your dev environment, you want to remove email servers, and install user test to test the database. Run: ```bash ./run.sh --stop-after-init -i user_test,disable_mail_server --dev all -d DATABASE ``` + +## Update production +Simply update all feature. +```bash +./run.sh --limit-time-real 99999 --stop-after-init -u all -d DATABASE +``` From 2ef60330a6ef0271257b85e56b4c150ff095111b Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Mon, 13 Jul 2020 01:06:56 -0400 Subject: [PATCH 15/18] [ADD] CHANGELOG.md with release 1.0.1 --- CHANGELOG.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 395c7fc..7704548 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,8 +11,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Update to Odoo Community 12.0 +## [1.0.1] - 2020-07-14 +### Added +- Improve documentation with development and production environment +- Improve documentation with git repo +- Move default.xml manifest to root, the default location +- Support default.stage.xml to update prod with dev +- Feature to show diff between manifest, between repo of different manifest +- Update manifest + - Muk theme in erplibre_base + - Add draft account invoice approbation in portal + - New module sale_fix_update_price_unit_when_update_qty + - New module account_invoice_approbation + - New module sale_margin_editor + ### Fixed -- Web module display +- Production installation with git_repo ## [1.0.0] - 2020-07-04 ### Added @@ -41,7 +55,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Support only python3.6 and python3.7, python3.8 causes error in runtime. -[Unreleased]: http://git.erplibre.ca/ERPLibre/compare/v1.0.0...HEAD +[Unreleased]: http://git.erplibre.ca/ERPLibre/compare/v1.0.1...HEAD +[1.0.1]: http://git.erplibre.ca/ERPLibre/compare/v1.0.0...v1.0.1 [1.0.0]: http://git.erplibre.ca/ERPLibre/compare/v0.1.1...v1.0.0 [0.1.1]: http://git.erplibre.ca/ERPLibre/compare/v0.1.0...v0.1.1 [0.1.0]: http://git.erplibre.ca/ERPLibre/releases/tag/v0.1.0 From d4c1ada94ba4247b4ce1239123979600379d831a Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Tue, 14 Jul 2020 02:42:27 -0400 Subject: [PATCH 16/18] [ADD] Readme.md with easy guide to run ERPLibre --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index 0ea50a9..fe65626 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,27 @@ # ERPLibre documentation Select a guide to install your environment! +## Easy way to run locally +Clone the project +```bash +git clone http://git.erplibre.ca/ERPLibre.git +cd ERPLibre +``` +Support Ubuntu 18.04 and OSX +```bash +./script/install_dev.sh +./script/install_locally_prod.sh +``` +Update your configuration if you need to run somehere than 127.0.0.1, file config.conf +``` +#xmlrpc_interface = 127.0.0.1 +#netrpc_interface = 127.0.0.1 +``` +Run +```bash +./run.sh +``` + ## Discover guide [Guide to run ERPLibre in discover to learn it](./doc/DISCOVER.md). From e02143e8d3aa572fa4a5daef1660a16c09809dc6 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Tue, 14 Jul 2020 03:38:47 -0400 Subject: [PATCH 17/18] [ADD] production.md with more information about managing prod - Support SSL - Command to watch log - Command to restart services - How to run with address ip --- doc/PRODUCTION.md | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/doc/PRODUCTION.md b/doc/PRODUCTION.md index 636ebfc..e71fa4e 100644 --- a/doc/PRODUCTION.md +++ b/doc/PRODUCTION.md @@ -4,18 +4,46 @@ ### 1. Clone the project: ```bash -git clone https://git.erplibre.ca/ERPLibre.git +git clone http://git.erplibre.ca/ERPLibre.git +cd ERPLibre ``` ### 2. Modify the parameters Modify the file env_var.sh for production installation. ### 3. Execute the script: +Support Ubuntu 18.04 server ```bash -cd ERPLibre ./script/install_dev.sh ./script/install_production.sh ``` +A service is running by systemd, you can access with the DNS name, found it in env_var.sh + +### 4. SSL: +Generate a ssl certificat +```bash +sudo certbot --nginx +``` + +## Watch log +```bash +sudo systemctl -feu [EL_USER] +``` + +## Run by address ip +Comment following line in /[EL_USER]/erplibre/config.conf +``` +#xmlrpc_interface = 127.0.0.1 +#netrpc_interface = 127.0.0.1 +#proxy_mode = True +``` +Add your address ip in nginx config at server_name in /etc/nginx/sites-available/[EL_WEBSITE_NAME] + +Restart daemon: +```bash +sudo systemctl restart nginx +sudo systemctl restart [EL_USER] +``` ## Production execution ```bash From 33020ce9d480728c4533ef710439ba381a6fa9cd Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Tue, 14 Jul 2020 21:06:22 -0400 Subject: [PATCH 18/18] [UPD] config: Force workers at 2 --- script/install_locally.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/install_locally.sh b/script/install_locally.sh index 07cced5..9e36c74 100755 --- a/script/install_locally.sh +++ b/script/install_locally.sh @@ -129,7 +129,7 @@ if [[ $EL_MINIMAL_ADDONS = "False" ]]; then fi printf "\n" >> ${EL_CONFIG_FILE} -printf "workers = 0\n" >> ${EL_CONFIG_FILE} +printf "workers = 2\n" >> ${EL_CONFIG_FILE} printf "max_cron_threads = 2\n" >> ${EL_CONFIG_FILE} if [ ${EL_INSTALL_NGINX} = "True" ]; then