Last active
March 23, 2018 05:39
-
-
Save ruter/4c3b0ea9f027dacb0c68cc2de44475c3 to your computer and use it in GitHub Desktop.
[删除文件 Controller] Odoo 删除文件 Controller #Odoo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@http.route('/api/v1/mro/delete_file', type='json', auth="user", method=['POST'], website=True) | |
def del_requirement_file(self, **kwargs): | |
data = request.jsonrequest | |
if data: | |
attach_ids = data.get('ids', None) | |
domain = [('id', 'in', attach_ids)] | |
res_id = data.get('res_id', None) | |
res_model = data.get('res_model', None) | |
if res_id: | |
domain.append(('res_id', '=', res_id)) | |
if res_model: | |
domain.append(('res_model', '=', res_model)) | |
if attach_ids: | |
attachments = request.env['ir.attachment'].search(domain) | |
if attachments: | |
attachments.unlink() | |
return { | |
'success': True, | |
'msg': u'附件删除成功' | |
} | |
return { | |
'success': False, | |
'msg': u'附件不存在' | |
} | |
return { | |
'success': False, | |
'msg': u'非法请求!' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment