grocy-cli/grocy/models.py

24 lines
803 B
Python

class Product(dict):
def __init__(self, **entries):
self.fields = [
'location_id',
'name',
'description',
'qu_id_purchase',
'qu_id_stock',
'qu_factor_purchase_to_stock',
'barcode',
'min_stock_amount',
'default_best_before_days',
'default_best_before_days_after_open',
'tare_weight', 'enable_tare_weight_handling', 'picture_file_name','product_group_id',
'allow_partial_units_in_stock']
self.__dict__.update(entries)
def toJSON(self):
obj = {}
for attr, value in self.__dict__.items():
if attr in self.fields and value is not None:
obj[attr] = value
return obj