用server action 删除附件的测试,(直接创建 计划动作
,应该就可以手动执行了)
方法1 (在py中定义一个方法,然后去 server action中调用)周同学Medoo提供:
@api.model def delete_xxx(self): self.env['.....'].search([('name', ....)]).unlink() 参考说明: >>> self.env['res.partner'] res.partner() >>> self.env['res.partner'].search([['is_company', '=',True], ['customer', '=',True]]) res.partner(7, 18, 12, 14, 17, 19, 8, 31, 26, 16, 13, 20, 30, 22, 29, 15, 23, 28, 74)
测试2
参考有个 Clean test answers 的, 还是要选中(这还不如 选中后 删除呢),不太方便, 还会报错
if records: env['ir.attachment'].search(['create_date','<','2022-06-02 16:00:00', ('res_model','!=','ir.ui.view')]).unlink()
测试3: 也是要选中,不方便
for rec in records: record['res_model'] != 'ir.ui.view' rec.unlink()