首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >IndexError:元组索引超出范围(Frappe/Erpnext)

IndexError:元组索引超出范围(Frappe/Erpnext)
EN

Stack Overflow用户
提问于 2019-04-17 01:41:41
回答 1查看 194关注 0票数 0

我正在尝试修改下面的代码,但是我得到了一个"tuple index out of range“错误。

代码语言:javascript
复制
price_list_name = frappe.db.sql("""select name
                from `tabItem Price` a 
                where a.item_code = %s and a.selling = 1 
                and a.uom = %s
                and a.creation = (select max(b.creation) from `tabItem Price` b 
                where a.item_code = b.item_code and b.selling = 1)""",(d.item_code, d.uom))
        frappe.log(price_list_name)
        name = price_list_name[0][0]
        price_doc = frappe.get_doc("Item Price",name)

以下是错误消息:

代码语言:javascript
复制
File "/home/frappe/erpnext/apps/xlevel_sales/xlevel_sales/custom_method.py", line 27, in update_item_price_list
name = price_list_name[0][0]
IndexError: tuple index out of range
EN

回答 1

Stack Overflow用户

发布于 2020-01-01 13:29:31

由于price_list_name未返回任何值,因此您将收到此错误,请添加if条件以避免此错误。

代码语言:javascript
复制
if price_list_name:
        name = price_list_name[0][0]
        price_doc = frappe.get_doc("Item Price",name)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55713832

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档