Merge branch 'main' of https://git.tunpok.com/ching/grocy-barcode-helper into main
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Ching 2024-03-08 16:28:42 +08:00
commit 8e17ee3932
2 changed files with 7 additions and 4 deletions

8
app.py
View File

@ -27,7 +27,8 @@ import base64
GROCY_URL = os.environ.get("GROCY_URL") GROCY_URL = os.environ.get("GROCY_URL")
GROCY_API_KEY = os.environ.get("GROCY_API_KEY") GROCY_API_KEY = os.environ.get("GROCY_API_KEY")
GROCY_PORT = os.environ.get("GROCY_PORT") GROCY_PORT = os.environ.get("GROCY_PORT")
GROCY_DEFAULT_QUANTITY_UNIT_ID = os.environ.get("GROCY_DEFAULT_QUANTITY_UNIT_ID") GROCY_DEFAULT_QUANTITY_UNIT_ID_PURCHASE = os.environ.get("GROCY_DEFAULT_QUANTITY_UNIT_ID_PURCHASE")
GROCY_DEFAULT_QUANTITY_UNIT_ID_STOCK = os.environ.get("GROCY_DEFAULT_QUANTITY_UNIT_ID_STOCK")
GROCY_DEFAULT_BEST_BEFORE_DAYS = os.environ.get("GROCY_DEFAULT_BEST_BEFORE_DAYS") GROCY_DEFAULT_BEST_BEFORE_DAYS = os.environ.get("GROCY_DEFAULT_BEST_BEFORE_DAYS")
X_RapidAPI_Key = os.environ.get("X_RapidAPI_Key") X_RapidAPI_Key = os.environ.get("X_RapidAPI_Key")
@ -60,8 +61,8 @@ def add_product(dict_good, location):
"name": good_name, "name": good_name,
"description": "", "description": "",
"location_id": location_map[location], "location_id": location_map[location],
"qu_id_purchase": GROCY_DEFAULT_QUANTITY_UNIT_ID, "qu_id_purchase": GROCY_DEFAULT_QUANTITY_UNIT_ID_PURCHASE,
"qu_id_stock": GROCY_DEFAULT_QUANTITY_UNIT_ID, "qu_id_stock": GROCY_DEFAULT_QUANTITY_UNIT_ID_STOCK,
"default_best_before_days": GROCY_DEFAULT_BEST_BEFORE_DAYS, "default_best_before_days": GROCY_DEFAULT_BEST_BEFORE_DAYS,
"default_consume_location_id": location_map[location], "default_consume_location_id": location_map[location],
"move_on_open": "1", "move_on_open": "1",
@ -75,6 +76,7 @@ def add_product(dict_good, location):
data_grocy["default_best_before_days"] = best_before_days data_grocy["default_best_before_days"] = best_before_days
if location_: if location_:
data_grocy["location_id"] = location_ data_grocy["location_id"] = location_
data_grocy["default_consume_location_id"] = location_
# add product # add product
response_grocy = grocy.add_generic(EntityType.PRODUCTS, data_grocy) response_grocy = grocy.add_generic(EntityType.PRODUCTS, data_grocy)

View File

@ -8,7 +8,8 @@ services:
- GROCY_API_KEY=your-api-key - GROCY_API_KEY=your-api-key
- GROCY_URL=https://grocy.tunpok.com - GROCY_URL=https://grocy.tunpok.com
- GROCY_PORT=443 - GROCY_PORT=443
- GROCY_DEFAULT_QUANTITY_UNIT_ID=1 - GROCY_DEFAULT_QUANTITY_UNIT_ID_PURCHASE=2
- GROCY_DEFAULT_QUANTITY_UNIT_ID_STOCK=6
- GROCY_DEFAULT_BEST_BEFORE_DAYS=365 - GROCY_DEFAULT_BEST_BEFORE_DAYS=365
ports: ports:
- 9288:9288 - 9288:9288