31 lines
1.1 KiB
Python
31 lines
1.1 KiB
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
|
||
|
|
||
|
#id:str = ''
|
||
|
#location_id:str = ''
|
||
|
#name:str = ''
|
||
|
#description:str = ''
|
||
|
#qu_id_purchase:str = ''
|
||
|
#qu_id_stock:str = ''
|
||
|
#qu_factor_purchase_to_stock:float = 0
|
||
|
#barcode:str = ''
|
||
|
#min_stock_amount:int = 0
|
||
|
#default_best_before_days:int = 0
|
||
|
#default_best_before_days_after_open:int = 0
|