diff options
| author | Raphael Collet <rco@openerp.com> | 2012-05-09 12:13:20 +0200 |
|---|---|---|
| committer | Raphael Collet <rco@openerp.com> | 2012-05-09 12:13:20 +0200 |
| commit | 8a4959cd290685109955677df2b75a40867d88d9 (patch) | |
| tree | f7255389b198d0a902af3c42863de21f5383548e /addons/project/project.py | |
| parent | e4fdf1b061b7cc859e3d257dcab504caf8e8ebf2 (diff) | |
| parent | 700061a30a4dea502d6e73f623d4704bdce0e8b0 (diff) | |
[MERGE] trunk-project-gallery-apa (project gallery view)
bzr revid: rco@openerp.com-20120509101320-rpprue0b12ss3laj
Diffstat (limited to 'addons/project/project.py')
| -rw-r--r-- | addons/project/project.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/addons/project/project.py b/addons/project/project.py index 0335b7cb540..a25e55d12e5 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -155,6 +155,13 @@ class project(osv.osv): raise osv.except_osv(_('Operation Not Permitted !'), _('You cannot delete a project containing tasks. I suggest you to desactivate it.')) return super(project, self).unlink(cr, uid, ids, *args, **kwargs) + def _task_count(self, cr, uid, ids, field_name, arg, context=None): + res = dict.fromkeys(ids, 0) + task_ids = self.pool.get('project.task').search(cr, uid, [('project_id', 'in', ids)]) + for task in self.pool.get('project.task').browse(cr, uid, task_ids, context): + res[task.project_id.id] += 1 + return res + _columns = { 'complete_name': fields.function(_complete_name, string="Project Name", type='char', size=250), 'active': fields.boolean('Active', help="If the active field is set to False, it will allow you to hide the project without removing it."), @@ -191,7 +198,15 @@ class project(osv.osv): 'warn_header': fields.text('Mail Header', help="Header added at the beginning of the email for the warning message sent to the customer when a task is closed.", states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}), 'warn_footer': fields.text('Mail Footer', help="Footer added at the beginning of the email for the warning message sent to the customer when a task is closed.", states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}), 'type_ids': fields.many2many('project.task.type', 'project_task_type_rel', 'project_id', 'type_id', 'Tasks Stages', states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}), + 'use_tasks': fields.boolean('Use Tasks', help="Check this field if this project is aimed at managing tasks"), + 'task_count': fields.function(_task_count, type='integer', string="Open Tasks"), + 'color': fields.integer('Color Index'), + 'company_uom_id': fields.related('company_id', 'project_time_mode_id', type='many2one', relation='product.uom'), } + + def dummy(self, cr, uid, ids, context): + return True + def _get_type_common(self, cr, uid, context): ids = self.pool.get('project.task.type').search(cr, uid, [('project_default','=',1)], context=context) return ids @@ -201,7 +216,8 @@ class project(osv.osv): 'active': True, 'priority': 1, 'sequence': 10, - 'type_ids': _get_type_common + 'type_ids': _get_type_common, + 'use_tasks': True, } # TODO: Why not using a SQL contraints ? |
