Merge lp:~ovnicraft/openobject-addons/7.0-bug-1095339 into lp:openobject-addons/7.0

Proposed by Cristian Salamea
Status: Needs review
Proposed branch: lp:~ovnicraft/openobject-addons/7.0-bug-1095339
Merge into: lp:openobject-addons/7.0
Diff against target: 17 lines (+6/-1)
1 file modified
document/document.py (+6/-1)
To merge this branch: bzr merge lp:~ovnicraft/openobject-addons/7.0-bug-1095339
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+144739@code.launchpad.net

Description of the change

Fix bug for 7.0 #1095339

To post a comment you must log in.

Unmerged revisions

8601. By Cristian Salamea

[FIX] fix directory per resource

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'document/document.py'
2--- document/document.py 2012-12-24 14:00:02 +0000
3+++ document/document.py 2013-01-24 16:27:33 +0000
4@@ -113,7 +113,12 @@
5 def create(self, cr, uid, vals, context=None):
6 if context is None:
7 context = {}
8- vals['parent_id'] = context.get('parent_id', False) or vals.get('parent_id', False)
9+ if vals.get('parent_id', False) or context.get('parent_id', False):
10+ vals['parent_id'] = context.get('parent_id', False) or vals.get('parent_id', False)
11+ elif vals.get('res_model', False):
12+ resource_id = self.pool.get('ir.model').search(cr, uid, [('model','=', vals.get('res_model', False))], context=context)[0]
13+ directory_ids = self.pool.get('document.directory').search(cr, uid, [('ressource_type_id','=', resource_id)], context=context)
14+ vals['parent_id'] = directory_ids[0] if directory_ids else False
15 # take partner from uid
16 if vals.get('res_id', False) and vals.get('res_model', False) and not vals.get('partner_id', False):
17 vals['partner_id'] = self.__get_partner_id(cr, uid, vals['res_model'], vals['res_id'], context)