Skip to content

Commit

Permalink
[FIX] attribute_set: assure _instanciate_attrs doesn't break
Browse files Browse the repository at this point in the history
  • Loading branch information
MiquelRForgeFlow committed Oct 16, 2023
1 parent bbc91ec commit 3bf8f21
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions attribute_set/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from . import models
from . import wizard
from . import utils
from .hooks import post_load_hook
1 change: 1 addition & 0 deletions attribute_set/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
],
"external_dependencies": {"python": ["unidecode"]},
"installable": True,
"post_load": "post_load_hook",
}
20 changes: 20 additions & 0 deletions attribute_set/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2023 ForgeFlow S.L. <https://www.forgeflow.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.addons.base_sparse_field.models.models import IrModelFields


def post_load_hook():
def _instanciate_attrs(self, field_data):
attrs = super(IrModelFields, self)._instanciate_attrs(field_data)
if attrs and field_data.get("serialization_field_id"):
serialization_record_id = field_data["serialization_field_id"]
try:
serialization_record = self.browse(serialization_record_id)
attrs["sparse"] = serialization_record.name
except AttributeError:
# due to https://github.com/OCA/odoo-pim/issues/134
# because depends_context isn't filled yet
attrs["sparse"] = None
return attrs

IrModelFields._instanciate_attrs = _instanciate_attrs

0 comments on commit 3bf8f21

Please sign in to comment.