diff --git a/inventree_supplier_panel/meta_access.py b/inventree_supplier_panel/meta_access.py index a430fa6..b00e026 100644 --- a/inventree_supplier_panel/meta_access.py +++ b/inventree_supplier_panel/meta_access.py @@ -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()