-
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] attribute_set: assure _instanciate_attrs doesn't break
- Loading branch information
1 parent
bbc91ec
commit 3bf8f21
Showing
3 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,5 @@ | |
], | ||
"external_dependencies": {"python": ["unidecode"]}, | ||
"installable": True, | ||
"post_load": "post_load_hook", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |