我正在尝试将模块从odoo 10更新为odoo12。下面的代码在使用python 2.7的odoo 10中效果很好,但是在python 3.x中出现了映射问题。
def _get_search_domain(self, search, category, attrib_values):
res =super(WebsiteSale,self)._get_search_domain(search,category,attrib_values)
filter_list = request.httprequest.args.getlist('filter')
domain = res
filter_values = [map(int, v.split("-")) for v in filter_list if v]
filters_ids = set([v[0] for v in filter_values])
filter_set = set([v[1] for v in filter_values])
if filter_values:
filter = None
ids = []
list_of_d = []
for value in filter_values:
v = False
if not filter:
filter = value[0]
ids.append(value[1])
elif value[0] == filter:
ids.append(value[1])
else:
domain += [('filter_line_ids.value_ids', 'in', ids)]
filter = value[0]
ids = [value[1]]
if filter:
domain += [('filter_line_ids.value_ids', 'in', ids)]
return domain
我收到错误消息:
“地图”对象不可下标
我从其他帮助中读到,我应该用列表将地图括起来。我尝试用以下代码替换,但仍然无法使用
filter_values = [list(map(int, v.split("-"))) for v in filter_list if v]
谁能帮助我。谢谢!
答案 0 :(得分:0)
filter_values = [list(map(int, v.split("-"))) for v in filter_list if v]
为什么将其强制转换为List,因为Filter_Values是dtype List