diff --git a/addons/project/project.py b/addons/project/project.py index c5c389e5510..07349e81c4d 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -206,6 +206,7 @@ class project(osv.osv): result = [] for proj in self.browse(cr, uid, ids, context=context): parent_id = context.get('parent_id',False) # check me where to pass context for parent id ?? + context.update({'analytic_project_copy': True}) new_id = project_obj.copy(cr, uid, proj.id, default = { 'name': proj.name +_(' (copy)'), 'state':'open', @@ -213,13 +214,10 @@ class project(osv.osv): result.append(new_id) cr.execute('select id from project_task where project_id=%s', (proj.id,)) res = cr.fetchall() - for (tasks_id,) in res: - task_obj.copy(cr, uid, tasks_id, default = { - 'project_id': new_id, - 'active':True}, context=context) - child_ids = self.search(cr, uid, [('parent_id','=', proj.id)], context=context) + child_ids = self.search(cr, uid, [('parent_id','=', proj.category_id.id)], context=context) + parent_id = self.read(cr, uid, new_id, ['category_id'])['category_id'][0] if child_ids: - self.duplicate_template(cr, uid, child_ids, context={'parent_id': new_id}) + self.duplicate_template(cr, uid, child_ids, context={'parent_id': parent_id}) if result and len(result): res_id = result[0] @@ -316,7 +314,7 @@ class task(osv.osv): 'description': fields.text('Description'), 'priority' : fields.selection([('4','Very Low'), ('3','Low'), ('2','Medium'), ('1','Urgent'), ('0','Very urgent')], 'Importance'), 'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of tasks."), - 'type': fields.many2one('project.task.type', 'Stage'), + 'type': fields.many2one('project.task.type', 'Stage',), 'state': fields.selection([('draft', 'Draft'),('open', 'In Progress'),('pending', 'Pending'), ('cancelled', 'Cancelled'), ('done', 'Done')], 'State', readonly=True, required=True, help='If the task is created the state \'Draft\'.\n If the task is started, the state becomes \'In Progress\'.\n If review is needed the task is in \'Pending\' state.\ \n If the task is over, the states is set to \'Done\'.'), @@ -626,4 +624,17 @@ class users(osv.osv): } users() +class account_analytic_account(osv.osv): + + _inherit = 'account.analytic.account' + _description = 'Analytic Account' + + def create(self, cr, uid, vals, context=None): + if context is None: + context = {} + if vals.get('child_ids', False) and context.get('analytic_project_copy', False): + vals['child_ids'] = [] + return super(account_analytic_account, self).create(cr, uid, vals, context=context) + +account_analytic_account() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index 7b299cdcccc..ef7bb92d1d6 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -39,8 +39,8 @@ - + @@ -55,11 +55,10 @@