credativ team mailing list archive
-
credativ team
-
Mailing list archive
-
Message #06093
[Branch ~credativ/openobject-addons/6.1] Rev 7060: [FIX] Do not check for duplicate file names on attachments. This breaks import of emails.
------------------------------------------------------------
revno: 7060
committer: Craig Gowing (credativ) <craig.gowing@xxxxxxxxxxxxxx>
branch nick: addons
timestamp: Mon 2014-09-15 10:13:07 +0100
message:
[FIX] Do not check for duplicate file names on attachments. This breaks import of emails.
Backport fix from addons-7.0 rev 7136.33.21 and 7136.33.14 for document/document.py
modified:
document/document.py
--
lp:~credativ/openobject-addons/6.1
https://code.launchpad.net/~credativ/openobject-addons/6.1
Your team credativ is subscribed to branch lp:~credativ/openobject-addons/6.1.
To unsubscribe from this branch go to https://code.launchpad.net/~credativ/openobject-addons/6.1/+edit-subscription
=== modified file 'document/document.py'
--- document/document.py 2012-08-22 09:10:40 +0000
+++ document/document.py 2014-09-15 09:13:07 +0000
@@ -146,30 +146,6 @@
_sql_constraints = [
# filename_uniq is not possible in pure SQL
]
- def _check_duplication(self, cr, uid, vals, ids=[], op='create'):
- name = vals.get('name', False)
- parent_id = vals.get('parent_id', False)
- res_model = vals.get('res_model', False)
- res_id = vals.get('res_id', 0)
- if op == 'write':
- for file in self.browse(cr, uid, ids): # FIXME fields_only
- if not name:
- name = file.name
- if not parent_id:
- parent_id = file.parent_id and file.parent_id.id or False
- if not res_model:
- res_model = file.res_model and file.res_model or False
- if not res_id:
- res_id = file.res_id and file.res_id or 0
- res = self.search(cr, uid, [('id', '<>', file.id), ('name', '=', name), ('parent_id', '=', parent_id), ('res_model', '=', res_model), ('res_id', '=', res_id)])
- if len(res):
- return False
- if op == 'create':
- res = self.search(cr, uid, [('name', '=', name), ('parent_id', '=', parent_id), ('res_id', '=', res_id), ('res_model', '=', res_model)])
- if len(res):
- return False
- return True
-
def check(self, cr, uid, ids, mode, context=None, values=None):
"""Check access wrt. res_model, relax the rule of ir.attachment parent
@@ -223,8 +199,6 @@
res = self.search(cr, uid, [('id', 'in', ids)])
if not len(res):
return False
- if not self._check_duplication(cr, uid, vals, ids, 'write'):
- raise osv.except_osv(_('ValidateError'), _('File name must be unique!'))
# if nodes call this write(), they must skip the code below
from_node = context and context.get('__from_node', False)
@@ -290,22 +264,8 @@
else:
if vals.get('file_size'):
del vals['file_size']
- result = self._check_duplication(cr, uid, vals)
- if not result:
- domain = [
- ('res_id', '=', vals['res_id']),
- ('res_model', '=', vals['res_model']),
- ('datas_fname', '=', vals['datas_fname']),
- ]
- attach_ids = self.search(cr, uid, domain, context=context)
- super(document_file, self).write(cr, uid, attach_ids,
- {'datas' : vals['datas']},
- context=context)
- result = attach_ids[0]
- else:
- #raise osv.except_osv(_('ValidateError'), _('File name must be unique!'))
- result = super(document_file, self).create(cr, uid, vals, context)
- return result
+
+ return super(document_file, self).create(cr, uid, vals, context)
def __get_partner_id(self, cr, uid, res_model, res_id, context=None):
""" A helper to retrieve the associated partner from any res_model+id