From 802b2e04c6a21bcbd48c9f531e6608b39a268e57 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 15 Mar 2024 09:00:08 +0100 Subject: [PATCH 1/3] [UPD] Copier update --- .copier-answers.yml | 9 +++++---- .eslintrc.yml | 1 + .github/workflows/pre-commit.yml | 13 ++++++++++++- .github/workflows/test.yml | 6 +++--- .gitignore | 1 + .pre-commit-config.yaml | 21 +++++++++++++++++++-- 6 files changed, 41 insertions(+), 10 deletions(-) diff --git a/.copier-answers.yml b/.copier-answers.yml index 8912a2766..5029ef5e2 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,8 +1,8 @@ # Do NOT update manually; changes here will be overwritten by Copier -_commit: v1.14.2 +_commit: v1.20 _src_path: gh:oca/oca-addons-repo-template ci: GitHub -dependency_installation_mode: PIP +convert_readme_fragments_to_markdown: false generate_requirements_txt: true github_check_license: true github_ci_extra_env: {} @@ -11,6 +11,7 @@ github_enable_makepot: true github_enable_stale_action: true github_enforce_dev_status_compatibility: true include_wkhtmltopdf: false +odoo_test_flavor: Both odoo_version: 15.0 org_name: Odoo Community Association (OCA) org_slug: OCA @@ -19,6 +20,6 @@ repo_description: 'TODO: add repo description.' repo_name: product-variant repo_slug: product-variant repo_website: https://github.com/OCA/product-variant -travis_apt_packages: [] -travis_apt_sources: [] +use_pyproject_toml: false +use_ruff: false diff --git a/.eslintrc.yml b/.eslintrc.yml index 9429bc688..fed88d70d 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -22,6 +22,7 @@ globals: 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 diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 64a21c3ef..745e3bbde 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -13,8 +13,10 @@ jobs: pre-commit: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v2 + - 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 @@ -25,6 +27,15 @@ jobs: 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)" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7fc809fb4..5c07e37d0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest name: Detect unreleased dependencies steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - run: | for reqfile in requirements.txt test-requirements.txt ; do if [ -f ${reqfile} ] ; then @@ -36,10 +36,10 @@ jobs: matrix: include: - container: ghcr.io/oca/oca-ci/py3.8-odoo15.0:latest - makepot: "true" name: test with Odoo - container: ghcr.io/oca/oca-ci/py3.8-ocb15.0:latest name: test with OCB + makepot: "true" services: postgres: image: postgres:9.6 @@ -50,7 +50,7 @@ jobs: ports: - 5432:5432 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: persist-credentials: false - name: Install addons and dependencies diff --git a/.gitignore b/.gitignore index 9c283fd41..0090721f5 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ __pycache__/ *.py[cod] /.venv /.pytest_cache +/.ruff_cache # C extensions *.so diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 705e18834..c2b27d3e0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,6 +12,10 @@ exclude: | /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: @@ -33,12 +37,25 @@ repos: language: fail files: '[a-zA-Z0-9_]*/i18n/en\.po$' - repo: https://github.com/oca/maintainer-tools - rev: dfba427ba03900b69e0a7f2c65890dc48921d36a + 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/OCA/product-variant"] + - id: oca-gen-addon-readme + args: + - --addons-dir=. + - --branch=15.0 + - --org-name=OCA + - --repo-name=product-variant + - --if-source-changed + - --keep-source-digest + - 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/myint/autoflake rev: v1.4 hooks: @@ -125,7 +142,7 @@ repos: name: flake8 additional_dependencies: ["flake8-bugbear==21.9.2"] - repo: https://github.com/OCA/pylint-odoo - rev: 7.0.2 + rev: 7.0.5 hooks: - id: pylint_odoo name: pylint with optional checks From ed1c0e29135d2b54f201d70baf490c0c4c0c946c Mon Sep 17 00:00:00 2001 From: David Date: Tue, 12 Mar 2024 16:28:49 +0100 Subject: [PATCH 2/3] [FIX] product_variant_default_code: recurrent prefix With a non automatic reference mask that has a code prefix, when that reference mask is recomputed, we could be repeating the prefix without noticing it. For instance, when we change an product.attribute name and that triggers all the default codes recomputations. In a product template with variants (i.e.: Conference Chair) - You'll have a reference mask ([Legs]) - Add a prefix: cc --> The prefix is duplicated in the reference mask: cccc[Legs] - Now you can delete de prefix manually from the mask and the resulting mask will be right: cc[Legs] - Now change the name of the attribute Legs to something else. --> The mask computation is retriggered and we get a duplicated prefix again cccc[Legs]. An extra issue would be that the mask isn't recomputed with the new attribute name, although that would need some extra work. TT48322 --- .../models/product.py | 8 ++++- .../tests/test_variant_default_code.py | 30 +++++++++++-------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/product_variant_default_code/models/product.py b/product_variant_default_code/models/product.py index c0b649959..76b3abab8 100644 --- a/product_variant_default_code/models/product.py +++ b/product_variant_default_code/models/product.py @@ -124,7 +124,13 @@ def _compute_reference_mask(self): if automask or not rec.reference_mask: rec.reference_mask = rec._get_default_mask() elif not automask and rec.code_prefix: - rec.reference_mask = rec.code_prefix + rec.reference_mask + reference_mask = rec.reference_mask + # Avoid prefixing the mask twice (or more). + # TODO: This needs a better design with a third field that sums both + # or using the sum of them in the variant default code computation + if reference_mask.startswith(rec.code_prefix): + reference_mask = reference_mask.lstrip(rec.code_prefix) + rec.reference_mask = rec.code_prefix + reference_mask def _inverse_reference_mask(self): self._compute_reference_mask() diff --git a/product_variant_default_code/tests/test_variant_default_code.py b/product_variant_default_code/tests/test_variant_default_code.py index 1c6b451ba..9df6791a3 100644 --- a/product_variant_default_code/tests/test_variant_default_code.py +++ b/product_variant_default_code/tests/test_variant_default_code.py @@ -368,17 +368,21 @@ def test_18_both_prefix_and_mask_changing(self): "reference_mask": "fix-[TColor]/[TSize]", } ) - for product in self.template1.mapped("product_variant_ids"): - expected_code = ( - self.template1.code_prefix - + "fix-" - + product.product_template_attribute_value_ids.filtered( - lambda x: x.product_attribute_value_id.attribute_id == self.attr2 - ).name[0:2] - + "/" - + product.product_template_attribute_value_ids.filtered( - lambda x: x.product_attribute_value_id.attribute_id == self.attr1 - ).name[0:2] - ) - self.assertEqual(product.default_code, expected_code) + attr1 = product.product_template_attribute_value_ids.filtered( + lambda x: x.product_attribute_value_id.attribute_id == self.attr2 + ).name[0:2] + attr2 = product.product_template_attribute_value_ids.filtered( + lambda x: x.product_attribute_value_id.attribute_id == self.attr1 + ).name[0:2] + self.assertEqual(product.default_code, f"pre/fix-{attr1}/{attr2}") + # The reference_mask stays the same even if recomputed + self.template1._compute_reference_mask() + for product in self.template1.mapped("product_variant_ids"): + attr1 = product.product_template_attribute_value_ids.filtered( + lambda x: x.product_attribute_value_id.attribute_id == self.attr2 + ).name[0:2] + attr2 = product.product_template_attribute_value_ids.filtered( + lambda x: x.product_attribute_value_id.attribute_id == self.attr1 + ).name[0:2] + self.assertEqual(product.default_code, f"pre/fix-{attr1}/{attr2}") From b632eb2ced0e788ad01f546c9043ec7c32d537df Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Fri, 15 Mar 2024 15:18:11 +0000 Subject: [PATCH 3/3] [BOT] post-merge updates --- README.md | 2 +- product_variant_default_code/README.rst | 2 +- product_variant_default_code/__manifest__.py | 2 +- product_variant_default_code/static/description/index.html | 3 +-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index dd53867d2..209ac2d3a 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ addon | version | maintainers | summary --- | --- | --- | --- [product_variant_configurator](product_variant_configurator/) | 15.0.1.0.0 | | Provides an abstract model for product variant configuration. [product_variant_configurator_manual_creation](product_variant_configurator_manual_creation/) | 15.0.1.0.0 | [![ChrisOForgeFlow](https://github.com/ChrisOForgeFlow.png?size=30px)](https://github.com/ChrisOForgeFlow) | Provides a wizards to make variants on demand -[product_variant_default_code](product_variant_default_code/) | 15.0.1.0.0 | [![Kev-Roche](https://github.com/Kev-Roche.png?size=30px)](https://github.com/Kev-Roche) | Product Variant Default Code +[product_variant_default_code](product_variant_default_code/) | 15.0.1.0.1 | [![Kev-Roche](https://github.com/Kev-Roche.png?size=30px)](https://github.com/Kev-Roche) | Product Variant Default Code [product_variant_sale_price](product_variant_sale_price/) | 15.0.1.0.0 | | Allows to write fixed prices in product variants [sale_order_line_variant_description](sale_order_line_variant_description/) | 15.0.2.0.0 | | Sale order line variant description diff --git a/product_variant_default_code/README.rst b/product_variant_default_code/README.rst index fc407899e..33800e066 100644 --- a/product_variant_default_code/README.rst +++ b/product_variant_default_code/README.rst @@ -7,7 +7,7 @@ Product Variant Default Code !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:c5bc987b9ee1845b73370e495be88344ab78d396cf4715f96ea54153ece415c7 + !! source digest: sha256:d4fd4a37a3d029a3333468ed24f7289cd75aa355cc34584c24f4751b944e46e0 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png diff --git a/product_variant_default_code/__manifest__.py b/product_variant_default_code/__manifest__.py index 1653e0f32..ad3b17794 100644 --- a/product_variant_default_code/__manifest__.py +++ b/product_variant_default_code/__manifest__.py @@ -9,7 +9,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "Product Variant Default Code", - "version": "15.0.1.0.0", + "version": "15.0.1.0.1", "author": "AvancOSC, Shine IT, Tecnativa, Akretion, Odoo Community Association (OCA)", "website": "https://github.com/OCA/product-variant", "license": "AGPL-3", diff --git a/product_variant_default_code/static/description/index.html b/product_variant_default_code/static/description/index.html index 1c97484d8..b13df75c0 100644 --- a/product_variant_default_code/static/description/index.html +++ b/product_variant_default_code/static/description/index.html @@ -1,4 +1,3 @@ - @@ -367,7 +366,7 @@

Product Variant Default Code

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:c5bc987b9ee1845b73370e495be88344ab78d396cf4715f96ea54153ece415c7 +!! source digest: sha256:d4fd4a37a3d029a3333468ed24f7289cd75aa355cc34584c24f4751b944e46e0 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: AGPL-3 OCA/product-variant Translate me on Weblate Try me on Runboat

This module automatically generate Product Reference (default_code)