diff --git a/attribute_set/README.rst b/attribute_set/README.rst index ebf81abe..7491ee13 100644 --- a/attribute_set/README.rst +++ b/attribute_set/README.rst @@ -17,28 +17,40 @@ Attribute Set :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fodoo--pim-lightgray.png?logo=github - :target: https://github.com/OCA/odoo-pim/tree/16.0/attribute_set + :target: https://github.com/OCA/odoo-pim/tree/17.0/attribute_set :alt: OCA/odoo-pim .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/odoo-pim-16-0/odoo-pim-16-0-attribute_set + :target: https://translation.odoo-community.org/projects/odoo-pim-17-0/odoo-pim-17-0-attribute_set :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/odoo-pim&target_branch=16.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/odoo-pim&target_branch=17.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| -This module allows the user to create Attributes to any model. -This is a basic module in the way that **it does not provide views to display these new Attributes.** +This module allows the user to create Attributes to any model. This is a +basic module in the way that **it does not provide views to display +these new Attributes.** -Each Attribute created will be related to an **existing field** (in case of a *"native"* Attribute) or to a newly **created field** (in case of a *"custom"* Attribute). +Each Attribute created will be related to an **existing field** (in case +of a *"native"* Attribute) or to a newly **created field** (in case of a +*"custom"* Attribute). -A *"custom"* Attribute can be of any type : Char, Text, Boolean, Date, Binary... but also Many2one or Many2many. +A *"custom"* Attribute can be of any type : Char, Text, Boolean, Date, +Binary... but also Many2one or Many2many. -In case of m2o or m2m, these attributes can be related to **custom options** created for the Attribute, or to **existing Odoo objects** from other models. +In case of m2o or m2m, these attributes can be related to **custom +options** created for the Attribute, or to **existing Odoo objects** +from other models. -Last but not least an Attribute can be **serialized** using the Odoo SA module `base_sparse_field `_ . -It means that all the serialized attributes will be stored in a single "JSON serialization field" and will not create new columns in the database (and better, it will not create new SQL tables in case of Many2many Attributes), **increasing significantly the requests speed** when dealing with thousands of Attributes. +Last but not least an Attribute can be **serialized** using the Odoo SA +module +`base_sparse_field `__ +. It means that all the serialized attributes will be stored in a single +"JSON serialization field" and will not create new columns in the +database (and better, it will not create new SQL tables in case of +Many2many Attributes), **increasing significantly the requests speed** +when dealing with thousands of Attributes. **Table of contents** @@ -48,23 +60,45 @@ It means that all the serialized attributes will be stored in a single "JSON ser Usage ===== -Even if this module does not provide views to display some model's Attributes, it provides however a Technical menu in *Settings > Technical > Database Structure > Attributes* to **create new Attributes**. +Even if this module does not provide views to display some model's +Attributes, it provides however a Technical menu in *Settings > +Technical > Database Structure > Attributes* to **create new +Attributes**. -An Attribute is related to both an Attribute Group and an Attribute Set : +An Attribute is related to both an Attribute Group and an Attribute Set +: -- The **Attribute Set** is related to the *"model's category"*, i.e. all the model's instances which will display the same Attributes. -- The **Attribute Group** is related to the *"attribute's category"*. All the attributes from the same Attribute Set and Attribute Group will be displayed under the same field's Group in the model's view. +- The **Attribute Set** is related to the *"model's category"*, i.e. + all the model's instances which will display the same Attributes. +- The **Attribute Group** is related to the *"attribute's category"*. + All the attributes from the same Attribute Set and Attribute Group + will be displayed under the same field's Group in the model's view. - 🔎 In order to create a custom Attribute many2one or many2many related to **other Odoo model**, you need to activate the Technical Setting **"Advanced Attribute Set settings"** (:code:`group_advanced_attribute_set`). + 🔎 In order to create a custom Attribute many2one or many2many + related to **other Odoo model**, you need to activate the + Technical Setting **"Advanced Attribute Set settings"** + (``group_advanced_attribute_set``). ------ +-------------- + +If you want to create a module displaying some specific model's +Attributes : + +1. Your model must **\_inherit the mixin** + ``"attribute.set.owner.mixin"`` +2. You need to **add a placeholder** + ```` at the desired + location in the model's form view. +3. Finally, **add a context** ``{"include_native_attribute": True}`` on + the action leading to this form view if the model's view needs to + display attributes related to native fields together with the other + "custom" attributes. + +Known issues / Roadmap +====================== -If you want to create a module displaying some specific model's Attributes : -1. Your model must **\_inherit the mixin** :code:`"attribute.set.owner.mixin"` -2. You need to **add a placeholder** :code:`` at the desired location in the model's form view. -3. Finally, **add a context** :code:`{"include_native_attribute": True}` on the action leading to this form view if the model's view needs to display attributes related to native fields together with the other "custom" attributes. Bug Tracker =========== @@ -72,7 +106,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. @@ -80,22 +114,22 @@ Credits ======= Authors -~~~~~~~ +------- * Akretion Contributors -~~~~~~~~~~~~ +------------ -* Sébastien BEAU -* Clément Mombereau -* Benoît Guillot -* Akretion Raphaël VALYI -* David Dufresne -* Denis Roussel +- Sébastien BEAU +- Clément Mombereau +- Benoît Guillot +- Akretion Raphaël VALYI +- David Dufresne +- Denis Roussel Maintainers -~~~~~~~~~~~ +----------- This module is maintained by the OCA. @@ -107,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/odoo-pim `_ project on GitHub. +This module is part of the `OCA/odoo-pim `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/attribute_set/models/attribute_attribute.py b/attribute_set/models/attribute_attribute.py index 064c8131..62b93e09 100644 --- a/attribute_set/models/attribute_attribute.py +++ b/attribute_set/models/attribute_attribute.py @@ -196,7 +196,7 @@ def _build_attribute_eview(self): att_group = attribute.attribute_group_id att_group_name = att_group.name.capitalize() if att_group in groups: - xpath = ".//group[@string='{}']".format(att_group_name) + xpath = f".//group[@string='{att_group_name}']" attribute_egroup = attribute_eview.find(xpath) else: att_set_ids = [] @@ -212,7 +212,7 @@ def _build_attribute_eview(self): "group", string=att_group_name, colspan="2", - attrs="{{'invisible' : {} }}".format(hide_domain), + attrs=f"{{'invisible' : {hide_domain} }}", ) groups.append(att_group) diff --git a/attribute_set/models/attribute_set_owner.py b/attribute_set/models/attribute_set_owner.py index 6043a820..9624442a 100644 --- a/attribute_set/models/attribute_set_owner.py +++ b/attribute_set/models/attribute_set_owner.py @@ -50,7 +50,7 @@ def remove_native_fields(self, eview): ] ) for attr in native_attrs: - efield = eview.xpath("//field[@name='{}']".format(attr.name)) + efield = eview.xpath(f"//field[@name='{attr.name}']") if len(efield): efield[0].getparent().remove(efield[0]) diff --git a/attribute_set/pyproject.toml b/attribute_set/pyproject.toml new file mode 100644 index 00000000..4231d0cc --- /dev/null +++ b/attribute_set/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/attribute_set/readme/CONTRIBUTORS.md b/attribute_set/readme/CONTRIBUTORS.md new file mode 100644 index 00000000..9a0083a6 --- /dev/null +++ b/attribute_set/readme/CONTRIBUTORS.md @@ -0,0 +1,6 @@ +- Sébastien BEAU \<\> +- Clément Mombereau \<\> +- Benoît Guillot \<\> +- Akretion Raphaël VALYI \<\> +- David Dufresne \<\> +- Denis Roussel \<\> diff --git a/attribute_set/readme/CONTRIBUTORS.rst b/attribute_set/readme/CONTRIBUTORS.rst deleted file mode 100644 index 85d78a19..00000000 --- a/attribute_set/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1,6 +0,0 @@ -* Sébastien BEAU -* Clément Mombereau -* Benoît Guillot -* Akretion Raphaël VALYI -* David Dufresne -* Denis Roussel diff --git a/attribute_set/readme/DESCRIPTION.md b/attribute_set/readme/DESCRIPTION.md new file mode 100644 index 00000000..884f7f83 --- /dev/null +++ b/attribute_set/readme/DESCRIPTION.md @@ -0,0 +1,23 @@ +This module allows the user to create Attributes to any model. This is a +basic module in the way that **it does not provide views to display +these new Attributes.** + +Each Attribute created will be related to an **existing field** (in case +of a *"native"* Attribute) or to a newly **created field** (in case of a +*"custom"* Attribute). + +A *"custom"* Attribute can be of any type : Char, Text, Boolean, Date, +Binary... but also Many2one or Many2many. + +In case of m2o or m2m, these attributes can be related to **custom +options** created for the Attribute, or to **existing Odoo objects** +from other models. + +Last but not least an Attribute can be **serialized** using the Odoo SA +module +[base_sparse_field](https://github.com/odoo/odoo/tree/16.0/addons/base_sparse_field) +. It means that all the serialized attributes will be stored in a single +"JSON serialization field" and will not create new columns in the +database (and better, it will not create new SQL tables in case of +Many2many Attributes), **increasing significantly the requests speed** +when dealing with thousands of Attributes. diff --git a/attribute_set/readme/DESCRIPTION.rst b/attribute_set/readme/DESCRIPTION.rst deleted file mode 100644 index 046d326e..00000000 --- a/attribute_set/readme/DESCRIPTION.rst +++ /dev/null @@ -1,11 +0,0 @@ -This module allows the user to create Attributes to any model. -This is a basic module in the way that **it does not provide views to display these new Attributes.** - -Each Attribute created will be related to an **existing field** (in case of a *"native"* Attribute) or to a newly **created field** (in case of a *"custom"* Attribute). - -A *"custom"* Attribute can be of any type : Char, Text, Boolean, Date, Binary... but also Many2one or Many2many. - -In case of m2o or m2m, these attributes can be related to **custom options** created for the Attribute, or to **existing Odoo objects** from other models. - -Last but not least an Attribute can be **serialized** using the Odoo SA module `base_sparse_field `_ . -It means that all the serialized attributes will be stored in a single "JSON serialization field" and will not create new columns in the database (and better, it will not create new SQL tables in case of Many2many Attributes), **increasing significantly the requests speed** when dealing with thousands of Attributes. diff --git a/attribute_set/readme/ROADMAP.md b/attribute_set/readme/ROADMAP.md new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/attribute_set/readme/ROADMAP.md @@ -0,0 +1 @@ + diff --git a/attribute_set/readme/ROADMAP.rst b/attribute_set/readme/ROADMAP.rst deleted file mode 100644 index e69de29b..00000000 diff --git a/attribute_set/readme/USAGE.md b/attribute_set/readme/USAGE.md new file mode 100644 index 00000000..0066c273 --- /dev/null +++ b/attribute_set/readme/USAGE.md @@ -0,0 +1,34 @@ +Even if this module does not provide views to display some model's +Attributes, it provides however a Technical menu in *Settings \> +Technical \> Database Structure \> Attributes* to **create new +Attributes**. + +An Attribute is related to both an Attribute Group and an Attribute Set +: + +- The **Attribute Set** is related to the *"model's category"*, i.e. all + the model's instances which will display the same Attributes. + +- The **Attribute Group** is related to the *"attribute's category"*. + All the attributes from the same Attribute Set and Attribute Group + will be displayed under the same field's Group in the model's view. + + > 🔎 In order to create a custom Attribute many2one or many2many + > related to **other Odoo model**, you need to activate the Technical + > Setting **"Advanced Attribute Set settings"** + > (`group_advanced_attribute_set`). + +------------------------------------------------------------------------ + +If you want to create a module displaying some specific model's +Attributes : + +1. Your model must **\_inherit the mixin** + `"attribute.set.owner.mixin"` +2. You need to **add a placeholder** + `` at the desired + location in the model's form view. +3. Finally, **add a context** `{"include_native_attribute": True}` on + the action leading to this form view if the model's view needs to + display attributes related to native fields together with the other + "custom" attributes. diff --git a/attribute_set/readme/USAGE.rst b/attribute_set/readme/USAGE.rst deleted file mode 100644 index 7e3cfa44..00000000 --- a/attribute_set/readme/USAGE.rst +++ /dev/null @@ -1,17 +0,0 @@ -Even if this module does not provide views to display some model's Attributes, it provides however a Technical menu in *Settings > Technical > Database Structure > Attributes* to **create new Attributes**. - -An Attribute is related to both an Attribute Group and an Attribute Set : - -- The **Attribute Set** is related to the *"model's category"*, i.e. all the model's instances which will display the same Attributes. -- The **Attribute Group** is related to the *"attribute's category"*. All the attributes from the same Attribute Set and Attribute Group will be displayed under the same field's Group in the model's view. - - - 🔎 In order to create a custom Attribute many2one or many2many related to **other Odoo model**, you need to activate the Technical Setting **"Advanced Attribute Set settings"** (:code:`group_advanced_attribute_set`). - ------ - -If you want to create a module displaying some specific model's Attributes : - -1. Your model must **\_inherit the mixin** :code:`"attribute.set.owner.mixin"` -2. You need to **add a placeholder** :code:`` at the desired location in the model's form view. -3. Finally, **add a context** :code:`{"include_native_attribute": True}` on the action leading to this form view if the model's view needs to display attributes related to native fields together with the other "custom" attributes. diff --git a/attribute_set/static/description/index.html b/attribute_set/static/description/index.html index df6084e1..d0ac75dd 100644 --- a/attribute_set/static/description/index.html +++ b/attribute_set/static/description/index.html @@ -369,66 +369,99 @@

Attribute Set

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:70a22a010d1706666b49f94906da9a8c7273649e03b5fce69b741553bebb3799 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/odoo-pim Translate me on Weblate Try me on Runboat

-

This module allows the user to create Attributes to any model. -This is a basic module in the way that it does not provide views to display these new Attributes.

-

Each Attribute created will be related to an existing field (in case of a “native” Attribute) or to a newly created field (in case of a “custom” Attribute).

-

A “custom” Attribute can be of any type : Char, Text, Boolean, Date, Binary… but also Many2one or Many2many.

-

In case of m2o or m2m, these attributes can be related to custom options created for the Attribute, or to existing Odoo objects from other models.

-

Last but not least an Attribute can be serialized using the Odoo SA module base_sparse_field . -It means that all the serialized attributes will be stored in a single “JSON serialization field” and will not create new columns in the database (and better, it will not create new SQL tables in case of Many2many Attributes), increasing significantly the requests speed when dealing with thousands of Attributes.

+

Beta License: AGPL-3 OCA/odoo-pim Translate me on Weblate Try me on Runboat

+

This module allows the user to create Attributes to any model. This is a +basic module in the way that it does not provide views to display +these new Attributes.

+

Each Attribute created will be related to an existing field (in case +of a “native” Attribute) or to a newly created field (in case of a +“custom” Attribute).

+

A “custom” Attribute can be of any type : Char, Text, Boolean, Date, +Binary… but also Many2one or Many2many.

+

In case of m2o or m2m, these attributes can be related to custom +options created for the Attribute, or to existing Odoo objects +from other models.

+

Last but not least an Attribute can be serialized using the Odoo SA +module +base_sparse_field +. It means that all the serialized attributes will be stored in a single +“JSON serialization field” and will not create new columns in the +database (and better, it will not create new SQL tables in case of +Many2many Attributes), increasing significantly the requests speed +when dealing with thousands of Attributes.

Table of contents

Usage

-

Even if this module does not provide views to display some model’s Attributes, it provides however a Technical menu in Settings > Technical > Database Structure > Attributes to create new Attributes.

-

An Attribute is related to both an Attribute Group and an Attribute Set :

+

Even if this module does not provide views to display some model’s +Attributes, it provides however a Technical menu in Settings > +Technical > Database Structure > Attributes to create new +Attributes.

+

An Attribute is related to both an Attribute Group and an Attribute Set +:

    -
  • The Attribute Set is related to the “model’s category”, i.e. all the model’s instances which will display the same Attributes.

    +
  • The Attribute Set is related to the “model’s category”, i.e. +all the model’s instances which will display the same Attributes.

  • -
  • The Attribute Group is related to the “attribute’s category”. All the attributes from the same Attribute Set and Attribute Group will be displayed under the same field’s Group in the model’s view.

    +
  • The Attribute Group is related to the “attribute’s category”. +All the attributes from the same Attribute Set and Attribute Group +will be displayed under the same field’s Group in the model’s view.

    -

    🔎 In order to create a custom Attribute many2one or many2many related to other Odoo model, you need to activate the Technical Setting “Advanced Attribute Set settings” (group_advanced_attribute_set).

    +

    🔎 In order to create a custom Attribute many2one or many2many +related to other Odoo model, you need to activate the +Technical Setting “Advanced Attribute Set settings” +(group_advanced_attribute_set).


-

If you want to create a module displaying some specific model’s Attributes :

+

If you want to create a module displaying some specific model’s +Attributes :

    -
  1. Your model must _inherit the mixin "attribute.set.owner.mixin"
  2. -
  3. You need to add a placeholder <separator name="attributes_placeholder" /> at the desired location in the model’s form view.
  4. -
  5. Finally, add a context {"include_native_attribute": True} on the action leading to this form view if the model’s view needs to display attributes related to native fields together with the other “custom” attributes.
  6. +
  7. Your model must _inherit the mixin +"attribute.set.owner.mixin"
  8. +
  9. You need to add a placeholder +<separator name="attributes_placeholder" /> at the desired +location in the model’s form view.
  10. +
  11. Finally, add a context {"include_native_attribute": True} on +the action leading to this form view if the model’s view needs to +display attributes related to native fields together with the other +“custom” attributes.
+
-

Bug Tracker

+

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.

-

Credits

+

Credits

-

Authors

+

Authors

  • Akretion
-

Contributors

+

Contributors

-

Maintainers

+

Maintainers

This module is maintained by the OCA.

Odoo Community Association

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/odoo-pim project on GitHub.

+

This module is part of the OCA/odoo-pim project on GitHub.

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

diff --git a/attribute_set/tests/test_build_view.py b/attribute_set/tests/test_build_view.py index 802903d4..b22f7fdc 100644 --- a/attribute_set/tests/test_build_view.py +++ b/attribute_set/tests/test_build_view.py @@ -185,7 +185,7 @@ def _check_attrset_visiblility(self, attrs, set_ids): self.assertEqual( set(set_ids), set(domain[2]), - "Expected {}, get {}".format(set(set_ids), set(domain[2])), + f"Expected {set(set_ids)}, get {set(domain[2])}", ) def _check_attrset_required(self, attrs, set_ids): @@ -197,12 +197,12 @@ def _check_attrset_required(self, attrs, set_ids): self.assertEqual( set(set_ids), set(domain[2]), - "Expected {}, get {}".format(set(set_ids), set(domain[2])), + f"Expected {set(set_ids)}, get {set(domain[2])}", ) def _get_attr_element(self, name): eview = self.env["res.partner"]._build_attribute_eview() - return eview.find("group/field[@name='{}']".format(name)) + return eview.find(f"group/field[@name='{name}']") def test_group_order(self): eview = self.env["res.partner"]._build_attribute_eview() @@ -265,7 +265,7 @@ def test_attr_required(self): def test_render_all_field_type(self): field = self.env["attribute.attribute"]._fields["attribute_type"] for attr_type, _name in field.selection: - name = "x_test_render_{}".format(attr_type) + name = f"x_test_render_{attr_type}" self._create_attribute( { "nature": "custom", @@ -298,7 +298,7 @@ def _get_eview_from_get_views(self, include_native_attribute=True): def test_include_native_attr(self): eview = self._get_eview_from_get_views() - attr = eview.xpath("//field[@name='{}']".format(self.attr_native.name)) + attr = eview.xpath(f"//field[@name='{self.attr_native.name}']") # Only one field with this name self.assertEqual(len(attr), 1) @@ -311,13 +311,13 @@ def test_include_native_attr(self): def test_native_readonly(self): eview = self._get_eview_from_get_views() - attr = eview.xpath("//field[@name='{}']".format(self.attr_native_readonly.name)) + attr = eview.xpath(f"//field[@name='{self.attr_native_readonly.name}']") self.assertTrue(attr[0].get("readonly")) def test_no_include_native_attr(self): # Run get_views on the test view with no "include_native_attribute" eview = self._get_eview_from_get_views(include_native_attribute=False) - attr = eview.xpath("//field[@name='{}']".format(self.attr_native.name)) + attr = eview.xpath(f"//field[@name='{self.attr_native.name}']") # Only one field with this name self.assertEqual(len(attr), 1) diff --git a/attribute_set/wizard/attribute_option_wizard.py b/attribute_set/wizard/attribute_option_wizard.py index e95599ab..f32526ed 100644 --- a/attribute_set/wizard/attribute_option_wizard.py +++ b/attribute_set/wizard/attribute_option_wizard.py @@ -42,9 +42,7 @@ def create(self, vals_list): { "attribute_id": vals["attribute_id"], "name": name, - "value_ref": "{},{}".format( - attr.relation_model_id.model, op_id - ), + "value_ref": f"{attr.relation_model_id.model},{op_id}", } ) if vals.get("option_ids"): diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..6f3f1c6f --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +# generated from manifests external_dependencies +unidecode