diff options
| author | Goran Kliska <goran.kliska@slobodni-programi.hr> | 2012-12-10 12:14:04 +0100 |
|---|---|---|
| committer | Goran Kliska <goran.kliska@slobodni-programi.hr> | 2012-12-10 12:14:04 +0100 |
| commit | afbb6ef717de99a4b9b191c4fe4d81ace6d15f65 (patch) | |
| tree | 56b83ffb9ab0998c1b57c5931462c08a59509010 /addons/project_long_term/project_long_term.py | |
| parent | 1370e3c6558544a5899c5839847abc71aa9fe199 (diff) | |
| parent | 590add54d41062e2638d751b52a46e626b8e368c (diff) | |
merge from trunk
bzr revid: goran.kliska@slobodni-programi.hr-20121210111404-jcwlv3nsa16bu8zq
Diffstat (limited to 'addons/project_long_term/project_long_term.py')
| -rw-r--r-- | addons/project_long_term/project_long_term.py | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/addons/project_long_term/project_long_term.py b/addons/project_long_term/project_long_term.py index 612bd784bb0..db6c532d503 100644 --- a/addons/project_long_term/project_long_term.py +++ b/addons/project_long_term/project_long_term.py @@ -110,14 +110,14 @@ class project_phase(osv.osv): 'previous_phase_ids': fields.many2many('project.phase', 'project_phase_rel', 'next_phase_id', 'prv_phase_id', 'Previous Phases', states={'cancelled':[('readonly',True)]}), 'sequence': fields.integer('Sequence', select=True, help="Gives the sequence order when displaying a list of phases."), 'duration': fields.float('Duration', required=True, help="By default in days", states={'done':[('readonly',True)], 'cancelled':[('readonly',True)]}), - 'product_uom': fields.many2one('product.uom', 'Duration UoM', required=True, help="UoM (Unit of Measure) is the unit of measurement for Duration", states={'done':[('readonly',True)], 'cancelled':[('readonly',True)]}), + 'product_uom': fields.many2one('product.uom', 'Duration Unit of Measure', required=True, help="Unit of Measure (Unit of Measure) is the unit of measurement for Duration", states={'done':[('readonly',True)], 'cancelled':[('readonly',True)]}), 'task_ids': fields.one2many('project.task', 'phase_id', "Project Tasks", states={'done':[('readonly',True)], 'cancelled':[('readonly',True)]}), 'user_force_ids': fields.many2many('res.users', string='Force Assigned Users'), 'user_ids': fields.one2many('project.user.allocation', 'phase_id', "Assigned Users",states={'done':[('readonly',True)], 'cancelled':[('readonly',True)]}, - help="The ressources on the project can be computed automatically by the scheduler"), - 'state': fields.selection([('draft', 'New'), ('open', 'In Progress'), ('pending', 'Pending'), ('cancelled', 'Cancelled'), ('done', 'Done')], 'State', readonly=True, required=True, - help='If the phase is created the state \'Draft\'.\n If the phase is started, the state becomes \'In Progress\'.\n If review is needed the phase is in \'Pending\' state.\ - \n If the phase is over, the states is set to \'Done\'.'), + help="The resources on the project can be computed automatically by the scheduler."), + 'state': fields.selection([('draft', 'New'), ('cancelled', 'Cancelled'),('open', 'In Progress'), ('pending', 'Pending'), ('done', 'Done')], 'Status', readonly=True, required=True, + help='If the phase is created the status \'Draft\'.\n If the phase is started, the status becomes \'In Progress\'.\n If review is needed the phase is in \'Pending\' status.\ + \n If the phase is over, the status is set to \'Done\'.'), 'progress': fields.function(_compute_progress, string='Progress', help="Computed based on related tasks"), } _defaults = { @@ -138,7 +138,7 @@ class project_phase(osv.osv): if default is None: default = {} if not default.get('name', False): - default['name'] = self.browse(cr, uid, id, context=context).name + _(' (copy)') + default.update(name=_('%s (copy)') % (self.browse(cr, uid, id, context=context).name)) return super(project_phase, self).copy(cr, uid, id, default, context) def set_draft(self, cr, uid, ids, *args): @@ -215,9 +215,19 @@ project_user_allocation() class project(osv.osv): _inherit = "project.project" + + def _phase_count(self, cr, uid, ids, field_name, arg, context=None): + res = dict.fromkeys(ids, 0) + phase_ids = self.pool.get('project.phase').search(cr, uid, [('project_id', 'in', ids)]) + for phase in self.pool.get('project.phase').browse(cr, uid, phase_ids, context): + res[phase.project_id.id] += 1 + return res + _columns = { 'phase_ids': fields.one2many('project.phase', 'project_id', "Project Phases"), + 'phase_count': fields.function(_phase_count, type='integer', string="Open Phases"), } + def schedule_phases(self, cr, uid, ids, context=None): context = context or {} if type(ids) in (long, int,): @@ -240,7 +250,7 @@ class project(osv.osv): # Maybe it's better to update than unlink/create if it already exists ? p = getattr(project_gantt, 'Phase_%d' % (phase.id,)) - self.pool.get('project.user.allocation').unlink(cr, uid, + self.pool.get('project.user.allocation').unlink(cr, uid, [x.id for x in phase.user_ids], context=context ) @@ -259,10 +269,30 @@ class project(osv.osv): return True project() +class account_analytic_account(osv.osv): + _inherit = 'account.analytic.account' + _description = 'Analytic Account' + _columns = { + 'use_phases': fields.boolean('Phases', help="Check this field if you plan to use phase-based scheduling"), + } + + def on_change_template(self, cr, uid, ids, template_id, context=None): + res = super(account_analytic_account, self).on_change_template(cr, uid, ids, template_id, context=context) + if template_id and 'value' in res: + template = self.browse(cr, uid, template_id, context=context) + res['value']['use_phases'] = template.use_phases + return res + + def _trigger_project_creation(self, cr, uid, vals, context=None): + res= super(account_analytic_account, self)._trigger_project_creation(cr, uid, vals, context=context) + return res or vals.get('use_phases') + +account_analytic_account() + class project_task(osv.osv): _inherit = "project.task" _columns = { - 'phase_id': fields.many2one('project.phase', 'Project Phase'), + 'phase_id': fields.many2one('project.phase', 'Project Phase', domain="[('project_id', '=', project_id)]"), } project_task() |
