我正在尝试从 db 返回一个值并收到此错误。我在这里尝试了以前回答的问题,但没有运气。有人可以帮助我吗?
@frappe.whitelist()
def generate_barcode():
last_barcode = frappe.db.sql("""\
select MAX(barcode) from `tabItem` """)
if last_barcode:
last_barcode = last_barcode + 1
else:
x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
random.shuffle(x)
last_barcode = x[0]
return {'last_barcode':last_barcode}
添加回溯:
Traceback (innermost last):
File "/home/adminuser/frappe-bench-hitech/apps/frappe/frappe/app.py", line 49, in application
response = frappe.handler.handle()
File "/home/adminuser/frappe-bench-hitech/apps/frappe/frappe/handler.py", line 66, in handle
execute_cmd(cmd)
File "/home/adminuser/frappe-bench-hitech/apps/frappe/frappe/handler.py", line 89, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File "/home/adminuser/frappe-bench-hitech/apps/frappe/frappe/__init__.py", line 531, in call
return fn(*args, **newargs)
File "/home/adminuser/frappe-bench-hitech/apps/erpnext/erpnext/stock/doctype/item/item.py", line 405, in generate_barcode
last_barcode = last_barcode + 1
TypeError: can only concatenate tuple (not "int") to tuple