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 committed Dec 5, 2023
1 parent 42f1c20 commit cfa78d0
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 278 deletions.
1 change: 0 additions & 1 deletion attribute_set/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
from . import models
from . import wizard
from . import utils
5 changes: 2 additions & 3 deletions 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 All @@ -13,8 +13,7 @@
"views/attribute_attribute_view.xml",
"views/attribute_group_view.xml",
"views/attribute_option_view.xml",
"views/attribute_set_view.xml",
"wizard/attribute_option_wizard_view.xml",
"views/attribute_set_view.xml"
],
"external_dependencies": {"python": ["unidecode"]},
"installable": True,
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"
49 changes: 19 additions & 30 deletions attribute_set/models/attribute_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

from lxml import etree

from odoo import _, api, fields, models
from odoo import _, api, fields, models, Command
from odoo.tools.safe_eval import safe_eval
from odoo.exceptions import ValidationError

from ..utils.orm import setup_modifiers
Expand Down Expand Up @@ -82,6 +83,11 @@ class AttributeAttribute(models.Model):
"ir.model", "Relational Model", ondelete="cascade"
)

relation_model_name = fields.Char(
"Relational Model Name",
related="relation_model_id.model"
)

widget = fields.Char(help="Specify widget to add to the field on the views.")

required_on_views = fields.Boolean(
Expand Down Expand Up @@ -269,22 +275,18 @@ def _onchange_domain(self):

def button_add_options(self):
self.ensure_one()
# Before adding another option delete the ones which are linked
# to a deleted object
for option in self.option_ids:
if not option.value_ref:
option.unlink()
# 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),
"name": _("Options Wizard"),
"view_type": "form",
"view_mode": "form",
"res_model": "attribute.option.wizard",
"type": "ir.actions.act_window",
"target": "new",
}
values = self.env[self.relation_model_id.model].search(
safe_eval(self.domain)
)
options = []
for value in values:
options.append(Command.create(
{
"name": value.display_name,
"value_ref": f"{value._name},{value.id}",
}
))
self.option_ids = options

@api.model_create_multi
def create(self, vals_list):
Expand Down Expand Up @@ -373,16 +375,6 @@ def create(self, vals_list):
vals["state"] = "manual"
return super().create(vals_list)

def _delete_related_option_wizard(self, option_vals):
"""Delete related attribute's options wizards."""
self.ensure_one()
for option_change in option_vals:
if option_change[0] == 2:
self.env["attribute.option.wizard"].search(
[("attribute_id", "=", self.id)]
).unlink()
break

def _delete_old_fields_options(self, options):
"""Delete outdated attribute's field values on existing records."""
self.ensure_one()
Expand Down Expand Up @@ -450,9 +442,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
2 changes: 0 additions & 2 deletions attribute_set/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@ access_attribute_set_attribute_set_user,attribute_set_attribute_set,attribute_se
access_attribute_set_attribute_group_user,attribute_set_attribute_group,attribute_set.model_attribute_group,base.group_user,1,0,0,0
access_attribute_set_attribute_attribute_user,attribute_set_attribute_attribute,attribute_set.model_attribute_attribute,base.group_user,1,0,0,0
access_attribute_set_attribute_option_user,attribute_set_attribute_option,attribute_set.model_attribute_option,base.group_user,1,0,0,0
access_attribute_set_attribute_option_wizard_user,attribute_set_attribute_option_wizard,attribute_set.model_attribute_option_wizard,base.group_user,1,0,0,0
access_attribute_set_attribute_option_wizard_erpmanager,attribute_set_attribute_option_wizard,attribute_set.model_attribute_option_wizard,base.group_erp_manager,1,1,1,1
Loading

0 comments on commit cfa78d0

Please sign in to comment.