Skip to content

Commit

Permalink
Fixes a weird issue where overridden mappings and resource will stay …
Browse files Browse the repository at this point in the history
…none when replacing them in projects
  • Loading branch information
viggo-devries committed Aug 23, 2024
1 parent a4ee365 commit 7a57871
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions oscar_odin/mappings/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,20 @@ def map_queryset(


class OscarBaseMapping(MappingBase, metaclass=MappingMeta):
def create_object(self, **field_values):
"""Create an instance of target object, this method can be customised to handle
custom object initialisation.
:param field_values: Dictionary of values for creating the target object.
"""
try:
new_obj = self.to_obj() # pylint: disable=E1102

for key, field_value in field_values.items():
setattr(new_obj, key, field_value)

return new_obj
except AttributeError:
return super().create_object(**field_value)

register_mapping = False

0 comments on commit 7a57871

Please sign in to comment.