V12 TypeError: can't compare datetime.date to unicode

I haven’t seen any post or comment about this so I figured I should create a subject for it.

After a fresh v11 to v12 upgrade - this is the error I receive when trying to create an Auto Repeat

Anybody else getting this error and having a solution ?

Likewise, anyone experiencing the same issue ? :slight_smile:

I have no choice. I must post again…

Really, nobody can reply regarding this subject ? not here ? not on GitHub ? Nobody ?

You have posted lots but seem to miss the point - to troubleshoot first you best give context - one line is scant to discover the problem to help your case

Have you found a traceback of your issue to post here?

Whatever you yourself have found and tried would help please

edit: reported here v12 Auto Repeat - TypeError: can’t compare datetime.date to unicode · Issue #18648 · frappe/erpnext · GitHub

Thank you for taking action Clark and for guiding me to the logs…

Here’s what I managed to pull out of frappe.log:

[ERROR] 2019-08-14 21:41:23,896 | /home/frappe/frappe-bench/apps/frappe/frappe/app.py:
Site: (I deleted the website name)
Form Dict: {
 "action": "Save",
 "cmd": "frappe.desk.form.save.savedocs",
 "doc": "{\"docstatus\":0,\"doctype\":\"Auto Repeat\",\"name\":\"New Auto Repeat 1\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"(I DELETED THE EMAIL ADDRESS)\",\"disabled\":0,\"start_date\":\"2019-08-15\",\"frequency\":\"Monthly\",\"repe$
}
Request Error
Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 60, in application
    response = frappe.api.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/api.py", line 55, in handle
    return frappe.handler.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 21, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 56, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1036, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/save.py", line 22, in savedocs
    doc.save()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 271, in save
    return self._save(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 294, in _save
    self.insert()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 221, in insert
    self.run_method("before_insert")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 786, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1055, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1038, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 780, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/automation/doctype/auto_repeat/auto_repeat.py", line 37, in before_insert
    if start_date <= today_date:
TypeError: can't compare datetime.date to unicode

Any opinions here guys ? :slight_smile:

An ongoing issue which I don’t know if it’s something I can fix or perhaps a bug.

hi @Iulian_Olaru ,
Can you show…how do you set the date to these two variables start_date and today_date ?
Becoz you are comparing both date and time…!

Hey Arokia,
Here’s a screenshot of how the auto repeat settings look.

@Iulian_Olaru Check whether it is a date field or date and time field and then if it is date field try to get these two dates in a variable and use in the if condition…it will work.

Well that sounds out of the ordinary - these fields are supposed to have the correct settings as they’re native directly from the system.

I will check but I don’t understand what to do regarding getting the dates in a variable etc…

LATE EDIT: In doctype the date fields of the auto repeat appear to be date fields, not date and time

What have you mentioned as today_date?

Obviously the date of today haha

Should it be something else ? perhaps the day of the task start date ?

LATE EDIT: I tried this also - error is the same

@Iulian_Olaru yes its your todays date but want i mean is in what format are you getting the todays date?
today_date = now_datetime().strftime(DATE_FORMAT)
from frappe.utils import flt, DATE_FORMAT,TIME_FORMAT,nowdate
Use this and try…!

Sorry because I’m not as advanced to understand what to do with the code you wrote…

Please tell me where to put it haha… your assistance is very much appreciated !

from frappe.utils import flt, DATE_FORMAT,TIME_FORMAT,nowdate
copy and paste the above code in top import function.
today_date = now_datetime().strftime(DATE_FORMAT)
if start_date <= today_date:
Use like this…!!hope you understand.

No unfortunately I’ve never done such a setting… I don’t know where frappe.utils is … I am so sorry :-))

I will keep looking to try to discover it.

@Iulian_Olaru let me help you.can you share your screen

what did you write in code for today_date? the format matters a lot

Yes I can. Let me know what you need to share. Teamviewer etc.

Thank you again :slight_smile:

yes. send me the teamviewer id?