Custom Button function not working

log_test.get(“log_test_machines”):

to get log_test_machines child table data from log_test doctype

updated code :

import json
import frappe
from frappe import _, msgprint
from frappe.model.mapper import get_mapped_doc
from frappe.query_builder.functions import Sum
from frappe.utils import cint, cstr, flt, get_link_to_form, getdate, new_line_sep, nowdate
from frappe.model.document import Document

class Log_Test(Document):
pass

@frappe.whitelist()
def make_log_schedule(source_name, target_doc=None):
“”“Creates a new Log_Schedule document based on a Log_Test document and its child tables.”“”

print(f"source_name: {source_name}")  # Check the value of source_name

log_test = frappe.get_doc("Log_Test", source_name)

print(f"log_test: {log_test}")  # Check the value of log_test

log_schedule = frappe.new_doc("Log_Schedule")

log_schedule.update({
    "machine_related_readings": log_schedule.machine_related_readings,
    "other_measurable_readings": log_schedule.other_measurable_readings,
})

for machine in log_test.get("log_test_machines"):
    new_machine = frappe.new_doc("Log_Schedule_Machines")
    new_machine.log_test = log_schedule.name
    new_machine.machine_group = machine.machine_group
    new_machine.unit_measure = machine.unit_measure
    new_machine.unit = machine.unit
    new_machine.min_max = machine.min_max
    new_machine.save()
    log_schedule.append("log_schedule_machines", new_machine)

for reading in log_test.get("log_test_readings"):
    new_reading = frappe.new_doc("Log_Schedule_Readings")
    new_reading.log_test = log_schedule.name
    new_reading.unit_measure = reading.unit_measure
    new_reading.unit = reading.unit
    new_reading.min_max = reading.min_max
    new_reading.save()
    log_schedule.append("log_schedule_readings", new_reading)

# Save the new Log_Schedule document
log_schedule.save()

your table field names are

  1. machine_related_readings
  2. other_measurable_readings

but what is log_test_machines which field is this

this is the names of the child tables
machine_related_readings
other_measurable_readings are the names of the table fields

and log_test_machines and log_test_readings are name of child doctypes

you need to add

 for machine in log_test.get("machine_related_readings"):

instead of log_test_machines.

changed it but it still not fetching data

what is the error?

Error: Value missing for None: parent

Error: Value missing for None: parenttype

{
“exception”: “frappe.exceptions.MandatoryError: [Log_Schedule_Machines, 26b6855e75]: parent, parenttype”,
“exc_type”: “MandatoryError”,
“_exc_source”: “workwings (app)”,
“exc”: “["Traceback (most recent call last):\n File \"apps/frappe/frappe/app.py\", line 110, in application\n response = frappe.api.handle(request)\n File \"apps/frappe/frappe/api/init.py\", line 49, in handle\n data = endpoint(**arguments)\n File \"apps/frappe/frappe/api/v1.py\", line 36, in handle_rpc_call\n return frappe.handler.handle()\n File \"apps/frappe/frappe/handler.py\", line 49, in handle\n data = execute_cmd(cmd)\n File \"apps/frappe/frappe/handler.py\", line 85, in execute_cmd\n return frappe.call(method, **frappe.form_dict)\n File \"apps/frappe/frappe/init.py\", line 1682, in call\n return fn(*args, **newargs)\n File \"apps/frappe/frappe/utils/typing_validations.py\", line 31, in wrapper\n return func(*args, **kwargs)\n File \"apps/frappe/frappe/model/mapper.py\", line 36, in make_mapped_doc\n return method(source_name)\n File \"apps/frappe/frappe/utils/typing_validations.py\", line 31, in wrapper\n return func(*args, **kwargs)\n File \"apps/workwings/workwings/plcm/doctype/log_test/log_test.py\", line 37, in make_log_schedule\n new_machine.save()\n File \"apps/frappe/frappe/model/document.py\", line 331, in save\n return self._save(*args, **kwargs)\n File \"apps/frappe/frappe/model/document.py\", line 353, in _save\n return self.insert()\n File \"apps/frappe/frappe/model/document.py\", line 286, in insert\n self._validate()\n File \"apps/frappe/frappe/model/document.py\", line 568, in _validate\n self._validate_mandatory()\n File \"apps/frappe/frappe/model/document.py\", line 904, in _validate_mandatory\n raise frappe.MandatoryError(\nfrappe.exceptions.MandatoryError: [Log_Schedule_Machines, 26b6855e75]: parent, parenttype\n"]”,
“_server_messages”: “["{\"message\": \"Error: Value missing for None: parent\", \"title\": \"Message\"}", "{\"message\": \"Error: Value missing for None: parenttype\", \"title\": \"Message\"}"]”
}

i think its from another line
show me the updated code

import json
import frappe
from frappe import _, msgprint
from frappe.model.mapper import get_mapped_doc
from frappe.query_builder.functions import Sum
from frappe.utils import cint, cstr, flt, get_link_to_form, getdate, new_line_sep, nowdate
from frappe.model.document import Document

class Log_Test(Document):
pass

@frappe.whitelist()
def make_log_schedule(source_name, target_doc=None):
“”“Creates a new Log_Schedule document based on a Log_Test document and its child tables.”“”

print(f"source_name: {source_name}")  # Check the value of source_name

log_test = frappe.get_doc("Log_Test", source_name)

print(f"log_test: {log_test}")  # Check the value of log_test

log_schedule = frappe.new_doc("Log_Schedule")

log_schedule.update({
    "machine_related_readings": log_schedule.machine_related_readings,
    "other_measurable_readings": log_schedule.other_measurable_readings,
})

for machine in log_test.get("machine_related_readings"):
    new_machine = frappe.new_doc("Log_Schedule_Machines")
    new_machine.log_test = log_schedule.name
    new_machine.machine_group = machine.machine_group
    new_machine.unit_measure = machine.unit_measure
    new_machine.unit = machine.unit
    new_machine.min_max = machine.min_max
    new_machine.save()
    log_schedule.append("log_schedule_machines", new_machine)

for reading in log_test.get("other_measurable_readings"):
    new_reading = frappe.new_doc("Log_Schedule_Readings")
    new_reading.log_test = log_schedule.name
    new_reading.unit_measure = reading.unit_measure
    new_reading.unit = reading.unit
    new_reading.min_max = reading.min_max
    new_reading.save()
    log_schedule.append("log_schedule_readings", new_reading)

# Save the new Log_Schedule document
log_schedule.save()

Do i need to add some code in log_schedule doctype python file also to retrive the data

No you missed some mandatory fields in the log schedule machines

all mandatory fields are filled

I mean in the code

JSON files of all the related doctypes

Log_Test
{
“actions”: ,
“allow_auto_repeat”: 1,
“allow_rename”: 1,
“autoname”: “format:{plant}-{division}-{subarea}-{YYYY}-{#####}”,
“creation”: “2024-03-29 11:20:14.770175”,
“doctype”: “DocType”,
“engine”: “InnoDB”,
“field_order”: [
“plant”,
“column_break_keim”,
“division”,
“column_break_hqer”,
“department”,
“column_break_ztzi”,
“area”,
“column_break_lhcj”,
“subarea”,
“section_break_nibt”,
“maintenance”,
“column_break_youe”,
“maintenance_type”,
“section_break_vzmf”,
“log_sheet_name”,
“section_break_qaqk”,
“machine_related_readings”,
“section_break_smqs”,
“other_measurable_readings”
],
“fields”: [
{
“fieldname”: “plant”,
“fieldtype”: “Link”,
“in_list_view”: 1,
“in_standard_filter”: 1,
“label”: “Plant”,
“options”: “Plant_Master”,
“reqd”: 1,
“set_only_once”: 1
},
{
“fieldname”: “column_break_keim”,
“fieldtype”: “Column Break”
},
{
“fieldname”: “division”,
“fieldtype”: “Link”,
“in_list_view”: 1,
“in_standard_filter”: 1,
“label”: “Division”,
“options”: “Division_Master”,
“reqd”: 1,
“set_only_once”: 1
},
{
“fieldname”: “column_break_hqer”,
“fieldtype”: “Column Break”
},
{
“fieldname”: “department”,
“fieldtype”: “Link”,
“in_list_view”: 1,
“in_standard_filter”: 1,
“label”: “Department”,
“options”: “Department”,
“reqd”: 1,
“set_only_once”: 1
},
{
“fieldname”: “column_break_ztzi”,
“fieldtype”: “Column Break”
},
{
“fieldname”: “area”,
“fieldtype”: “Link”,
“in_list_view”: 1,
“in_standard_filter”: 1,
“label”: “Area”,
“options”: “Area_Master”,
“reqd”: 1,
“set_only_once”: 1
},
{
“fieldname”: “column_break_lhcj”,
“fieldtype”: “Column Break”
},
{
“fieldname”: “subarea”,
“fieldtype”: “Link”,
“in_list_view”: 1,
“in_standard_filter”: 1,
“label”: “Subarea”,
“options”: “Subarea_Master”,
“reqd”: 1,
“set_only_once”: 1
},
{
“fieldname”: “section_break_nibt”,
“fieldtype”: “Section Break”
},
{
“fieldname”: “maintenance”,
“fieldtype”: “Link”,
“label”: “Maintenance”,
“options”: “Maintenance”,
“reqd”: 1,
“set_only_once”: 1
},
{
“fieldname”: “column_break_youe”,
“fieldtype”: “Column Break”
},
{
“fetch_from”: “maintenance.maintenance_type”,
“fieldname”: “maintenance_type”,
“fieldtype”: “Data”,
“label”: “Maintenance Type”,
“read_only”: 1
},
{
“fieldname”: “section_break_vzmf”,
“fieldtype”: “Section Break”
},
{
“fieldname”: “log_sheet_name”,
“fieldtype”: “Data”,
“in_standard_filter”: 1,
“label”: “Log Sheet Name”,
“reqd”: 1,
“set_only_once”: 1
},
{
“fieldname”: “section_break_qaqk”,
“fieldtype”: “Section Break”
},
{
“fieldname”: “machine_related_readings”,
“fieldtype”: “Table”,
“label”: “Machine Related Readings”,
“options”: “Log_Test_Machines”
},
{
“fieldname”: “section_break_smqs”,
“fieldtype”: “Section Break”
},
{
“fieldname”: “other_measurable_readings”,
“fieldtype”: “Table”,
“label”: “Other Measurable Readings”,
“options”: “Log_Test_Readings”
}
],
“index_web_pages_for_search”: 1,
“links”: ,
“modified”: “2024-04-01 16:02:08.244868”,
“modified_by”: “Administrator”,
“module”: “PLCM”,
“name”: “Log_Test”,
“naming_rule”: “Expression”,
“owner”: “Administrator”,
“permissions”: [
{
“create”: 1,
“delete”: 1,
“email”: 1,
“export”: 1,
“print”: 1,
“read”: 1,
“report”: 1,
“role”: “System Manager”,
“share”: 1,
“write”: 1
},
{
“email”: 1,
“export”: 1,
“print”: 1,
“read”: 1,
“report”: 1,
“role”: “Log Entry”,
“share”: 1
}
],
“sort_field”: “modified”,
“sort_order”: “DESC”,
“states”: ,
“track_changes”: 1
}

Log_Test_Machines
{
“actions”: ,
“allow_rename”: 1,
“creation”: “2024-03-29 11:15:17.646355”,
“doctype”: “DocType”,
“editable_grid”: 1,
“engine”: “InnoDB”,
“field_order”: [
“machine_group”,
“machine”,
“unit_measure”,
“unit”,
“min_max”,
“current_value”
],
“fields”: [
{
“fieldname”: “machine_group”,
“fieldtype”: “Link”,
“in_list_view”: 1,
“label”: “Machine Group”,
“options”: “Machine_Group”,
“reqd”: 1,
“set_only_once”: 1
},
{
“fieldname”: “machine”,
“fieldtype”: “Link”,
“in_list_view”: 1,
“label”: “Machine”,
“options”: “Machine_Master”
},
{
“fieldname”: “unit_measure”,
“fieldtype”: “Link”,
“in_list_view”: 1,
“label”: “Unit Measure”,
“options”: “UOM_Measure”,
“reqd”: 1,
“set_only_once”: 1
},
{
“fieldname”: “unit”,
“fieldtype”: “Link”,
“in_list_view”: 1,
“label”: “Unit”,
“options”: “UOM”,
“reqd”: 1,
“set_only_once”: 1
},
{
“fieldname”: “min_max”,
“fieldtype”: “Data”,
“in_list_view”: 1,
“label”: “Min Max”,
“reqd”: 1
},
{
“fieldname”: “current_value”,
“fieldtype”: “Data”,
“in_list_view”: 1,
“label”: “Current Value”
}
],
“index_web_pages_for_search”: 1,
“istable”: 1,
“links”: ,
“modified”: “2024-03-29 17:50:23.998642”,
“modified_by”: “Administrator”,
“module”: “PLCM”,
“name”: “Log_Test_Machines”,
“owner”: “Administrator”,
“permissions”: ,
“sort_field”: “modified”,
“sort_order”: “DESC”,
“states”:
}

Log_Test_Readings
{
“actions”: ,
“allow_rename”: 1,
“creation”: “2024-03-29 11:18:16.239388”,
“doctype”: “DocType”,
“editable_grid”: 1,
“engine”: “InnoDB”,
“field_order”: [
“machine_group”,
“machine”,
“unit_measure”,
“unit”,
“min_max”,
“current_value”
],
“fields”: [
{
“fieldname”: “machine_group”,
“fieldtype”: “Link”,
“label”: “Machine Group”,
“options”: “Machine_Group”,
“read_only”: 1
},
{
“fieldname”: “machine”,
“fieldtype”: “Link”,
“label”: “Machine”,
“options”: “Machine_Master”,
“read_only”: 1
},
{
“fieldname”: “unit_measure”,
“fieldtype”: “Link”,
“in_list_view”: 1,
“label”: “Unit Measure”,
“options”: “UOM_Measure”,
“reqd”: 1,
“set_only_once”: 1
},
{
“fieldname”: “unit”,
“fieldtype”: “Link”,
“in_list_view”: 1,
“label”: “Unit”,
“options”: “UOM”,
“reqd”: 1,
“set_only_once”: 1
},
{
“fieldname”: “min_max”,
“fieldtype”: “Data”,
“in_list_view”: 1,
“label”: “Min Max”,
“reqd”: 1
},
{
“fieldname”: “current_value”,
“fieldtype”: “Data”,
“in_list_view”: 1,
“label”: "Current Value "
}
],
“index_web_pages_for_search”: 1,
“istable”: 1,
“links”: ,
“modified”: “2024-03-29 17:57:14.488706”,
“modified_by”: “Administrator”,
“module”: “PLCM”,
“name”: “Log_Test_Readings”,
“owner”: “Administrator”,
“permissions”: ,
“sort_field”: “modified”,
“sort_order”: “DESC”,
“states”:
}

Log_Schedule
{
“actions”: ,
“allow_rename”: 1,
“autoname”: “format:{plant}-{division}-{subarea}-{YYYY}-{######}”,
“creation”: “2024-04-02 16:08:04.771585”,
“doctype”: “DocType”,
“engine”: “InnoDB”,
“field_order”: [
“section_break_yabb”,
“amended_from”,
“log_template”,
“section_break_hkdw”,
“plant”,
“column_break_ekjs”,
“division”,
“column_break_cahb”,
“department”,
“column_break_zuut”,
“area”,
“column_break_nmja”,
“subarea”,
“section_break_ucwt”,
“maintenance”,
“column_break_fkue”,
“maintenance_type”,
“section_break_ycrv”,
“machine_related_readings”,
“section_break_megm”,
“other_measurable_readings”
],
“fields”: [
{
“fieldname”: “section_break_yabb”,
“fieldtype”: “Section Break”
},
{
“fieldname”: “amended_from”,
“fieldtype”: “Link”,
“label”: “Amended From”,
“no_copy”: 1,
“options”: “Log_Schedule”,
“print_hide”: 1,
“read_only”: 1,
“search_index”: 1
},
{
“fieldname”: “log_template”,
“fieldtype”: “Link”,
“label”: “Log Template”,
“options”: “Log_Test”
},
{
“fieldname”: “section_break_hkdw”,
“fieldtype”: “Section Break”
},
{
“fetch_from”: “log_template.plant”,
“fieldname”: “plant”,
“fieldtype”: “Data”,
“label”: “Plant”,
“read_only”: 1
},
{
“fieldname”: “column_break_ekjs”,
“fieldtype”: “Column Break”
},
{
“fetch_from”: “log_template.division”,
“fieldname”: “division”,
“fieldtype”: “Data”,
“label”: “Division”,
“read_only”: 1
},
{
“fieldname”: “column_break_cahb”,
“fieldtype”: “Column Break”
},
{
“fetch_from”: “log_template.department”,
“fieldname”: “department”,
“fieldtype”: “Data”,
“label”: “Department”,
“read_only”: 1
},
{
“fieldname”: “column_break_zuut”,
“fieldtype”: “Column Break”
},
{
“fetch_from”: “log_template.area”,
“fieldname”: “area”,
“fieldtype”: “Data”,
“label”: “Area”,
“read_only”: 1
},
{
“fieldname”: “column_break_nmja”,
“fieldtype”: “Column Break”
},
{
“fetch_from”: “log_template.subarea”,
“fieldname”: “subarea”,
“fieldtype”: “Data”,
“label”: “Subarea”,
“read_only”: 1
},
{
“fieldname”: “section_break_ucwt”,
“fieldtype”: “Section Break”
},
{
“fetch_from”: “log_template.maintenance”,
“fieldname”: “maintenance”,
“fieldtype”: “Data”,
“label”: “Maintenance”,
“read_only”: 1
},
{
“fieldname”: “column_break_fkue”,
“fieldtype”: “Column Break”
},
{
“fetch_from”: “log_template.maintenance_type”,
“fieldname”: “maintenance_type”,
“fieldtype”: “Data”,
“label”: “Maintenance Type”,
“read_only”: 1
},
{
“fieldname”: “section_break_ycrv”,
“fieldtype”: “Section Break”
},
{
“columns”: 7,
“fieldname”: “machine_related_readings”,
“fieldtype”: “Table”,
“label”: “Machine Related Readings”,
“options”: “Log_Schedule_Machines”,
“width”: “2”
},
{
“fieldname”: “section_break_megm”,
“fieldtype”: “Section Break”
},
{
“fieldname”: “other_measurable_readings”,
“fieldtype”: “Table”,
“label”: “Other Measurable Readings”,
“options”: “Log_Schedule_Readings”
}
],
“index_web_pages_for_search”: 1,
“is_submittable”: 1,
“links”: ,
“modified”: “2024-04-09 17:43:04.273015”,
“modified_by”: “Administrator”,
“module”: “PLCM”,
“name”: “Log_Schedule”,
“naming_rule”: “Expression”,
“owner”: “Administrator”,
“permissions”: [
{
“create”: 1,
“delete”: 1,
“email”: 1,
“export”: 1,
“print”: 1,
“read”: 1,
“report”: 1,
“role”: “System Manager”,
“share”: 1,
“submit”: 1,
“write”: 1
}
],
“sort_field”: “modified”,
“sort_order”: “DESC”,
“states”:
}

Log_Schedule_Machines
{
“actions”: ,
“allow_rename”: 1,
“creation”: “2024-04-02 16:00:36.679239”,
“doctype”: “DocType”,
“editable_grid”: 1,
“engine”: “InnoDB”,
“field_order”: [
“machine_group”,
“machine”,
“unit_measure”,
“unit”,
“min_max”,
“current_value”,
“current_condition”
],
“fields”: [
{
“fieldname”: “machine_group”,
“fieldtype”: “Link”,
“in_list_view”: 1,
“label”: “Machine Group”,
“options”: “Machine_Group”,
“reqd”: 1
},
{
“fieldname”: “machine”,
“fieldtype”: “Link”,
“in_list_view”: 1,
“label”: “Machine”,
“options”: “Machine_Master”
},
{
“fieldname”: “unit_measure”,
“fieldtype”: “Link”,
“in_list_view”: 1,
“label”: “Unit Measure”,
“options”: “UOM_Measure”,
“reqd”: 1
},
{
“fieldname”: “unit”,
“fieldtype”: “Link”,
“in_list_view”: 1,
“label”: “Unit”,
“options”: “UOM”,
“reqd”: 1,
“width”: “1”
},
{
“fieldname”: “min_max”,
“fieldtype”: “Data”,
“in_list_view”: 1,
“label”: “Min Max”,
“width”: “1”
},
{
“fieldname”: “current_value”,
“fieldtype”: “Int”,
“in_list_view”: 1,
“label”: “Current Value”,
“width”: “1”
},
{
“fieldname”: “current_condition”,
“fieldtype”: “Select”,
“label”: “Current Condition”,
“options”: “Yes\nNo\nNormal\nAbnormal”
}
],
“index_web_pages_for_search”: 1,
“istable”: 1,
“links”: ,
“modified”: “2024-04-08 17:00:17.194263”,
“modified_by”: “Administrator”,
“module”: “PLCM”,
“name”: “Log_Schedule_Machines”,
“owner”: “Administrator”,
“permissions”: ,
“sort_field”: “modified”,
“sort_order”: “DESC”,
“states”:
}

Log_Schedule_Readings
{
“actions”: ,
“allow_rename”: 1,
“creation”: “2024-04-02 16:05:35.570081”,
“doctype”: “DocType”,
“editable_grid”: 1,
“engine”: “InnoDB”,
“field_order”: [
“unit_measure”,
“unit”,
“min_max”,
“current_value”,
“current_condition”
],
“fields”: [
{
“fieldname”: “unit_measure”,
“fieldtype”: “Link”,
“in_list_view”: 1,
“label”: “Unit Measure”,
“options”: “UOM_Measure”,
“reqd”: 1
},
{
“fieldname”: “unit”,
“fieldtype”: “Link”,
“in_list_view”: 1,
“label”: “Unit”,
“options”: “UOM”,
“reqd”: 1
},
{
“fieldname”: “min_max”,
“fieldtype”: “Data”,
“in_list_view”: 1,
“label”: “Min Max”,
“reqd”: 1
},
{
“fieldname”: “current_value”,
“fieldtype”: “Int”,
“in_list_view”: 1,
“label”: “Current Value”
},
{
“fieldname”: “current_condition”,
“fieldtype”: “Select”,
“in_list_view”: 1,
“label”: “Current Condition”,
“options”: “Yes\nNo\nNormal\nAbnormal”
}
],
“index_web_pages_for_search”: 1,
“istable”: 1,
“links”: ,
“modified”: “2024-04-08 16:57:28.241610”,
“modified_by”: “Administrator”,
“module”: “PLCM”,
“name”: “Log_Schedule_Readings”,
“owner”: “Administrator”,
“permissions”: ,
“sort_field”: “modified”,
“sort_order”: “DESC”,
“states”:
}

@Safvan_Ph
Is this fetching the machine field from the tables

because the field machine is not mandatory and empty ,should be filled after create schedule

Ok please try to include these lines in the code before new_machine.save()
add

new_machine.parent = log_schedule.name
new_machine.parenttype = "Log_Schedule"

Error: Value missing for None: parent

{
“exception”: “frappe.exceptions.MandatoryError: [Log_Schedule_Machines, 76c10838fa]: parent”,
“exc_type”: “MandatoryError”,
“_exc_source”: “workwings (app)”,
“exc”: “["Traceback (most recent call last):\n File \"apps/frappe/frappe/app.py\", line 110, in application\n response = frappe.api.handle(request)\n File \"apps/frappe/frappe/api/init.py\", line 49, in handle\n data = endpoint(**arguments)\n File \"apps/frappe/frappe/api/v1.py\", line 36, in handle_rpc_call\n return frappe.handler.handle()\n File \"apps/frappe/frappe/handler.py\", line 49, in handle\n data = execute_cmd(cmd)\n File \"apps/frappe/frappe/handler.py\", line 85, in execute_cmd\n return frappe.call(method, **frappe.form_dict)\n File \"apps/frappe/frappe/init.py\", line 1682, in call\n return fn(*args, **newargs)\n File \"apps/frappe/frappe/utils/typing_validations.py\", line 31, in wrapper\n return func(*args, **kwargs)\n File \"apps/frappe/frappe/model/mapper.py\", line 36, in make_mapped_doc\n return method(source_name)\n File \"apps/frappe/frappe/utils/typing_validations.py\", line 31, in wrapper\n return func(*args, **kwargs)\n File \"apps/workwings/workwings/plcm/doctype/log_test/log_test.py\", line 39, in make_log_schedule\n new_machine.save()\n File \"apps/frappe/frappe/model/document.py\", line 331, in save\n return self._save(*args, **kwargs)\n File \"apps/frappe/frappe/model/document.py\", line 353, in _save\n return self.insert()\n File \"apps/frappe/frappe/model/document.py\", line 286, in insert\n self._validate()\n File \"apps/frappe/frappe/model/document.py\", line 568, in _validate\n self._validate_mandatory()\n File \"apps/frappe/frappe/model/document.py\", line 904, in _validate_mandatory\n raise frappe.MandatoryError(\nfrappe.exceptions.MandatoryError: [Log_Schedule_Machines, 76c10838fa]: parent\n"]”,
“_server_messages”: “["{\"message\": \"Error: Value missing for None: parent\", \"title\": \"Message\"}"]”
}

try to add this log_schedule.save() after

 log_schedule = frappe.new_doc("Log_Schedule")

and remove from the last

added it after log_schedule.save()

but still same error giving

Error: Value missing for None: parent

Error: Value missing for None: parenttype

{
“exception”: “frappe.exceptions.MandatoryError: [Log_Schedule_Machines, d465653493]: parent, parenttype”,
“exc_type”: “MandatoryError”,
“_exc_source”: “workwings (app)”,
“exc”: “["Traceback (most recent call last):\n File \"apps/frappe/frappe/app.py\", line 110, in application\n response = frappe.api.handle(request)\n File \"apps/frappe/frappe/api/init.py\", line 49, in handle\n data = endpoint(**arguments)\n File \"apps/frappe/frappe/api/v1.py\", line 36, in handle_rpc_call\n return frappe.handler.handle()\n File \"apps/frappe/frappe/handler.py\", line 49, in handle\n data = execute_cmd(cmd)\n File \"apps/frappe/frappe/handler.py\", line 85, in execute_cmd\n return frappe.call(method, **frappe.form_dict)\n File \"apps/frappe/frappe/init.py\", line 1682, in call\n return fn(*args, **newargs)\n File \"apps/frappe/frappe/utils/typing_validations.py\", line 31, in wrapper\n return func(*args, **kwargs)\n File \"apps/frappe/frappe/model/mapper.py\", line 36, in make_mapped_doc\n return method(source_name)\n File \"apps/frappe/frappe/utils/typing_validations.py\", line 31, in wrapper\n return func(*args, **kwargs)\n File \"apps/workwings/workwings/plcm/doctype/log_test/log_test.py\", line 36, in make_log_schedule\n new_machine.save()\n File \"apps/frappe/frappe/model/document.py\", line 331, in save\n return self._save(*args, **kwargs)\n File \"apps/frappe/frappe/model/document.py\", line 353, in _save\n return self.insert()\n File \"apps/frappe/frappe/model/document.py\", line 286, in insert\n self._validate()\n File \"apps/frappe/frappe/model/document.py\", line 568, in _validate\n self._validate_mandatory()\n File \"apps/frappe/frappe/model/document.py\", line 904, in _validate_mandatory\n raise frappe.MandatoryError(\nfrappe.exceptions.MandatoryError: [Log_Schedule_Machines, d465653493]: parent, parenttype\n"]”,
“_server_messages”: “["{\"message\": \"Error: Value missing for None: parent\", \"title\": \"Message\"}", "{\"message\": \"Error: Value missing for None: parenttype\", \"title\": \"Message\"}"]”
}

show me the code