Fault (code object of type 'DateTime' has no len()) occurred.
When trying to connect to an odoo database to create a sale order , Zapier throws an error:
File "/home/odoo/addons/odoo/odoo/addons/base/controllers/rpc.py", line 60, in xmlrpc_1 response = self._xmlrpc(service) File "/home/odoo/addons/odoo/odoo/addons/base/controllers/rpc.py", line 49, in _xmlrpc result = dispatch_rpc(service, method, params) File "/home/odoo/addons/odoo/odoo/http.py", line 139, in dispatch_rpc result = dispatch(method, params) File "/home/odoo/addons/odoo/odoo/service/model.py", line 41, in dispatch res = fn(db, uid, *params) File "/home/odoo/addons/odoo/odoo/service/model.py", line 94, in wrapper return f(dbname, *args, **kwargs) File "/home/odoo/addons/odoo/odoo/service/model.py", line 181, in execute res = execute_cr(cr, uid, obj, method, *args, **kw) File "/home/odoo/addons/odoo/odoo/service/model.py", line 165, in execute_cr result = odoo.api.call_kw(recs, method, args, kw) File "/home/odoo/addons/odoo/odoo/api.py", line 385, in call_kw result = _call_kw_model_create(method, model, args, kwargs) File "/home/odoo/addons/odoo/odoo/api.py", line 365, in _call_kw_model_create result = method(recs, *args, **kwargs) File "<decorator-gen-202>", line 2, in create File "/home/odoo/addons/odoo/odoo/api.py", line 314, in _model_create_single return create(self, arg) File "/home/odoo/addons/odoo/addons/crm/models/calendar.py", line 50, in create event = super(CalendarEvent, self).create(vals) File "<decorator-gen-123>", line 2, in create File "/home/odoo/addons/odoo/odoo/api.py", line 335, in _model_create_multi return create(self, [arg]) File "/home/odoo/addons/odoo/addons/calendar/models/calendar.py", line 1602, in create values['duration'] = self._get_duration(values['start'], values['stop']) File "/home/odoo/addons/odoo/addons/calendar/models/calendar.py", line 753, in _get_duration diff = fields.Datetime.from_string(stop) - fields.Datetime.from_string(start) File "/home/odoo/addons/odoo/odoo/fields.py", line 1821, in to_datetime return datetime.strptime(value, DATETIME_FORMAT[:len(value)-2]) TypeError: object of type 'DateTime' has no len()
You can also try reaching out to Odoo Support for possible guidance with using their app in Zaps.
Thank your for reply @Troy Tessalone ,
I think the issue is with Zapier. The order date field is automatically converted into a Datetime object, and that's causing the problem. Odoo expects this as a string and doesn't convert it on the fly, which is why this issue occurs. I can't use custom input either, and since it's a mandatory field, I can't skip it. I've tried using the Zapier Formatter, but it doesn't help.
Is there any way to solve this issue?
Thanks in advance.
@Nazeer
For us to have more info, post screenshots with how your Zap step is configured in EDIT mode so we can see the field types and field descriptions/tooltips from the field label.
This is my zap step when ever new order created in shopify i need to replicate that in odoo.sh as well. i have issue in Order Date. so try to convert it as “YYYY-MM-DD” format. Also tried to convert as string format but no use.
This is issue get :
Failed to create a create record in Odoo ERP Self Hosted (Legacy)
Fault (code object of type 'DateTime' has no len()) occurred. Message: Traceback (most recent call last): File "/home/odoo/src/odoo/odoo/addons/base/controllers/rpc.py", line 81, in xmlrpc_1 response = self._xmlrpc(service) File "/home/odoo/src/odoo/odoo/addons/base/controllers/rpc.py", line 70, in _xmlrpc result = dispatch_rpc(service, method, params) File "/home/odoo/src/odoo/odoo/http.py", line 141, in dispatch_rpc result = dispatch(method, params) File "/home/odoo/src/odoo/odoo/service/model.py", line 41, in dispatch res = fn(db, uid, *params) File "/home/odoo/src/odoo/odoo/service/model.py", line 94, in wrapper return f(dbname, *args, **kwargs) File "/home/odoo/src/odoo/odoo/service/model.py", line 176, in execute res = execute_cr(cr, uid, obj, method, *args, **kw) File "/home/odoo/src/odoo/odoo/service/model.py", line 160, in execute_cr result = odoo.api.call_kw(recs, method, args, kw) File "/home/odoo/src/odoo/odoo/api.py", line 469, in call_kw result = _call_kw_model_create(method, model, args, kwargs) File "/home/odoo/src/odoo/odoo/api.py", line 447, in _call_kw_model_create result = method(recs, *args, **kwargs) File "<decorator-gen-304>", line 2, in create File "/home/odoo/src/odoo/odoo/api.py", line 417, in _model_create_multi return create(self, earg]) File "/home/odoo/src/odoo/addons/base_automation/models/base_automation.py", line 321, in create records = create.origin(self.with_env(actions.env), vals_list, **kw) File "<decorator-gen-289>", line 2, in create File "/home/odoo/src/odoo/odoo/api.py", line 398, in _model_create_single return self.browse().concat(*(create(self, vals) for vals in arg)) File "/home/odoo/src/odoo/odoo/api.py", line 398, in <genexpr> return self.browse().concat(*(create(self, vals) for vals in arg)) File "/home/odoo/src/odoo/addons/sale_stock/models/sale_order.py", line 96, in create return super().create(vals) File "<decorator-gen-280>", line 2, in create File "/home/odoo/src/odoo/odoo/api.py", line 395, in _model_create_single return create(self, arg) File "/home/odoo/src/odoo/addons/sale/models/sale_order.py", line 556, in create result = super(SaleOrder, self).create(vals) File "<decorator-gen-127>", line 2, in create File "/home/odoo/src/odoo/odoo/api.py", line 417, in _model_create_multi return create(self, earg]) File "/home/odoo/src/odoo/addons/mail/models/mail_thread.py", line 265, in create threads = super(MailThread, self).create(vals_list) File "<decorator-gen-69>", line 2, in create File "/home/odoo/src/odoo/odoo/api.py", line 418, in _model_create_multi return create(self, arg) File "/home/odoo/src/odoo/odoo/addons/base/models/ir_fields.py", line 613, in create recs = super().create(vals_list) File "<decorator-gen-15>", line 2, in create File "/home/odoo/src/odoo/odoo/api.py", line 418, in _model_create_multi return create(self, arg) File "/home/odoo/src/odoo/odoo/models.py", line 4095, in create records = self._create(data_list) File "/home/odoo/src/odoo/odoo/models.py", line 4224, in _create cache_value = field.convert_to_cache(value, record) File "/home/odoo/src/odoo/odoo/fields.py", line 2058, in convert_to_cache return self.to_datetime(value) File "/home/odoo/src/odoo/odoo/fields.py", line 2038, in to_datetime return datetime.strptime(value, DATETIME_FORMATE:len(value)-2]) TypeError: object of type 'DateTime' has no len()
@Nazeer
Try adding this second Formatter step:
Formatter > Text > Default Value
This should return a string
@Troy Tessalone
I have followed your suggestion, but I am still facing the same issue. The problem isn't the value type we pass in the order field; it's how Zapier passes the value to Odoo.
When Zapier sends data to Odoo, it wraps the value with an extra tag like this:
I have opened a ticket with Zapier support. I will update the chat if I receive a solution, either from my side or from Zapier support.
I kindly request everyone facing the same issue to raise a ticket with Zapier. This problem has been occurring for more than a year, and it still hasn't been resolved.
@Nazeer
Most Zap app integrations are created and maintained by the app developer using the Zapier Developer Platform.
Hopefully Zapier Support can configure if Odoo or Zapier managed the Odoo ERP Self Hosted Zap app integration.
If it is Odoo, then it would be the responsibility of Odoo to fix their Zap app integration, so you may want to contact Odoo Support.
Hi @Nazeer,
We just wanted to see how everything is going with your Zap. Did Troy's recommendation get the job done? Feel free to reach out if you need further assistance with your Zap. We're glad to address any concerns and assist you.