Skip to content

Commit

Permalink
Fixed bug in meta_access
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeoLacruz committed Jan 21, 2025
1 parent b497c54 commit 099c7b6
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions inventree_supplier_panel/meta_access.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# Class to access the meta data field in InvenTree. The wrappers build
# a dict with plugin name so that the data from different plugins does
# not overlap

class MetaAccess():

def get_value(self, inventree_object, app, key):
def get_value(self, inventree_object, key):
try:
value = inventree_object.metadata[app][key]
value = inventree_object.metadata[self.NAME][key]
except Exception:
value = None
print('<----', app, key, value)
return (value)

def set_value(self, inventree_object, app, key, value):
print('---->', app, key, value)
def set_value(self, inventree_object, key, value):
data = inventree_object.metadata
if data is None:
data = {}
print('out ', data)
if app in data:
app_data = data[app]
if self.NAME in data:
app_data = data[self.NAME]
app_data.update({key: value})
data.update({app: app_data})
data.update({self.NAME: app_data})
else:
data.update({app: {key: value}})
print('changed', data)
data.update({self.NAME: {key: value}})
inventree_object.metadata = data
inventree_object.save()

0 comments on commit 099c7b6

Please sign in to comment.