diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 75194054e..000000000 --- a/.coveragerc +++ /dev/null @@ -1,17 +0,0 @@ -# Config file .coveragerc - -[report] -include = - */compassion-accounting/* - -omit = - */tests/* - *__init__.py - -# Regexes for lines to exclude from consideration -exclude_lines = - # Have to re-enable the standard pragma - pragma: no cover - - # Don't complain about null context checking - if context is None: \ No newline at end of file diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..bfd7ac53d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,20 @@ +# Configuration for known file extensions +[*.{css,js,json,less,md,py,rst,sass,scss,xml,yaml,yml}] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.{json,yml,yaml,rst,md}] +indent_size = 2 + +# Do not configure editor for libs and autogenerated content +[{*/static/{lib,src/lib}/**,*/static/description/index.html,*/readme/../README.rst}] +charset = unset +end_of_line = unset +indent_size = unset +indent_style = unset +insert_final_newline = false +trim_trailing_whitespace = false diff --git a/.eslintrc.yml b/.eslintrc.yml new file mode 100644 index 000000000..fed88d70d --- /dev/null +++ b/.eslintrc.yml @@ -0,0 +1,188 @@ +env: + browser: true + es6: true + +# See https://github.com/OCA/odoo-community.org/issues/37#issuecomment-470686449 +parserOptions: + ecmaVersion: 2019 + +overrides: + - files: + - "**/*.esm.js" + parserOptions: + sourceType: module + +# Globals available in Odoo that shouldn't produce errorings +globals: + _: readonly + $: readonly + fuzzy: readonly + jQuery: readonly + moment: readonly + odoo: readonly + openerp: readonly + owl: readonly + luxon: readonly + +# Styling is handled by Prettier, so we only need to enable AST rules; +# see https://github.com/OCA/maintainer-quality-tools/pull/618#issuecomment-558576890 +rules: + accessor-pairs: warn + array-callback-return: warn + callback-return: warn + capitalized-comments: + - warn + - always + - ignoreConsecutiveComments: true + ignoreInlineComments: true + complexity: + - warn + - 15 + constructor-super: warn + dot-notation: warn + eqeqeq: warn + global-require: warn + handle-callback-err: warn + id-blacklist: warn + id-match: warn + init-declarations: error + max-depth: warn + max-nested-callbacks: warn + max-statements-per-line: warn + no-alert: warn + no-array-constructor: warn + no-caller: warn + no-case-declarations: warn + no-class-assign: warn + no-cond-assign: error + no-const-assign: error + no-constant-condition: warn + no-control-regex: warn + no-debugger: error + no-delete-var: warn + no-div-regex: warn + no-dupe-args: error + no-dupe-class-members: error + no-dupe-keys: error + no-duplicate-case: error + no-duplicate-imports: error + no-else-return: warn + no-empty-character-class: warn + no-empty-function: error + no-empty-pattern: error + no-empty: warn + no-eq-null: error + no-eval: error + no-ex-assign: error + no-extend-native: warn + no-extra-bind: warn + no-extra-boolean-cast: warn + no-extra-label: warn + no-fallthrough: warn + no-func-assign: error + no-global-assign: error + no-implicit-coercion: + - warn + - allow: ["~"] + no-implicit-globals: warn + no-implied-eval: warn + no-inline-comments: warn + no-inner-declarations: warn + no-invalid-regexp: warn + no-irregular-whitespace: warn + no-iterator: warn + no-label-var: warn + no-labels: warn + no-lone-blocks: warn + no-lonely-if: error + no-mixed-requires: error + no-multi-str: warn + no-native-reassign: error + no-negated-condition: warn + no-negated-in-lhs: error + no-new-func: warn + no-new-object: warn + no-new-require: warn + no-new-symbol: warn + no-new-wrappers: warn + no-new: warn + no-obj-calls: warn + no-octal-escape: warn + no-octal: warn + no-param-reassign: warn + no-path-concat: warn + no-process-env: warn + no-process-exit: warn + no-proto: warn + no-prototype-builtins: warn + no-redeclare: warn + no-regex-spaces: warn + no-restricted-globals: warn + no-restricted-imports: warn + no-restricted-modules: warn + no-restricted-syntax: warn + no-return-assign: error + no-script-url: warn + no-self-assign: warn + no-self-compare: warn + no-sequences: warn + no-shadow-restricted-names: warn + no-shadow: warn + no-sparse-arrays: warn + no-sync: warn + no-this-before-super: warn + no-throw-literal: warn + no-undef-init: warn + no-undef: error + no-unmodified-loop-condition: warn + no-unneeded-ternary: error + no-unreachable: error + no-unsafe-finally: error + no-unused-expressions: error + no-unused-labels: error + no-unused-vars: error + no-use-before-define: error + no-useless-call: warn + no-useless-computed-key: warn + no-useless-concat: warn + no-useless-constructor: warn + no-useless-escape: warn + no-useless-rename: warn + no-void: warn + no-with: warn + operator-assignment: [error, always] + prefer-const: warn + radix: warn + require-yield: warn + sort-imports: warn + spaced-comment: [error, always] + strict: [error, function] + use-isnan: error + valid-jsdoc: + - warn + - prefer: + arg: param + argument: param + augments: extends + constructor: class + exception: throws + func: function + method: function + prop: property + return: returns + virtual: abstract + yield: yields + preferType: + array: Array + bool: Boolean + boolean: Boolean + number: Number + object: Object + str: String + string: String + requireParamDescription: false + requireReturn: false + requireReturnDescription: false + requireReturnType: false + valid-typeof: warn + yoda: warn diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 000000000..602ecbca2 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,46 @@ +name: pre-commit + +on: + pull_request: + branches: + - "14.0*" + push: + branches: + - "14.0" + - "14.0-ocabot-*" + +jobs: + pre-commit: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v2 + with: + python-version: "3.11" + - name: Get python version + run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV + - uses: actions/cache@v1 + with: + path: ~/.cache/pre-commit + key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} + - name: Install pre-commit + run: pip install pre-commit + - name: Run pre-commit + run: pre-commit run --all-files --show-diff-on-failure --color=always + env: + # Consider valid a PR that changes README fragments but doesn't + # change the README.rst file itself. It's not really a problem + # because the bot will update it anyway after merge. This way, we + # lower the barrier for functional contributors that want to fix the + # readme fragments, while still letting developers get README + # auto-generated (which also helps functionals when using runboat). + # DOCS https://pre-commit.com/#temporarily-disabling-hooks + SKIP: oca-gen-addon-readme + - name: Check that all files generated by pre-commit are in git + run: | + newfiles="$(git ls-files --others --exclude-from=.gitignore)" + if [ "$newfiles" != "" ] ; then + echo "Please check-in the following files:" + echo "$newfiles" + exit 1 + fi diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..64231125e --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,69 @@ +name: tests + +on: + pull_request: + branches: + - "14.0*" + push: + branches: + - "14.0" + - "14.0-ocabot-*" + +jobs: + unreleased-deps: + runs-on: ubuntu-latest + name: Detect unreleased dependencies + steps: + - uses: actions/checkout@v3 + - run: | + for reqfile in requirements.txt test-requirements.txt ; do + if [ -f ${reqfile} ] ; then + result=0 + # reject non-comment lines that contain a / (i.e. URLs, relative paths) + grep "^[^#].*/" ${reqfile} || result=$? + if [ $result -eq 0 ] ; then + echo "Unreleased dependencies found in ${reqfile}." + exit 1 + fi + fi + done + test: + runs-on: ubuntu-22.04 + container: ${{ matrix.container }} + name: ${{ matrix.name }} + strategy: + fail-fast: false + matrix: + include: + - container: ghcr.io/oca/oca-ci/py3.6-odoo14.0:latest + name: test with Odoo + makepot: "true" + services: + postgres: + image: postgres:9.6 + env: + POSTGRES_USER: odoo + POSTGRES_PASSWORD: odoo + POSTGRES_DB: odoo + ports: + - 5432:5432 + steps: + - uses: actions/checkout@v3 + with: + persist-credentials: false + - name: Install addons and dependencies + run: oca_install_addons + - name: Check licenses + run: manifestoo -d . check-licenses + continue-on-error: true + - name: Check development status + run: manifestoo -d . check-dev-status --default-dev-status=Beta + continue-on-error: true + - name: Initialize test db + run: oca_init_test_database + - name: Run tests + run: oca_run_tests + - uses: codecov/codecov-action@v1 + - name: Update .pot files + run: oca_export_and_push_pot https://x-access-token:${{ secrets.GIT_PUSH_TOKEN }}@github.com/${{ github.repository }} + if: ${{ matrix.makepot == 'true' && github.event_name == 'push' && github.repository_owner == 'CompassionCH' }} diff --git a/.gitignore b/.gitignore index 51cbe8525..0090721f5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] +/.venv +/.pytest_cache +/.ruff_cache # C extensions *.so @@ -13,7 +16,6 @@ build/ develop-eggs/ dist/ eggs/ -lib/ lib64/ parts/ sdist/ @@ -21,6 +23,7 @@ var/ *.egg-info/ .installed.cfg *.egg +*.eggs # Installer logs pip-log.txt @@ -37,6 +40,22 @@ coverage.xml # Translations *.mo +# Pycharm +.idea + +# Eclipse +.settings + +# Visual Studio cache/options directory +.vs/ +.vscode + +# OSX Files +.DS_Store + +# Django stuff: +*.log + # Mr Developer .mr.developer.cfg .project @@ -45,10 +64,12 @@ coverage.xml # Rope .ropeproject -# Django stuff: -*.log -*.pot - # Sphinx documentation docs/_build/ +# Backup files +*~ +*.swp + +# OCA rules +!static/lib/ diff --git a/.oca_hooks.cfg b/.oca_hooks.cfg new file mode 100644 index 000000000..1f3e3e426 --- /dev/null +++ b/.oca_hooks.cfg @@ -0,0 +1,2 @@ +[MESSAGES_CONTROL] +disable=xml-deprecated-data-node,xml-deprecated-tree-attribute diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..b875861c2 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,133 @@ +exclude: | + (?x) + # NOT INSTALLABLE ADDONS + # END NOT INSTALLABLE ADDONS + # Files and folders generated by bots, to avoid loops + ^setup/|/static/description/index\.html$| + # We don't want to mess with tool-generated files + .svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/| + # Maybe reactivate this when all README files include prettier ignore tags? + ^README\.md$| + # Library files can have extraneous formatting (even minimized) + /static/(src/)?lib/| + # Repos using Sphinx to generate docs don't need prettying + ^docs/_templates/.*\.html$| + # Don't bother non-technical authors with formatting issues in docs + readme/.*\.(rst|md)$| + # Ignore build and dist directories in addons + /build/|/dist/| + # You don't usually want a bot to modify your legal texts + (LICENSE.*|COPYING.*) +default_language_version: + python: python3 + node: "14.13.0" +repos: + - repo: local + hooks: + # These files are most likely copier diff rejection junks; if found, + # review them manually, fix the problem (if needed) and remove them + - id: forbidden-files + name: forbidden files + 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/oca/maintainer-tools + rev: 9a170331575a265c092ee6b24b845ec508e8ef75 + hooks: + # update the NOT INSTALLABLE ADDONS section above + - id: oca-update-pre-commit-excluded-addons + - id: oca-fix-manifest-website + args: ["https://github.com/CompassionCH/test-repo"] + - id: oca-gen-addon-readme + args: + - --addons-dir=. + - --branch=14.0 + - --org-name=CompassionCH + - --repo-name=test-repo + - --if-source-changed + - --keep-source-digest + - --convert-fragments-to-markdown + - repo: https://github.com/OCA/odoo-pre-commit-hooks + rev: v0.0.25 + hooks: + - id: oca-checks-odoo-module + - id: oca-checks-po + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v2.1.2 + hooks: + - id: prettier + name: prettier (with plugin-xml) + additional_dependencies: + - "prettier@2.1.2" + - "@prettier/plugin-xml@0.12.0" + args: + - --plugin=@prettier/plugin-xml + files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$ + - repo: https://github.com/pre-commit/mirrors-eslint + rev: v7.8.1 + hooks: + - id: eslint + verbose: true + args: + - --color + - --fix + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.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"] + - id: check-case-conflict + - id: check-docstring-first + - id: check-executables-have-shebangs + - id: check-merge-conflict + # exclude files where underlines are not distinguishable from merge conflicts + exclude: /README\.rst$|^docs/.*\.rst$ + - id: check-symlinks + - id: check-xml + - id: mixed-line-ending + args: ["--fix=lf"] + - repo: https://github.com/asottile/pyupgrade + rev: v2.7.2 + hooks: + - id: pyupgrade + args: ["--keep-percent-format"] + - repo: https://github.com/acsone/setuptools-odoo + rev: 3.1.8 + hooks: + - id: setuptools-odoo-make-default + - id: setuptools-odoo-get-requirements + args: + - --output + - requirements.txt + - --header + - "# generated from manifests external_dependencies" + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.3 + hooks: + - id: ruff + args: [--fix, --exit-non-zero-on-fix] + - id: ruff-format + - repo: https://github.com/OCA/pylint-odoo + rev: 7.0.2 + hooks: + - id: pylint_odoo + name: pylint with optional checks + args: + - --rcfile=.pylintrc + - --exit-zero + verbose: true + - id: pylint_odoo + args: + - --rcfile=.pylintrc-mandatory diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 000000000..7adfd06d2 --- /dev/null +++ b/.pylintrc @@ -0,0 +1,90 @@ + + +[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=Compassion Switzerland +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=14.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, + # 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 diff --git a/.pylintrc-mandatory b/.pylintrc-mandatory new file mode 100644 index 000000000..ddc691654 --- /dev/null +++ b/.pylintrc-mandatory @@ -0,0 +1,65 @@ + +[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=Compassion Switzerland +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=14.0 + +[MESSAGES CONTROL] +disable=all + +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 + +[REPORTS] +msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg} +output-format=colorized +reports=no diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 000000000..d75c6d979 --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,28 @@ + +fix = true + +[lint] +extend-select = [ + "B", + "C90", + "E501", # line too long (default 88) + "I", # isort +] +exclude = ["setup/*"] + +[format] +exclude = ["setup/*"] + +[per-file-ignores] +"__init__.py" = ["F401", "I001"] # ignore unused and unsorted imports in __init__.py +"__manifest__.py" = ["B018"] # useless expression + +[isort] +section-order = ["future", "standard-library", "third-party", "odoo", "odoo-addons", "first-party", "local-folder"] + +[isort.sections] +"odoo" = ["odoo"] +"odoo-addons" = ["odoo.addons"] + +[mccabe] +max-complexity = 16 diff --git a/.sonarcloud.properties b/.sonarcloud.properties new file mode 100644 index 000000000..1dcea701d --- /dev/null +++ b/.sonarcloud.properties @@ -0,0 +1,2 @@ +# Exclude files or directories +sonar.exclusions=**/__manifest__.py,**/description/index.html diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 00194aeab..000000000 --- a/.travis.yml +++ /dev/null @@ -1,35 +0,0 @@ -language: python - -python: - - "3.6" - -cache: - pip: true - - -addons: - postgresql: "9.6" - apt: - packages: - - expect-dev # provides unbuffer utility - - python-lxml # because pip installation is slow - -env: - global: - - VERSION="12.0" TESTS="0" LINT_CHECK="0" TRANSIFEX="0" - - matrix: - - LINT_CHECK="1" - - TESTS="1" ODOO_REPO="odoo/odoo" - - -install: - - git clone --depth=1 https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools - - export PATH=${HOME}/maintainer-quality-tools/travis:${PATH} - - travis_install_nightly - -script: - - travis_run_tests - -after_success: - - travis_after_tests_success diff --git a/LICENSE b/LICENSE index 58777e31a..be3f7b28e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,7 @@ -GNU AFFERO GENERAL PUBLIC LICENSE + GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -633,8 +633,8 @@ the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -643,7 +643,7 @@ the "copyright" line and a pointer to where the full notice is found. GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . + along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. @@ -658,4 +658,4 @@ specific requirements. You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see -. +. diff --git a/README.md b/README.md index 2aaf3f2e5..27f2bb331 100644 --- a/README.md +++ b/README.md @@ -1,49 +1,50 @@ -[![Build Status](https://travis-ci.org/CompassionCH/compassion-accounting.svg)](https://travis-ci.org/CompassionCH/compassion-accounting.svg) -[![Coverage Status](https://coveralls.io/repos/CompassionCH/compassion-accounting/badge.svg?branch=8.0&service=github)](https://coveralls.io/github/CompassionCH/compassion-accounting?branch=8.0) -Compassion Accounting Modules -============================= + +[![Pre-commit Status](https://github.com/CompassionCH/test-repo/actions/workflows/pre-commit.yml/badge.svg?branch=14.0)](https://github.com/CompassionCH/test-repo/actions/workflows/pre-commit.yml?query=branch%3A14.0) +[![Build Status](https://github.com/CompassionCH/test-repo/actions/workflows/test.yml/badge.svg?branch=14.0)](https://github.com/CompassionCH/test-repo/actions/workflows/test.yml?query=branch%3A14.0) +[![codecov](https://codecov.io/gh/CompassionCH/test-repo/branch/14.0/graph/badge.svg)](https://codecov.io/gh/CompassionCH/test-repo) + -It extends Odoo/OpenERP to add needed functionnalites to use Odoo/OpenERP in Switzerland. + -account_analytic_attribution ----------------------------- +# Compassion Accounting -Set rules to dispatch analytic lines into analytic accounts. +All accounting extensions needed for supporting Compassion's mission, in particular with the child sponsosrhip program. -account_analytic_compassion ---------------------------- + -This module installs the needed analytic accounts for Compassion CH. + -account_asset_compassion ------------------------- +[//]: # (addons) -Modifications to fit Compassion needs. +Available addons +---------------- +addon | version | maintainers | summary +--- | --- | --- | --- +[account_analytic_attribution](account_analytic_attribution/) | 14.0.1.0.0 | | Set rules to dispatch analytic lines into analytic accounts +[account_analytic_compassion](account_analytic_compassion/) | 14.0.1.0.0 | | Compassion Analytic Accounts +[account_ebics_CH](account_ebics_CH/) | 14.0.1.0.0 | | add specific EBICS order type and file format for Switzerland +[account_ebics_payment_return](account_ebics_payment_return/) | 14.0.1.0.0 | | Download Payment Order return via EBICS +[account_invoice_split_invoice](account_invoice_split_invoice/) | 14.0.1.0.1 | | Split invoices into two separate invoices +[account_move_periodic_accounting_transfer](account_move_periodic_accounting_transfer/) | 14.0.1.0.0 | | Move from an ending accounting period to an open one +[account_payment_line_free](account_payment_line_free/) | 14.0.1.0.1 | | Account payment line free +[account_statement_completion](account_statement_completion/) | 14.0.1.0.1 | | Account Statement Completion Rules +[compassion_sub_chart_account](compassion_sub_chart_account/) | 14.0.1.0.0 | | Comapssion subsidiary- Accounting +[donation_report_compassion](donation_report_compassion/) | 14.0.1.0.0 | | Compassion Donation Report +[invoice_restrictions](invoice_restrictions/) | 14.0.1.0.5 | | Contract for recurring invoicing +[recurring_contract](recurring_contract/) | 14.0.1.0.5 | | Contract for recurring invoicing -account_invoice_split_invoice ------------------------------ +[//]: # (end addons) -Split invoices into two separate invoices + -account_reconcile_compassion ----------------------------- +## Licenses -Reconcile rules with bvr_ref of invoice for Compassion CH. - -account_statment_completion_compassion --------------------------------------- - -Account Statement Additions for Compassion CH. - -chart_account_compassion ------------------------- - -Chart account Compassion - -recurring_contract ------------------- - -Contract for recurring invoicing +This repository is licensed under [AGPL-3.0](LICENSE). +However, each module can have a totally different license, as long as they adhere to Compassion Switzerland +policy. Consult each module's `__manifest__.py` file, which contains a `license` key +that explains its license. +---- + diff --git a/account_analytic_attribution/README.rst b/account_analytic_attribution/README.rst index 62f578eba..577f0e655 100644 --- a/account_analytic_attribution/README.rst +++ b/account_analytic_attribution/README.rst @@ -2,24 +2,30 @@ Analytic attribution ==================== -.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:bb127fa2ae85e89a77954af616c239bd36a10006ee77aa56ed35a1bd0bdda63a + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -.. |badge1| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png +.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png + :target: https://odoo-community.org/page/development-status + :alt: Production/Stable +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 -.. |badge2| image:: https://img.shields.io/badge/github-CompassionCH%2Fcompassion--accounting-lightgray.png?logo=github - :target: https://github.com/CompassionCH/compassion-accounting/tree/11.0/account_analytic_attribution - :alt: CompassionCH/compassion-accounting +.. |badge3| image:: https://img.shields.io/badge/github-CompassionCH%2Ftest--repo-lightgray.png?logo=github + :target: https://github.com/CompassionCH/test-repo/tree/14.0/account_analytic_attribution + :alt: CompassionCH/test-repo -|badge1| |badge2| +|badge1| |badge2| |badge3| This module is meant to be the successor of Odoo 8 Analytic Plans. -However, it works a bit differently. Instead of directly -dispatch analytic lines into several analytic accounts, you can setup rules -on how you want to perform the distribution, and distribution will be done +However, it works a bit differently. Instead of directly dispatch +analytic lines into several analytic accounts, you can setup rules on +how you want to perform the distribution, and distribution will be done periodically (or can be triggered manually). **Table of contents** @@ -31,32 +37,34 @@ Configuration ============= In order to use Analytic Distribution, you must first set analytic tags -on the analytic accounts for which you want to dispatch the analytic lines. -Those tags will be used to create the rules. +on the analytic accounts for which you want to dispatch the analytic +lines. Those tags will be used to create the rules. -The module comes with a CRON `Perform Analytic Distribution` that you can +The module comes with a CRON Perform Analytic Distribution that you can enable to launch the attribution automatically when you want. It will -perform the distribution for the last fiscal year (closed period). One good -idea is to setup the CRON to launch at the beginning of your fiscal year. +perform the distribution for the last fiscal year (closed period). One +good idea is to setup the CRON to launch at the beginning of your fiscal +year. Usage ===== To use this module, go to menu Invoicing/Analytic Accounting: -* Create analytic attributions: choose an analytic tag and setup the - distribution applied for this tag. You can add conditions to filter analytic - lines that will be distributed. -* The distribution is either performed with the CRON or you can launch it - manually for the current fiscal year using the menu `Launch Distribution` +- Create analytic attributions: choose an analytic tag and setup the + distribution applied for this tag. You can add conditions to filter + analytic lines that will be distributed. +- The distribution is either performed with the CRON or you can launch + it manually for the current fiscal year using the menu Launch + Distribution Bug Tracker =========== -Bugs are tracked on `GitHub Issues `_. +Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -64,26 +72,19 @@ Credits ======= Authors -~~~~~~~ +------- * Compassion CH Contributors -~~~~~~~~~~~~ +------------ -* Emanuel Cino -* Quentin Gigon +- Emanuel Cino +- Quentin Gigon Maintainers -~~~~~~~~~~~ - -This module is maintained by Compassion Switzerland. - -.. image:: https://upload.wikimedia.org/wikipedia/en/8/83/CompassionInternationalLogo.png - :alt: Compassion Switzerland - :target: https://www.compassion.ch +----------- -Compassion Switzerland is a nonprofit organization whose -mission is to release children from extreme poverty in Jesus name. +This module is part of the `CompassionCH/test-repo `_ project on GitHub. -This module is part of the `CompassionCH/compassion-accounting `_ project on GitHub. +You are welcome to contribute. diff --git a/account_analytic_attribution/__init__.py b/account_analytic_attribution/__init__.py index 08a74f2f8..6b4c5e770 100644 --- a/account_analytic_attribution/__init__.py +++ b/account_analytic_attribution/__init__.py @@ -1,12 +1,12 @@ -############################################################################## -# -# Copyright (C) 2015 Compassion CH (http://www.compassion.ch) -# Releasing children from poverty in Jesus' name -# @author: Emanuel Cino -# -# The licence is in the file __manifest__.py -# -############################################################################## - -from . import models -from . import wizards +############################################################################## +# +# Copyright (C) 2015 Compassion CH (http://www.compassion.ch) +# Releasing children from poverty in Jesus' name +# @author: Emanuel Cino +# +# The licence is in the file __manifest__.py +# +############################################################################## + +from . import models +from . import wizards diff --git a/account_analytic_attribution/__manifest__.py b/account_analytic_attribution/__manifest__.py index 3adaf85dd..b5c7e8d3e 100644 --- a/account_analytic_attribution/__manifest__.py +++ b/account_analytic_attribution/__manifest__.py @@ -27,24 +27,24 @@ ############################################################################## # pylint: disable=C8101 { - 'name': 'Analytic attribution', - 'summary': 'Set rules to dispatch analytic lines into analytic accounts', - 'version': "14.0.1.0.0", - 'license': 'AGPL-3', - 'author': 'Compassion CH', - 'website': 'https://www.compassion.ch', - 'category': 'Accounting', - 'depends': [ - 'analytic', - 'account_fiscal_month', # oca/account-financial-tools,oca/server-ux + "name": "Analytic attribution", + "summary": "Set rules to dispatch analytic lines into analytic accounts", + "version": "14.0.1.0.0", + "license": "AGPL-3", + "author": "Compassion CH", + "website": "https://github.com/CompassionCH/test-repo", + "category": "Accounting", + "depends": [ + "analytic", + "account_fiscal_month", # oca/account-financial-tools,oca/server-ux ], - 'external_dependencies': {}, - 'data': [ - 'security/ir.model.access.csv', - 'data/analytic_tag.xml', - 'views/analytic_attribution_view.xml', + "external_dependencies": {}, + "data": [ + "security/ir.model.access.csv", + "data/analytic_tag.xml", + "views/analytic_attribution_view.xml", ], - 'demo': [], - 'installable': True, - 'development_status': 'Stable' + "demo": [], + "installable": True, + "development_status": "Production/Stable", } diff --git a/account_analytic_attribution/data/analytic_tag.xml b/account_analytic_attribution/data/analytic_tag.xml index 3e04899f2..c48bb966c 100644 --- a/account_analytic_attribution/data/analytic_tag.xml +++ b/account_analytic_attribution/data/analytic_tag.xml @@ -1,4 +1,4 @@ - + -

Beta License: AGPL-3 OCA/{compassion-accounting} Translate me on Weblate

+

Production/Stable License: AGPL-3 CompassionCH/test-repo

This module is meant to be the successor of Odoo 8 Analytic Plans. -However, it works a bit differently. Instead of directly -dispatch analytic lines into several analytic accounts, you can setup rules -on how you want to perform the distribution, and distribution will be done +However, it works a bit differently. Instead of directly dispatch +analytic lines into several analytic accounts, you can setup rules on +how you want to perform the distribution, and distribution will be done periodically (or can be triggered manually).

Table of contents

-

Configuration

+

Configuration

In order to use Analytic Distribution, you must first set analytic tags -on the analytic accounts for which you want to dispatch the analytic lines. -Those tags will be used to create the rules.

-

The module comes with a CRON Perform Analytic Distribution that you can +on the analytic accounts for which you want to dispatch the analytic +lines. Those tags will be used to create the rules.

+

The module comes with a CRON Perform Analytic Distribution that you can enable to launch the attribution automatically when you want. It will -perform the distribution for the last fiscal year (closed period). One good -idea is to setup the CRON to launch at the beginning of your fiscal year.

+perform the distribution for the last fiscal year (closed period). One +good idea is to setup the CRON to launch at the beginning of your fiscal +year.

+
+
+

Usage

+

To use this module, go to menu Invoicing/Analytic Accounting:

+
    +
  • Create analytic attributions: choose an analytic tag and setup the +distribution applied for this tag. You can add conditions to filter +analytic lines that will be distributed.
  • +
  • The distribution is either performed with the CRON or you can launch +it manually for the current fiscal year using the menu Launch +Distribution
  • +
-

Bug Tracker

-

Bugs are tracked on GitHub Issues. +

Bug Tracker

+

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and welcomed -feedback.

+If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

Do not contact contributors directly about support or help with technical issues.

-

Credits

+

Credits

-

Authors

+

Authors

  • Compassion CH
-

Maintainers

-

This module is maintained by the OCA.

-Odoo Community Association -

OCA, or the Odoo Community Association, is a nonprofit organization whose -mission is to support the collaborative development of Odoo features and -promote its widespread use.

-

This module is part of the OCA/{compassion-accounting} project on GitHub.

-

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+

Maintainers

+

This module is part of the CompassionCH/test-repo project on GitHub.

+

You are welcome to contribute.

diff --git a/account_analytic_attribution/tests/__init__.py b/account_analytic_attribution/tests/__init__.py index 1fa23e7bf..8b0991c13 100644 --- a/account_analytic_attribution/tests/__init__.py +++ b/account_analytic_attribution/tests/__init__.py @@ -7,4 +7,3 @@ # The licence is in the file __manifest__.py # ############################################################################## - diff --git a/account_analytic_attribution/tests/test_analytic_attribution.py b/account_analytic_attribution/tests/test_analytic_attribution.py index bc72d7ae4..3d0f795dc 100644 --- a/account_analytic_attribution/tests/test_analytic_attribution.py +++ b/account_analytic_attribution/tests/test_analytic_attribution.py @@ -18,25 +18,26 @@ class TestAnalyticAttribution(TransactionCase): - def setUp(self): - super(TestAnalyticAttribution, self).setUp() - self.analytic_account = self.env["account.analytic.account"] \ - .create({"name": "Test Account"}) - self.account = self.env["account.account"] \ - .search([('code', '=', '1050')]) - self.tag = self.env.ref('account_analytic_attribution.tag_attribution') - self.Attribution = self.env['account.analytic.attribution'] + super().setUp() + self.analytic_account = self.env["account.analytic.account"].create( + {"name": "Test Account"} + ) + self.account = self.env["account.account"].search([("code", "=", "1050")]) + self.tag = self.env.ref("account_analytic_attribution.tag_attribution") + self.Attribution = self.env["account.analytic.attribution"] def test_perform_distribution__line_generation(self): self._create_line_with_amount_twelve(self.analytic_account) self._create_line_with_amount_twelve(self.analytic_account) attribution = self.Attribution.create({}) - self.env['account.analytic.distribution.line'].create({ - 'rate': 40, - 'account_analytic_id': self.analytic_account.id, - 'attribution_id': attribution.id - }) + self.env["account.analytic.distribution.line"].create( + { + "rate": 40, + "account_analytic_id": self.analytic_account.id, + "attribution_id": attribution.id, + } + ) self._assert_analytic_lines_count(2) line = attribution.perform_distribution() @@ -45,12 +46,11 @@ def test_perform_distribution__line_generation(self): self.assertEqual(len(line), 1) self.assertAlmostEqual(line.amount, 9.6) # 40% of (2*12) self.assertEqual(line.account_id.id, self.analytic_account.id) - self.assertTrue('Analytic attribution for' in line.name) + self.assertTrue("Analytic attribution for" in line.name) def test_perform_distribution__should_evict_old_analytic_lines(self): line = self._create_line_with_amount_twelve(self.analytic_account) - line.tag_ids += self.env \ - .ref('account_analytic_attribution.tag_attribution') + line.tag_ids += self.env.ref("account_analytic_attribution.tag_attribution") attribution = self.Attribution.create({}) self._assert_analytic_lines_count(1) @@ -59,21 +59,21 @@ def test_perform_distribution__should_evict_old_analytic_lines(self): def test_get_attribution__match_if_filters_are_not_set(self): attribution = self.Attribution.create({}) - self.env['account.analytic.distribution.line'].create({ - 'rate': 40, - 'account_analytic_id': self.analytic_account.id, - 'attribution_id': attribution.id - }) + self.env["account.analytic.distribution.line"].create( + { + "rate": 40, + "account_analytic_id": self.analytic_account.id, + "attribution_id": attribution.id, + } + ) matched = attribution.get_attribution(False, False, datetime.now()) self.assertEqual(len(matched), 1) def test_get_attribution__matching_by_date(self): - attribution = self.Attribution.create({ - 'rate': 40, - 'date_start': datetime.now(), - 'date_stop': datetime.now() - }) + attribution = self.Attribution.create( + {"rate": 40, "date_start": datetime.now(), "date_stop": datetime.now()} + ) yesterday = datetime.now() - timedelta(days=-1) rules = attribution.get_attribution(False, False, yesterday) @@ -83,9 +83,7 @@ def test_get_attribution__matching_by_date(self): self.assertEqual(len(matched), 1) def test_get_attribution__matching_by_tag(self): - attribution = self.Attribution.create({ - 'rate': 40 - }) + attribution = self.Attribution.create({"rate": 40}) attribution.analytic_tag_id += self.tag now = datetime.now() @@ -98,14 +96,16 @@ def test_get_attribution__matching_by_tag(self): def _create_line_with_amount_twelve(self, account): date = datetime.now() - relativedelta(years=1) - return self.env['account.analytic.line'].create({ - 'name': 'test line', - 'amount': 12.0, - 'account_id': account.id, - 'general_account_id': 1, - 'date': date - }) + return self.env["account.analytic.line"].create( + { + "name": "test line", + "amount": 12.0, + "account_id": account.id, + "general_account_id": 1, + "date": date, + } + ) def _assert_analytic_lines_count(self, count): - lines_after = self.env['account.analytic.line'].search([]) + lines_after = self.env["account.analytic.line"].search([]) self.assertEqual(len(lines_after), count) diff --git a/account_analytic_attribution/views/analytic_attribution_view.xml b/account_analytic_attribution/views/analytic_attribution_view.xml index ef71b3886..d75080959 100644 --- a/account_analytic_attribution/views/analytic_attribution_view.xml +++ b/account_analytic_attribution/views/analytic_attribution_view.xml @@ -1,4 +1,4 @@ - + @@ -6,11 +6,11 @@ account.analytic.attribution - - - - - + + + + + @@ -23,21 +23,24 @@
- + - + - - + + - - - - + + + +
@@ -50,21 +53,30 @@ account.analytic.attribution.wizard
-

This will trigger the analytic attribution for the selected fiscal months.

+

This will trigger the analytic attribution for the selected fiscal months.

- +
-
- + Launch Attribution account.analytic.attribution.wizard form @@ -79,14 +91,16 @@ + action="action_attribution_list" + id="menu_analytic_attribution_list" + parent="account.menu_analytic_accounting" + /> + action="action_analytic_attribution_wizard" + id="menu_analytic_attribution_wizard" + parent="account.menu_analytic_accounting" + sequence="12" + />
diff --git a/account_analytic_attribution/wizards/__init__.py b/account_analytic_attribution/wizards/__init__.py index b11fa39b9..f50a46d0e 100644 --- a/account_analytic_attribution/wizards/__init__.py +++ b/account_analytic_attribution/wizards/__init__.py @@ -1,4 +1,4 @@ -############################################################################## +############################################################################## # # Copyright (C) 2015 Compassion CH (http://www.compassion.ch) # Releasing children from poverty in Jesus' name diff --git a/account_analytic_attribution/wizards/account_analytic_attribution_wizard.py b/account_analytic_attribution/wizards/account_analytic_attribution_wizard.py index cea747873..743efb6cf 100644 --- a/account_analytic_attribution/wizards/account_analytic_attribution_wizard.py +++ b/account_analytic_attribution/wizards/account_analytic_attribution_wizard.py @@ -1,4 +1,4 @@ -############################################################################## +############################################################################## # # Copyright (C) 2014-2017 Compassion CH (http://www.compassion.ch) # Releasing children from poverty in Jesus' name @@ -8,37 +8,40 @@ # ############################################################################## -from odoo import api, models, fields, _ +from odoo import _, fields, models class AttributionWizard(models.TransientModel): """Wizard for performing attribution of analytic lines into other analytic accounts.""" - _name = 'account.analytic.attribution.wizard' - _description = 'Account Analytic Attribution Wizard' + + _name = "account.analytic.attribution.wizard" + _description = "Account Analytic Attribution Wizard" date_range_ids = fields.Many2many( - 'date.range', 'attribution_wizard_date_range_rel', - string='Date range', - domain=[('type_id.fiscal_month', '=', True)], - help='Takes the current year if none is selected.', readonly=False + "date.range", + "attribution_wizard_date_range_rel", + string="Date range", + domain=[("type_id.fiscal_month", "=", True)], + help="Takes the current year if none is selected.", + readonly=False, ) def perform_distribution(self): - """ Perform analytic attributions. """ + """Perform analytic attributions.""" self.ensure_one() - lines = self.env['account.analytic.line'] + lines = self.env["account.analytic.line"] for date_range in self.date_range_ids: - lines += self.env[ - 'account.analytic.attribution'].perform_distribution( - date_range.date_start, date_range.date_end) + lines += self.env["account.analytic.attribution"].perform_distribution( + date_range.date_start, date_range.date_end + ) return { - 'name': _('Generated Analytic Lines'), - 'view_mode': 'tree,form', - 'view_type': 'form', - 'res_model': 'account.analytic.line', - 'domain': [('id', 'in', lines.ids)], - 'context': {'group_by': ['ref']}, - 'type': 'ir.actions.act_window', + "name": _("Generated Analytic Lines"), + "view_mode": "tree,form", + "view_type": "form", + "res_model": "account.analytic.line", + "domain": [("id", "in", lines.ids)], + "context": {"group_by": ["ref"]}, + "type": "ir.actions.act_window", } diff --git a/account_analytic_compassion/README.rst b/account_analytic_compassion/README.rst index c97a71cbb..bf3c277d7 100644 --- a/account_analytic_compassion/README.rst +++ b/account_analytic_compassion/README.rst @@ -1,27 +1,27 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :alt: License: AGPL-3 - -Compassion Analytic Accounts -============================ - -This module installs the needed analytic accounts for Compassion CH. - -Installation -============ - -To install this module, you need to: - -* Install this module before 'sponsorship_compassion' in test databases. - -Credits -======= - -Contributors ------------- - -* Emanuel Cino - -Maintainer ----------- - -This module is maintained by `Compassion Switzerland `. +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License: AGPL-3 + +Compassion Analytic Accounts +============================ + +This module installs the needed analytic accounts for Compassion CH. + +Installation +============ + +To install this module, you need to: + +* Install this module before 'sponsorship_compassion' in test databases. + +Credits +======= + +Contributors +------------ + +* Emanuel Cino + +Maintainer +---------- + +This module is maintained by `Compassion Switzerland `. diff --git a/account_analytic_compassion/__init__.py b/account_analytic_compassion/__init__.py index 654e8ac28..b9d78707f 100644 --- a/account_analytic_compassion/__init__.py +++ b/account_analytic_compassion/__init__.py @@ -8,4 +8,4 @@ # ############################################################################## -from . import models \ No newline at end of file +from . import models diff --git a/account_analytic_compassion/__manifest__.py b/account_analytic_compassion/__manifest__.py index d0dec1863..9a55b219a 100644 --- a/account_analytic_compassion/__manifest__.py +++ b/account_analytic_compassion/__manifest__.py @@ -27,25 +27,25 @@ ############################################################################## # pylint: disable=C8101 { - 'name': 'Compassion Analytic Accounts', - 'version': "14.0.1.0.0", - 'category': 'Other', - 'author': 'Compassion CH', - 'license': 'AGPL-3', - 'website': 'http://www.compassion.ch', - 'depends': [ - 'account_analytic_distribution_required', - 'account_asset_management', - 'analytic', - 'account', - 'product', + "name": "Compassion Analytic Accounts", + "version": "14.0.1.0.0", + "category": "Other", + "author": "Compassion CH", + "license": "AGPL-3", + "website": "https://github.com/CompassionCH/test-repo", + "depends": [ + "account_analytic_distribution_required", + "account_asset_management", + "analytic", + "account", + "product", ], - 'data': [ - 'views/product_view.xml', - 'views/res_config_setting_view.xml', - 'views/account_asset_view.xml', + "data": [ + "views/product_view.xml", + "views/res_config_setting_view.xml", + "views/account_asset_view.xml", ], - 'demo': ['analytic_account_data.xml'], - 'installable': True, - 'auto_install': False, + "demo": ["analytic_account_data.xml"], + "installable": True, + "auto_install": False, } diff --git a/account_analytic_compassion/analytic_account_data.xml b/account_analytic_compassion/analytic_account_data.xml index 98c1aeb59..4c7ab6d16 100644 --- a/account_analytic_compassion/analytic_account_data.xml +++ b/account_analytic_compassion/analytic_account_data.xml @@ -1,56 +1,92 @@ - - - - - - Income - - - PS - - - SS - - - - DES - normal - AA102 - - - - UNDES - normal - AA110 - - - - ADV - normal - AA091 - - - - CD - normal - AA092 - - - - SDM - normal - AA108 - - - - ADM - normal - AA090 - - - - + + + + + + Income + + + PS + + + SS + + + + DES + normal + AA102 + + + + UNDES + normal + AA110 + + + + ADV + normal + AA091 + + + + CD + normal + AA092 + + + + SDM + normal + AA108 + + + + ADM + normal + AA090 + + + + diff --git a/account_analytic_compassion/models/account.py b/account_analytic_compassion/models/account.py index 07ca7af91..eefd8c74d 100644 --- a/account_analytic_compassion/models/account.py +++ b/account_analytic_compassion/models/account.py @@ -7,22 +7,21 @@ # ############################################################################## -from odoo import api, models import re +from odoo import api, models + class AccountMoveLine(models.Model): _inherit = "account.move.line" def _check_analytic_distribution_required_msg(self): - message = super(AccountMoveLine, self).\ - _check_analytic_distribution_required_msg() - pattern = r'.*mutually exclusive.*' + message = super()._check_analytic_distribution_required_msg() + pattern = r".*mutually exclusive.*" if message and not re.match(pattern, message, re.IGNORECASE): return message @api.model def _get_asset_analytic_values(self, vals, asset_vals): super()._get_asset_analytic_values(vals, asset_vals) - asset_vals['analytic_tag_ids'] = vals.get( - 'analytic_tag_ids', False) + asset_vals["analytic_tag_ids"] = vals.get("analytic_tag_ids", False) diff --git a/account_analytic_compassion/models/account_asset.py b/account_analytic_compassion/models/account_asset.py index e503d0011..7b4903680 100644 --- a/account_analytic_compassion/models/account_asset.py +++ b/account_analytic_compassion/models/account_asset.py @@ -6,30 +6,30 @@ # The licence is in the file __manifest__.py # ############################################################################## -from odoo import models, fields +from odoo import fields, models class AccountAsset(models.Model): - _inherit = 'account.asset' + _inherit = "account.asset" # Many2many field to account.analytic.tag table analytic_tag_ids = fields.Many2many( - comodel_name='account.analytic.tag', - string='Analytic Tags', + comodel_name="account.analytic.tag", + string="Analytic Tags", ) class AccountAssetLine(models.Model): - _inherit = 'account.asset.line' + _inherit = "account.asset.line" # override of parent method _setup_move_line_data # inherited from object AccountAssetLine # at account-financial-tools/account_asset_management/models/account_asset_line.py def _setup_move_line_data(self, depreciation_date, account, ml_type, move): - move_line_data = super()._setup_move_line_data(depreciation_date, - account, - ml_type, - move) - move_line_data['analytic_tag_ids'] = [ - (6, 0, self.asset_id.analytic_tag_ids.ids)] + move_line_data = super()._setup_move_line_data( + depreciation_date, account, ml_type, move + ) + move_line_data["analytic_tag_ids"] = [ + (6, 0, self.asset_id.analytic_tag_ids.ids) + ] return move_line_data diff --git a/account_analytic_compassion/models/exchange_rate_analytic_tag.py b/account_analytic_compassion/models/exchange_rate_analytic_tag.py index f87049ff5..84f7407ea 100644 --- a/account_analytic_compassion/models/exchange_rate_analytic_tag.py +++ b/account_analytic_compassion/models/exchange_rate_analytic_tag.py @@ -6,7 +6,7 @@ # The licence is in the file __manifest__.py # ############################################################################## -from odoo import models, api +from odoo import api, models class AccountPartialReconcile(models.Model): @@ -14,9 +14,14 @@ class AccountPartialReconcile(models.Model): @api.model def create_exchange_rate_entry(self, aml_to_fix, move): - exchange_analytic_tag_id = self.env['ir.config_parameter'].\ - search([('key', '=', 'account_analytic_compassion.analytic_tag_id')]).value - return super(AccountPartialReconcile, self.with_context( - default_analytic_tag_ids=[ - (6, 0, [exchange_analytic_tag_id]) - ])).create_exchange_rate_entry(aml_to_fix, move) + exchange_analytic_tag_id = ( + self.env["ir.config_parameter"] + .search([("key", "=", "account_analytic_compassion.analytic_tag_id")]) + .value + ) + return super( + AccountPartialReconcile, + self.with_context( + default_analytic_tag_ids=[(6, 0, [exchange_analytic_tag_id])] + ), + ).create_exchange_rate_entry(aml_to_fix, move) diff --git a/account_analytic_compassion/models/product.py b/account_analytic_compassion/models/product.py index 119b57244..c48e8566b 100644 --- a/account_analytic_compassion/models/product.py +++ b/account_analytic_compassion/models/product.py @@ -7,7 +7,7 @@ # The licence is in the file __manifest__.py # ############################################################################## -from odoo import models, fields +from odoo import fields, models class ProductTemplate(models.Model): diff --git a/account_analytic_compassion/models/res_config_setting.py b/account_analytic_compassion/models/res_config_setting.py index 803331ba4..d0bf1f31e 100644 --- a/account_analytic_compassion/models/res_config_setting.py +++ b/account_analytic_compassion/models/res_config_setting.py @@ -2,12 +2,14 @@ class ResConfigSettings(models.TransientModel): - _inherit = 'res.config.settings' + _inherit = "res.config.settings" - analytic_tag_id = fields.Many2one('account.analytic.tag', string='Analytic Tag', - readonly=False, help="analytic tag id to use " - "when automatic move are created." - ) + analytic_tag_id = fields.Many2one( + "account.analytic.tag", + string="Analytic Tag", + readonly=False, + help="analytic tag id to use when automatic move are created.", + ) def set_values(self): super().set_values() @@ -21,8 +23,6 @@ def get_values(self): res = super().get_values() param_obj = self.env["ir.config_parameter"].sudo() res["analytic_tag_id"] = int( - param_obj.get_param( - "account_analytic_compassion.analytic_tag_id" - ) + param_obj.get_param("account_analytic_compassion.analytic_tag_id") ) return res diff --git a/account_analytic_compassion/views/account_asset_view.xml b/account_analytic_compassion/views/account_asset_view.xml index f14c8f141..df960ec58 100644 --- a/account_analytic_compassion/views/account_asset_view.xml +++ b/account_analytic_compassion/views/account_asset_view.xml @@ -1,14 +1,17 @@ - + account.asset.view.form account.asset - + form - + @@ -16,12 +19,15 @@ account.asset.view.tree account.asset - + tree - + - \ No newline at end of file + diff --git a/account_analytic_compassion/views/product_view.xml b/account_analytic_compassion/views/product_view.xml index 871bbd44d..8732cf642 100644 --- a/account_analytic_compassion/views/product_view.xml +++ b/account_analytic_compassion/views/product_view.xml @@ -1,14 +1,14 @@ - + product.compassion.form product.template - + form - + - \ No newline at end of file + diff --git a/account_analytic_compassion/views/res_config_setting_view.xml b/account_analytic_compassion/views/res_config_setting_view.xml index c4701dff7..539ae89c8 100644 --- a/account_analytic_compassion/views/res_config_setting_view.xml +++ b/account_analytic_compassion/views/res_config_setting_view.xml @@ -1,15 +1,21 @@ - + res.config.settings.view.form.inherit.account res.config.settings - + form - +
-
diff --git a/account_ebics_CH/README.rst b/account_ebics_CH/README.rst index 4c26fab71..a9d518056 100644 --- a/account_ebics_CH/README.rst +++ b/account_ebics_CH/README.rst @@ -21,4 +21,3 @@ Usage Known issues / Roadmap ====================== - diff --git a/account_ebics_CH/__manifest__.py b/account_ebics_CH/__manifest__.py index 46220fde3..5f5098c98 100644 --- a/account_ebics_CH/__manifest__.py +++ b/account_ebics_CH/__manifest__.py @@ -5,7 +5,8 @@ "name": "add specific EBICS order type and file format for Switzerland", "version": "14.0.1.0.0", "license": "LGPL-3", - "author": "Compassion", + "author": "Compassion Switzerland", + "website": "https://github.com/CompassionCH/test-repo", "category": "Accounting & Finance", "depends": [ "account_ebics", diff --git a/account_ebics_CH/data/auto_ebics_processing_cron.xml b/account_ebics_CH/data/auto_ebics_processing_cron.xml index 31e4021cf..9b6b0cce5 100644 --- a/account_ebics_CH/data/auto_ebics_processing_cron.xml +++ b/account_ebics_CH/data/auto_ebics_processing_cron.xml @@ -1,9 +1,9 @@ - + Auto EBICS Processing - + 4 hours code diff --git a/account_ebics_CH/models/auto_ebics_processing.py b/account_ebics_CH/models/auto_ebics_processing.py index c17cd1d82..9db971cb0 100644 --- a/account_ebics_CH/models/auto_ebics_processing.py +++ b/account_ebics_CH/models/auto_ebics_processing.py @@ -1,8 +1,7 @@ -import logging -import traceback import datetime +import logging -from odoo import models, api +from odoo import api, models _logger = logging.getLogger(__name__) @@ -19,16 +18,18 @@ def process(self, n_days_ago=None): if an integer is specified retrieve the EBICS from n days ago instead of the new ones """ - _logger.info(f"Starting") + _logger.info("Starting") d = {} if n_days_ago is not None: n_days_ago = datetime.date.today() - datetime.timedelta(days=n_days_ago) d.update({"date_from": n_days_ago, "date_to": n_days_ago}) for conf in self.env["ebics.config"].search([("state", "=", "confirm")]): - d.update({ - 'ebics_config_id': conf.id, - 'ebics_userid_id': conf.ebics_userid_ids[0].id - }) + d.update( + { + "ebics_config_id": conf.id, + "ebics_userid_id": conf.ebics_userid_ids[0].id, + } + ) xfer = self.env["ebics.xfer"].create(d) try: output = xfer.ebics_download() @@ -36,7 +37,7 @@ def process(self, n_days_ago=None): output["context"]["ebics_file_ids"] ) except Exception: - _logger.error(f"Failed", traceback.format_exc()) + _logger.error("Failed", exc_info=True) return False for ebics in ebics_retrieved: @@ -47,8 +48,8 @@ def process(self, n_days_ago=None): except Exception: _logger.warning( f"EBICS file {ebics.display_name} could not be processed", - traceback.format_exc(), + exc_info=True, ) xfer.unlink() - _logger.info(f"Finished") + _logger.info("Finished") return True diff --git a/account_ebics_CH/models/ebics_config.py b/account_ebics_CH/models/ebics_config.py index 77e8b2a99..b582c4f24 100644 --- a/account_ebics_CH/models/ebics_config.py +++ b/account_ebics_CH/models/ebics_config.py @@ -1,7 +1,7 @@ # Copyright 2020 Compassion. # License LGPL-3 or later (http://www.gnu.org/licenses/lpgl). -from odoo import models, fields +from odoo import fields, models class EbicsConfig(models.Model): diff --git a/account_ebics_CH/models/ebics_file_format.py b/account_ebics_CH/models/ebics_file_format.py index 52cf3023d..2b113ee46 100644 --- a/account_ebics_CH/models/ebics_file_format.py +++ b/account_ebics_CH/models/ebics_file_format.py @@ -1,13 +1,13 @@ # Copyright 2020 Compassion. # License LGPL-3 or later (http://www.gnu.org/licenses/lpgl). -from odoo import models, fields, api +from odoo import fields, models class EbicsFileFormat(models.Model): _inherit = "ebics.file.format" - display_name = fields.Char(compute="_display_name") + display_name = fields.Char(compute="_compute_display_name") def _supported_download_order_types(self): res = super()._supported_download_order_types() @@ -15,7 +15,7 @@ def _supported_download_order_types(self): res.append("ZZQ") return res - def _display_name(self): + def _compute_display_name(self): for record in self: record.display_name = record.name + " (" + record.order_type + ")" diff --git a/account_ebics_payment_return/README.rst b/account_ebics_payment_return/README.rst index 001e35458..fcf4d10db 100644 --- a/account_ebics_payment_return/README.rst +++ b/account_ebics_payment_return/README.rst @@ -24,4 +24,3 @@ if the file tells it's accepted, the payment order will be set as successully up Known issues / Roadmap ====================== - diff --git a/account_ebics_payment_return/__manifest__.py b/account_ebics_payment_return/__manifest__.py index 9b3480f19..ed18914d4 100644 --- a/account_ebics_payment_return/__manifest__.py +++ b/account_ebics_payment_return/__manifest__.py @@ -5,13 +5,14 @@ "name": "Download Payment Order return via EBICS", "version": "14.0.1.0.0", "license": "LGPL-3", - "author": "Compassion", + "author": "Compassion Switzerland", + "website": "https://github.com/CompassionCH/test-repo", "category": "Accounting & Finance", "depends": [ "account_ebics", "account_payment_line_free", "account_payment_return_import", - "account_payment_return_import_pain_ch" # l10n-switzerland + "account_payment_return_import_pain_ch", # l10n-switzerland ], "data": [ # 'views/account_payment_order.xml', diff --git a/account_ebics_payment_return/models/account_payment_return.py b/account_ebics_payment_return/models/account_payment_return.py index 739456c9f..392c98638 100644 --- a/account_ebics_payment_return/models/account_payment_return.py +++ b/account_ebics_payment_return/models/account_payment_return.py @@ -1,11 +1,12 @@ # Copyright 2009-2019 Noviat. # License LGPL-3 or later (http://www.gnu.org/licenses/lpgl). +import base64 +import logging +import xml.etree.ElementTree as ET + from odoo import models from odoo.exceptions import UserError -import xml.etree.cElementTree as ET -import logging -import base64 _logger = logging.getLogger(__name__) @@ -121,8 +122,8 @@ def _on_error_parse_xml_and_cancel(self, err_message): if t.find("./ns:TxSts", namespaces={"ns": ns}).text == "RJCT": # search for payment line payment_line_ids = payment_order.bank_line_ids.filtered( - lambda r: r.name - == t.find( + lambda r, transaction=t: r.name + == transaction.find( "./ns:OrgnlEndToEndId", namespaces={"ns": ns} ).text )[0].payment_line_ids diff --git a/account_invoice_split_invoice/README.rst b/account_invoice_split_invoice/README.rst index 9e7c401b9..c143fab81 100644 --- a/account_invoice_split_invoice/README.rst +++ b/account_invoice_split_invoice/README.rst @@ -2,10 +2,13 @@ Split invoices ============== -.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:1095de63cbdd091d049686b4f32ad8669d08478017674068986af12478a1885b + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status @@ -13,29 +16,32 @@ Split invoices .. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 -.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcompassion--accounting-lightgray.png?logo=github - :target: https://github.com/OCA/compassion-accounting/tree/11.0/account_invoice_split_invoice - :alt: OCA/compassion-accounting -.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/compassion-accounting-11-0/compassion-accounting-11-0-account_invoice_split_invoice - :alt: Translate me on Weblate +.. |badge3| image:: https://img.shields.io/badge/github-CompassionCH%2Ftest--repo-lightgray.png?logo=github + :target: https://github.com/CompassionCH/test-repo/tree/14.0/account_invoice_split_invoice + :alt: CompassionCH/test-repo -|badge1| |badge2| |badge3| |badge4| +|badge1| |badge2| |badge3| -This module adds the ability to split an existing invoice into two different invoices. +This module adds the ability to split an existing invoice into two +different invoices. **Table of contents** .. contents:: :local: +Usage +===== + +When on an Invoice, you can split it using the action drop-menu + Bug Tracker =========== -Bugs are tracked on `GitHub Issues `_. +Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -43,30 +49,20 @@ Credits ======= Authors -~~~~~~~ +------- * Compassion CH Contributors -~~~~~~~~~~~~ +------------ -* Emanuel Cino -* Steve Ferry -* Quentin Gigon +- Emanuel Cino +- Steve Ferry +- Quentin Gigon Maintainers -~~~~~~~~~~~ - -This module is maintained by the OCA. - -.. image:: https://odoo-community.org/logo.png - :alt: Odoo Community Association - :target: https://odoo-community.org - -OCA, or the Odoo Community Association, is a nonprofit organization whose -mission is to support the collaborative development of Odoo features and -promote its widespread use. +----------- -This module is part of the `OCA/compassion-accounting `_ project on GitHub. +This module is part of the `CompassionCH/test-repo `_ project on GitHub. -You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. +You are welcome to contribute. diff --git a/account_invoice_split_invoice/__init__.py b/account_invoice_split_invoice/__init__.py index 7d3ef8c35..6c1a92fe5 100644 --- a/account_invoice_split_invoice/__init__.py +++ b/account_invoice_split_invoice/__init__.py @@ -1,11 +1,11 @@ -############################################################################## -# -# Copyright (C) 2015 Compassion CH (http://www.compassion.ch) -# Releasing children from poverty in Jesus' name -# @author: Emanuel Cino -# -# The licence is in the file __manifest__.py -# -############################################################################## - -from . import wizards +############################################################################## +# +# Copyright (C) 2015 Compassion CH (http://www.compassion.ch) +# Releasing children from poverty in Jesus' name +# @author: Emanuel Cino +# +# The licence is in the file __manifest__.py +# +############################################################################## + +from . import wizards diff --git a/account_invoice_split_invoice/__manifest__.py b/account_invoice_split_invoice/__manifest__.py index c611d47b1..0e2134390 100644 --- a/account_invoice_split_invoice/__manifest__.py +++ b/account_invoice_split_invoice/__manifest__.py @@ -27,18 +27,18 @@ ############################################################################## # pylint: disable=C8101 { - 'name': 'Split invoices', - 'summary': 'Split invoices into two separate invoices', - 'version': "14.0.1.0.1", - 'license': 'AGPL-3', - 'author': 'Compassion CH', - 'website': 'https://www.compassion.ch', - 'category': 'Accounting', - 'depends': ['account'], - 'external_dependencies': {}, - 'data': [ - 'views/account_invoice_split_wizard_view.xml', + "name": "Split invoices", + "summary": "Split invoices into two separate invoices", + "version": "14.0.1.0.1", + "license": "AGPL-3", + "author": "Compassion CH", + "website": "https://github.com/CompassionCH/test-repo", + "category": "Accounting", + "depends": ["account"], + "external_dependencies": {}, + "data": [ + "views/account_invoice_split_wizard_view.xml", ], - 'demo': [], - 'installable': True, + "demo": [], + "installable": True, } diff --git a/account_invoice_split_invoice/migrations/14.0.1.0.1/pre-migration.py b/account_invoice_split_invoice/migrations/14.0.1.0.1/pre-migration.py index 1ceb8d84a..79efb4101 100644 --- a/account_invoice_split_invoice/migrations/14.0.1.0.1/pre-migration.py +++ b/account_invoice_split_invoice/migrations/14.0.1.0.1/pre-migration.py @@ -3,7 +3,14 @@ @openupgrade.migrate() def migrate(env, version): - if openupgrade.column_exists(env.cr, 'account_invoice_line_2_splitwizard', 'account_move_line_id'): + if openupgrade.column_exists( + env.cr, "account_invoice_line_2_splitwizard", "account_move_line_id" + ): openupgrade.rename_columns( - env.cr, {'account_invoice_line_2_splitwizard': [('account_move_line_id', 'account_invoice_line_id')]} + env.cr, + { + "account_invoice_line_2_splitwizard": [ + ("account_move_line_id", "account_invoice_line_id") + ] + }, ) diff --git a/account_invoice_split_invoice/readme/CONTRIBUTORS.md b/account_invoice_split_invoice/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..020892e66 --- /dev/null +++ b/account_invoice_split_invoice/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- Emanuel Cino \<\> +- Steve Ferry \<\> +- Quentin Gigon \<\> diff --git a/account_invoice_split_invoice/readme/CONTRIBUTORS.rst b/account_invoice_split_invoice/readme/CONTRIBUTORS.rst deleted file mode 100644 index 96804f070..000000000 --- a/account_invoice_split_invoice/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1,3 +0,0 @@ -* Emanuel Cino -* Steve Ferry -* Quentin Gigon diff --git a/account_invoice_split_invoice/readme/DESCRIPTION.rst b/account_invoice_split_invoice/readme/DESCRIPTION.md similarity index 73% rename from account_invoice_split_invoice/readme/DESCRIPTION.rst rename to account_invoice_split_invoice/readme/DESCRIPTION.md index 0c1af3468..a3fca57c5 100644 --- a/account_invoice_split_invoice/readme/DESCRIPTION.rst +++ b/account_invoice_split_invoice/readme/DESCRIPTION.md @@ -1 +1,2 @@ -This module adds the ability to split an existing invoice into two different invoices. +This module adds the ability to split an existing invoice into two +different invoices. diff --git a/account_invoice_split_invoice/readme/USAGE.rst b/account_invoice_split_invoice/readme/USAGE.md similarity index 100% rename from account_invoice_split_invoice/readme/USAGE.rst rename to account_invoice_split_invoice/readme/USAGE.md diff --git a/account_invoice_split_invoice/static/description/index.html b/account_invoice_split_invoice/static/description/index.html index 1328691bf..14b9e446b 100644 --- a/account_invoice_split_invoice/static/description/index.html +++ b/account_invoice_split_invoice/static/description/index.html @@ -1,20 +1,19 @@ - - + Split invoices + + +
+

Comapssion subsidiary- Accounting

+ + +

Beta License: AGPL-3 CompassionCH/test-repo

+

Bare minimum accounts for a new compassion subsidiary company.

+

Adds security restrictions for products, product templates and partners +in multi-company mode.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • CompassionCH
  • +
+
+
+

Maintainers

+

This module is part of the CompassionCH/test-repo project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/donation_report_compassion/README.rst b/donation_report_compassion/README.rst index 21de44150..3139a2cc6 100644 --- a/donation_report_compassion/README.rst +++ b/donation_report_compassion/README.rst @@ -2,10 +2,13 @@ Compassion Donation Report ========================== -.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:75e4c0ead993a2aad46c33fe6b3ca92c2582ab1f0e846deb21a223acd5fc5466 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status @@ -13,14 +16,14 @@ Compassion Donation Report .. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 -.. |badge3| image:: https://img.shields.io/badge/github-CompassionCH%2Fcompassion--accounting-lightgray.png?logo=github - :target: https://github.com/CompassionCH/compassion-accounting/tree/11.0/donation_report_compassion - :alt: CompassionCH/compassion-accounting +.. |badge3| image:: https://img.shields.io/badge/github-CompassionCH%2Ftest--repo-lightgray.png?logo=github + :target: https://github.com/CompassionCH/test-repo/tree/14.0/donation_report_compassion + :alt: CompassionCH/test-repo -|badge1| |badge2| |badge3| +|badge1| |badge2| |badge3| -This module adds fields in account_invoice_report to group the data between the fiscal years. -It adds default filters for Compassion. +This module adds fields in account_invoice_report to group the data +between the fiscal years. It adds default filters for Compassion. **Table of contents** @@ -30,10 +33,10 @@ It adds default filters for Compassion. Bug Tracker =========== -Bugs are tracked on `GitHub Issues `_. +Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -41,27 +44,18 @@ Credits ======= Authors -~~~~~~~ +------- * Compassion CH Contributors -~~~~~~~~~~~~ +------------ -* Emanuel Cino +- Emanuel Cino Maintainers -~~~~~~~~~~~ - -This module is maintained by Compassion Switzerland. - -.. image:: https://upload.wikimedia.org/wikipedia/en/8/83/CompassionInternationalLogo.png - :alt: Compassion Switzerland - :target: https://www.compassion.ch - -Compassion Switzerland is a nonprofit organization whose -mission is to release children from extreme poverty in Jesus name. +----------- -This module is part of the `CompassionCH/compassion-accounting `_ project on GitHub. +This module is part of the `CompassionCH/test-repo `_ project on GitHub. You are welcome to contribute. diff --git a/donation_report_compassion/__init__.py b/donation_report_compassion/__init__.py index e2b543ce3..40aa90a04 100644 --- a/donation_report_compassion/__init__.py +++ b/donation_report_compassion/__init__.py @@ -1,4 +1,4 @@ -############################################################################## +############################################################################## # # Copyright (C) 2018-2020 Compassion CH (http://www.compassion.ch) # Releasing children from poverty in Jesus' name diff --git a/donation_report_compassion/__manifest__.py b/donation_report_compassion/__manifest__.py index 300dc0667..780a2a304 100644 --- a/donation_report_compassion/__manifest__.py +++ b/donation_report_compassion/__manifest__.py @@ -31,12 +31,12 @@ "version": "14.0.1.0.0", "author": "Compassion CH", "category": "Finance", - "website": "http://www.compassion.ch", + "website": "https://github.com/CompassionCH/test-repo", "depends": [ - 'account_fiscal_year', # OCA/account-financial-reporting - 'account_fiscal_month' # OCA/account-financial-reporting + "account_fiscal_year", # OCA/account-financial-reporting + "account_fiscal_month", # OCA/account-financial-reporting ], - "data": ['views/account_invoice_report_view.xml'], + "data": ["views/account_invoice_report_view.xml"], "demo": [], "test": [], "license": "AGPL-3", diff --git a/donation_report_compassion/readme/CONTRIBUTORS.md b/donation_report_compassion/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..651645fe2 --- /dev/null +++ b/donation_report_compassion/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Emanuel Cino \<\> diff --git a/donation_report_compassion/readme/CONTRIBUTORS.rst b/donation_report_compassion/readme/CONTRIBUTORS.rst deleted file mode 100644 index 6a9ca3183..000000000 --- a/donation_report_compassion/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1 +0,0 @@ -* Emanuel Cino diff --git a/donation_report_compassion/readme/DESCRIPTION.md b/donation_report_compassion/readme/DESCRIPTION.md new file mode 100644 index 000000000..afd376862 --- /dev/null +++ b/donation_report_compassion/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module adds fields in account_invoice_report to group the data +between the fiscal years. It adds default filters for Compassion. diff --git a/donation_report_compassion/readme/DESCRIPTION.rst b/donation_report_compassion/readme/DESCRIPTION.rst deleted file mode 100644 index b8a8321ed..000000000 --- a/donation_report_compassion/readme/DESCRIPTION.rst +++ /dev/null @@ -1,2 +0,0 @@ -This module adds fields in account_invoice_report to group the data between the fiscal years. -It adds default filters for Compassion. diff --git a/donation_report_compassion/reports/__init__.py b/donation_report_compassion/reports/__init__.py index 986e1c551..7ba45095a 100644 --- a/donation_report_compassion/reports/__init__.py +++ b/donation_report_compassion/reports/__init__.py @@ -1,4 +1,4 @@ -############################################################################## +############################################################################## # # Copyright (C) 2018-2020 Compassion CH (http://www.compassion.ch) # Releasing children from poverty in Jesus' name diff --git a/donation_report_compassion/reports/account_invoice_report.py b/donation_report_compassion/reports/account_invoice_report.py index 39f4f0815..60e7ca106 100644 --- a/donation_report_compassion/reports/account_invoice_report.py +++ b/donation_report_compassion/reports/account_invoice_report.py @@ -11,5 +11,5 @@ def _select(self): July is the first month and June is the twelve month """ select_str = super()._select() - select_str += ', ' + self._select_fiscal_year('move.invoice_date') + select_str += ", " + self._select_fiscal_year("move.invoice_date") return select_str diff --git a/donation_report_compassion/reports/fiscal_year_report.py b/donation_report_compassion/reports/fiscal_year_report.py index dba6f1e76..0cafe0170 100644 --- a/donation_report_compassion/reports/fiscal_year_report.py +++ b/donation_report_compassion/reports/fiscal_year_report.py @@ -1,20 +1,22 @@ -from odoo import models, fields +from odoo import fields, models class AccountInvoiceReport(models.AbstractModel): """ Abstract class used in reports to add fiscal year analysis on a date field """ + _name = "fiscal.year.report" _description = "Fiscal Year Report" fiscal_month_number = fields.Integer(readonly=True) valid_month = fields.Boolean( - help='Is the fiscal month already passed in current fiscal year?', - readonly=True + help="Is the fiscal month already passed in current fiscal year?", readonly=True ) fiscal_year = fields.Char(readonly=True) - contract_id = fields.Many2one('recurring.contract', string='contract', readonly=True) + contract_id = fields.Many2one( + "recurring.contract", string="contract", readonly=True + ) def _select_fiscal_year(self, date_field): """ @@ -56,5 +58,5 @@ def _select_fiscal_year(self, date_field): EXTRACT(year FROM {date_field})::varchar END AS fiscal_year, - line.contract_id + line.contract_id """ diff --git a/donation_report_compassion/static/description/index.html b/donation_report_compassion/static/description/index.html index aaed7b008..60ccd25eb 100644 --- a/donation_report_compassion/static/description/index.html +++ b/donation_report_compassion/static/description/index.html @@ -1,20 +1,19 @@ - - + Compassion Donation Report + + +
+

Restrictions on invoices

+ + +

Production/Stable License: AGPL-3 CompassionCH/test-repo

+

Technical module to handle some restrictions we want on the invoices +such as : * Restrict modification of an invoice if it’s associated to a +payment order

+

Table of contents

+ +
+

Usage

+

This module is adding some hidden functionalities so it can’t be used by +itself. It impacts the behaviour of the payment orders.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Compassion Switzerland
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is part of the CompassionCH/test-repo project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/oca_dependencies.txt b/oca_dependencies.txt index 1750ef17b..e04b3888b 100644 --- a/oca_dependencies.txt +++ b/oca_dependencies.txt @@ -14,6 +14,7 @@ # To provide both the URL and a branch, use: # sale-workflow https://github.com/OCA/sale-workflow branchname account-analytic +account_ebics https://github.com/Noviat/account_ebics.git 14.0 account-financial-tools bank-payment queue diff --git a/recurring_contract/README.rst b/recurring_contract/README.rst index c3f296962..f80586e44 100644 --- a/recurring_contract/README.rst +++ b/recurring_contract/README.rst @@ -2,22 +2,29 @@ Recurring contract ================== -.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:a26bde9147e1bb5f2055b3bd06da9438a1b8c4fbc54582735b56c247532f175e + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -.. |badge1| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png +.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png + :target: https://odoo-community.org/page/development-status + :alt: Production/Stable +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 -.. |badge2| image:: https://img.shields.io/badge/github-CompassionCH%2Fcompassion--accounting-lightgray.png?logo=github - :target: https://github.com/CompassionCH/compassion-accounting/tree/11.0/recurring_contract - :alt: CompassionCH/compassion-accounting +.. |badge3| image:: https://img.shields.io/badge/github-CompassionCH%2Ftest--repo-lightgray.png?logo=github + :target: https://github.com/CompassionCH/test-repo/tree/14.0/recurring_contract + :alt: CompassionCH/test-repo -|badge1| |badge2| +|badge1| |badge2| |badge3| Recurring contracts are made to handle recurring invoice generation. -Each contract is part of a contract group. This way, only one invoice is generated for each group. +Each contract is part of a contract group. This way, only one invoice is +generated for each group. **Table of contents** @@ -29,15 +36,15 @@ Usage To use this module, you need to: -#. Go to Invoicing -> Contracts +1. Go to Invoicing -> Contracts Bug Tracker =========== -Bugs are tracked on `GitHub Issues `_. +Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -45,28 +52,21 @@ Credits ======= Authors -~~~~~~~ +------- * Compassion CH Contributors -~~~~~~~~~~~~ +------------ -* Cyril Sester -* Emanuel Cino -* David Coninckx -* Steve Ferry +- Cyril Sester +- Emanuel Cino +- David Coninckx +- Steve Ferry Maintainers -~~~~~~~~~~~ - -This module is maintained by Compassion Switzerland. - -.. image:: https://upload.wikimedia.org/wikipedia/en/8/83/CompassionInternationalLogo.png - :alt: Compassion Switzerland - :target: https://www.compassion.ch +----------- -Compassion Switzerland is a nonprofit organization whose -mission is to release children from extreme poverty in Jesus name. +This module is part of the `CompassionCH/test-repo `_ project on GitHub. -This module is part of the `CompassionCH/compassion-accounting `_ project on GitHub. +You are welcome to contribute. diff --git a/recurring_contract/__manifest__.py b/recurring_contract/__manifest__.py index 1fd64a8d1..d6c02c1ec 100644 --- a/recurring_contract/__manifest__.py +++ b/recurring_contract/__manifest__.py @@ -27,40 +27,40 @@ ############################################################################## # pylint: disable=C8101 { - 'name': 'Recurring contract', - 'summary': 'Contract for recurring invoicing', - 'version': "14.0.1.0.5", - 'license': 'AGPL-3', - 'author': 'Compassion CH', - 'development_status': 'Production/Stable', - 'website': 'https://www.compassion.ch', - 'category': 'Accounting', - 'depends': [ - 'account_invoice_pricelist', # OCA/account-invoicing - 'account_payment_order', - 'base_automation', - 'account_payment_partner', # OCA/bank-payment, - 'queue_job', # OCA/queue, - 'utm' + "name": "Recurring contract", + "summary": "Contract for recurring invoicing", + "version": "14.0.1.0.5", + "license": "AGPL-3", + "author": "Compassion CH", + "development_status": "Production/Stable", + "website": "https://github.com/CompassionCH/test-repo", + "category": "Accounting", + "depends": [ + "account_invoice_pricelist", # OCA/account-invoicing + "account_payment_order", + "base_automation", + "account_payment_partner", # OCA/bank-payment, + "queue_job", # OCA/queue, + "utm", ], - 'external_dependencies': {}, - 'data': [ - 'views/end_contract_wizard_view.xml', - 'views/activate_contract_view.xml', - 'views/contract_group_view.xml', - 'views/recurring_contract_view.xml', - 'views/recurring_invoicer_view.xml', - 'views/recurring_invoicer_wizard_view.xml', - 'views/res_config_settings_view.xml', - 'views/utm_medium_view.xml', - 'data/balance_product_for_migr.xml', - 'data/recurring_contract_sequence.xml', - 'data/contract_expire_cron.xml', - 'data/pricelist_item_base_automation.xml', - 'data/daily_invoicer_cron.xml', - 'data/utm_data.xml', - 'data/queue_job.xml', - 'security/ir.model.access.csv', + "external_dependencies": {}, + "data": [ + "views/end_contract_wizard_view.xml", + "views/activate_contract_view.xml", + "views/contract_group_view.xml", + "views/recurring_contract_view.xml", + "views/recurring_invoicer_view.xml", + "views/recurring_invoicer_wizard_view.xml", + "views/res_config_settings_view.xml", + "views/utm_medium_view.xml", + "data/balance_product_for_migr.xml", + "data/recurring_contract_sequence.xml", + "data/contract_expire_cron.xml", + "data/pricelist_item_base_automation.xml", + "data/daily_invoicer_cron.xml", + "data/utm_data.xml", + "data/queue_job.xml", + "security/ir.model.access.csv", ], - 'installable': True, + "installable": True, } diff --git a/recurring_contract/data/balance_product_for_migr.xml b/recurring_contract/data/balance_product_for_migr.xml index caa0941de..daa3e3da1 100644 --- a/recurring_contract/data/balance_product_for_migr.xml +++ b/recurring_contract/data/balance_product_for_migr.xml @@ -1,4 +1,4 @@ - + - - + -1 + + model.generate_from_cron()
diff --git a/recurring_contract/data/pricelist_item_base_automation.xml b/recurring_contract/data/pricelist_item_base_automation.xml index 700a1d128..4ff183463 100644 --- a/recurring_contract/data/pricelist_item_base_automation.xml +++ b/recurring_contract/data/pricelist_item_base_automation.xml @@ -1,4 +1,4 @@ - + - Contract line update on pricelist item end date - - + Contract line update on pricelist item end date + + on_time - + 0 minutes code records.update_cl_amount() - \ No newline at end of file +
diff --git a/recurring_contract/data/queue_job.xml b/recurring_contract/data/queue_job.xml index b9f508046..795eb821d 100644 --- a/recurring_contract/data/queue_job.xml +++ b/recurring_contract/data/queue_job.xml @@ -2,13 +2,13 @@ recurring_contract - + - + _generate_invoices - + -
\ No newline at end of file + diff --git a/recurring_contract/data/recurring_contract_sequence.xml b/recurring_contract/data/recurring_contract_sequence.xml index b1eb82da3..18a17cf70 100644 --- a/recurring_contract/data/recurring_contract_sequence.xml +++ b/recurring_contract/data/recurring_contract_sequence.xml @@ -1,4 +1,4 @@ - + +

Production/Stable License: AGPL-3 CompassionCH/test-repo

+

Recurring contracts are made to handle recurring invoice generation. +Each contract is part of a contract group. This way, only one invoice is +generated for each group.

+

Table of contents

+ +
+

Usage

+

To use this module, you need to:

+
    +
  1. Go to Invoicing -> Contracts
  2. +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Compassion CH
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is part of the CompassionCH/test-repo project on GitHub.

+

You are welcome to contribute.

+
+
+ + + diff --git a/recurring_contract/tests/__init__.py b/recurring_contract/tests/__init__.py index e5a40e7bd..57a84c938 100644 --- a/recurring_contract/tests/__init__.py +++ b/recurring_contract/tests/__init__.py @@ -1,2 +1,2 @@ from . import test_account_move -from . import test_recurring_contract \ No newline at end of file +from . import test_recurring_contract diff --git a/recurring_contract/tests/test_account_move.py b/recurring_contract/tests/test_account_move.py index 13b54b878..dfed5c73e 100644 --- a/recurring_contract/tests/test_account_move.py +++ b/recurring_contract/tests/test_account_move.py @@ -1,20 +1,35 @@ from odoo import fields from odoo.tests import tagged + from odoo.addons.account.tests.common import AccountTestInvoicingCommon -@tagged('post_install', '-at_install', 'only_this') +@tagged("post_install", "-at_install", "only_this") class AccountInvoiceTestCase(AccountTestInvoicingCommon): """Unit tests of the methods implemented on the object account move""" + def setUp(self): - super(AccountInvoiceTestCase, self).setUp() - self.invoice_model = self.env['account.move'] - self.invoice = self.invoice_model.create({ - 'partner_id': self.partner_a.id, - 'name': 'Invoice 1', - 'move_type': 'out_invoice', - 'invoice_line_ids': [(0, 0, {'product_id': self.product_a.id, 'quantity': 1, 'price_unit': 10.0})] - }) + super().setUp() + self.invoice_model = self.env["account.move"] + self.invoice_name = "Invoice 1" + self.invoice = self.invoice_model.create( + { + "partner_id": self.partner_a.id, + "name": self.invoice_name, + "move_type": "out_invoice", + "invoice_line_ids": [ + ( + 0, + 0, + { + "product_id": self.product_a.id, + "quantity": 1, + "price_unit": 10.0, + }, + ) + ], + } + ) def test_update_invoices(self): """ @@ -23,7 +38,9 @@ def test_update_invoices(self): """ updt_val = { self.invoice.name: { - 'invoice_line_ids': [(1, self.invoice.invoice_line_ids[0].id, {'price_unit': 20.0})] + "invoice_line_ids": [ + (1, self.invoice.invoice_line_ids[0].id, {"price_unit": 20.0}) + ] } } self.invoice.update_open_invoices(updt_val) @@ -32,44 +49,59 @@ def test_update_invoices(self): def test_update_invoices_cancel_invoice(self): """ Test updating the invoice with a new price and check if it's canceled - Asserts that the total amount is correct after the update and that the invoice state is 'cancel' + Asserts that the total amount is correct after the update and that + the invoice state is 'cancel' """ updt_val = { self.invoice.name: { - 'invoice_line_ids': [(1, self.invoice.invoice_line_ids[0].id, {'price_unit': 0.0})] + "invoice_line_ids": [ + (1, self.invoice.invoice_line_ids[0].id, {"price_unit": 0.0}) + ] } } self.invoice.update_open_invoices(updt_val) - self.assertEqual(self.invoice.state, 'cancel') + self.assertEqual(self.invoice.state, "cancel") def test_update_invoices_post_invoice(self): """ Test updating the invoice with a new price and check if it's posted - Asserts that the total amount is correct after the update and that the invoice state is 'posted' + Asserts that the total amount is correct after the update and + that the invoice state is 'posted' """ updt_val = { self.invoice.name: { - 'invoice_line_ids': [(1, self.invoice.invoice_line_ids[0].id, {'price_unit': 100.0})] + "invoice_line_ids": [ + (1, self.invoice.invoice_line_ids[0].id, {"price_unit": 100.0}) + ] } } self.invoice.update_open_invoices(updt_val) self.assertEqual(self.invoice.amount_total, 100.0) - self.assertEqual(self.invoice.state, 'posted') + self.assertEqual(self.invoice.state, "posted") def test_build_invoice_data(self): """ - Test building the invoice data dictionary - Asserts that the returned dictionary contains the correct invoice data - """ + Test building the invoice data dictionary + Asserts that the returned dictionary contains the correct invoice data + """ invoice_date = fields.Date.today() ref = "12345" pay_mode_id = self.payment_mode.id - payment_term_id = self.env['account.payment.term'].search([], limit=1).id - partner_id = self.env['res.partner'].search([], limit=1).id - result = self.invoice._build_invoices_data(invoice_date=invoice_date, ref=ref, pay_mode_id=pay_mode_id, - payment_term_id=payment_term_id, partner_id=partner_id) - self.assertEqual(result.get('Invoice 1').get('date'), invoice_date) - self.assertEqual(result.get('Invoice 1').get('payment_reference'), ref) - self.assertEqual(result.get('Invoice 1').get('payment_mode_id'), pay_mode_id) - self.assertEqual(result.get('Invoice 1').get('invoice_payment_term_id'), payment_term_id) - self.assertEqual(result.get('Invoice 1').get('partner_id'), partner_id) + payment_term_id = self.env["account.payment.term"].search([], limit=1).id + partner_id = self.env["res.partner"].search([], limit=1).id + result = self.invoice._build_invoices_data( + invoice_date=invoice_date, + ref=ref, + pay_mode_id=pay_mode_id, + payment_term_id=payment_term_id, + partner_id=partner_id, + ) + self.assertEqual(result.get(self.invoice_name).get("date"), invoice_date) + self.assertEqual(result.get(self.invoice_name).get("payment_reference"), ref) + self.assertEqual(result.get(self.invoice_name).get("payment_mode_id"), + pay_mode_id) + self.assertEqual( + result.get(self.invoice_name).get("invoice_payment_term_id"), + payment_term_id + ) + self.assertEqual(result.get(self.invoice_name).get("partner_id"), partner_id) diff --git a/recurring_contract/tests/test_recurring_contract.py b/recurring_contract/tests/test_recurring_contract.py index 8dc4a4993..dfd3f6ba1 100644 --- a/recurring_contract/tests/test_recurring_contract.py +++ b/recurring_contract/tests/test_recurring_contract.py @@ -7,13 +7,15 @@ # The licence is in the file __manifest__.py # ############################################################################## -from dateutil.relativedelta import relativedelta -from dateutil.utils import today -from odoo.tests.common import TransactionCase import logging import random import string +from dateutil.relativedelta import relativedelta +from dateutil.utils import today + +from odoo.tests.common import TransactionCase + logger = logging.getLogger(__name__) @@ -28,38 +30,45 @@ class BaseContractTest(TransactionCase): def setUp(self): super().setUp() - self.env['ir.config_parameter'].set_param(f'recurring_contract.do_generate_curr_month_{self.env.company.id}', 'False') - self.env['ir.config_parameter'].set_param(f'recurring_contract.inv_block_day_{self.env.company.id}', 31) - self.partner_1 = self.env.ref('base.res_partner_address_1') - self.partner_2 = self.env.ref('base.res_partner_address_2') - self.partner_3 = self.env.ref('base.res_partner_address_3') - self.RecurringContractGroup = self.env['recurring.contract.group'].with_context( - async_mode=False) - self.RecurringContract = self.env['recurring.contract'].with_context( - async_mode=False) - self.payment_mode = self.env.ref('account_payment_mode.payment_mode_inbound_ct2') - self.product = self.env.ref('product.product_product_1') - self.product_2 = self.env.ref('product.product_product_2') + self.env["ir.config_parameter"].set_param( + f"recurring_contract.do_generate_curr_month_{self.env.company.id}", "False" + ) + self.env["ir.config_parameter"].set_param( + f"recurring_contract.inv_block_day_{self.env.company.id}", 31 + ) + self.partner_1 = self.env.ref("base.res_partner_address_1") + self.partner_2 = self.env.ref("base.res_partner_address_2") + self.partner_3 = self.env.ref("base.res_partner_address_3") + self.RecurringContractGroup = self.env["recurring.contract.group"].with_context( + async_mode=False + ) + self.RecurringContract = self.env["recurring.contract"].with_context( + async_mode=False + ) + self.payment_mode = self.env.ref( + "account_payment_mode.payment_mode_inbound_ct2" + ) + self.product = self.env.ref("product.product_product_1") + self.product_2 = self.env.ref("product.product_product_2") # Creation of a group and a contracts with one line - self.group = self.create_group({'partner_id': self.partner_1.id}) + self.group = self.create_group({"partner_id": self.partner_1.id}) self.contract = self.create_contract( { - 'partner_id': self.partner_1.id, - 'group_id': self.group.id, + "partner_id": self.partner_1.id, + "group_id": self.group.id, }, - [{'amount': 40.0, 'product_id': self.product.id}] + [{"amount": 40.0, "product_id": self.product.id}], ) def ref(self, length): - return ''.join(random.choice(string.ascii_lowercase) - for i in range(length)) + return "".join(random.choice(string.ascii_lowercase) for _ in range(length)) def create_group(self, vals): base_vals = { - 'advance_billing_months': 1, - 'payment_mode_id': self.payment_mode.id, - 'recurring_value': 1, - 'recurring_unit': 'month', + "advance_billing_months": 1, + "payment_mode_id": self.payment_mode.id, + "recurring_value": 1, + "recurring_unit": "month", } base_vals.update(vals) return self.RecurringContractGroup.create(base_vals) @@ -67,31 +76,35 @@ def create_group(self, vals): def create_contract(self, vals, line_vals): name = self.ref(10) base_vals = { - 'reference': name, - 'state': 'draft', - 'pricelist_id': self.env['product.pricelist'].create({ - "name": "global pricelist", - "company_id": self.env.ref("base.main_company").id, - "item_ids": [ - ( - 0, - 0, - { - "product_tmpl_id": False, - "base": "list_price", - "fixed_price": 10, - "applied_on": "3_global", - }, - ) - ], - }).id, - 'contract_line_ids': [(0, 0, l) for l in line_vals] + "reference": name, + "state": "draft", + "pricelist_id": self.env["product.pricelist"] + .create( + { + "name": "global pricelist", + "company_id": self.env.ref("base.main_company").id, + "item_ids": [ + ( + 0, + 0, + { + "product_tmpl_id": False, + "base": "list_price", + "fixed_price": 10, + "applied_on": "3_global", + }, + ) + ], + } + ) + .id, + "contract_line_ids": [(0, 0, line) for line in line_vals], } - for line in base_vals['contract_line_ids']: - if 'product_id' not in line[2]: - line[2]['product_id'] = self.product.id - if 'quantity' not in line[2]: - line[2]['quantity'] = 1.0 + for line in base_vals["contract_line_ids"]: + if "product_id" not in line[2]: + line[2]["product_id"] = self.product.id + if "quantity" not in line[2]: + line[2]["quantity"] = 1.0 base_vals.update(vals) return self.RecurringContract.create(base_vals) @@ -104,11 +117,11 @@ def _pay_invoice(self, invoice): bank_journal = self.env["account.journal"].search( [("code", "=", "BNK1")], limit=1 ) - # Generate payment with the wizard (the context simulate what's done in the web interface) - self.env["account.payment.register"].with_context({ - "active_ids": invoice.ids, - "active_model": invoice._name - }).create( + # Generate payment with the wizard + # (the context simulate what's done in the web interface) + self.env["account.payment.register"].with_context( + {"active_ids": invoice.ids, "active_model": invoice._name} + ).create( { "journal_id": bank_journal.id, "amount": invoice.amount_total, @@ -121,33 +134,34 @@ def _pay_invoice(self, invoice): class TestRecurringContract(BaseContractTest): """ - Test Project recurring contract. + Test Project recurring contract. """ def test_contract_basic_workflow(self): """ - Test the basic workflow of a contract. - Created in draft -> Waiting with invoices generated -> active by paying the invoices - -> terminated + Test the basic workflow of a contract. + Created in draft -> Waiting with invoices generated -> + active by paying the invoices -> terminated """ contract = self.contract # We validate the contract # When the contract is in waiting state it should generate invoices contract.contract_waiting() - self.assertEqual(contract.state, 'waiting') + self.assertEqual(contract.state, "waiting") invoices = contract.invoice_line_ids.mapped("move_id") - # Ensure the good number of moves are generated 2 (for current month and next month) + # Ensure the good number of moves are generated 2 + # (for current month and next month) self.assertEqual(len(invoices), 1) # Ensure once the invoice has been paid the contract is active self._pay_invoices(invoices) - self.assertEqual(contract.state, 'active') - # We end a contract it should put it in state terminated if it has been activated + self.assertEqual(contract.state, "active") + # We end a contract it should put it in state terminated + # if it has been activated contract.action_contract_terminate() - self.assertEqual(contract.state, 'terminated') + self.assertEqual(contract.state, "terminated") # Ensure the cancellation of all invoices invoices = contract.invoice_line_ids.mapped("move_id").filtered( - lambda m: m.state == "posted" - and m.payment_state == "not_paid" + lambda m: m.state == "posted" and m.payment_state == "not_paid" ) self.assertEqual(len(invoices), 0) @@ -157,7 +171,7 @@ def test_infinite_invoice_gen(self): self.assertEqual(len(contract.contract_line_ids), 1) contract.contract_waiting() # We try to generate thousand times the same contract - for i in range(0, 10): + for _ in range(0, 10): contract.button_generate_invoices() invoices = contract.invoice_line_ids.mapped("move_id") # Ensure that the number of invoices didn't exploded @@ -167,9 +181,11 @@ def test_invoice_suspension(self): """We test the field invoice suspension""" contract = self.contract # don't generate the two first s invoices - contract.group_id.write({ - 'invoice_suspended_until': (today() + relativedelta(months=1)).date(), - }) + contract.group_id.write( + { + "invoice_suspended_until": (today() + relativedelta(months=1)).date(), + } + ) self.assertEqual(len(contract.contract_line_ids), 1) contract.contract_waiting() contract.button_generate_invoices() @@ -179,8 +195,8 @@ def test_invoice_suspension(self): def test_generate_invoice_data_coherency(self): """ - We test the generations and coherence of the invoices generated - We also test to modfiy the contract it should update the invoice + We test the generations and coherence of the invoices generated + We also test to modfiy the contract it should update the invoice """ contract = self.contract self.assertEqual(len(contract.contract_line_ids), 1) @@ -188,79 +204,100 @@ def test_generate_invoice_data_coherency(self): # When the contract is in waiting state it should generate invoices contract.contract_waiting() invoices = contract.invoice_line_ids.mapped("move_id") - # Ensure the good number of moves are generated 2 (for current month and next month) + # Ensure the good number of moves are generated 2 + # (for current month and next month) self.assertEqual(len(invoices), 1) # Ensure that the data of the invoice are correct for invoice in invoices: - self.assertEqual(invoice.partner_id, contract.partner_id, "The partners doesn't match") + self.assertEqual( + invoice.partner_id, contract.partner_id, "The partners doesn't match" + ) self.assertEqual(invoice.payment_mode_id, contract.group_id.payment_mode_id) for invoice_line in invoice.invoice_line_ids: self.assertEqual(invoice_line.contract_id, contract) - self.assertEqual(invoice_line.product_id, contract.contract_line_ids[0].product_id) - self.assertEqual(invoice_line.quantity, contract.contract_line_ids[0].quantity) - self.assertEqual(invoice_line.price_unit, contract.contract_line_ids[0].amount) - contract.write({ - "partner_id": self.partner_2.id, - "group_id": self.create_group({"partner_id": self.partner_2.id}) - }) + self.assertEqual( + invoice_line.product_id, contract.contract_line_ids[0].product_id + ) + self.assertEqual( + invoice_line.quantity, contract.contract_line_ids[0].quantity + ) + self.assertEqual( + invoice_line.price_unit, contract.contract_line_ids[0].amount + ) + contract.write( + { + "partner_id": self.partner_2.id, + "group_id": self.create_group({"partner_id": self.partner_2.id}), + } + ) self.assertEqual(invoices.mapped("partner_id"), contract.partner_id) - contract.group_id.write({ - "advance_billing_months": 3 - }) + contract.group_id.write({"advance_billing_months": 3}) invoices = contract.invoice_line_ids.mapped("move_id") self.assertEqual(len(invoices), 3) def test_invoice_multiple_contract_one_pay_opt(self): """ - We want to test the behaviour of the generation of invoices - when we have multiple contract on one payment option - It should generate one invoice with multiple invoice line + We want to test the behaviour of the generation of invoices + when we have multiple contract on one payment option + It should generate one invoice with multiple invoice line """ contract = self.contract self.assertEqual(len(contract.contract_line_ids), 1) contract_2 = self.create_contract( { - 'partner_id': contract.partner_id.id, - 'group_id': contract.group_id.id, + "partner_id": contract.partner_id.id, + "group_id": contract.group_id.id, }, - [{'amount': 20.0, 'product_id': self.product_2.id}] + [{"amount": 20.0, "product_id": self.product_2.id}], ) contracts = contract + contract_2 # We validate the contract # When the contract is in waiting state it should generate invoices contracts.contract_waiting() invoices = contracts.mapped("invoice_line_ids.move_id") - # Ensure the good number of moves are generated 2 (for current month and next month) + # Ensure the good number of moves are generated 2 + # (for current month and next month) self.assertEqual(len(invoices), 1) # Ensure that the data of the invoice are correct contract_lines = contracts.mapped("contract_line_ids") for invoice in invoices: - self.assertEqual(invoice.partner_id, contract.partner_id, "The partners doesn't match") + self.assertEqual( + invoice.partner_id, contract.partner_id, "The partners doesn't match" + ) self.assertEqual(invoice.payment_mode_id, contract.group_id.payment_mode_id) invoice_lines = invoice.invoice_line_ids self.assertListEqual(invoice_lines.mapped("contract_id").ids, contracts.ids) - self.assertListEqual(invoice_lines.mapped("product_id").ids, contract_lines.mapped("product_id").ids) - self.assertListEqual(invoice_lines.mapped("quantity"), contract_lines.mapped("quantity")) - self.assertListEqual(invoice_lines.mapped("price_unit"), contract_lines.mapped("amount")) + self.assertListEqual( + invoice_lines.mapped("product_id").ids, + contract_lines.mapped("product_id").ids, + ) + self.assertListEqual( + invoice_lines.mapped("quantity"), contract_lines.mapped("quantity") + ) + self.assertListEqual( + invoice_lines.mapped("price_unit"), contract_lines.mapped("amount") + ) # Terminating one contract (line should be erased of the open invoice contracts[0].action_contract_terminate() - no_invoice = invoices.mapped("invoice_line_ids").filtered(lambda l: l.contract_id == contracts[0]) + no_invoice = invoices.mapped("invoice_line_ids").filtered( + lambda invl: invl.contract_id == contracts[0] + ) self.assertEqual(len(no_invoice), 0) def test_invoice_create_contract_invoice_already_paid(self): """ - We are testing that when creating a new contract on existing payment option - that has some invoices already paid. - A new invoice is generated for the contract just created. + We are testing that when creating a new contract on existing payment option + that has some invoices already paid. + A new invoice is generated for the contract just created. """ contract = self.contract self.assertEqual(len(contract.contract_line_ids), 1) contract_2 = self.create_contract( { - 'partner_id': contract.partner_id.id, - 'group_id': contract.group_id.id, + "partner_id": contract.partner_id.id, + "group_id": contract.group_id.id, }, - [{'amount': 20.0, 'product_id': self.product_2.id}] + [{"amount": 20.0, "product_id": self.product_2.id}], ) contract.contract_waiting() invoices = contract.mapped("invoice_line_ids.move_id") @@ -272,23 +309,27 @@ def test_invoice_create_contract_invoice_already_paid(self): contracts = contract + contract_2 invoices_after = contracts.mapped("invoice_line_ids.move_id") self.assertEqual(len(invoices_after), 2) - self.assertListEqual(invoices_after.mapped("amount_total"), contracts.mapped("total_amount")) + self.assertListEqual( + invoices_after.mapped("amount_total"), contracts.mapped("total_amount") + ) def test_invoice_create_contract_invoice_already_paid_do_gen_curr_month(self): """ - We are testing that when creating a new contract on existing payment option - that has some invoices already paid. - A new invoice is generated for the contract just created. + We are testing that when creating a new contract on existing payment option + that has some invoices already paid. + A new invoice is generated for the contract just created. """ - self.env['ir.config_parameter'].set_param(f'recurring_contract.do_generate_curr_month_{self.env.company.id}', 'True') + self.env["ir.config_parameter"].set_param( + f"recurring_contract.do_generate_curr_month_{self.env.company.id}", "True" + ) contract = self.contract self.assertEqual(len(contract.contract_line_ids), 1) contract_2 = self.create_contract( { - 'partner_id': contract.partner_id.id, - 'group_id': contract.group_id.id, + "partner_id": contract.partner_id.id, + "group_id": contract.group_id.id, }, - [{'amount': 20.0, 'product_id': self.product_2.id}] + [{"amount": 20.0, "product_id": self.product_2.id}], ) contract.contract_waiting() invoices = contract.mapped("invoice_line_ids.move_id") @@ -300,6 +341,6 @@ def test_invoice_create_contract_invoice_already_paid_do_gen_curr_month(self): contracts = contract + contract_2 invoices_after = contracts.mapped("invoice_line_ids.move_id") self.assertEqual(len(invoices_after), 4) - amounts = contracts.mapped("total_amount")*2 + amounts = contracts.mapped("total_amount") * 2 amounts.sort(reverse=True) self.assertEqual(invoices_after.mapped("amount_total"), amounts) diff --git a/recurring_contract/tools/__init__.py b/recurring_contract/tools/__init__.py index fda23f14c..71cf74616 100644 --- a/recurring_contract/tools/__init__.py +++ b/recurring_contract/tools/__init__.py @@ -1,4 +1,4 @@ def chunks(lst, n): """Yield successive n-sized chunks from lst.""" for i in range(0, len(lst), n): - yield lst[i:i + n] + yield lst[i : i + n] diff --git a/recurring_contract/views/activate_contract_view.xml b/recurring_contract/views/activate_contract_view.xml index 673c36f5c..91bd03b47 100644 --- a/recurring_contract/views/activate_contract_view.xml +++ b/recurring_contract/views/activate_contract_view.xml @@ -1,14 +1,20 @@ - + contract.activate.form recurring.contract.activate.wizard - +
-

This will mark the contract as Active, even if the partner has made no payment. Please be sure that you want to do this.

+

This will mark the contract as Active, even if the partner has made no payment. Please be sure that you want to do this.

-
@@ -18,7 +24,7 @@ Force activation recurring.contract.activate.wizard - + form new diff --git a/recurring_contract/views/contract_group_view.xml b/recurring_contract/views/contract_group_view.xml index b15332a4c..2471890f7 100644 --- a/recurring_contract/views/contract_group_view.xml +++ b/recurring_contract/views/contract_group_view.xml @@ -1,4 +1,4 @@ - +
-
diff --git a/recurring_contract/views/recurring_contract_view.xml b/recurring_contract/views/recurring_contract_view.xml index 62e8f6dbf..e906c34d6 100644 --- a/recurring_contract/views/recurring_contract_view.xml +++ b/recurring_contract/views/recurring_contract_view.xml @@ -1,4 +1,4 @@ - +