diff options
| author | Fabien Pinckaers <fp@tinyerp.com> | 2012-10-11 16:23:08 +0200 |
|---|---|---|
| committer | Fabien Pinckaers <fp@tinyerp.com> | 2012-10-11 16:23:08 +0200 |
| commit | cd014978dce0fe49d9a699d3356642838f49a5a2 (patch) | |
| tree | 12773ef9ed0a21f5c50025bed304172cdb59879e /addons/document/document.py | |
| parent | 666f634b85e6446944f803512644a3251802462f (diff) | |
| parent | 92e7f3f6422a367c695acd87a824b5b8c8746109 (diff) | |
[MERGE] trunk
bzr revid: fp@tinyerp.com-20121011142308-vdynmuonffi31yug
Diffstat (limited to 'addons/document/document.py')
| -rw-r--r-- | addons/document/document.py | 44 |
1 files changed, 2 insertions, 42 deletions
diff --git a/addons/document/document.py b/addons/document/document.py index b5d0080d816..37a0219d143 100644 --- a/addons/document/document.py +++ b/addons/document/document.py @@ -155,30 +155,6 @@ class document_file(osv.osv): res['value'].update({'name': datas_fname}) return res - 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 @@ -225,8 +201,6 @@ class document_file(osv.osv): 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) @@ -292,22 +266,8 @@ class document_file(osv.osv): 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 |
