From 0b5b4989f0d2141d582adf24447b4d97bf05a12d Mon Sep 17 00:00:00 2001 From: Ivan Vilata-i-Balaguer Date: Tue, 28 Apr 2026 12:02:00 +0200 Subject: [PATCH 1/3] [IMP] update dotfiles Mainly to avoid `ModuleNotFoundError: No module named 'pkg_resources'` when running the `setuptools-odoo` pre-commit hook, as v3.1.8 was bitten by the removal of `pkg_resources` from recent versions of `setuptools`. This was fixed by v1.38 of `oca-addons-repo-template` by updating `setuptools-odoo` to v3.3.2. See #1421 for more more information. --- .copier-answers.yml | 3 +- .gitattributes | 1 + .github/workflows/pre-commit.yml | 2 + .github/workflows/test.yml | 9 ++++- .pre-commit-config.yaml | 10 ++++- .pylintrc | 69 ++++++++++++++++---------------- .pylintrc-mandatory | 50 +++++++++++------------ README.md | 5 ++- 8 files changed, 83 insertions(+), 66 deletions(-) create mode 100644 .gitattributes diff --git a/.copier-answers.yml b/.copier-answers.yml index b1999bfecc..b22299e189 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,7 +1,6 @@ # Do NOT update manually; changes here will be overwritten by Copier -_commit: v1.29 +_commit: v1.40 _src_path: gh:oca/oca-addons-repo-template -ci: GitHub convert_readme_fragments_to_markdown: false enable_checklog_odoo: false generate_requirements_txt: true diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..e0d56685a9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +test-requirements.txt merge=union diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index afd7524ef0..43b82fe8e7 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -17,6 +17,8 @@ jobs: - uses: actions/setup-python@v5 with: python-version: "3.11" + cache: 'pip' + cache-dependency-path: '.pre-commit-config.yaml' - name: Get python version run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV - uses: actions/cache@v4 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5d0f95283c..5ec4eb783e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,7 +42,7 @@ jobs: makepot: "true" services: postgres: - image: postgres:12.0 + image: postgres:12 env: POSTGRES_USER: odoo POSTGRES_PASSWORD: odoo @@ -63,6 +63,13 @@ jobs: run: oca_init_test_database - name: Run tests run: oca_run_tests + - name: Upload screenshots from JS tests + uses: actions/upload-artifact@v4 + if: ${{ failure() }} + with: + name: Screenshots of failed JS tests - ${{ matrix.name }}${{ join(matrix.include) }} + path: /tmp/odoo_tests/${{ env.PGDATABASE }} + if-no-files-found: ignore - uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fde4b78f99..c18a35e0e6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -38,8 +38,13 @@ repos: entry: found a en.po file language: fail files: '[a-zA-Z0-9_]*/i18n/en\.po$' + - id: obsolete dotfiles + name: obsolete dotfiles + entry: found obsolete files; remove them + files: '^(\.travis\.yml|\.t2d\.yml|CONTRIBUTING\.md)$' + language: fail - repo: https://github.com/oca/maintainer-tools - rev: d5fab7ee87fceee858a3d01048c78a548974d935 + rev: f9b919b9868143135a9c9cb03021089cabba8223 hooks: # update the NOT INSTALLABLE ADDONS section above - id: oca-update-pre-commit-excluded-addons @@ -104,6 +109,7 @@ repos: additional_dependencies: - "eslint@8.24.0" - "eslint-plugin-jsdoc@" + - "globals@" - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.3.0 hooks: @@ -140,7 +146,7 @@ repos: - --settings=. exclude: /__init__\.py$ - repo: https://github.com/acsone/setuptools-odoo - rev: 3.1.8 + rev: 3.3.2 hooks: - id: setuptools-odoo-make-default - id: setuptools-odoo-get-requirements diff --git a/.pylintrc b/.pylintrc index 554913276b..0a521c31ff 100644 --- a/.pylintrc +++ b/.pylintrc @@ -25,19 +25,25 @@ 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, + openerp-exception-warning, + redundant-modulename-xml, + relative-import, + rst-syntax-error, + wrong-tabs-instead-of-spaces, + xml-syntax-error, + assignment-from-none, + attribute-deprecated, + dangerous-default-value, + development-status-allowed, + duplicate-key, + eval-used, license-allowed, manifest-author-string, manifest-deprecated-key, @@ -48,73 +54,68 @@ enable=anomalous-backslash-in-string, method-inverse, method-required-super, method-search, - openerp-exception-warning, pointless-statement, pointless-string-statement, print-used, redundant-keyword-arg, - redundant-modulename-xml, reimported, - relative-import, return-in-init, - rst-syntax-error, sql-injection, too-few-format-args, translation-field, translation-required, unreachable, use-vim-comment, - wrong-tabs-instead-of-spaces, - xml-syntax-error, - attribute-string-redundant, character-not-valid-in-resource-link, - consider-merging-classes-inherited, - context-overridden, create-user-wo-reset-password, dangerous-filter-wo-user, dangerous-qweb-replace-wo-priority, deprecated-data-xml-node, deprecated-openerp-xml-node, duplicate-po-message-definition, - except-pass, file-not-used, + missing-newline-extrafiles, + old-api7-method-defined, + po-msgstr-variables, + po-syntax-error, + str-format-used, + unnecessary-utf8-coding-comment, + xml-attribute-translatable, + xml-deprecated-qweb-directive, + xml-deprecated-tree-attribute, + attribute-string-redundant, + consider-merging-classes-inherited, + context-overridden, + except-pass, invalid-commit, manifest-maintainers-list, - missing-newline-extrafiles, missing-readme, missing-return, odoo-addons-relative-import, - old-api7-method-defined, - po-msgstr-variables, - po-syntax-error, renamed-field-parameter, resource-not-exist, - str-format-used, test-folder-imported, translation-contains-variable, translation-positional-used, - unnecessary-utf8-coding-comment, website-manifest-key-not-valid-uri, - xml-attribute-translatable, - xml-deprecated-qweb-directive, - xml-deprecated-tree-attribute, external-request-timeout, - # messages that do not cause the lint step to fail - consider-merging-classes-inherited, + missing-manifest-dependency, + too-complex,, 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, + unnecessary-utf8-coding-comment, + # messages that do not cause the lint step to fail + consider-merging-classes-inherited, + deprecated-module, + invalid-commit, + missing-readme, + odoo-addons-relative-import, redefined-builtin, - too-complex, - unnecessary-utf8-coding-comment + manifest-external-assets [REPORTS] diff --git a/.pylintrc-mandatory b/.pylintrc-mandatory index 7a0cd4efef..098393aadb 100644 --- a/.pylintrc-mandatory +++ b/.pylintrc-mandatory @@ -17,19 +17,25 @@ 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, + openerp-exception-warning, + redundant-modulename-xml, + relative-import, + rst-syntax-error, + wrong-tabs-instead-of-spaces, + xml-syntax-error, + assignment-from-none, + attribute-deprecated, + dangerous-default-value, + development-status-allowed, + duplicate-key, + eval-used, license-allowed, manifest-author-string, manifest-deprecated-key, @@ -40,56 +46,50 @@ enable=anomalous-backslash-in-string, method-inverse, method-required-super, method-search, - openerp-exception-warning, pointless-statement, pointless-string-statement, print-used, redundant-keyword-arg, - redundant-modulename-xml, reimported, - relative-import, return-in-init, - rst-syntax-error, sql-injection, too-few-format-args, translation-field, translation-required, unreachable, use-vim-comment, - wrong-tabs-instead-of-spaces, - xml-syntax-error, - attribute-string-redundant, character-not-valid-in-resource-link, - consider-merging-classes-inherited, - context-overridden, create-user-wo-reset-password, dangerous-filter-wo-user, dangerous-qweb-replace-wo-priority, deprecated-data-xml-node, deprecated-openerp-xml-node, duplicate-po-message-definition, - except-pass, file-not-used, + missing-newline-extrafiles, + old-api7-method-defined, + po-msgstr-variables, + po-syntax-error, + str-format-used, + unnecessary-utf8-coding-comment, + xml-attribute-translatable, + xml-deprecated-qweb-directive, + xml-deprecated-tree-attribute, + attribute-string-redundant, + consider-merging-classes-inherited, + context-overridden, + except-pass, invalid-commit, manifest-maintainers-list, - missing-newline-extrafiles, missing-readme, missing-return, odoo-addons-relative-import, - old-api7-method-defined, - po-msgstr-variables, - po-syntax-error, renamed-field-parameter, resource-not-exist, - str-format-used, test-folder-imported, translation-contains-variable, translation-positional-used, - unnecessary-utf8-coding-comment, website-manifest-key-not-valid-uri, - xml-attribute-translatable, - xml-deprecated-qweb-directive, - xml-deprecated-tree-attribute, external-request-timeout [REPORTS] diff --git a/README.md b/README.md index a028d24e62..63d2fcfc4d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ +[![Support the OCA](https://odoo-community.org/readme-banner-image)](https://odoo-community.org/get-involved?utm_source=repo-readme) + +# contract [![Runboat](https://img.shields.io/badge/runboat-Try%20me-875A7B.png)](https://runboat.odoo-community.org/builds?repo=OCA/contract&target_branch=16.0) [![Pre-commit Status](https://github.com/OCA/contract/actions/workflows/pre-commit.yml/badge.svg?branch=16.0)](https://github.com/OCA/contract/actions/workflows/pre-commit.yml?query=branch%3A16.0) [![Build Status](https://github.com/OCA/contract/actions/workflows/test.yml/badge.svg?branch=16.0)](https://github.com/OCA/contract/actions/workflows/test.yml?query=branch%3A16.0) @@ -7,8 +10,6 @@ -# contract - TODO: add repo description. From b5be51c75c90eca05fc5e17b609df877265d2f1b Mon Sep 17 00:00:00 2001 From: Ivan Vilata-i-Balaguer Date: Wed, 29 Apr 2026 15:34:34 +0200 Subject: [PATCH 2/3] [FIX] contract_payment_auto: Update unit test code This includes a couple of `_do_auto_pay` tests which were missing a `test_target_state` context (added in later commits), and a `_pay_invoice` test which did not clear the invoice's residual amount. --- contract_payment_auto/tests/test_contract.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contract_payment_auto/tests/test_contract.py b/contract_payment_auto/tests/test_contract.py index 50d7b023f2..1a546a6d61 100644 --- a/contract_payment_auto/tests/test_contract.py +++ b/contract_payment_auto/tests/test_contract.py @@ -111,14 +111,14 @@ def test_do_auto_pay_invoice_ensure_one(self): def test_do_auto_pay_open_invoice(self): """It should open the invoice.""" invoice = self._create_invoice() - self.contract._do_auto_pay(invoice) + self.contract.with_context(test_target_state="done")._do_auto_pay(invoice) self.assertEqual(invoice.state, "posted") def test_do_auto_pay_sends_message(self): """It should call the send message method with the invoice.""" with mock.patch.object(contract.Contract, "_send_invoice_message") as m: invoice = self._create_invoice() - self.contract._do_auto_pay(invoice) + self.contract.with_context(test_target_state="done")._do_auto_pay(invoice) m.assert_called_once_with(invoice) def test_do_auto_pay_does_pay(self): @@ -136,8 +136,8 @@ def test_pay_invoice_not_open(self): def test_pay_invoice_no_residual(self): """It should return None if no residual on the invoice.""" - invoice = self._create_invoice() - invoice.state = "posted" + invoice = self._create_invoice(True) + invoice.amount_residual = 0.0 res = self.contract._pay_invoice(invoice) self.assertIs(res, None) From 6163e0a0aec07a3bfcdc22a791265c79a8e0b593 Mon Sep 17 00:00:00 2001 From: Ivan Vilata-i-Balaguer Date: Thu, 7 May 2026 16:38:34 +0200 Subject: [PATCH 3/3] [FIX] subscription_oca: Trust company accounts in unit test code So that they can pay refunds etc. no matter what account in arbitrarily chosen when creating an invoice from a subscription. This avoids "UserError: The company bank account linked to this invoice is not trusted, please double-check and trust it before confirming, or remove it" in `TestSubscriptionOCA.test_subscription_oca_sub8_workflow`. --- subscription_oca/tests/test_subscription_oca.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/subscription_oca/tests/test_subscription_oca.py b/subscription_oca/tests/test_subscription_oca.py index 70e5bf99d9..6710bfa66f 100644 --- a/subscription_oca/tests/test_subscription_oca.py +++ b/subscription_oca/tests/test_subscription_oca.py @@ -38,6 +38,10 @@ def setUpClass(cls): ("company_id", "=", cls.env.ref("base.main_company").id), ] )[0] + # Allow paying from no matter what company acct used for refunds etc. + cls.env.ref("base.main_company").partner_id.bank_ids.update( + {"allow_out_payment": True} + ) cls.pricelist1 = cls.env["product.pricelist"].create( { "name": "pricelist for contract test",