Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Требуется помощь в создании сделки #110

Open
kpak3h opened this issue Dec 18, 2023 · 1 comment
Open

Требуется помощь в создании сделки #110

kpak3h opened this issue Dec 18, 2023 · 1 comment

Comments

@kpak3h
Copy link

kpak3h commented Dec 18, 2023

Добрый день!
Не получается создать сделку, чаще всего ошибка "400"

Пробовал создать что-то типо подобного, но не выходит
lead = Lead.objects.create(pepiline=1111111, phone=1111111, name=11111)
lead.save()

С АПИ до этого не работал, возможно нужно добавить поля или что-то ещё? Посмотрел темы до этого и не особо понял

@NikolaiKryshnev
Copy link

NikolaiKryshnev commented Dec 29, 2023

@kpak3h
``def create_lead_in_amocrm(_process, _person, _document, _source_language, _target_language, _is_sworn, file_id):
class Lead(_Lead):
# Находим кастомные поля
process = custom_field.TextCustomField("process")
person = custom_field.TextCustomField("person")
document_type = custom_field.TextCustomField("document_type")
source_language = custom_field.TextCustomField("source_language")
target_language = custom_field.TextCustomField("target_language")
is_sworn = custom_field.TextCustomField("is_sworn")
document_file = custom_field.TextCustomField("document_file")

	try:
		# Создание новой сделки
		new_lead = Lead(
				name="Новая сделка 10",  # Название нужно будет генерировать новое
				pipeline=7567610,  # Воронка
				status=62673734,  # Этап
		)
		# Добавление значений в кастомные поля
		new_lead.process = _process
		new_lead.person = _person
		new_lead.document_type = _document
		new_lead.source_language = _source_language
		new_lead.target_language = _target_language
		new_lead.is_sworn = _is_sworn

		#  Метод для сохранения сделки
		new_lead.save()

		

		
		
		
		return jsonify({"translation_status": "accepted"})

	except Exception as e:
		print(f"Error creating lead: {e}")
		return False

``

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants