20 lines
805 B
Python
20 lines
805 B
Python
from grocy.models.schema import Schema
|
|
|
|
class Product(Schema):
|
|
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)
|
|
#self._init_rest_service()
|
|
|
|
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
|
|
|