Skip to content

Commit

Permalink
[IMP] product_variant_configurator: black, isort, prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelregidor committed Jun 6, 2024
1 parent b474744 commit 5d83b27
Show file tree
Hide file tree
Showing 14 changed files with 150 additions and 145 deletions.
111 changes: 57 additions & 54 deletions product_variant_configurator/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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**

Expand All @@ -46,87 +46,90 @@ 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
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-variant/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 <https://github.com/OCA/product-variant/issues/new?body=module:%20product_variant_configurator%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/product-variant/issues/new?body=module:%20product_variant_configurator%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~
-------

* AvanzOSC
* Tecnativa
* ACSONE SA/NV

Contributors
~~~~~~~~~~~~

* Oihane Crucelaegui <[email protected]>
* Pedro M. Baeza <[email protected]>
* Ana Juaristi <[email protected]>
* Thomas Binsfeld <[email protected]>
* Zakaria Makrelouf (acsone) <[email protected]>
* Stéphane Bidoul <[email protected]>
* Laurent Mignon <[email protected]>
* David Vidal <[email protected]>
* Simone Versienti <[email protected]>
* Adria Gil Sorribes <[email protected]>
* Héctor Villarreal Ortega <[email protected]>
------------

- Oihane Crucelaegui <[email protected]>
- Pedro M. Baeza <[email protected]>
- Ana Juaristi <[email protected]>
- Thomas Binsfeld <[email protected]>
- Zakaria Makrelouf (acsone) <[email protected]>
- Stéphane Bidoul <[email protected]>
- Laurent Mignon <[email protected]>
- David Vidal <[email protected]>
- Simone Versienti <[email protected]>
- Adria Gil Sorribes <[email protected]>
- Héctor Villarreal Ortega <[email protected]>

Maintainers
~~~~~~~~~~~
-----------

This module is maintained by the OCA.

Expand All @@ -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 <https://github.com/OCA/product-variant/tree/16.0/product_variant_configurator>`_ project on GitHub.
This module is part of the `OCA/product-variant <https://github.com/OCA/product-variant/tree/17.0/product_variant_configurator>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion product_variant_configurator/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 3 additions & 0 deletions product_variant_configurator/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
14 changes: 14 additions & 0 deletions product_variant_configurator/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -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`.
13 changes: 0 additions & 13 deletions product_variant_configurator/readme/CONFIGURE.rst

This file was deleted.

11 changes: 11 additions & 0 deletions product_variant_configurator/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
- Oihane Crucelaegui \<<[email protected]>\>
- Pedro M. Baeza \<<[email protected]>\>
- Ana Juaristi \<<[email protected]>\>
- Thomas Binsfeld \<<[email protected]>\>
- Zakaria Makrelouf (acsone) \<<[email protected]>\>
- Stéphane Bidoul \<<[email protected]>\>
- Laurent Mignon \<<[email protected]>\>
- David Vidal \<<[email protected]>\>
- Simone Versienti \<<[email protected]>\>
- Adria Gil Sorribes \<<[email protected]>\>
- Héctor Villarreal Ortega \<<[email protected]>\>
11 changes: 0 additions & 11 deletions product_variant_configurator/readme/CONTRIBUTORS.rst

This file was deleted.

9 changes: 9 additions & 0 deletions product_variant_configurator/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -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.
9 changes: 0 additions & 9 deletions product_variant_configurator/readme/DESCRIPTION.rst

This file was deleted.

26 changes: 26 additions & 0 deletions product_variant_configurator/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -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.

&nbsp;

class AModel(models.Model):
_inherit = ['module.model', 'product.configurator']
name = fields.Char(related="delegated_field.related_field")
26 changes: 0 additions & 26 deletions product_variant_configurator/readme/USAGE.rst

This file was deleted.

Loading

0 comments on commit 5d83b27

Please sign in to comment.