Last active
April 16, 2020 14:00
-
-
Save Meshugah/b10ab123fecb3f1e7f020d0f43d350a6 to your computer and use it in GitHub Desktop.
Frappe - get from db/get BOM + insert a doc + set_value + frappe.call + submit a saved doc + get_doc + auto-submit example + all doctypes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
frappe.db.get_list('BOM') | |
frappe.db.insert({ | |
doctype: 'Stock Entry', | |
stock_entry_type: 'Material Receipt', | |
items: [ | |
{ | |
'item_code': '0002', | |
'item_name': 'Spring Clip', | |
'schedule_date': '30 - 11 - 2021', | |
'qty': 12, | |
'stock_uom': 'Nos', | |
'uom': 'Nos', | |
'conversion_factor': 1, | |
'warehouse': 'Stores - VTK', | |
}, | |
] | |
}).then(function(doc) { | |
console.log(`${doc.doctype} ${doc.name} created on ${doc.creation}`); | |
}); | |
frappe.model.set_value(cur_frm.doc.items[0].doctype,cur_frm.doc.items[0].name,'qty','1000') | |
frappe.call({ | |
method: "frappe.client.get", | |
args: { | |
doctype: "Task", | |
name: "TASK00226", | |
}, | |
callback(r) { | |
if(r.message) { | |
var task = r.message; | |
console.log(task); | |
} | |
} | |
}); | |
callback: function(r){ | |
frappe.call({ | |
"method": "frappe.client.submit", | |
"args": { | |
"doctype": res.message.doctype, | |
"docname": res.message.name | |
} | |
}) | |
} | |
doc = frappe.get_doc("Stock Entry", 'MAT-STE-2020-00088') | |
frappe.db.insert({ | |
doctype: 'Stock Entry', | |
stock_entry_type: 'Material Receipt', | |
to_warehouse: 'Stores - VTK', | |
items: [ | |
{ | |
'item_code': '0002', | |
'item_name': 'Spring Clip', | |
'schedule_date': '30 - 11 - 2021', | |
'qty': 12, | |
'stock_uom': 'Nos', | |
'uom': 'Nos', | |
'conversion_factor': 1, | |
'warehouse': 'Stores - VTK', | |
}, | |
] | |
}).then(function(doc) { | |
frappe.call({ | |
"method": "frappe.client.submit", | |
"args": { | |
"doc" : doc | |
} | |
}); | |
}); | |
https://github.com/frappe/erpnext/blob/d4d7d211ead84d26a029fbed9e6e6d06011a4bf3/erpnext/config/stock.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment