Hi,
update:
I don’t know if it’s a bug or a feature.
doesn’t metter, which doc I am creating with frappe.db.insert no data is automatically fetched from template.
Tested again with Payment Requests.
I am trying to create a Sales Invoice with frappe.db.insert out of Opportunity.
If I am using frappe.new_doc(“Sales Invoice”, … taxes are automatically fetched from template, but if I am using frappe.db.insert taxes are not automatically fetched from template.
Is there a possibility to force erpnext to do this?
frappe.ui.form.on('Opportunity', {
refresh: function(frm, cdt, cdn) {
frm.add_custom_button(__('Sales Invoice Test'), function () {
frappe.db.insert({
doctype: 'Sales Invoice',
customer: frm.doc.party_name,
custom_anf_nr: frm.doc.name,
custom_wwre_nr : frm.doc.custom_wwre_nr,
docstatus :0,
posting_date : frm.doc.custom_verrechnung_datum,
custom_adresse : frm.doc.custom_plz + " "+ frm.doc.custom_ort + ", "+ frm.doc.custom_adresse,
custom_anf_obj_id : frm.doc.custom_objnr,
custom_anf_opportunity_amount : frm.doc.opportunity_amount,
base_grand_total : 0,
grand_total : 0,
taxes_and_charges : 'Austria Tax - MGAH',
'items': [
{
'item_code' : 'Verrechnung',
'item_name' : 'Verrechnung',
'qty': 1
}
]
}).then(doc => {
console.log(doc);
frappe.msgprint(__("RE done. " + doc.name));
frm.set_value('custom_test1', doc.name);
frm.set_value('custom_reid', doc.name);
frm.dirty();
frm.save();
})
}).addClass("btn-danger");
}
});