We are creating a custom document that once submitted will allow us to add or create a record to another document from the data entered. how ever I have encountered an error “object has no attribute”
JS:
frappe.ui.form.on(‘Custom Document’, {
make_timesheet: function(frm) {
frappe.confirm(__(‘This action will create or add entry to existingdoc. Do you want to proceed?’),
function() {
frappe.call({
method: “erpnext.hr.doctype.custom_document.custom_document.make_existingdocs”,
args: {
“dc”: frm.doc,
“dt”: frm.doc.doctype,
“dn”: frm.doc.name
},
callback: function() {frm.events.refresh(frm);},
doc: frm.doc,
freeze: true,
freeze_message: ‘Creating or updating existingdoc…’
});
},
function() {
if(frappe.dom.freeze_count) {
frappe.dom.unfreeze();
frm.events.refresh(frm);
}
}
);
},
});
PYTHON:
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
import json
from datetime import timedelta
from erpnext.controllers.queries import get_match_cond
from frappe.utils import flt, time_diff_in_hours, get_datetime, getdate, cint
from frappe.model.document import Document
class CustomDocumentTool(Document):
.
.
.
@frappe.whitelist()
def make_existingdocs(doc,dt,dn):
for employee_data in doc.employee_log:
edoc = get_employee_existingdoc(employee_data.employee,doc.for_date)
if not edoc:
edoc = frappe.new_doc({"doctype":"ExistingDocument","company":doc.company,"employee":employee_data.employee})