From 5d83b2712d9742dbec9a700a657035f44afe6ada Mon Sep 17 00:00:00 2001 From: manu Date: Thu, 6 Jun 2024 11:43:52 +0200 Subject: [PATCH] [IMP] product_variant_configurator: black, isort, prettier --- product_variant_configurator/README.rst | 111 +++++++++--------- .../models/product_product.py | 2 +- product_variant_configurator/pyproject.toml | 3 + .../readme/CONFIGURE.md | 14 +++ .../readme/CONFIGURE.rst | 13 -- .../readme/CONTRIBUTORS.md | 11 ++ .../readme/CONTRIBUTORS.rst | 11 -- .../readme/DESCRIPTION.md | 9 ++ .../readme/DESCRIPTION.rst | 9 -- product_variant_configurator/readme/USAGE.md | 26 ++++ product_variant_configurator/readme/USAGE.rst | 26 ---- .../static/description/index.html | 55 ++++----- .../tests/test_product_pricelist.py | 4 +- .../test_product_variant_configurator.py | 1 - 14 files changed, 150 insertions(+), 145 deletions(-) create mode 100644 product_variant_configurator/pyproject.toml create mode 100644 product_variant_configurator/readme/CONFIGURE.md delete mode 100644 product_variant_configurator/readme/CONFIGURE.rst create mode 100644 product_variant_configurator/readme/CONTRIBUTORS.md delete mode 100644 product_variant_configurator/readme/CONTRIBUTORS.rst create mode 100644 product_variant_configurator/readme/DESCRIPTION.md delete mode 100644 product_variant_configurator/readme/DESCRIPTION.rst create mode 100644 product_variant_configurator/readme/USAGE.md delete mode 100644 product_variant_configurator/readme/USAGE.rst diff --git a/product_variant_configurator/README.rst b/product_variant_configurator/README.rst index bf25ffadb..0918a7fcb 100644 --- a/product_variant_configurator/README.rst +++ b/product_variant_configurator/README.rst @@ -17,26 +17,26 @@ Product Variant Configurator :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_configurator + :target: https://github.com/OCA/product-variant/tree/17.0/product_variant_configurator :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_configurator + :target: https://translation.odoo-community.org/projects/product-variant-17-0/product-variant-17-0-product_variant_configurator :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| -Provides an abstract model for product variant configuration. It provides the -basic functionality for presenting a table with the attributes of a template -and the possibility to select one of the valid values. You can try this -functionality creating a product variant directly selecting a product -template that has attributes. +Provides an abstract model for product variant configuration. It +provides the basic functionality for presenting a table with the +attributes of a template and the possibility to select one of the valid +values. You can try this functionality creating a product variant +directly selecting a product template that has attributes. -This module also prevents in a configurable way the creation of the product -variants when defining the attributes and attribute values of the product -template. +This module also prevents in a configurable way the creation of the +product variants when defining the attributes and attribute values of +the product template. **Table of contents** @@ -46,49 +46,52 @@ template. Configuration ============= -(after installing `sale_management` application) +(after installing sale_management application) To configure the creation of the variants behaviour, you need to: -#. Go to ``Sales > Configuration > Settings``, and select "Attributes and - Variants (Set product attributes (e.g. color, size) to sell variants)" on - "Product Catalog" section. -#. Go to ``Sales > Catalog > Products``, and select a product. -#. On the Variants tab edit the value of the field ``Variant Creation``. -#. If you want to stop the automatic creation of the variant, and have the same - behaviour for all the products in the same category, go to ``Inventory > - Configuration > Product Categories``, select the category and check the checkbox +1. Go to ``Sales > Configuration > Settings``, and select "Attributes + and Variants (Set product attributes (e.g. color, size) to sell + variants)" on "Product Catalog" section. +2. Go to ``Sales > Catalog > Products``, and select a product. +3. On the Variants tab edit the value of the field ``Variant Creation``. +4. If you want to stop the automatic creation of the variant, and have + the same behaviour for all the products in the same category, go to + ``Inventory > Configuration > Product Categories``, select the + category and check the checkbox ``Don't create variants automatically``. Usage ===== -(after installing `sale_management` application) +(after installing sale_management application) -#. Go to ``Sales > Catalog > Product Variants``. -#. Click on "Create" button for creating a new one. -#. On the field "Product Template", select a product template that has several - attributes. -#. A table with the attributes of the template will appear below. -#. Select all the attribute values and click on "Save" button. -#. A new product variant will be created for that attributes. -#. An error will raise if there's another variant with the same attribute - values or if you haven't filled all the required values. +1. Go to ``Sales > Catalog > Product Variants``. +2. Click on "Create" button for creating a new one. +3. On the field "Product Template", select a product template that has + several attributes. +4. A table with the attributes of the template will appear below. +5. Select all the attribute values and click on "Save" button. +6. A new product variant will be created for that attributes. +7. An error will raise if there's another variant with the same + attribute values or if you haven't filled all the required values. **Developers** To use product configurator in your model, you need to: -#. The product.configurator is an abstract model, hence, to be used it must be - inherited in your model: -#. If the model you're inheriting has ``name`` attribute, and it uses the - related parameter you must override it. +1. The product.configurator is an abstract model, hence, to be used it + must be inherited in your model: +2. If the model you're inheriting has ``name`` attribute, and it uses + the related parameter you must override it. + +  :: - class AModel(models.Model): - _inherit = ['module.model', 'product.configurator'] - name = fields.Char(related="delegated_field.related_field") + class AModel(models.Model): + _inherit = ['module.model', 'product.configurator'] + name = fields.Char(related="delegated_field.related_field") Bug Tracker =========== @@ -96,7 +99,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. @@ -104,29 +107,29 @@ Credits ======= Authors -~~~~~~~ +------- * AvanzOSC * Tecnativa * ACSONE SA/NV Contributors -~~~~~~~~~~~~ - -* Oihane Crucelaegui -* Pedro M. Baeza -* Ana Juaristi -* Thomas Binsfeld -* Zakaria Makrelouf (acsone) -* Stéphane Bidoul -* Laurent Mignon -* David Vidal -* Simone Versienti -* Adria Gil Sorribes -* Héctor Villarreal Ortega +------------ + +- Oihane Crucelaegui +- Pedro M. Baeza +- Ana Juaristi +- Thomas Binsfeld +- Zakaria Makrelouf (acsone) +- Stéphane Bidoul +- Laurent Mignon +- David Vidal +- Simone Versienti +- Adria Gil Sorribes +- Héctor Villarreal Ortega Maintainers -~~~~~~~~~~~ +----------- This module is maintained by the OCA. @@ -138,6 +141,6 @@ 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/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_configurator/models/product_product.py b/product_variant_configurator/models/product_product.py index 6eef4058d..ef5c882a4 100644 --- a/product_variant_configurator/models/product_product.py +++ b/product_variant_configurator/models/product_product.py @@ -23,7 +23,7 @@ def _get_product_attributes_values_dict(self): def _get_product_attributes_values_text(self): description = self.product_template_attribute_value_ids.mapped( - lambda x: "{}: {}".format(x.attribute_id.name, x.name) + lambda x: f"{x.attribute_id.name}: {x.name}" ) if description: return "{}\n{}".format(self.product_tmpl_id.name, "\n".join(description)) diff --git a/product_variant_configurator/pyproject.toml b/product_variant_configurator/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/product_variant_configurator/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/product_variant_configurator/readme/CONFIGURE.md b/product_variant_configurator/readme/CONFIGURE.md new file mode 100644 index 000000000..f69a69fb3 --- /dev/null +++ b/product_variant_configurator/readme/CONFIGURE.md @@ -0,0 +1,14 @@ +(after installing sale_management application) + +To configure the creation of the variants behaviour, you need to: + +1. Go to `Sales > Configuration > Settings`, and select "Attributes and + Variants (Set product attributes (e.g. color, size) to sell + variants)" on "Product Catalog" section. +2. Go to `Sales > Catalog > Products`, and select a product. +3. On the Variants tab edit the value of the field `Variant Creation`. +4. If you want to stop the automatic creation of the variant, and have + the same behaviour for all the products in the same category, go to + `Inventory > Configuration > Product Categories`, select the + category and check the checkbox + `Don't create variants automatically`. diff --git a/product_variant_configurator/readme/CONFIGURE.rst b/product_variant_configurator/readme/CONFIGURE.rst deleted file mode 100644 index 068a374d4..000000000 --- a/product_variant_configurator/readme/CONFIGURE.rst +++ /dev/null @@ -1,13 +0,0 @@ -(after installing `sale_management` application) - -To configure the creation of the variants behaviour, you need to: - -#. Go to ``Sales > Configuration > Settings``, and select "Attributes and - Variants (Set product attributes (e.g. color, size) to sell variants)" on - "Product Catalog" section. -#. Go to ``Sales > Catalog > Products``, and select a product. -#. On the Variants tab edit the value of the field ``Variant Creation``. -#. If you want to stop the automatic creation of the variant, and have the same - behaviour for all the products in the same category, go to ``Inventory > - Configuration > Product Categories``, select the category and check the checkbox - ``Don't create variants automatically``. diff --git a/product_variant_configurator/readme/CONTRIBUTORS.md b/product_variant_configurator/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..6c2d1a226 --- /dev/null +++ b/product_variant_configurator/readme/CONTRIBUTORS.md @@ -0,0 +1,11 @@ +- Oihane Crucelaegui \<\> +- Pedro M. Baeza \<\> +- Ana Juaristi \<\> +- Thomas Binsfeld \<\> +- Zakaria Makrelouf (acsone) \<\> +- Stéphane Bidoul \<\> +- Laurent Mignon \<\> +- David Vidal \<\> +- Simone Versienti \<\> +- Adria Gil Sorribes \<\> +- Héctor Villarreal Ortega \<\> diff --git a/product_variant_configurator/readme/CONTRIBUTORS.rst b/product_variant_configurator/readme/CONTRIBUTORS.rst deleted file mode 100644 index 4ba8595bc..000000000 --- a/product_variant_configurator/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1,11 +0,0 @@ -* Oihane Crucelaegui -* Pedro M. Baeza -* Ana Juaristi -* Thomas Binsfeld -* Zakaria Makrelouf (acsone) -* Stéphane Bidoul -* Laurent Mignon -* David Vidal -* Simone Versienti -* Adria Gil Sorribes -* Héctor Villarreal Ortega diff --git a/product_variant_configurator/readme/DESCRIPTION.md b/product_variant_configurator/readme/DESCRIPTION.md new file mode 100644 index 000000000..96c5ae979 --- /dev/null +++ b/product_variant_configurator/readme/DESCRIPTION.md @@ -0,0 +1,9 @@ +Provides an abstract model for product variant configuration. It +provides the basic functionality for presenting a table with the +attributes of a template and the possibility to select one of the valid +values. You can try this functionality creating a product variant +directly selecting a product template that has attributes. + +This module also prevents in a configurable way the creation of the +product variants when defining the attributes and attribute values of +the product template. diff --git a/product_variant_configurator/readme/DESCRIPTION.rst b/product_variant_configurator/readme/DESCRIPTION.rst deleted file mode 100644 index 8aeed1c0d..000000000 --- a/product_variant_configurator/readme/DESCRIPTION.rst +++ /dev/null @@ -1,9 +0,0 @@ -Provides an abstract model for product variant configuration. It provides the -basic functionality for presenting a table with the attributes of a template -and the possibility to select one of the valid values. You can try this -functionality creating a product variant directly selecting a product -template that has attributes. - -This module also prevents in a configurable way the creation of the product -variants when defining the attributes and attribute values of the product -template. diff --git a/product_variant_configurator/readme/USAGE.md b/product_variant_configurator/readme/USAGE.md new file mode 100644 index 000000000..fcb7fe975 --- /dev/null +++ b/product_variant_configurator/readme/USAGE.md @@ -0,0 +1,26 @@ +(after installing sale_management application) + +1. Go to `Sales > Catalog > Product Variants`. +2. Click on "Create" button for creating a new one. +3. On the field "Product Template", select a product template that has + several attributes. +4. A table with the attributes of the template will appear below. +5. Select all the attribute values and click on "Save" button. +6. A new product variant will be created for that attributes. +7. An error will raise if there's another variant with the same + attribute values or if you haven't filled all the required values. + +**Developers** + +To use product configurator in your model, you need to: + +1. The product.configurator is an abstract model, hence, to be used it + must be inherited in your model: +2. If the model you're inheriting has `name` attribute, and it uses the + related parameter you must override it. + +  + + class AModel(models.Model): + _inherit = ['module.model', 'product.configurator'] + name = fields.Char(related="delegated_field.related_field") diff --git a/product_variant_configurator/readme/USAGE.rst b/product_variant_configurator/readme/USAGE.rst deleted file mode 100644 index 93ed49560..000000000 --- a/product_variant_configurator/readme/USAGE.rst +++ /dev/null @@ -1,26 +0,0 @@ -(after installing `sale_management` application) - -#. Go to ``Sales > Catalog > Product Variants``. -#. Click on "Create" button for creating a new one. -#. On the field "Product Template", select a product template that has several - attributes. -#. A table with the attributes of the template will appear below. -#. Select all the attribute values and click on "Save" button. -#. A new product variant will be created for that attributes. -#. An error will raise if there's another variant with the same attribute - values or if you haven't filled all the required values. - -**Developers** - -To use product configurator in your model, you need to: - -#. The product.configurator is an abstract model, hence, to be used it must be - inherited in your model: -#. If the model you're inheriting has ``name`` attribute, and it uses the - related parameter you must override it. - -:: - - class AModel(models.Model): - _inherit = ['module.model', 'product.configurator'] - name = fields.Char(related="delegated_field.related_field") diff --git a/product_variant_configurator/static/description/index.html b/product_variant_configurator/static/description/index.html index 80d742125..1039bff0c 100644 --- a/product_variant_configurator/static/description/index.html +++ b/product_variant_configurator/static/description/index.html @@ -368,15 +368,15 @@

Product Variant Configurator

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:d2fa5418fe70ab374e81c7fb45080165ffe44bc2c46c10cbae6507957b10f721 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

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

-

Provides an abstract model for product variant configuration. It provides the -basic functionality for presenting a table with the attributes of a template -and the possibility to select one of the valid values. You can try this -functionality creating a product variant directly selecting a product -template that has attributes.

-

This module also prevents in a configurable way the creation of the product -variants when defining the attributes and attribute values of the product -template.

+

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

+

Provides an abstract model for product variant configuration. It +provides the basic functionality for presenting a table with the +attributes of a template and the possibility to select one of the valid +values. You can try this functionality creating a product variant +directly selecting a product template that has attributes.

+

This module also prevents in a configurable way the creation of the +product variants when defining the attributes and attribute values of +the product template.

Table of contents

    @@ -393,41 +393,42 @@

    Product Variant Configurator

Configuration

-

(after installing sale_management application)

+

(after installing sale_management application)

To configure the creation of the variants behaviour, you need to:

    -
  1. Go to Sales > Configuration > Settings, and select “Attributes and -Variants (Set product attributes (e.g. color, size) to sell variants)” on -“Product Catalog” section.
  2. +
  3. Go to Sales > Configuration > Settings, and select “Attributes +and Variants (Set product attributes (e.g. color, size) to sell +variants)” on “Product Catalog” section.
  4. Go to Sales > Catalog > Products, and select a product.
  5. On the Variants tab edit the value of the field Variant Creation.
  6. -
  7. If you want to stop the automatic creation of the variant, and have the same -behaviour for all the products in the same category, go to Inventory > -Configuration > Product Categories, select the category and check the checkbox +
  8. If you want to stop the automatic creation of the variant, and have +the same behaviour for all the products in the same category, go to +Inventory > Configuration > Product Categories, select the +category and check the checkbox Don't create variants automatically.

Usage

-

(after installing sale_management application)

+

(after installing sale_management application)

  1. Go to Sales > Catalog > Product Variants.
  2. Click on “Create” button for creating a new one.
  3. -
  4. On the field “Product Template”, select a product template that has several -attributes.
  5. +
  6. On the field “Product Template”, select a product template that has +several attributes.
  7. A table with the attributes of the template will appear below.
  8. Select all the attribute values and click on “Save” button.
  9. A new product variant will be created for that attributes.
  10. -
  11. An error will raise if there’s another variant with the same attribute -values or if you haven’t filled all the required values.
  12. +
  13. An error will raise if there’s another variant with the same +attribute values or if you haven’t filled all the required values.

Developers

To use product configurator in your model, you need to:

    -
  1. The product.configurator is an abstract model, hence, to be used it must be -inherited in your model:
  2. -
  3. If the model you’re inheriting has name attribute, and it uses the -related parameter you must override it.
  4. +
  5. The product.configurator is an abstract model, hence, to be used it +must be inherited in your model:
  6. +
  7. If the model you’re inheriting has name attribute, and it uses +the related parameter you must override it.
 class AModel(models.Model):
@@ -440,7 +441,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.

@@ -476,7 +477,7 @@

Maintainers

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/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_configurator/tests/test_product_pricelist.py b/product_variant_configurator/tests/test_product_pricelist.py index c73842320..a42161139 100644 --- a/product_variant_configurator/tests/test_product_pricelist.py +++ b/product_variant_configurator/tests/test_product_pricelist.py @@ -179,9 +179,7 @@ def test_02_price_rule_get_multi_template(self): uom=self.iphone_template.uom_po_id.id, date="2016-01-01" ).template_price_get( self.iphone_template, 4, self.env.ref("base.res_partner_1").id - )[ - self.pricelist.id - ] + )[self.pricelist.id] self.assertEqual(price, 500 * 0.9) def test_03_price_rule_get_multi_template(self): diff --git a/product_variant_configurator/tests/test_product_variant_configurator.py b/product_variant_configurator/tests/test_product_variant_configurator.py index b4940399f..8c7df2ab8 100644 --- a/product_variant_configurator/tests/test_product_variant_configurator.py +++ b/product_variant_configurator/tests/test_product_variant_configurator.py @@ -529,7 +529,6 @@ def test_get_product_attributes_values_text(self): self.assertEqual(result, self.product_template_yes.name) def test_unlink(self): - product = self.product_product.create( { "name": "Test product Check",