From 0cda7ad697b781eb3452e34d0146162da99a3a97 Mon Sep 17 00:00:00 2001 From: Janik von Rotz Date: Wed, 12 Jul 2023 10:34:54 +0200 Subject: [PATCH] update custom module and linting files --- addons/odoo_apps_partner | 2 +- addons/partner_contact | 2 +- addons/product_attribute | 2 +- addons/project | 2 +- addons/sale_workflow | 2 +- addons/server_tools | 2 +- addons/social | 2 +- addons/vertical_job_portal | 2 +- addons/vertical_saas | 2 +- addons/website | 2 +- enterprise | 2 +- oca/account-closing | 2 +- oca/account-financial-tools | 2 +- oca/account-invoicing | 2 +- oca/bank-payment | 2 +- oca/bank-statement-import | 2 +- oca/credit-control | 2 +- oca/edi | 2 +- oca/manufacture | 2 +- oca/partner-contact | 2 +- oca/product-attribute | 2 +- oca/project | 2 +- oca/server-backend | 2 +- oca/timesheet | 2 +- oca/website | 2 +- odoo | 2 +- task | 18 ++- template/.flake8 | 12 ++ template/{custom_module => }/.gitignore | 0 template/.isort.cfg | 13 ++ .../.pre-commit-config.yaml | 34 +++-- template/.pylintrc | 121 ++++++++++++++++++ template/{custom_module => module}/LICENSE | 0 template/{custom_module => module}/README.rst | 0 .../{custom_module => module}/__init__.py | 0 .../{custom_module => module}/__manifest__.py | 0 .../data/ir_actions.xml | 0 .../data/ir_sequence.xml | 0 .../{custom_module => module}/demo/demo.xml | 0 .../images/screen.png | Bin .../models/__init__.py | 0 .../models/models.py | 0 .../report/invoice_document.xml | 0 .../security/ir.model.access.csv | 0 .../static/description/icon.png | Bin .../static/src/css/style.css | 0 .../static/src/js/widget.js | 0 .../views/assets.xml | 0 .../views/sale_order.xml | 0 49 files changed, 204 insertions(+), 46 deletions(-) create mode 100644 template/.flake8 rename template/{custom_module => }/.gitignore (100%) create mode 100644 template/.isort.cfg rename template/{custom_module => }/.pre-commit-config.yaml (80%) create mode 100644 template/.pylintrc rename template/{custom_module => module}/LICENSE (100%) rename template/{custom_module => module}/README.rst (100%) rename template/{custom_module => module}/__init__.py (100%) rename template/{custom_module => module}/__manifest__.py (100%) rename template/{custom_module => module}/data/ir_actions.xml (100%) rename template/{custom_module => module}/data/ir_sequence.xml (100%) rename template/{custom_module => module}/demo/demo.xml (100%) rename template/{custom_module => module}/images/screen.png (100%) rename template/{custom_module => module}/models/__init__.py (100%) rename template/{custom_module => module}/models/models.py (100%) rename template/{custom_module => module}/report/invoice_document.xml (100%) rename template/{custom_module => module}/security/ir.model.access.csv (100%) rename template/{custom_module => module}/static/description/icon.png (100%) rename template/{custom_module => module}/static/src/css/style.css (100%) rename template/{custom_module => module}/static/src/js/widget.js (100%) rename template/{custom_module => module}/views/assets.xml (100%) rename template/{custom_module => module}/views/sale_order.xml (100%) diff --git a/addons/odoo_apps_partner b/addons/odoo_apps_partner index 74d70583..b3fd3ddc 160000 --- a/addons/odoo_apps_partner +++ b/addons/odoo_apps_partner @@ -1 +1 @@ -Subproject commit 74d70583685efca072ebe8f67efab92dbe8c0882 +Subproject commit b3fd3ddcb6a489966387901b6c360b03c54b1cc4 diff --git a/addons/partner_contact b/addons/partner_contact index 7cde1181..aedc2a9d 160000 --- a/addons/partner_contact +++ b/addons/partner_contact @@ -1 +1 @@ -Subproject commit 7cde11812955be1b96b7e4373a6bc316f124d69d +Subproject commit aedc2a9dde8f0cc3cf1f5243f10393cecb239333 diff --git a/addons/product_attribute b/addons/product_attribute index 04258d5c..287f5595 160000 --- a/addons/product_attribute +++ b/addons/product_attribute @@ -1 +1 @@ -Subproject commit 04258d5c91db528982882398e659b21a9a4ec52b +Subproject commit 287f559562504aa6a5859195f4ab2aa5886d11c1 diff --git a/addons/project b/addons/project index 9a918d22..ecccf10e 160000 --- a/addons/project +++ b/addons/project @@ -1 +1 @@ -Subproject commit 9a918d227aa6ef638d8fcc010218b166a6a3f601 +Subproject commit ecccf10ee9deabc3506f32202b9076849fc683a2 diff --git a/addons/sale_workflow b/addons/sale_workflow index a67cce6f..c7e5482b 160000 --- a/addons/sale_workflow +++ b/addons/sale_workflow @@ -1 +1 @@ -Subproject commit a67cce6f5005f3ce185dd4a5833bdd9ad8857072 +Subproject commit c7e5482be8c6cbfa9cd54fbbe721c162a971bbf4 diff --git a/addons/server_tools b/addons/server_tools index 44134c7c..381ff99b 160000 --- a/addons/server_tools +++ b/addons/server_tools @@ -1 +1 @@ -Subproject commit 44134c7c6f699261225789f7e17fcf7f0ca9ff53 +Subproject commit 381ff99b7cf98d46799113e0384c164dc3c6aedd diff --git a/addons/social b/addons/social index 74f8c777..2bd69fcc 160000 --- a/addons/social +++ b/addons/social @@ -1 +1 @@ -Subproject commit 74f8c7778daf863a3938d179a72cc0e248083044 +Subproject commit 2bd69fcc760eac3de3c27c5a90f93d36253e53ef diff --git a/addons/vertical_job_portal b/addons/vertical_job_portal index 75b4e1dc..2347edbb 160000 --- a/addons/vertical_job_portal +++ b/addons/vertical_job_portal @@ -1 +1 @@ -Subproject commit 75b4e1dc9248752d5b9cf8c7f84e25cf1ef5b2d4 +Subproject commit 2347edbb0fd751042ac9e8c8cf64dad47093c2f5 diff --git a/addons/vertical_saas b/addons/vertical_saas index d4228227..08e169d5 160000 --- a/addons/vertical_saas +++ b/addons/vertical_saas @@ -1 +1 @@ -Subproject commit d4228227afb0bab9d914ac548bdbe29fd74e08a8 +Subproject commit 08e169d5e7fe3168eaa6355453c6ffa90f86e4c1 diff --git a/addons/website b/addons/website index 43cc4a86..8b7f3dcd 160000 --- a/addons/website +++ b/addons/website @@ -1 +1 @@ -Subproject commit 43cc4a86d797f55413cd6c617a58c39702d611d5 +Subproject commit 8b7f3dcd300ff406bb9564cca0b29d3fcf4eab17 diff --git a/enterprise b/enterprise index 065a952e..adfe654f 160000 --- a/enterprise +++ b/enterprise @@ -1 +1 @@ -Subproject commit 065a952e26481201fe8178ee91c51bdafa93800c +Subproject commit adfe654f14fe1cf962e7a8151df6bb47162391be diff --git a/oca/account-closing b/oca/account-closing index f96036f2..ab30edc2 160000 --- a/oca/account-closing +++ b/oca/account-closing @@ -1 +1 @@ -Subproject commit f96036f2725b7e443ab8a456028b3e6410f59d69 +Subproject commit ab30edc2aca805805ff91283344d81313d993c9c diff --git a/oca/account-financial-tools b/oca/account-financial-tools index e642974d..8f520483 160000 --- a/oca/account-financial-tools +++ b/oca/account-financial-tools @@ -1 +1 @@ -Subproject commit e642974d15972abc11a573401ba4fae42be9b335 +Subproject commit 8f520483b9477206d4ecc4c330bd848c57a4a776 diff --git a/oca/account-invoicing b/oca/account-invoicing index f95c865c..c2cfb66a 160000 --- a/oca/account-invoicing +++ b/oca/account-invoicing @@ -1 +1 @@ -Subproject commit f95c865c66a0e0e21a4926f1b9113a302b1a2594 +Subproject commit c2cfb66a7a68302c2740adf91d0798d0c90e6b79 diff --git a/oca/bank-payment b/oca/bank-payment index 1cc068dd..eb35cd19 160000 --- a/oca/bank-payment +++ b/oca/bank-payment @@ -1 +1 @@ -Subproject commit 1cc068dd7ac6c473d6cc086cc52ce46f644bac6a +Subproject commit eb35cd1919f3b5f1d512e3d9de6f3de5c5bc6a2c diff --git a/oca/bank-statement-import b/oca/bank-statement-import index 25ad7bd1..6befd80a 160000 --- a/oca/bank-statement-import +++ b/oca/bank-statement-import @@ -1 +1 @@ -Subproject commit 25ad7bd106789d38cbc0d4c067600769e204d88c +Subproject commit 6befd80a2f383cc8618544924a1471ba9e78f9a1 diff --git a/oca/credit-control b/oca/credit-control index 5b1b8453..112aaf66 160000 --- a/oca/credit-control +++ b/oca/credit-control @@ -1 +1 @@ -Subproject commit 5b1b8453d89b3f49171f2b9562fb5ae915a6e475 +Subproject commit 112aaf66ea268d2fa1000092139a02f63cf1f473 diff --git a/oca/edi b/oca/edi index ace4738e..9cc7dc1c 160000 --- a/oca/edi +++ b/oca/edi @@ -1 +1 @@ -Subproject commit ace4738eec703fcac427a3c3604a56853f80d281 +Subproject commit 9cc7dc1c1809f69e844138b5b97665a610b71c4a diff --git a/oca/manufacture b/oca/manufacture index fd14862d..62f64fa4 160000 --- a/oca/manufacture +++ b/oca/manufacture @@ -1 +1 @@ -Subproject commit fd14862dd8cc42fb977efd9ef150c738d42f94e5 +Subproject commit 62f64fa459927d634b2f0b797d83d5476039b5d8 diff --git a/oca/partner-contact b/oca/partner-contact index dc19d6a0..a8f37c5e 160000 --- a/oca/partner-contact +++ b/oca/partner-contact @@ -1 +1 @@ -Subproject commit dc19d6a06c4c7583b441aac53cb6384a6665c57c +Subproject commit a8f37c5e263536246bf14e33b32367492921c2a6 diff --git a/oca/product-attribute b/oca/product-attribute index eb9f76cb..07d71b50 160000 --- a/oca/product-attribute +++ b/oca/product-attribute @@ -1 +1 @@ -Subproject commit eb9f76cb86bacbc1dc2abf35f5c2c490f6782a2e +Subproject commit 07d71b505ccee97c299954989c58e287e1a569e5 diff --git a/oca/project b/oca/project index d1fb961f..da69f2fe 160000 --- a/oca/project +++ b/oca/project @@ -1 +1 @@ -Subproject commit d1fb961f7b49871adc996730ff066db3124e1af2 +Subproject commit da69f2fecb941a7295de7b368dd7676e5b36aa08 diff --git a/oca/server-backend b/oca/server-backend index 0a5f4101..d99347f1 160000 --- a/oca/server-backend +++ b/oca/server-backend @@ -1 +1 @@ -Subproject commit 0a5f41017b8e83c427e5bed9583a08f48b1c77ea +Subproject commit d99347f1000a614983ab8f62ab70acebd10998d3 diff --git a/oca/timesheet b/oca/timesheet index fb3bb704..e628799e 160000 --- a/oca/timesheet +++ b/oca/timesheet @@ -1 +1 @@ -Subproject commit fb3bb704a21c407f9e17e61f8600dc02c8399f85 +Subproject commit e628799e4d11f564f1748145a9cb7a930871ca1c diff --git a/oca/website b/oca/website index 6b45a2cd..db98c3b2 160000 --- a/oca/website +++ b/oca/website @@ -1 +1 @@ -Subproject commit 6b45a2cdfd746440b68d8fb3e54d9168665e1513 +Subproject commit db98c3b2ed7b6de069b3924f969595bd2edc8cad diff --git a/odoo b/odoo index d54bae78..2b7e86da 160000 --- a/odoo +++ b/odoo @@ -1 +1 @@ -Subproject commit d54bae78db25dc62687e3afc64f8699dfbfd5cf8 +Subproject commit 2b7e86da909187a002939cc29b0e5a76b95b9136 diff --git a/task b/task index f1b744a5..74c27830 100755 --- a/task +++ b/task @@ -293,15 +293,21 @@ function lint-module() { echo "Set file and folder permissions on $1" find $1 -type d -exec chmod u=rwx,go=rx {} \; find $1 -type f -exec chmod u=rw,go=r {} \; - echo "Copy default .gignore" - cp template/custom_module/.gitignore "$1"/ - echo "Run pylint in $1" - pylint --load-plugins=pylint_odoo -d all -e odoolint $1 - cd $1 + + echo "Copy default configurtion files" + cp template/{.flake8,.gitignore,.isort.cfg,.pre-commit-config.yaml,.pylintrc} $1/../ + + # echo "Run pylint in $1" + # cd $1 + # pylint --load-plugins=pylint_odoo -d all -e odoolint $1 --valid-odoo-versions=$GIT_BRANCH + echo "Run pre-commit in $1" + cd $1 pre-commit run --files ./* + echo "Update index.html" rst2html5 README.rst static/description/index.html + echo "Stage changes" git add . } @@ -408,7 +414,7 @@ function create-module() { locale activate-venv echo "Scaffolding module $MODULE_NAME in $PARENT_DIR ..." - odoo-bin scaffold "$MODULE_NAME" "$PARENT_DIR" -t template/custom_module + odoo-bin scaffold "$MODULE_NAME" "$PARENT_DIR" -t template/module } function drop-db() { diff --git a/template/.flake8 b/template/.flake8 new file mode 100644 index 00000000..784e5771 --- /dev/null +++ b/template/.flake8 @@ -0,0 +1,12 @@ +[flake8] +max-line-length = 88 +max-complexity = 16 +# B = bugbear +# B9 = bugbear opinionated (incl line length) +select = C,E,F,W,B,B9 +# E203: whitespace before ':' (black behaviour) +# E501: flake8 line length (covered by bugbear B950) +# W503: line break before binary operator (black behaviour) +ignore = E203,E501,W503 +per-file-ignores= + __init__.py:F401 \ No newline at end of file diff --git a/template/custom_module/.gitignore b/template/.gitignore similarity index 100% rename from template/custom_module/.gitignore rename to template/.gitignore diff --git a/template/.isort.cfg b/template/.isort.cfg new file mode 100644 index 00000000..e9ca60ff --- /dev/null +++ b/template/.isort.cfg @@ -0,0 +1,13 @@ +[settings] +; see https://github.com/psf/black +multi_line_output=3 +include_trailing_comma=True +force_grid_wrap=0 +combine_as_imports=True +use_parentheses=True +line_length=88 +known_odoo=odoo +known_odoo_addons=odoo.addons +sections=FUTURE,STDLIB,THIRDPARTY,ODOO,ODOO_ADDONS,FIRSTPARTY,LOCALFOLDER +default_section=THIRDPARTY +ensure_newline_before_comments = True \ No newline at end of file diff --git a/template/custom_module/.pre-commit-config.yaml b/template/.pre-commit-config.yaml similarity index 80% rename from template/custom_module/.pre-commit-config.yaml rename to template/.pre-commit-config.yaml index c5000d30..2718392d 100644 --- a/template/custom_module/.pre-commit-config.yaml +++ b/template/.pre-commit-config.yaml @@ -10,15 +10,12 @@ exclude: | ^README\.md$| # Library files can have extraneous formatting (even minimized) /static/(src/)?lib/| - # test_repo is expected to break lints - test_repo/| # Repos using Sphinx to generate docs don't need prettying ^docs/_templates/.*\.html$| # You don't usually want a bot to modify your legal texts (LICENSE.*|COPYING.*) default_language_version: python: python3 - node: "16.17.0" repos: - repo: local hooks: @@ -29,8 +26,13 @@ repos: entry: found forbidden files; remove them language: fail files: "\\.rej$" + - id: en-po-files + name: en.po files cannot exist + entry: found a en.po file + language: fail + files: '[a-zA-Z0-9_]*/i18n/en\.po$' - repo: https://github.com/myint/autoflake - rev: v1.7.6 + rev: v1.6.1 hooks: - id: autoflake args: @@ -41,14 +43,18 @@ repos: - --remove-duplicate-keys - --remove-unused-variables - repo: https://github.com/psf/black - rev: 22.10.0 + rev: 22.8.0 hooks: - id: black - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.3.0 hooks: - id: trailing-whitespace + # exclude autogenerated files + exclude: /README\.rst$|\.pot?$ - id: end-of-file-fixer + # exclude autogenerated files + exclude: /README\.rst$|\.pot?$ - id: debug-statements - id: fix-encoding-pragma args: ["--remove"] @@ -62,13 +68,8 @@ repos: - id: check-xml - id: mixed-line-ending args: ["--fix=lf"] - - repo: https://github.com/asottile/pyupgrade - rev: v3.1.0 - hooks: - - id: pyupgrade - args: ["--keep-percent-format"] - repo: https://github.com/PyCQA/isort - rev: 5.11.5 + rev: 5.12.0 hooks: - id: isort name: isort except __init__.py @@ -81,7 +82,12 @@ repos: - id: flake8 name: flake8 additional_dependencies: ["flake8-bugbear==21.9.2"] - - repo: https://github.com/PyCQA/pylint - rev: v2.15.4 + - repo: https://github.com/OCA/pylint-odoo + rev: 7.0.2 hooks: - - id: pylint \ No newline at end of file + - id: pylint_odoo + name: pylint with optional checks + args: + - --rcfile=.pylintrc + - --exit-zero + verbose: true \ No newline at end of file diff --git a/template/.pylintrc b/template/.pylintrc new file mode 100644 index 00000000..49292140 --- /dev/null +++ b/template/.pylintrc @@ -0,0 +1,121 @@ +[MASTER] +load-plugins=pylint_odoo +score=n + +[ODOOLINT] +readme_template_url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst" +manifest_required_authors=Mint System GmbH +manifest_required_keys=license +manifest_deprecated_keys=description,active +license_allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3 +valid_odoo_versions=16.0 + +[MESSAGES CONTROL] +disable=all + +# This .pylintrc contains optional AND mandatory checks and is meant to be +# loaded in an IDE to have it check everything, in the hope this will make +# optional checks more visible to contributors who otherwise never look at a +# green travis to see optional checks that failed. +# .pylintrc-mandatory containing only mandatory checks is used the pre-commit +# config as a blocking check. + +enable=anomalous-backslash-in-string, + api-one-deprecated, + api-one-multi-together, + assignment-from-none, + attribute-deprecated, + class-camelcase, + dangerous-default-value, + dangerous-view-replace-wo-priority, + development-status-allowed, + duplicate-id-csv, + duplicate-key, + duplicate-xml-fields, + duplicate-xml-record-id, + eval-referenced, + eval-used, + incoherent-interpreter-exec-perm, + license-allowed, + manifest-author-string, + manifest-deprecated-key, + manifest-required-author, + manifest-required-key, + manifest-version-format, + method-compute, + method-inverse, + method-required-super, + method-search, + openerp-exception-warning, + pointless-statement, + pointless-string-statement, + print-used, + redundant-keyword-arg, + redundant-modulename-xml, + reimported, + relative-import, + return-in-init, + rst-syntax-error, + sql-injection, + too-few-format-args, + translation-field, + translation-required, + unreachable, + use-vim-comment, + wrong-tabs-instead-of-spaces, + xml-syntax-error, + attribute-string-redundant, + character-not-valid-in-resource-link, + consider-merging-classes-inherited, + context-overridden, + create-user-wo-reset-password, + dangerous-filter-wo-user, + dangerous-qweb-replace-wo-priority, + deprecated-data-xml-node, + deprecated-openerp-xml-node, + duplicate-po-message-definition, + except-pass, + file-not-used, + invalid-commit, + manifest-maintainers-list, + missing-newline-extrafiles, + missing-readme, + missing-return, + odoo-addons-relative-import, + old-api7-method-defined, + po-msgstr-variables, + po-syntax-error, + renamed-field-parameter, + resource-not-exist, + str-format-used, + test-folder-imported, + translation-contains-variable, + translation-positional-used, + unnecessary-utf8-coding-comment, + website-manifest-key-not-valid-uri, + xml-attribute-translatable, + xml-deprecated-qweb-directive, + xml-deprecated-tree-attribute, + external-request-timeout, + # messages that do not cause the lint step to fail + consider-merging-classes-inherited, + create-user-wo-reset-password, + dangerous-filter-wo-user, + deprecated-module, + file-not-used, + invalid-commit, + missing-manifest-dependency, + missing-newline-extrafiles, + missing-readme, + no-utf8-coding-comment, + odoo-addons-relative-import, + old-api7-method-defined, + redefined-builtin, + too-complex, + unnecessary-utf8-coding-comment + + +[REPORTS] +msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg} +output-format=colorized +reports=no \ No newline at end of file diff --git a/template/custom_module/LICENSE b/template/module/LICENSE similarity index 100% rename from template/custom_module/LICENSE rename to template/module/LICENSE diff --git a/template/custom_module/README.rst b/template/module/README.rst similarity index 100% rename from template/custom_module/README.rst rename to template/module/README.rst diff --git a/template/custom_module/__init__.py b/template/module/__init__.py similarity index 100% rename from template/custom_module/__init__.py rename to template/module/__init__.py diff --git a/template/custom_module/__manifest__.py b/template/module/__manifest__.py similarity index 100% rename from template/custom_module/__manifest__.py rename to template/module/__manifest__.py diff --git a/template/custom_module/data/ir_actions.xml b/template/module/data/ir_actions.xml similarity index 100% rename from template/custom_module/data/ir_actions.xml rename to template/module/data/ir_actions.xml diff --git a/template/custom_module/data/ir_sequence.xml b/template/module/data/ir_sequence.xml similarity index 100% rename from template/custom_module/data/ir_sequence.xml rename to template/module/data/ir_sequence.xml diff --git a/template/custom_module/demo/demo.xml b/template/module/demo/demo.xml similarity index 100% rename from template/custom_module/demo/demo.xml rename to template/module/demo/demo.xml diff --git a/template/custom_module/images/screen.png b/template/module/images/screen.png similarity index 100% rename from template/custom_module/images/screen.png rename to template/module/images/screen.png diff --git a/template/custom_module/models/__init__.py b/template/module/models/__init__.py similarity index 100% rename from template/custom_module/models/__init__.py rename to template/module/models/__init__.py diff --git a/template/custom_module/models/models.py b/template/module/models/models.py similarity index 100% rename from template/custom_module/models/models.py rename to template/module/models/models.py diff --git a/template/custom_module/report/invoice_document.xml b/template/module/report/invoice_document.xml similarity index 100% rename from template/custom_module/report/invoice_document.xml rename to template/module/report/invoice_document.xml diff --git a/template/custom_module/security/ir.model.access.csv b/template/module/security/ir.model.access.csv similarity index 100% rename from template/custom_module/security/ir.model.access.csv rename to template/module/security/ir.model.access.csv diff --git a/template/custom_module/static/description/icon.png b/template/module/static/description/icon.png similarity index 100% rename from template/custom_module/static/description/icon.png rename to template/module/static/description/icon.png diff --git a/template/custom_module/static/src/css/style.css b/template/module/static/src/css/style.css similarity index 100% rename from template/custom_module/static/src/css/style.css rename to template/module/static/src/css/style.css diff --git a/template/custom_module/static/src/js/widget.js b/template/module/static/src/js/widget.js similarity index 100% rename from template/custom_module/static/src/js/widget.js rename to template/module/static/src/js/widget.js diff --git a/template/custom_module/views/assets.xml b/template/module/views/assets.xml similarity index 100% rename from template/custom_module/views/assets.xml rename to template/module/views/assets.xml diff --git a/template/custom_module/views/sale_order.xml b/template/module/views/sale_order.xml similarity index 100% rename from template/custom_module/views/sale_order.xml rename to template/module/views/sale_order.xml