Skip to content

Commit

Permalink
[MIG] attribute_set: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
damcar authored and kobros-tech committed Feb 17, 2025
1 parent 24b2aab commit 37b53ad
Show file tree
Hide file tree
Showing 16 changed files with 102 additions and 202 deletions.
31 changes: 16 additions & 15 deletions attribute_set/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,17 @@ 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``).

--------------

Expand Down Expand Up @@ -121,12 +121,13 @@ Authors
Contributors
------------

- Sébastien BEAU <sebastien.beau@akretion.com>
- Clément Mombereau <clement.mombereau@akretion.com.br>
- Benoît Guillot <benoit.guillot@akretion.com>
- Akretion Raphaël VALYI <raphael.valyi@akretion.com>
- David Dufresne <david.dufresne@savoirfairelinux.com>
- Denis Roussel <denis.roussel@acsone.eu>
- Sébastien BEAU <sebastien.beau@akretion.com>
- Clément Mombereau <clement.mombereau@akretion.com.br>
- Benoît Guillot <benoit.guillot@akretion.com>
- Akretion Raphaël VALYI <raphael.valyi@akretion.com>
- David Dufresne <david.dufresne@savoirfairelinux.com>
- Denis Roussel <denis.roussel@acsone.eu>
- Mohamed Alkobrosli <malkobrosly@kencove.com>

Maintainers
-----------
Expand Down
2 changes: 1 addition & 1 deletion attribute_set/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Attribute Set",
"version": "16.0.1.1.0",
"version": "17.0.1.0.0",
"category": "Generic Modules/Others",
"license": "AGPL-3",
"author": "Akretion,Odoo Community Association (OCA)",
Expand Down
41 changes: 0 additions & 41 deletions attribute_set/i18n/attribute_set.pot
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,6 @@ msgstr ""
msgid "Can't change the type of an attribute. Please create a new one."
msgstr ""

#. module: attribute_set
#: model_terms:ir.ui.view,arch_db:attribute_set.attribute_option_wizard_form_view
msgid "Cancel"
msgstr ""

#. module: attribute_set
#: model:ir.model.fields.selection,name:attribute_set.selection__attribute_attribute__attribute_type__char
msgid "Char"
Expand Down Expand Up @@ -180,7 +175,6 @@ msgstr ""
#: model:ir.model.fields,field_description:attribute_set.field_attribute_attribute__create_uid
#: model:ir.model.fields,field_description:attribute_set.field_attribute_group__create_uid
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option__create_uid
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option_wizard__create_uid
#: model:ir.model.fields,field_description:attribute_set.field_attribute_set__create_uid
msgid "Created by"
msgstr ""
Expand All @@ -193,7 +187,6 @@ msgstr ""
#. module: attribute_set
#: model:ir.model.fields,field_description:attribute_set.field_attribute_group__create_date
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option__create_date
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option_wizard__create_date
#: model:ir.model.fields,field_description:attribute_set.field_attribute_set__create_date
msgid "Created on"
msgstr ""
Expand All @@ -203,11 +196,6 @@ msgstr ""
msgid "Custom"
msgstr ""

#. module: attribute_set
#: model:ir.model,name:attribute_set.model_attribute_option_wizard
msgid "Custom Attributes Option"
msgstr ""

#. module: attribute_set
#: model:ir.model.fields.selection,name:attribute_set.selection__attribute_attribute__attribute_type__date
msgid "Date"
Expand Down Expand Up @@ -235,7 +223,6 @@ msgstr ""
#: model:ir.model.fields,field_description:attribute_set.field_attribute_attribute__display_name
#: model:ir.model.fields,field_description:attribute_set.field_attribute_group__display_name
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option__display_name
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option_wizard__display_name
#: model:ir.model.fields,field_description:attribute_set.field_attribute_set__display_name
msgid "Display Name"
msgstr ""
Expand Down Expand Up @@ -313,7 +300,6 @@ msgstr ""
#: model:ir.model.fields,field_description:attribute_set.field_attribute_attribute__id
#: model:ir.model.fields,field_description:attribute_set.field_attribute_group__id
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option__id
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option_wizard__id
#: model:ir.model.fields,field_description:attribute_set.field_attribute_set__id
msgid "ID"
msgstr ""
Expand Down Expand Up @@ -404,7 +390,6 @@ msgstr ""
#: model:ir.model.fields,field_description:attribute_set.field_attribute_attribute____last_update
#: model:ir.model.fields,field_description:attribute_set.field_attribute_group____last_update
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option____last_update
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option_wizard____last_update
#: model:ir.model.fields,field_description:attribute_set.field_attribute_set____last_update
msgid "Last Modified on"
msgstr ""
Expand All @@ -413,7 +398,6 @@ msgstr ""
#: model:ir.model.fields,field_description:attribute_set.field_attribute_attribute__write_uid
#: model:ir.model.fields,field_description:attribute_set.field_attribute_group__write_uid
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option__write_uid
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option_wizard__write_uid
#: model:ir.model.fields,field_description:attribute_set.field_attribute_set__write_uid
msgid "Last Updated by"
msgstr ""
Expand All @@ -422,7 +406,6 @@ msgstr ""
#: model:ir.model.fields,field_description:attribute_set.field_attribute_attribute__write_date
#: model:ir.model.fields,field_description:attribute_set.field_attribute_group__write_date
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option__write_date
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option_wizard__write_date
#: model:ir.model.fields,field_description:attribute_set.field_attribute_set__write_date
msgid "Last Updated on"
msgstr ""
Expand Down Expand Up @@ -477,17 +460,8 @@ msgstr ""
msgid "On delete property for many2one fields"
msgstr ""

#. module: attribute_set
#. odoo-python
#: code:addons/attribute_set/models/attribute_attribute.py:0
#: model_terms:ir.ui.view,arch_db:attribute_set.attribute_option_wizard_form_view
#, python-format
msgid "Options Wizard"
msgstr ""

#. module: attribute_set
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option__attribute_id
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option_wizard__attribute_id
msgid "Product Attribute"
msgstr ""

Expand Down Expand Up @@ -717,11 +691,6 @@ msgid ""
"Used for custom many2many fields to define a custom relation table name"
msgstr ""

#. module: attribute_set
#: model_terms:ir.ui.view,arch_db:attribute_set.attribute_option_wizard_form_view
msgid "Validate"
msgstr ""

#. module: attribute_set
#: model:ir.model.fields,help:attribute_set.field_attribute_attribute__copied
msgid "Whether the value is copied when duplicating a record."
Expand Down Expand Up @@ -753,13 +722,3 @@ msgid ""
"Specify a Python expression defining a list of triplets.\n"
"For example : `[('color', '=', 'red')]`"
msgstr ""

#. module: attribute_set
#: model_terms:ir.ui.view,arch_db:attribute_set.attribute_option_wizard_form_view
msgid "options_placeholder"
msgstr ""

#. module: attribute_set
#: model_terms:ir.ui.view,arch_db:attribute_set.attribute_option_wizard_form_view
msgid "or"
msgstr ""
41 changes: 0 additions & 41 deletions attribute_set/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,6 @@ msgstr ""
msgid "Can't change the type of an attribute. Please create a new one."
msgstr "No se puede cambiar el tipo de un atributo. Por favor, cree uno nuevo."

#. module: attribute_set
#: model_terms:ir.ui.view,arch_db:attribute_set.attribute_option_wizard_form_view
msgid "Cancel"
msgstr "Cancelar"

#. module: attribute_set
#: model:ir.model.fields.selection,name:attribute_set.selection__attribute_attribute__attribute_type__char
msgid "Char"
Expand Down Expand Up @@ -194,7 +189,6 @@ msgstr "Copiado"
#: model:ir.model.fields,field_description:attribute_set.field_attribute_attribute__create_uid
#: model:ir.model.fields,field_description:attribute_set.field_attribute_group__create_uid
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option__create_uid
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option_wizard__create_uid
#: model:ir.model.fields,field_description:attribute_set.field_attribute_set__create_uid
msgid "Created by"
msgstr "Creado por"
Expand All @@ -207,7 +201,6 @@ msgstr "Fecha de creación"
#. module: attribute_set
#: model:ir.model.fields,field_description:attribute_set.field_attribute_group__create_date
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option__create_date
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option_wizard__create_date
#: model:ir.model.fields,field_description:attribute_set.field_attribute_set__create_date
msgid "Created on"
msgstr "Creado el"
Expand All @@ -217,11 +210,6 @@ msgstr "Creado el"
msgid "Custom"
msgstr "Personalizar"

#. module: attribute_set
#: model:ir.model,name:attribute_set.model_attribute_option_wizard
msgid "Custom Attributes Option"
msgstr "Opción Atributos personalizados"

#. module: attribute_set
#: model:ir.model.fields.selection,name:attribute_set.selection__attribute_attribute__attribute_type__date
msgid "Date"
Expand Down Expand Up @@ -253,7 +241,6 @@ msgstr ""
#: model:ir.model.fields,field_description:attribute_set.field_attribute_attribute__display_name
#: model:ir.model.fields,field_description:attribute_set.field_attribute_group__display_name
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option__display_name
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option_wizard__display_name
#: model:ir.model.fields,field_description:attribute_set.field_attribute_set__display_name
msgid "Display Name"
msgstr "Mostrar Nombre"
Expand Down Expand Up @@ -333,7 +320,6 @@ msgstr "Grupos"
#: model:ir.model.fields,field_description:attribute_set.field_attribute_attribute__id
#: model:ir.model.fields,field_description:attribute_set.field_attribute_group__id
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option__id
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option_wizard__id
#: model:ir.model.fields,field_description:attribute_set.field_attribute_set__id
msgid "ID"
msgstr "ID"
Expand Down Expand Up @@ -455,7 +441,6 @@ msgstr ""
#: model:ir.model.fields,field_description:attribute_set.field_attribute_attribute____last_update
#: model:ir.model.fields,field_description:attribute_set.field_attribute_group____last_update
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option____last_update
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option_wizard____last_update
#: model:ir.model.fields,field_description:attribute_set.field_attribute_set____last_update
msgid "Last Modified on"
msgstr "Última actualización el"
Expand All @@ -464,7 +449,6 @@ msgstr "Última actualización el"
#: model:ir.model.fields,field_description:attribute_set.field_attribute_attribute__write_uid
#: model:ir.model.fields,field_description:attribute_set.field_attribute_group__write_uid
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option__write_uid
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option_wizard__write_uid
#: model:ir.model.fields,field_description:attribute_set.field_attribute_set__write_uid
msgid "Last Updated by"
msgstr "Última actualización por"
Expand All @@ -473,7 +457,6 @@ msgstr "Última actualización por"
#: model:ir.model.fields,field_description:attribute_set.field_attribute_attribute__write_date
#: model:ir.model.fields,field_description:attribute_set.field_attribute_group__write_date
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option__write_date
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option_wizard__write_date
#: model:ir.model.fields,field_description:attribute_set.field_attribute_set__write_date
msgid "Last Updated on"
msgstr "Última Actualización el"
Expand Down Expand Up @@ -528,17 +511,8 @@ msgstr "En Eliminar"
msgid "On delete property for many2one fields"
msgstr "En la propiedad eliminar para campos many2one"

#. module: attribute_set
#. odoo-python
#: code:addons/attribute_set/models/attribute_attribute.py:0
#: model_terms:ir.ui.view,arch_db:attribute_set.attribute_option_wizard_form_view
#, python-format
msgid "Options Wizard"
msgstr "Asistente para Opciones"

#. module: attribute_set
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option__attribute_id
#: model:ir.model.fields,field_description:attribute_set.field_attribute_option_wizard__attribute_id
msgid "Product Attribute"
msgstr "Atributo de Producto"

Expand Down Expand Up @@ -784,11 +758,6 @@ msgstr ""
"Se utiliza en los campos many2many personalizados para definir un nombre de "
"tabla de relación personalizado"

#. module: attribute_set
#: model_terms:ir.ui.view,arch_db:attribute_set.attribute_option_wizard_form_view
msgid "Validate"
msgstr "Validar"

#. module: attribute_set
#: model:ir.model.fields,help:attribute_set.field_attribute_attribute__copied
msgid "Whether the value is copied when duplicating a record."
Expand Down Expand Up @@ -825,13 +794,3 @@ msgstr ""
"`%(domain)s` es un nombre de dominio inválido.\n"
"Especifica una expresión Python que define una lista de tripletas.\n"
"Por ejemplo: `[('color', '=', 'red')]`"

#. module: attribute_set
#: model_terms:ir.ui.view,arch_db:attribute_set.attribute_option_wizard_form_view
msgid "options_placeholder"
msgstr "options_placeholder"

#. module: attribute_set
#: model_terms:ir.ui.view,arch_db:attribute_set.attribute_option_wizard_form_view
msgid "or"
msgstr "o"
23 changes: 11 additions & 12 deletions attribute_set/models/attribute_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def _build_attribute_field(self, attribute_egroup):
Conditional invisibility based on its attribute sets.
"""
self.ensure_one()
kwargs = {"name": "%s" % self.name}
kwargs = {"name": f"{self.name}"}
kwargs["attrs"] = str(self._get_attrs())
if self.widget:
kwargs["widget"] = self.widget
Expand All @@ -154,7 +154,7 @@ def _build_attribute_field(self, attribute_egroup):
else:
# Display only options linked to an existing object
ids = [op.value_ref.id for op in self.option_ids if op.value_ref]
kwargs["domain"] = "[('id', 'in', %s)]" % ids
kwargs["domain"] = f"[('id', 'in', {ids})]"
# Add color options if the attribute's Relational Model
# has a color field
relation_model_obj = self.env[self.relation_model_id.model]
Expand All @@ -163,8 +163,8 @@ def _build_attribute_field(self, attribute_egroup):
elif self.nature == "custom":
# Define field's domain and context with attribute's id to go along with
# Attribute Options search and creation
kwargs["domain"] = "[('attribute_id', '=', %s)]" % (self.id)
kwargs["context"] = "{'default_attribute_id': %s}" % (self.id)
kwargs["domain"] = f"[('attribute_id', '=', {self.id})]"
kwargs["context"] = f"{{'default_attribute_id': {self.id}}}"
elif self.nature != "custom":
kwargs["context"] = self._get_native_field_context()

Expand Down Expand Up @@ -215,10 +215,11 @@ def _build_attribute_eview(self):
attrs=f"{{'invisible' : {hide_domain} }}",
)
groups.append(att_group)

setup_modifiers(attribute_egroup)
attribute_with_env = (
attribute.sudo() if attribute.check_access_rights("read") else self
attribute.sudo()
if not attribute.check_access_rights("read")
else attribute
)
attribute_with_env._build_attribute_field(attribute_egroup)

Expand All @@ -237,7 +238,7 @@ def onchange_field_description(self):
def onchange_name(self):
name = self.name
if not name.startswith("x_"):
self.name = "x_%s" % name
self.name = f"x_{name}"

@api.onchange("attribute_type")
def onchange_attribute_type(self):
Expand Down Expand Up @@ -277,7 +278,7 @@ def button_add_options(self):
# Then open the Options Wizard which will display an 'opt_ids' m2m field related
# to the 'relation_model_id' model
return {
"context": dict(self.env.context, attribute_id=self.id),
"context": {"default_attribute_id": self.id},
"name": _("Options Wizard"),
"view_type": "form",
"view_mode": "form",
Expand Down Expand Up @@ -325,7 +326,8 @@ def create(self, vals_list):
vals["ttype"] = "many2many"
vals["relation"] = relation
# Specify the relation_table's name in case of m2m not serialized
# to avoid creating the same default relation_table name for any attribute
# to avoid creating the same default
# relation_table name for any attribute
# linked to the same attribute.option or relation_model_id's model.
if not vals.get("serialized"):
att_model_id = self.env["ir.model"].browse(vals["model_id"])
Expand Down Expand Up @@ -450,9 +452,6 @@ def write(self, vals):
if att.relation_model_id:
options = self.env[att.relation_model_id.model]
if "option_ids" in list(vals.keys()):
# Delete related attribute.option.wizard if an attribute.option
# has been deleted
att._delete_related_option_wizard(vals["option_ids"])
# If there is still some attribute.option available, override
# 'options' with the objects they are refering to.
options = options.search(
Expand Down
1 change: 0 additions & 1 deletion attribute_set/models/attribute_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def _selection_model_list(self):
value_ref = fields.Reference(
selection="_selection_model_list",
string="Reference",
groups="base.group_erp_manager",
)

attribute_id = fields.Many2one(
Expand Down
1 change: 1 addition & 0 deletions attribute_set/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
- Akretion Raphaël VALYI \<<raphael.valyi@akretion.com>\>
- David Dufresne \<<david.dufresne@savoirfairelinux.com>\>
- Denis Roussel \<<denis.roussel@acsone.eu>\>
- Mohamed Alkobrosli \<<malkobrosly@kencove.com>\>
Loading

0 comments on commit 37b53ad

Please sign in to comment.