Currently I add “Time” as a filedtype in my doctype(Service2) of my custom app(seva_management). When I create new document and fills the values in fields except “Time” and save. It automatically takes the current time. This feature I want to stop. How I can achieve this?
Hey @NCP This code is banning the autofilling of end_time as time but my requirement is i want to fill it manually. Currently if this field end_time i keep empty and save the documnet it automatically takes current time. But i want to fill it manually and if i do not fill it manually then only it should be banned.
How can i do that?
What exactly do you need? Could you provide a video or image? Also, could you explain the specific problem you’re facing? If it’s a standard document type, you can override it, but if it’s a custom one, you can adjust it to fit your needs.
Let’s say you have 2 time fields in any doctype. For ex: Start Time & End Time.
When you fill only Start time, End time should be null, but if no value is provided then it is taking current time.
According to what @Sandeep_Kakde said, the script will appear like this:
def before_save(doc, method):
if doc.start_time and not doc.end_time:
doc.end_time = None
elif not doc.start_time and not doc.end_time:
doc.end_time = frappe.utils.now_datetime()
I agree with you. When you save the doctype, it automatically sets the default value if the field type is “Time.” Similarly, this applies to the field type “Int” where it sets the value to 0. In your situation, it seems that the default current time value is being set.