如何解决在odoo8的many2many字段中附加新文档时,添加已删除的文档
我们正在使用 sync_mail_multi_attach_ext(多重附件上传器模块),当我上传文档并删除并再次上传其他文档时,此模块小部件已在odoo 8的many2many字段中使用添加。如何从将已删除的文档添加到当前文档中来解决该问题。
'session.web.form.FieldMany2ManyBinaryMultiFiles.include({
on_file_change: function (event) {
event.stopPropagation();
var self = this;
var $target = $(event.target);
if ($target.val() !== '') {
var filename = $target.val().replace(/.*[\\\/]/,'');
// don't uplode more of one file in same time
if (self.data[0] && self.data[0].upload ) {
return false;
}
for (var id in this.get('value')) {
// if the files exits,delete the file before upload (if it's a new file)
if (self.data[id] && (self.data[id].filename || self.data[id].name) == filename && !self.data[id].no_unlink ) {
self.ds_file.unlink([id]);
}
}
// block UI or not
if(this.node.attrs.blockui>0) {
instance.web.blockUI();
}
// TODO : unactivate send on wizard and form
_.each($target[0].files,function(file){
var querydata = new FormData();
querydata.append('callback','oe_fileupload_temp2');
querydata.append('ufile',file);
querydata.append('model','hr.documents');
querydata.append('id','0');
querydata.append('multi','true');
$.ajax({
url: '/web/binary/upload_attachment',type: 'POST',data: querydata,cache: false,processData: false,contentType: false,success: function(id){
self.data[id] = {
'id': parseInt(id),'name': file.name,'filename': filename.name,'url': '','upload': false
};
},});
});
// submit file
this.$('form.oe_form_binary_form').submit();
}
},'
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。