fix 1c update
This commit is contained in:
parent
339bfd390f
commit
338f716835
|
@ -26,7 +26,7 @@ services:
|
|||
- redis
|
||||
command: poetry run celery -A mns beat --loglevel=info
|
||||
redis:
|
||||
image: redis:latest
|
||||
image: ci.svs-tech.pro/redis:latest
|
||||
restart: always
|
||||
networks:
|
||||
- minimal_bridge
|
||||
|
|
|
@ -8,4 +8,4 @@ def update_calcmodel_prices():
|
|||
"""
|
||||
Задача для обновления цен в модели.
|
||||
"""
|
||||
update_ref1c_prices.delay("CalcModelRef1CConnection")
|
||||
update_ref1c_prices.delay("CalcModelRef1CConnection", "kupizabor")
|
||||
|
|
|
@ -82,7 +82,7 @@ def fetch_price_from_1c(ref_key):
|
|||
|
||||
|
||||
@shared_task
|
||||
def update_ref1c_prices(model_name, ref1c_field="ref1c"):
|
||||
def update_ref1c_prices(model_name, app_label, ref1c_field="ref1c"):
|
||||
"""
|
||||
Универсальная периодическая задача для обновления цен в любой модели,
|
||||
связанной с Ref1C через указанные поля.
|
||||
|
@ -94,7 +94,7 @@ def update_ref1c_prices(model_name, ref1c_field="ref1c"):
|
|||
|
||||
try:
|
||||
# Получаем модель динамически
|
||||
Model = apps.get_model(app_label="skamejka", model_name=model_name)
|
||||
Model = apps.get_model(app_label, model_name=model_name)
|
||||
connections = Model.objects.select_related(ref1c_field).all()
|
||||
logger.info(f"Найдено {len(connections)} связей модели {model_name} с Ref1C.")
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
from celery import shared_task
|
||||
from mns.utils import update_ref1c_prices
|
||||
|
||||
|
||||
@shared_task
|
||||
def update_calcmodel_prices():
|
||||
"""
|
||||
Задача для обновления цен в модели SkamejkaConnection.
|
||||
"""
|
||||
update_ref1c_prices.delay("SkamejkaConnection")
|
||||
update_ref1c_prices.delay("SkamejkaConnection", "skamejka")
|
||||
|
|
Loading…
Reference in New Issue