【发布时间】:2021-02-26 11:03:22
【问题描述】:
请我是编程新手。我正在做一个关于 frappe 的项目。我的数据库不更新。请有人帮帮我
问题详情 我在 doctype inventory_reconcilation 上做了一个按钮,代码如下 //
frappe.ui.form.on('Inventory Reconciliation', {
update_inventory: function(frm) {
frappe.call({
method: "parkeyauto.api.reconcile_item_quantity",
freeze:true,
callback: (response) => {
console.log(response)
}
})
}
});
它是调用一个api并更新我的数据库,api代码是
#from future 导入 unicode_literals 进口冰沙
#http://localhost:8001/api/method/parkeyauto.api.reconcile_item_quantity
@frappe.whitelist()
def reconcile_item_quantity():
update_item_lists_to_zero_total()
def update_item_lists_to_zero_total():
try:
query = ("SELECT item_name,initial_inventory_qty,po_qty, so_qty, damaged_qty, missing_qty, average_cost_price FROM _d101da5a9b48a4a9.`tabItem2`;")
result_array = frappe.db.sql(query, as_dict=True)
for detail in result_array:
item = frappe.get_doc('Item', detail.item_name)
item.initial_inventory_qty = 0
item.po_qty = 0
item.so_qty = 0
item.damaged_qty = 0
item.missing_qty = 0
item.average_cost_price = 0
item.save()
return True
except Exception as e:
return e
请我知道为什么我的数据库没有更新。
【问题讨论】:
标签: api whitelist erpnext frappe