Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ Example::
utm = custom_field.UrlCustomField("UTM метка")
delivery_type = custom_field.SelectCustomField("Способ доставки")
address = custom_field.TextCustomField("Адрес")
date = custom_field.DateCustomField(
"Дата платежа")

my_lead = Lead.objects.get(object_id=33462781)
my_lead.date = "10.12.2025" # дату можно указать в виде строки День.Месяц.Год

Однако мапинг всех кастомных полей дело утоминетльное,
поэтому для генерации файла с готовым мапингом есть команда::
Expand Down
6 changes: 5 additions & 1 deletion amocrm/v2/entity/custom_field.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections import namedtuple
from datetime import datetime
from datetime import datetime, timezone

from .. import fields, manager, model
from ..interaction import GenericInteraction
Expand Down Expand Up @@ -244,6 +244,10 @@ def on_get(self, values):
def on_set(self, value):
if isinstance(value, datetime):
value = value.timestamp()
if isinstance(value, str):
date_obj = datetime.strptime(value, "%d.%m.%Y")
date_obj_utc = date_obj.replace(tzinfo=timezone.utc)
value = date_obj_utc.strftime("%Y-%m-%dT%H:%M:%S%z")
return super().on_set(value)


Expand Down
2 changes: 2 additions & 0 deletions amocrm/v2/interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ def create(self, data):

def update(self, object_id, data):
path = "{}/{}".format(self._get_path(), object_id)
for item in data['custom_fields_values']:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Поправь пожалйста тест https://github.com/Krukov/amocrm_api/actions/runs/5716884646/job/15494368967?pr=99#step:5:89

и можно еще попросить использовать только двойные кавычки

item.pop('is_computed', None)
response, status = self.request("patch", path, data=data)
if status == 400:
raise exceptions.ValidationError(response)
Expand Down