【发布时间】:2019-09-19 13:50:09
【问题描述】:
我不知道 name_get()[0][1] 是什么意思
display_name = product_id.name_get()[0][1]
if product_id.description_sale:
display_name += '\n' + product_id.description_sale
【问题讨论】:
标签: python-3.7 odoo-12
我不知道 name_get()[0][1] 是什么意思
display_name = product_id.name_get()[0][1]
if product_id.description_sale:
display_name += '\n' + product_id.description_sale
【问题讨论】:
标签: python-3.7 odoo-12
向后分解:[0][1] 表示二维数组的一个元素(一个数组,其元素也是数组),因此我们可以推断出预期是 name_get() 返回一个二维数组 - 我们可以不过,不要说这些数组中的值的类型 - python 是动态类型的。
product.name_get()表示name_get()是产品类/文件的方法/函数。
例如 - name_get() 可能会返回类似
[ ["savings account", "current account"], ["credit card", "store card"] ]
所以name_get()[0][1] 将评估为"current account"
【讨论】: