New Field creation bug on timesheet details doctype

Information about bug

I am trying to add Date Worked Date field to the Timesheet Detail doctype and it keeps giving this error because of the hours float field.

I do not get this error when I updated any existing fields ONLY when i try to add a new field to the this doctype.

Module

projects

Version

Frappe - 15.70.0
ERPNext - 15.65.1

Installation method

docker

Relevant log output / Stack trace / Full Error Message.

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 115, in application
    response = frappe.api.handle(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/__init__.py", line 49, in handle
    data = endpoint(**arguments)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call
    return frappe.handler.handle()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 51, in handle
    data = execute_cmd(cmd)
           ^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 84, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 1751, in call
    return fn(*args, **newargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 334, in run_doc_method
    response = doc.run_method(method)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1007, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1367, in composer
    return composed(self, method, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1349, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1004, in fn
    return method_object(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/custom/doctype/customize_form/customize_form.py", line 231, in save_customization
    self.update_custom_fields()
  File "apps/frappe/frappe/custom/doctype/customize_form/customize_form.py", line 461, in update_custom_fields
    self.add_custom_field(df, i)
  File "apps/frappe/frappe/custom/doctype/customize_form/customize_form.py", line 480, in add_custom_field
    d.insert()
  File "apps/frappe/frappe/model/document.py", line 334, in insert
    self.run_post_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1173, in run_post_save_methods
    self.run_method("on_update")
  File "apps/frappe/frappe/model/document.py", line 1007, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1367, in composer
    return composed(self, method, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1349, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1004, in fn
    return method_object(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/custom/doctype/custom_field/custom_field.py", line 213, in on_update
    frappe.db.updatedb(self.dt)
  File "apps/frappe/frappe/database/mariadb/database.py", line 463, in updatedb
    db_table.sync()
  File "apps/frappe/frappe/database/schema.py", line 46, in sync
    self.alter()
  File "apps/frappe/frappe/database/mariadb/schema.py", line 67, in alter
    col.build_for_alter_table(self.current_columns.get(col.fieldname.lower()))
  File "apps/frappe/frappe/database/schema.py", line 244, in build_for_alter_table
    self.default_changed(current_def)
  File "apps/frappe/frappe/database/schema.py", line 259, in default_changed
    return self.default_changed_for_decimal(current_def)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/database/schema.py", line 299, in default_changed_for_decimal
    return float(current_def["default"]) != float(self.default)
                                            ^^^^^^^^^^^^^^^^^^^
ValueError: could not convert string to float: 'hours'

https://discuss.frappe.io/t/unable-to-save-doctype-valueerror-could-not-convert-string-to-float

I check the schema but didnt find anything unusual:

+---------------------+---------------+------+-----+-------------+-------+
| Field               | Type          | Null | Key | Default     | Extra |
+---------------------+---------------+------+-----+-------------+-------+
| name                | varchar(140)  | NO   | PRI | NULL        |       |
| creation            | datetime(6)   | YES  |     | NULL        |       |
| modified            | datetime(6)   | YES  |     | NULL        |       |
+---------------------+---------------+------+-----+-------------+-------+
| Field               | Type          | Null | Key | Default     | Extra |
+---------------------+---------------+------+-----+-------------+-------+
| name                | varchar(140)  | NO   | PRI | NULL        |       |
| creation            | datetime(6)   | YES  |     | NULL        |       |
| modified            | datetime(6)   | YES  |     | NULL        |       |
+---------------------+---------------+------+-----+-------------+-------+
| Field               | Type          | Null | Key | Default     | Extra |
+---------------------+---------------+------+-----+-------------+-------+
| name                | varchar(140)  | NO   | PRI | NULL        |       |
| creation            | datetime(6)   | YES  |     | NULL        |       |
| modified            | datetime(6)   | YES  |     | NULL        |       |
| modified_by         | varchar(140)  | YES  |     | NULL        |       |
| owner               | varchar(140)  | YES  |     | NULL        |       |
| docstatus           | int(1)        | NO   |     | 0           |       |
| idx                 | int(8)        | NO   |     | 0           |       |
| activity_type       | varchar(140)  | YES  |     | NULL        |       |
| from_time           | datetime(6)   | YES  |     | NULL        |       |
| description         | text          | YES  |     | NULL        |       |
| expected_hours      | decimal(21,9) | NO   |     | 0.000000000 |       |
| to_time             | datetime(6)   | YES  |     | NULL        |       |
| hours               | decimal(21,9) | NO   |     | 0.000000000 |       |
| completed           | int(1)        | NO   |     | 0           |       |
| project             | varchar(140)  | YES  |     | NULL        |       |
| project_name        | varchar(140)  | YES  |     | NULL        |       |
| task                | varchar(140)  | YES  |     | NULL        |       |
| is_billable         | int(1)        | NO   |     | 0           |       |
| sales_invoice       | varchar(140)  | YES  |     | NULL        |       |
| billing_hours       | decimal(21,9) | NO   |     | 0.000000000 |       |
| base_billing_rate   | decimal(21,9) | NO   |     | 0.000000000 |       |
| base_billing_amount | decimal(21,9) | NO   |     | 0.000000000 |       |
| base_costing_rate   | decimal(21,9) | NO   |     | 0.000000000 |       |
| base_costing_amount | decimal(21,9) | NO   |     | 0.000000000 |       |
| billing_rate        | decimal(21,9) | NO   |     | 0.000000000 |       |
| billing_amount      | decimal(21,9) | NO   |     | 0.000000000 |       |
| costing_rate        | decimal(21,9) | NO   |     | 0.000000000 |       |
| costing_amount      | decimal(21,9) | NO   |     | 0.000000000 |       |
| parent              | varchar(140)  | YES  | MUL | NULL        |       |
| parentfield         | varchar(140)  | YES  |     | NULL        |       |
| parenttype          | varchar(140)  | YES  |     | NULL        |       |
+---------------------+---------------+------+-----+-------------+-------+

Hi,

Tried on a v16 docker and 15.71.0 / 15.65.4 using the UI , custom form, details add field and it went without any errors. Are there any other customizations other than adding a field?

MariaDB [_c4121001e0e2317d]> DESCRIBE tabTimesheet Detail;
±--------------------±--------------±-----±----±------------±------+
| Field | Type | Null | Key | Default | Extra |
±--------------------±--------------±-----±----±------------±------+
| name | varchar(140) | NO | PRI | NULL | |
| creation | datetime(6) | YES | | NULL | |
| modified | datetime(6) | YES | | NULL | |
| modified_by | varchar(140) | YES | | NULL | |
| owner | varchar(140) | YES | | NULL | |
| docstatus | tinyint(4) | NO | | 0 | |
| idx | int(11) | NO | | 0 | |
| activity_type | varchar(140) | YES | | NULL | |
| from_time | datetime(6) | YES | | NULL | |
| description | text | YES | | NULL | |
| expected_hours | decimal(21,9) | NO | | 0.000000000 | |
| to_time | datetime(6) | YES | | NULL | |
| hours | decimal(21,9) | NO | | 0.000000000 | |
| completed | tinyint(4) | NO | | 0 | |
| project | varchar(140) | YES | | NULL | |
| project_name | varchar(140) | YES | | NULL | |
| task | varchar(140) | YES | | NULL | |
| is_billable | tinyint(4) | NO | | 0 | |
| sales_invoice | varchar(140) | YES | | NULL | |
| billing_hours | decimal(21,9) | NO | | 0.000000000 | |
| base_billing_rate | decimal(21,9) | NO | | 0.000000000 | |
| base_billing_amount | decimal(21,9) | NO | | 0.000000000 | |
| base_costing_rate | decimal(21,9) | NO | | 0.000000000 | |
| base_costing_amount | decimal(21,9) | NO | | 0.000000000 | |
| billing_rate | decimal(21,9) | NO | | 0.000000000 | |
| billing_amount | decimal(21,9) | NO | | 0.000000000 | |
| costing_rate | decimal(21,9) | NO | | 0.000000000 | |
| costing_amount | decimal(21,9) | NO | | 0.000000000 | |
| parent | varchar(140) | YES | MUL | NULL | |
| parentfield | varchar(140) | YES | | NULL | |
| parenttype | varchar(140) | YES | | NULL | |
| custom_date_worked | decimal(21,9) | NO | | 0.000000000 | |
±--------------------±--------------±-----±----±------------±------+

No other customization. Just adding the fields. Im not sure what the error means.