当前位置:网站首页>Curd of odoo basic development (add, delete, check, change)
Curd of odoo basic development (add, delete, check, change)
2022-07-20 18:54:00 【Gentle and progressive C】
odoo Increase of basic development 、 Delete 、 check 、 Change
Introduction to the environment
- odoo edition :odoo 13
- python edition :3.7.3
- odoo Environment below 12 edition , Some operation methods need to add specific decorators ( Such as :@api.multi), higher than odoo12 The version can define the operation just like the normal method .
Operation introduction
Add data :
- Sample code :
@api.model
def create(self, vals_list):
res = super(EpidemicRecord, self).create(vals_list)
return res
- Parameter interpretation :
- vals_list: Dictionary type , When adding data , When the data has not been saved to the database , Data is saved here , Dictionary key Is the model field name , Dictionary value Is the field value of the model .vals_list[‘ Field name ’]= field value
- res: After successful creation , That is, the data has been saved to the database . Returned data record set .res. Field name = field value
- super( Model class name ,self). The first parameter is the model class name , Not the model name .
- Trigger this method when you click Save , Instead of triggering this method when you click Create .
- Creation does not trigger :
- Triggered on save :
Modifying data :
- Sample code :
def write(self, vals):
res = super(EpidemicRecord, self).write(vals)
return res
- Parameter interpretation :
- self: As object , Metadata of the dataset currently being modified , It can be multiple pieces of data
- vals: Is dictionary type , The data of the field we modified ,key For field name ,value Is the field value
- res: The return value is of boolean type , Modified return successfully True, Modification failure returns False
- When creating a record to save , Only execute create Method , Don't execute write Method , Just after modifying the data , Save data before execution write Method , And create Method will be executed only once when it is created .
Delete data :
- Sample code :
def unlink(self):
res = super(EpidemicRecord, self).unlink()
return res
- Parameter interpretation :
- self: Data set of current operation
- Delete all records in the current dataset , And returns a Boolean value ,true Delete successful ,false Delete failed .
- You can override this method , To achieve false deletion , Instead of deleting directly from the database .
- Batch deletion :
- Single delete :
Find data :
- self.browse(ids) Method ,ids It's a list
- self.search(domain, order=‘id’, limit=1) Method ,domain Yes query criteria , limit Take before limit individual ,order sort order
边栏推荐
- JMeter practical operation -- database data drive
- windows下celery配置连接redis报错问题修复(TypeError: __init__() got an unexpected keyword argement )
- Cut rope
- 如何选择开源的自动化测试框架?这9款开源工具你一定要知道
- 为 KubeSphere 集群启用免费的泛域名 SSL 证书并实现证书自动更新和分发
- When running selenium remotedriver, there is a problem with nativeconstructoraccessorimpl Newinstance0 bad sessionnotcreatedexception error
- FreeRTOS personal notes - time slice support
- Draw 95% confidence interval diagram with MATLAB
- 【软件测试】测试大纲法——测试用例编写
- Cobbler offline installation
猜你喜欢
随机推荐
地学学术资源II
Matlab计算质心
Force deduction solution summary 731- my schedule II
Go language - Testing and performance
Matlab数据写入文件常用函数
There are 13 steps to install pychart, isn't it? (super detailed tutorial)
DevOps 实践多年,最痛的居然是?
MIT6.S081-Lab10 mmap [2021Fall]
教你使用CANN将照片一键转换成卡通风格
cobbler離線安裝
Paging storage management mode
After graduating from college in 19 years, I chose software testing after recognizing the truth of life
理想L9,过不了路上一个坑?
新茶饮,开始“打群架”
tp5.1 foreach在控制器记录中新增加一个字段,其它字段不变也不用重新全部写一遍 (不在模板中操作)(分页)
webdriver点击登录失效问题的解决
Draw sequence diagram with code! It's so cool
软件测试岗——面试时三大灵魂拷问,你受得住吗?
Are you still worried about the implementation plan change for Oracle database migration?
力扣解法汇总731-我的日程安排表 II