odoo14 与 odoo13 多对多的赋值不同 Python TypeError:‘int‘ object is not subscriptable
Python not is 不同 object 赋值 int TypeError
2023-09-11 14:20:47 时间
@api.model def default_get(self, field_names): try: defaults = super().default_get(field_names) act_ids = self.env.context['active_ids'] getids=[] for item in act_ids: yp = self.env['dmssp.dmssp'].sudo().search([('id', '=', item), ('pzhr', '=', self.env.user.id)]) if len(yp)>0: # print(len(yp)) if yp.state == 'shq': getids.append(item) if len(getids)>0: defaults['xs']=True defaults['jcxm_ids'] = getids
以上代码在13中没问题,在14中就出错了 Python TypeError:'int' object is not subscriptable 改下给值方式就可以了 @api.model def default_get(self, fields): try: defaults = super().default_get(fields) print(defaults) act_ids = self.env.context['active_ids'] print(act_ids) defaults['jcxm_ids'] = [(6, 0, act_ids)] return defaults except: raise UserError('选择有误,其它异常')
相关文章
- python之simplejson,Python版的简单、 快速、 可扩展 JSON 编码器/解码器
- python卸载或者安装时提示There is a problem with this Windows Installer package.A program required for this install to complete could not be run. Contact your support personnel or package vendor
- 【36】报错‘_1‘ was not declared in this scope return boost::python::make_function(boost::bind(&BiFunctio
- Python字符串类型详解(一)——字符串基础
- Python报错:IndentationError: unindent does not match any outer indentation level解决办法
- paip.python NameError name 'xxx' is not defined
- Python: 爬虫入门-python爬虫入门教程(非常详细)
- Python编程语言学习:python语言中快速查询python自带模块&函数的用法及其属性方法、如何查询某个函数&关键词的用法、输出一个类或者实例化对象的所有属性和方法名之详细攻略
- Python之tkinter:动态演示调用python库的tkinter带你进入GUI世界(LabelFrame/Checkbutton/Radiobutton)
- Python:pmml格式文件的简介、安装、使用方法(利用python将机器学习模型转为Java常用的pmml格式文件)之详细攻略
- Python语言学习:基于python五种方法实现使用某函数名【func_01】的字符串格式('func_01')来调用该函数【func_01】执行功能
- Python语言学习之文件夹那些事:python和文件夹的使用方法之详细攻略
- Python之API:基于python语言调用华为云API(华为网站)实现特定功能
- 成功解决AttributeError: module 'tensorflow.python.keras' has no attribute 'Model'
- 已解决(Python语法报错)SyntaxError: invalid syntax
- 《看漫画学Python》1、2版分享,python最佳入门教程,中学生用业余时间都能学会,北大教授看完都这样定义它
- 10大理由告诉你为什么要学习Python
- python文件流习题解析
- 【阶段四】Python深度学习08篇:深度学习项目实战:循环神经网络SimpleRNN、LSTM进行淘宝商品评论文本情感分析
- python模块之collections
- RuntimeError: Python is not installed as a framework
- Python编程:查看python语法中的关键字keyword
- Python编程:读取pdf、pptx、docx、xlsx文件的页数
- python 'defaultdict' is not defined
- python基础===Python 代码优化常见技巧
- Python 使jupyter notebook 从指定浏览器启动 以及编程中途更换浏览器
- python零基础学编程:Python是什么?为什么Python这么火,学Python能干什么?
- python常见问题解决方案