Chris Biersbach (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/7.0-issue_task_default_stage-cbi into 
lp:openobject-addons/7.0.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/7.0-issue_task_default_stage-cbi/+merge/141391

The issue: Tasks and issues get the wrong default stage_id (a "random" draft 
stage)

The reason: The default value for the stage_id is  using a value 
"default_project_id" in the context, which is not there. This results in an 
empty search domain, returning all the draft stages, and the first one is 
selected.

The fix: In the create methods, I call the method to compute the default value 
again, providing the correct default_project_id via the context. A correct 
draft stage is then selected.
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/7.0-issue_task_default_stage-cbi/+merge/141391
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/7.0-issue_task_default_stage-cbi.
=== modified file 'project/project.py'
--- project/project.py	2012-12-20 11:47:30 +0000
+++ project/project.py	2012-12-28 08:52:21 +0000
@@ -1089,6 +1089,10 @@
         return True
 
     def create(self, cr, uid, vals, context=None):
+        if not context.get('default_project_id', False) and vals.get('project_id', False):
+            ctx = context.copy()
+            ctx['default_project_id'] = vals['project_id']
+            vals['stage_id'] = self._get_default_stage_id(cr, uid, context=ctx)
         task_id = super(task, self).create(cr, uid, vals, context=context)
         self._store_history(cr, uid, [task_id], context=context)
         return task_id

=== modified file 'project_issue/project_issue.py'
--- project_issue/project_issue.py	2012-12-27 09:43:51 +0000
+++ project_issue/project_issue.py	2012-12-28 08:52:21 +0000
@@ -64,6 +64,13 @@
         },
     }
 
+    def create(self, cr, uid, vals, context=None):
+        if not context.get('default_project_id', False) and vals.get('project_id', False):
+            ctx = context.copy()
+            ctx['default_project_id'] = vals['project_id']
+            vals['stage_id'] = self._get_default_stage_id(cr, uid, context=ctx)
+        return super(project_issue, self).create(cr, uid, vals, context=context)
+
     def _get_default_project_id(self, cr, uid, context=None):
         """ Gives default project by checking if present in the context """
         return self._resolve_project_id_from_context(cr, uid, context=context)

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : openerp-dev-gtk@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to