Merge lp:~openerp-dev/openobject-addons/6.1-opw-573644-dhs into lp:openobject-addons/6.1

Proposed by Dhruti Shastri(OpenERP)
Status: Work in progress
Proposed branch: lp:~openerp-dev/openobject-addons/6.1-opw-573644-dhs
Merge into: lp:openobject-addons/6.1
Diff against target: 53 lines (+16/-13)
1 file modified
document/document.py (+16/-13)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/6.1-opw-573644-dhs
Reviewer Review Type Date Requested Status
Naresh(OpenERP) (community) Needs Fixing
Review via email: mp+109078@code.launchpad.net

Description of the change

Description :
Navigate to: Knowledge/Documents/Documents. Create new document and
set Directory = Document (static Directory) and save it. Edit it and change the Directory =
Admin Folder(Folder per resource) save it, It will throws following error.
Client Traceback (most recent call last):
  File "/home/vpa/workspace/6.1/web-6.1/addons/web/common/http.py", line
180, in dispatch
    response["result"] = method(controller, self, **self.params)
  File "/home/vpa/workspace/6.1/web-6.1/addons/web/controllers/main.py",
line 971, in save
    r = m.write([id], data, req.session.eval_context(req.context))
  File
"/home/vpa/workspace/6.1/web-6.1/addons/web/common/openerplib/main.py",
line 250, in proxy
    args, kw)
  File
"/home/vpa/workspace/6.1/web-6.1/addons/web/common/openerplib/main.py",
line 117, in proxy
    result = self.connector.send(self.service_name, method, *args)
  File "/home/vpa/workspace/6.1/web-6.1/addons/web/common/http.py", line
611, in send
    raise fault
Server Traceback (most recent call last):
  File "/home/vpa/workspace/6.1/web-6.1/addons/web/common/http.py", line
592, in send
    result = openerp.netsvc.dispatch_rpc(service_name, method, args)
  File "/home/vpa/workspace/6.1/sever-6.1/openerp/netsvc.py", line 360,
in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method,
params)
  File
"/home/vpa/workspace/6.1/sever-6.1/openerp/service/web_services.py",
line 586, in dispatch
    res = fn(db, uid, *params)
  File "/home/vpa/workspace/6.1/sever-6.1/openerp/osv/osv.py", line 167,
in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/home/vpa/workspace/6.1/sever-6.1/openerp/osv/osv.py", line 121,
in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/vpa/workspace/6.1/sever-6.1/openerp/osv/osv.py", line 176,
in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/vpa/workspace/6.1/sever-6.1/openerp/osv/osv.py", line 164,
in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/vpa/workspace/6.1/addons-6.1/document/document.py", line
241, in write
    res = fnode.move_to(cr, dnode or fnode.parent, vals.get('name',
fbro.name), fbro, dbro, True)
  File "/home/vpa/workspace/6.1/addons-6.1/document/nodes.py", line
1332, in move_to
    raise NotImplementedError('Cannot move files between dynamic
folders')
NotImplementedError: Cannot move files between dynamic folders

To post a comment you must log in.
Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

It will be good if you have try ...except block for the move_to call...i.e

- res = fnode.move_to(cr, dnode or fnode.parent, vals.get('name', fbro.name), fbro, dbro, True)
+ try :
+ res = fnode.move_to(cr, dnode or fnode.parent, vals.get('name', fbro.name), fbro, dbro, True)
+ except Exception, e:
+ raise orm.except_orm(_('Error'), str(e))
                 if isinstance(res, dict):
                     vals2 = vals.copy()
                     vals2.update(res)

Thanks,

review: Needs Fixing
Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

Hello,

This bug was qualified as Not Reproducible on Trunk (means that architecture on trunk has changed and so this bug has no meaning anymore). If this Merge Proposal could not be merged in v6.1 at the release of v7.0, it will be closed.

Thanks,
Naresh Soni

Unmerged revisions

6834. By Dhruti Shastri(OpenERP)

[document] : Cannot save document After changing Directory from Static to Dyanmic (Case:573644)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'document/document.py'
--- document/document.py 2011-12-19 16:54:40 +0000
+++ document/document.py 2012-06-07 07:07:20 +0000
@@ -20,7 +20,7 @@
20##############################################################################20##############################################################################
2121
22import base6422import base64
23from osv import osv, fields23from osv import osv, fields, orm
24import os24import os
2525
26# from psycopg2 import Binary26# from psycopg2 import Binary
@@ -186,7 +186,6 @@
186 context=context, count=False)186 context=context, count=False)
187 if not ids:187 if not ids:
188 return 0 if count else []188 return 0 if count else []
189
190 # Filter out documents that are in directories that the user is not allowed to read.189 # Filter out documents that are in directories that the user is not allowed to read.
191 # Must use pure SQL to avoid access rules exceptions (we want to remove the records,190 # Must use pure SQL to avoid access rules exceptions (we want to remove the records,
192 # not fail), and the records have been filtered in parent's search() anyway.191 # not fail), and the records have been filtered in parent's search() anyway.
@@ -238,17 +237,21 @@
238 ids2.append(fbro.id)237 ids2.append(fbro.id)
239 continue238 continue
240 fnode = nctx.get_file_node(cr, fbro)239 fnode = nctx.get_file_node(cr, fbro)
241 res = fnode.move_to(cr, dnode or fnode.parent, vals.get('name', fbro.name), fbro, dbro, True)240 try :
242 if isinstance(res, dict):241 res = fnode.move_to(cr, dnode or fnode.parent, vals.get('name', fbro.name), fbro, dbro, True)
243 vals2 = vals.copy()242 if isinstance(res, dict):
244 vals2.update(res)243 vals2 = vals.copy()
245 wid = res.get('id', fbro.id)244 vals2.update(res)
246 result = super(document_file,self).write(cr,uid,wid,vals2,context=context)245 wid = res.get('id', fbro.id)
247 # TODO: how to handle/merge several results?246 result = super(document_file,self).write(cr,uid,wid,vals2,context=context)
248 elif res == True:247 # TODO: how to handle/merge several results?
249 ids2.append(fbro.id)248 elif res == True:
250 elif res == False:249 ids2.append(fbro.id)
251 pass250 elif res == False:
251 pass
252 except Exception, e:
253 raise orm.except_orm(_('Error'), str(e))
254
252 ids = ids2255 ids = ids2
253 if 'file_size' in vals: # only write that field using direct SQL calls256 if 'file_size' in vals: # only write that field using direct SQL calls
254 del vals['file_size']257 del vals['file_size']