From aa821f8471a1f952665a0feaddbb3de27921c883 Mon Sep 17 00:00:00 2001 From: andrea Date: Mon, 8 Apr 2024 15:07:17 +0200 Subject: [PATCH] [MIG] product_variant_default_code: pre-commit --- product_variant_default_code/README.rst | 127 +++++++++--------- .../models/product.py | 2 +- product_variant_default_code/pyproject.toml | 3 + .../readme/CONTRIBUTORS.md | 9 ++ .../readme/CONTRIBUTORS.rst | 10 -- .../readme/DESCRIPTION.md | 16 +++ .../readme/DESCRIPTION.rst | 18 --- .../readme/ROADMAP.md | 1 + .../readme/ROADMAP.rst | 1 - product_variant_default_code/readme/USAGE.md | 50 +++++++ product_variant_default_code/readme/USAGE.rst | 47 ------- .../static/description/index.html | 101 +++++++------- 12 files changed, 202 insertions(+), 183 deletions(-) create mode 100644 product_variant_default_code/pyproject.toml create mode 100644 product_variant_default_code/readme/CONTRIBUTORS.md delete mode 100644 product_variant_default_code/readme/CONTRIBUTORS.rst create mode 100644 product_variant_default_code/readme/DESCRIPTION.md delete mode 100644 product_variant_default_code/readme/DESCRIPTION.rst create mode 100644 product_variant_default_code/readme/ROADMAP.md delete mode 100644 product_variant_default_code/readme/ROADMAP.rst create mode 100644 product_variant_default_code/readme/USAGE.md delete mode 100644 product_variant_default_code/readme/USAGE.rst diff --git a/product_variant_default_code/README.rst b/product_variant_default_code/README.rst index cad2b664a..862b62a84 100644 --- a/product_variant_default_code/README.rst +++ b/product_variant_default_code/README.rst @@ -17,13 +17,13 @@ Product Variant Default Code :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproduct--variant-lightgray.png?logo=github - :target: https://github.com/OCA/product-variant/tree/16.0/product_variant_default_code + :target: https://github.com/OCA/product-variant/tree/17.0/product_variant_default_code :alt: OCA/product-variant .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/product-variant-16-0/product-variant-16-0-product_variant_default_code + :target: https://translation.odoo-community.org/projects/product-variant-17-0/product-variant-17-0-product_variant_default_code :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/product-variant&target_branch=16.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/product-variant&target_branch=17.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -31,21 +31,22 @@ Product Variant Default Code This module automatically generate Product Reference (default_code) according to attributes data with a configurable behavior. -It defines a reference mask on the product templates so the -variants references are automatically set. For example: +It defines a reference mask on the product templates so the variants +references are automatically set. For example: -- Product template: Jacket -- Attributes: - - Color: White, Black - - Size: M, L -- Reference mask: `JKT01-[Color]-[Size]` +- Product template: Jacket +- Attributes: -- Reference on variants: + - Color: White, Black + - Size: M, L - - `JKT01-Wh-M` Jacket White M - - `JKT01-Bl-M` Jacket Black M - - `JKT01-Wh-L` Jacket White L - - `JKT01-Bl-L` Jacket Black L +- Reference mask: JKT01-[Color]-[Size] +- Reference on variants: + + - JKT01-Wh-M Jacket White M + - JKT01-Bl-M Jacket Black M + - JKT01-Wh-L Jacket White L + - JKT01-Bl-L Jacket Black L **Table of contents** @@ -55,58 +56,64 @@ variants references are automatically set. For example: Usage ===== -To set the reference mask up on any product template 'Variant reference mask' -new field. +To set the reference mask up on any product template 'Variant reference +mask' new field. -When creating a new product template without specifying the *Variant reference -mask*, a default value for *Variant reference mask* will be automatically -generated according to the attribute line settings on the product template (if -any). The mask will then be used as an instruction to generate default code of -each product variant of the product template with the corresponding *Attribute -Code* (of the attribute value) inserted. Besides the default value, *Variant -reference mask* can be configured to your liking, make sure putting the -*Attribute Name* inside `[]` marks (it is case sensitive). +When creating a new product template without specifying the *Variant +reference mask*, a default value for *Variant reference mask* will be +automatically generated according to the attribute line settings on the +product template (if any). The mask will then be used as an instruction +to generate default code of each product variant of the product template +with the corresponding *Attribute Code* (of the attribute value) +inserted. Besides the default value, *Variant reference mask* can be +configured to your liking, make sure putting the *Attribute Name* inside +[] marks (it is case sensitive). Example: -Creating a product named *Jacket* with two attributes, *Size* and *Color*:: +Creating a product named *Jacket* with two attributes, *Size* and +*Color*: + +:: Product: Jacket Color: Black(Bl), White(Wh) # Black and White are the attribute values; 'Bl' and 'Wh' are the corresponding codes Size: L (L), XL(XL) -The automatically generated default value for the Variant reference mask will -be `[Color]-[Size]` and so the 'default code' on the variants will be `Bl-L`, -`Wh-L`, `Bl-XL` and `Wh-XL`. +The automatically generated default value for the Variant reference mask +will be [Color]-[Size] and so the 'default code' on the variants will be +Bl-L, Wh-L, Bl-XL and Wh-XL. -The mask value can be fully customized whatever you like. You can even have -the attribute name appear more than once in the mask such as, -`Jacket/[Size]~[Color]~[Size]`, and the generated code on variants will be -something like `Jacket/L~Bl~L` (for variant with Color "Black" and Size "L"). +The mask value can be fully customized whatever you like. You can even +have the attribute name appear more than once in the mask such as, +Jacket/[Size]~[Color]~[Size], and the generated code on variants will be +something like Jacket/L~Bl~L (for variant with Color "Black" and Size +"L"). -When the code attribute is changed, it automatically regenerates the 'default -code' on all variants affected. +When the code attribute is changed, it automatically regenerates the +'default code' on all variants affected. -Aditionally, a product attribute can be set and so it will be appended to the -product `default_code`. In the first example, setting a `Color` code to `CO` -would give `default_code` like this: `COBl-L`, `COWh-L`, `COBl-XL` and -`COWh-XL`. +Aditionally, a product attribute can be set and so it will be appended +to the product default_code. In the first example, setting a Color code +to CO would give default_code like this: COBl-L, COWh-L, COBl-XL and +COWh-XL. Avoiding mask in variants -~~~~~~~~~~~~~~~~~~~~~~~~~ +------------------------- -You can avoid this behavior or force a manual default_code on variant. To do -so, go to *Product Variants > [any variant you want to set up]* and set -manually its reference code. The field `manual code` will be set to on and the -variant internal reference will no longer be changed by this module. +You can avoid this behavior or force a manual default_code on variant. +To do so, go to *Product Variants > [any variant you want to set up]* +and set manually its reference code. The field manual code will be set +to on and the variant internal reference will no longer be changed by +this module. -Unset `manual code` and the reference code will be unlocked again. +Unset manual code and the reference code will be unlocked again. Known issues / Roadmap ====================== -* In case of attribute name update, related mask are not updated. +- In case of attribute name update, related mask are not updated. Bug Tracker =========== @@ -114,7 +121,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -122,7 +129,7 @@ Credits ======= Authors -~~~~~~~ +------- * AvancOSC * Shine IT @@ -130,21 +137,21 @@ Authors * Akretion Contributors -~~~~~~~~~~~~ +------------ -* Alfredo de la Fuente -* Tony Gu -* David Beal -* Daniel Campos -* Kévin Roche +- Alfredo de la Fuente +- Tony Gu +- David Beal +- Daniel Campos +- Kévin Roche +- Tecnativa : -* Tecnativa : - * David Vidal - * Pedro M. Baeza - * João Marques + - David Vidal + - Pedro M. Baeza + - João Marques Maintainers -~~~~~~~~~~~ +----------- This module is maintained by the OCA. @@ -164,6 +171,6 @@ Current `maintainer `__: |maintainer-Kev-Roche| -This module is part of the `OCA/product-variant `_ project on GitHub. +This module is part of the `OCA/product-variant `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/product_variant_default_code/models/product.py b/product_variant_default_code/models/product.py index 110b25699..481994e8a 100644 --- a/product_variant_default_code/models/product.py +++ b/product_variant_default_code/models/product.py @@ -146,7 +146,7 @@ def _get_default_mask(self): main_lang = self._guess_main_lang() for line in self.attribute_line_ids: attribute_names.append( - "[{}]".format(line.attribute_id.with_context(lang=main_lang).name) + f"[{line.attribute_id.with_context(lang=main_lang).name}]" ) default_mask = (self.code_prefix or "") + default_reference_separator.join( attribute_names diff --git a/product_variant_default_code/pyproject.toml b/product_variant_default_code/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/product_variant_default_code/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/product_variant_default_code/readme/CONTRIBUTORS.md b/product_variant_default_code/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..5544620ec --- /dev/null +++ b/product_variant_default_code/readme/CONTRIBUTORS.md @@ -0,0 +1,9 @@ +- Alfredo de la Fuente \<\> +- Tony Gu \<\> +- David Beal \<\> +- Daniel Campos \<\> +- Kévin Roche \<\> +- Tecnativa \: + - David Vidal + - Pedro M. Baeza + - João Marques diff --git a/product_variant_default_code/readme/CONTRIBUTORS.rst b/product_variant_default_code/readme/CONTRIBUTORS.rst deleted file mode 100644 index 2c3d56ad3..000000000 --- a/product_variant_default_code/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1,10 +0,0 @@ -* Alfredo de la Fuente -* Tony Gu -* David Beal -* Daniel Campos -* Kévin Roche - -* Tecnativa : - * David Vidal - * Pedro M. Baeza - * João Marques diff --git a/product_variant_default_code/readme/DESCRIPTION.md b/product_variant_default_code/readme/DESCRIPTION.md new file mode 100644 index 000000000..6fd1f275b --- /dev/null +++ b/product_variant_default_code/readme/DESCRIPTION.md @@ -0,0 +1,16 @@ +This module automatically generate Product Reference (default_code) +according to attributes data with a configurable behavior. + +It defines a reference mask on the product templates so the variants +references are automatically set. For example: + +- Product template: Jacket +- Attributes: + - Color: White, Black + - Size: M, L +- Reference mask: JKT01-\[Color\]-\[Size\] +- Reference on variants: + - JKT01-Wh-M Jacket White M + - JKT01-Bl-M Jacket Black M + - JKT01-Wh-L Jacket White L + - JKT01-Bl-L Jacket Black L diff --git a/product_variant_default_code/readme/DESCRIPTION.rst b/product_variant_default_code/readme/DESCRIPTION.rst deleted file mode 100644 index 36ddbda6d..000000000 --- a/product_variant_default_code/readme/DESCRIPTION.rst +++ /dev/null @@ -1,18 +0,0 @@ -This module automatically generate Product Reference (default_code) -according to attributes data with a configurable behavior. - -It defines a reference mask on the product templates so the -variants references are automatically set. For example: - -- Product template: Jacket -- Attributes: - - Color: White, Black - - Size: M, L -- Reference mask: `JKT01-[Color]-[Size]` - -- Reference on variants: - - - `JKT01-Wh-M` Jacket White M - - `JKT01-Bl-M` Jacket Black M - - `JKT01-Wh-L` Jacket White L - - `JKT01-Bl-L` Jacket Black L diff --git a/product_variant_default_code/readme/ROADMAP.md b/product_variant_default_code/readme/ROADMAP.md new file mode 100644 index 000000000..eb87f2edb --- /dev/null +++ b/product_variant_default_code/readme/ROADMAP.md @@ -0,0 +1 @@ +- In case of attribute name update, related mask are not updated. diff --git a/product_variant_default_code/readme/ROADMAP.rst b/product_variant_default_code/readme/ROADMAP.rst deleted file mode 100644 index 79d630a39..000000000 --- a/product_variant_default_code/readme/ROADMAP.rst +++ /dev/null @@ -1 +0,0 @@ -* In case of attribute name update, related mask are not updated. diff --git a/product_variant_default_code/readme/USAGE.md b/product_variant_default_code/readme/USAGE.md new file mode 100644 index 000000000..74c81e182 --- /dev/null +++ b/product_variant_default_code/readme/USAGE.md @@ -0,0 +1,50 @@ +To set the reference mask up on any product template 'Variant reference +mask' new field. + +When creating a new product template without specifying the *Variant +reference mask*, a default value for *Variant reference mask* will be +automatically generated according to the attribute line settings on the +product template (if any). The mask will then be used as an instruction +to generate default code of each product variant of the product template +with the corresponding *Attribute Code* (of the attribute value) +inserted. Besides the default value, *Variant reference mask* can be +configured to your liking, make sure putting the *Attribute Name* inside +\[\] marks (it is case sensitive). + +Example: + +Creating a product named *Jacket* with two attributes, *Size* and +*Color*: + + Product: Jacket + Color: Black(Bl), White(Wh) # Black and White are the attribute values; + 'Bl' and 'Wh' are the corresponding codes + Size: L (L), XL(XL) + +The automatically generated default value for the Variant reference mask +will be \[Color\]-\[Size\] and so the 'default code' on the variants +will be Bl-L, Wh-L, Bl-XL and Wh-XL. + +The mask value can be fully customized whatever you like. You can even +have the attribute name appear more than once in the mask such as, +Jacket/\[Size\]~\[Color\]~\[Size\], and the generated code on variants +will be something like Jacket/L~Bl~L (for variant with Color "Black" and +Size "L"). + +When the code attribute is changed, it automatically regenerates the +'default code' on all variants affected. + +Aditionally, a product attribute can be set and so it will be appended +to the product default_code. In the first example, setting a Color code +to CO would give default_code like this: COBl-L, COWh-L, COBl-XL and +COWh-XL. + +## Avoiding mask in variants + +You can avoid this behavior or force a manual default_code on variant. +To do so, go to *Product Variants \> \[any variant you want to set up\]* +and set manually its reference code. The field manual code will be set +to on and the variant internal reference will no longer be changed by +this module. + +Unset manual code and the reference code will be unlocked again. diff --git a/product_variant_default_code/readme/USAGE.rst b/product_variant_default_code/readme/USAGE.rst deleted file mode 100644 index 84eea84e0..000000000 --- a/product_variant_default_code/readme/USAGE.rst +++ /dev/null @@ -1,47 +0,0 @@ -To set the reference mask up on any product template 'Variant reference mask' -new field. - -When creating a new product template without specifying the *Variant reference -mask*, a default value for *Variant reference mask* will be automatically -generated according to the attribute line settings on the product template (if -any). The mask will then be used as an instruction to generate default code of -each product variant of the product template with the corresponding *Attribute -Code* (of the attribute value) inserted. Besides the default value, *Variant -reference mask* can be configured to your liking, make sure putting the -*Attribute Name* inside `[]` marks (it is case sensitive). - -Example: - -Creating a product named *Jacket* with two attributes, *Size* and *Color*:: - - Product: Jacket - Color: Black(Bl), White(Wh) # Black and White are the attribute values; - 'Bl' and 'Wh' are the corresponding codes - Size: L (L), XL(XL) - -The automatically generated default value for the Variant reference mask will -be `[Color]-[Size]` and so the 'default code' on the variants will be `Bl-L`, -`Wh-L`, `Bl-XL` and `Wh-XL`. - -The mask value can be fully customized whatever you like. You can even have -the attribute name appear more than once in the mask such as, -`Jacket/[Size]~[Color]~[Size]`, and the generated code on variants will be -something like `Jacket/L~Bl~L` (for variant with Color "Black" and Size "L"). - -When the code attribute is changed, it automatically regenerates the 'default -code' on all variants affected. - -Aditionally, a product attribute can be set and so it will be appended to the -product `default_code`. In the first example, setting a `Color` code to `CO` -would give `default_code` like this: `COBl-L`, `COWh-L`, `COBl-XL` and -`COWh-XL`. - -Avoiding mask in variants -~~~~~~~~~~~~~~~~~~~~~~~~~ - -You can avoid this behavior or force a manual default_code on variant. To do -so, go to *Product Variants > [any variant you want to set up]* and set -manually its reference code. The field `manual code` will be set to on and the -variant internal reference will no longer be changed by this module. - -Unset `manual code` and the reference code will be unlocked again. diff --git a/product_variant_default_code/static/description/index.html b/product_variant_default_code/static/description/index.html index dba66fa60..93791f776 100644 --- a/product_variant_default_code/static/description/index.html +++ b/product_variant_default_code/static/description/index.html @@ -1,3 +1,4 @@ + @@ -368,22 +369,24 @@

Product Variant Default Code

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:42f13ad70dacb35beedc51c40bf0a16dd9edba56fab52c09515d91aea0303275 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

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

+

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

This module automatically generate Product Reference (default_code) according to attributes data with a configurable behavior.

-

It defines a reference mask on the product templates so the -variants references are automatically set. For example:

+

It defines a reference mask on the product templates so the variants +references are automatically set. For example:

  • Product template: Jacket
  • -
  • Attributes: -- Color: White, Black -- Size: M, L
  • -
  • Reference mask: JKT01-[Color]-[Size]
  • +
  • Attributes:
      +
    • Color: White, Black
    • +
    • Size: M, L
    • +
    +
  • +
  • Reference mask: JKT01-[Color]-[Size]
  • Reference on variants:
      -
    • JKT01-Wh-M Jacket White M
    • -
    • JKT01-Bl-M Jacket Black M
    • -
    • JKT01-Wh-L Jacket White L
    • -
    • JKT01-Bl-L Jacket Black L
    • +
    • JKT01-Wh-M Jacket White M
    • +
    • JKT01-Bl-M Jacket Black M
    • +
    • JKT01-Wh-L Jacket White L
    • +
    • JKT01-Bl-L Jacket Black L
@@ -406,44 +409,48 @@

Product Variant Default Code

Usage

-

To set the reference mask up on any product template ‘Variant reference mask’ -new field.

-

When creating a new product template without specifying the Variant reference -mask, a default value for Variant reference mask will be automatically -generated according to the attribute line settings on the product template (if -any). The mask will then be used as an instruction to generate default code of -each product variant of the product template with the corresponding Attribute -Code (of the attribute value) inserted. Besides the default value, Variant -reference mask can be configured to your liking, make sure putting the -Attribute Name inside [] marks (it is case sensitive).

+

To set the reference mask up on any product template ‘Variant reference +mask’ new field.

+

When creating a new product template without specifying the Variant +reference mask, a default value for Variant reference mask will be +automatically generated according to the attribute line settings on the +product template (if any). The mask will then be used as an instruction +to generate default code of each product variant of the product template +with the corresponding Attribute Code (of the attribute value) +inserted. Besides the default value, Variant reference mask can be +configured to your liking, make sure putting the Attribute Name inside +[] marks (it is case sensitive).

Example:

-

Creating a product named Jacket with two attributes, Size and Color:

+

Creating a product named Jacket with two attributes, Size and +Color:

 Product: Jacket
 Color: Black(Bl), White(Wh) # Black and White are the attribute values;
                               'Bl' and 'Wh' are the corresponding codes
 Size: L (L), XL(XL)
 
-

The automatically generated default value for the Variant reference mask will -be [Color]-[Size] and so the ‘default code’ on the variants will be Bl-L, -Wh-L, Bl-XL and Wh-XL.

-

The mask value can be fully customized whatever you like. You can even have -the attribute name appear more than once in the mask such as, -Jacket/[Size]~[Color]~[Size], and the generated code on variants will be -something like Jacket/L~Bl~L (for variant with Color “Black” and Size “L”).

-

When the code attribute is changed, it automatically regenerates the ‘default -code’ on all variants affected.

-

Aditionally, a product attribute can be set and so it will be appended to the -product default_code. In the first example, setting a Color code to CO -would give default_code like this: COBl-L, COWh-L, COBl-XL and -COWh-XL.

+

The automatically generated default value for the Variant reference mask +will be [Color]-[Size] and so the ‘default code’ on the variants will be +Bl-L, Wh-L, Bl-XL and Wh-XL.

+

The mask value can be fully customized whatever you like. You can even +have the attribute name appear more than once in the mask such as, +Jacket/[Size]~[Color]~[Size], and the generated code on variants will be +something like Jacket/L~Bl~L (for variant with Color “Black” and Size +“L”).

+

When the code attribute is changed, it automatically regenerates the +‘default code’ on all variants affected.

+

Aditionally, a product attribute can be set and so it will be appended +to the product default_code. In the first example, setting a Color code +to CO would give default_code like this: COBl-L, COWh-L, COBl-XL and +COWh-XL.

Avoiding mask in variants

-

You can avoid this behavior or force a manual default_code on variant. To do -so, go to Product Variants > [any variant you want to set up] and set -manually its reference code. The field manual code will be set to on and the -variant internal reference will no longer be changed by this module.

-

Unset manual code and the reference code will be unlocked again.

+

You can avoid this behavior or force a manual default_code on variant. +To do so, go to Product Variants > [any variant you want to set up] +and set manually its reference code. The field manual code will be set +to on and the variant internal reference will no longer be changed by +this module.

+

Unset manual code and the reference code will be unlocked again.

@@ -457,7 +464,7 @@

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.

+feedback.

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

@@ -479,10 +486,12 @@

Contributors

  • David Beal <david.beal@akretion.com>
  • Daniel Campos <danielcampos@avanzosc.es>
  • Kévin Roche <kevin.roche@akretion.com>
  • -
  • Tecnativa <tecnativa.com>: -* David Vidal -* Pedro M. Baeza -* João Marques
  • +
  • Tecnativa <tecnativa.com>:
      +
    • David Vidal
    • +
    • Pedro M. Baeza
    • +
    • João Marques
    • +
    +
  • @@ -494,7 +503,7 @@

    Maintainers

    promote its widespread use.

    Current maintainer:

    Kev-Roche

    -

    This module is part of the OCA/product-variant project on GitHub.

    +

    This module is part of the OCA/product-variant project on GitHub.

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