[REF] project: refector code of reevaluate task wizard
bzr revid: hmo@tinyerp.com-20100827113648-gbv52qxn9i71wxqn
This commit is contained in:
@@ -38,6 +38,7 @@ work done on tasks, eso. It is able to render planning, order tasks, eso.
|
||||
"security/project_security.xml",
|
||||
"wizard/project_task_delegate_view.xml",
|
||||
"wizard/project_task_close_view.xml",
|
||||
"wizard/project_task_reevaluate_view.xml",
|
||||
"security/ir.model.access.csv",
|
||||
"project_data.xml",
|
||||
"project_view.xml",
|
||||
|
||||
+4
-102
@@ -522,10 +522,11 @@ class task(osv.osv):
|
||||
self.log(cr, uid, task.id, message)
|
||||
return True
|
||||
|
||||
def do_reopen(self, cr, uid, ids, *args):
|
||||
def do_reopen(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
request = self.pool.get('res.request')
|
||||
tasks = self.browse(cr, uid, ids)
|
||||
for task in tasks:
|
||||
for task in self.browse(cr, uid, ids, context=context):
|
||||
project = task.project_id
|
||||
if project and project.warn_manager and project.user_id.id and (project.user_id.id != uid):
|
||||
request.create(cr, uid, {
|
||||
@@ -672,105 +673,6 @@ class project_work(osv.osv):
|
||||
|
||||
project_work()
|
||||
|
||||
class config_compute_remaining(osv.osv_memory):
|
||||
_name='config.compute.remaining'
|
||||
|
||||
def _get_remaining(self,cr, uid, context=None):
|
||||
if context and 'active_id' in context:
|
||||
return self.pool.get('project.task').browse(cr, uid, context['active_id'], context=context).remaining_hours
|
||||
return False
|
||||
|
||||
_columns = {
|
||||
'remaining_hours' : fields.float('Remaining Hours', digits=(16,2), help="Put here the remaining hours required to close the task."),
|
||||
'email':fields.boolean('Email', help="If True then send a email of assigned user and description"),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'remaining_hours': _get_remaining,
|
||||
'email':lambda *a : True,
|
||||
}
|
||||
|
||||
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
||||
users_obj = self.pool.get('res.users')
|
||||
obj_tm = users_obj.browse(cr, uid, uid, context).company_id.project_time_mode_id
|
||||
tm = obj_tm and obj_tm.name or 'Hours'
|
||||
|
||||
res = super(config_compute_remaining, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu=submenu)
|
||||
|
||||
if tm in ['Hours','Hour']:
|
||||
return res
|
||||
|
||||
eview = etree.fromstring(res['arch'])
|
||||
|
||||
def _check_rec(eview):
|
||||
if eview.attrib.get('widget','') == 'float_time':
|
||||
eview.set('widget','float')
|
||||
for child in eview:
|
||||
_check_rec(child)
|
||||
return True
|
||||
|
||||
_check_rec(eview)
|
||||
|
||||
res['arch'] = etree.tostring(eview)
|
||||
|
||||
for f in res['fields']:
|
||||
if 'Hours' in res['fields'][f]['string']:
|
||||
res['fields'][f]['string'] = res['fields'][f]['string'].replace('Hours',tm)
|
||||
return res
|
||||
|
||||
def compute_hours(self, cr, uid, ids, context=None):
|
||||
data=self.read(cr,uid,ids)[0]
|
||||
if context is None:
|
||||
context = {}
|
||||
task_obj = self.pool.get('project.task')
|
||||
request = self.pool.get('res.request')
|
||||
user_obj=self.pool.get('res.users')
|
||||
if 'active_id' in context:
|
||||
user_name = self.pool.get('res.users').browse(cr, uid, uid).name
|
||||
description = _("Reopen By ") + user_name + _(" At ") + time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
description += "\n" + "=================================" + "\n"
|
||||
remaining_hrs = self.browse(cr,uid,ids)[0].remaining_hours
|
||||
task_obj.write(cr,uid,context['active_id'],{'remaining_hours':remaining_hrs,'description':description})
|
||||
if context.get('button_reactivate', False):
|
||||
tasks = task_obj.browse(cr, uid, [context['active_id']], context=context)
|
||||
for task in tasks:
|
||||
project = task.project_id
|
||||
if project and project.warn_manager and project.user_id.id and (project.user_id.id != uid):
|
||||
request.create(cr, uid, {
|
||||
'name': _("Task '%s' set in progress") % task.name,
|
||||
'state': 'waiting',
|
||||
'act_from': uid,
|
||||
'act_to': project.user_id.id,
|
||||
'ref_partner_id': task.partner_id.id,
|
||||
'ref_doc1': 'project.task,%d' % task.id,
|
||||
'ref_doc2': 'project.project,%d' % project.id,
|
||||
})
|
||||
task_obj.write(cr, uid, [task.id], {'state': 'open'})
|
||||
if data['email']:
|
||||
if not task.user_id.user_email:
|
||||
raise osv.except_osv(_('Error'), _("Couldn't send mail because email address is not configured!"))
|
||||
else:
|
||||
val = {
|
||||
'name': task.name,
|
||||
'user_id': task.user_id.name,
|
||||
'task_id': "%d/%d" % (project.id, task.id),
|
||||
'state': task.state
|
||||
}
|
||||
subject = "Reopen Task '%s' " % task.name
|
||||
user_email= user_obj.browse(cr, uid, uid).address_id.email
|
||||
signature=user_obj.browse(cr, uid, uid).signature
|
||||
header = (project.warn_header or '') % val
|
||||
footer = (project.warn_footer or '') % val
|
||||
body = u'%s\n%s\n%s\n\n-- \n%s' % (header, task.description, footer, signature)
|
||||
mail_id = email(user_email,[task.user_id.user_email], subject, body.encode('utf-8'), email_bcc=[user_email])
|
||||
if not mail_id:
|
||||
raise osv.except_osv(_('Error'), _("Couldn't send mail! Check the email ids and smtp configuration settings"))
|
||||
|
||||
return {
|
||||
'type': 'ir.actions.act_window_close',
|
||||
}
|
||||
|
||||
config_compute_remaining()
|
||||
class account_analytic_account(osv.osv):
|
||||
|
||||
_inherit = 'account.analytic.account'
|
||||
|
||||
@@ -189,34 +189,6 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_config_compute_remaining" model="ir.ui.view">
|
||||
<field name="name">Compute Remaining Hours </field>
|
||||
<field name="model">config.compute.remaining</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Reevaluate Hours">
|
||||
<separator colspan="4" string="Change Remaining Time"/>
|
||||
<newline/>
|
||||
<field name="remaining_hours" widget="float_time"/>
|
||||
<field name="email"/>
|
||||
<separator string="" colspan="4"/>
|
||||
<group col="4" colspan="4">
|
||||
<button icon="gtk-close" special="cancel" string="Close"/>
|
||||
<button icon="gtk-apply" name="compute_hours" string="Update" type="object" default_focus="1"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_config_compute_remaining" model="ir.actions.act_window">
|
||||
<field name="name">Compute Remaining Hours</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">config.compute.remaining</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<!-- Task -->
|
||||
<record id="view_task_form2" model="ir.ui.view">
|
||||
<field name="name">project.task.form</field>
|
||||
@@ -245,7 +217,7 @@
|
||||
</group>
|
||||
<group col="3" colspan="2">
|
||||
<field name="remaining_hours" widget="float_time" attrs="{'readonly':[('state','!=','draft')]}" colspan="2"/>
|
||||
<button name="%(action_config_compute_remaining)d" string="Reevaluate" type="action" colspan="1" target="new" states="open,pending" icon="gtk-edit"/>
|
||||
<button name="%(action_project_task_reevaluate)d" string="Reevaluate" type="action" colspan="1" target="new" states="open,pending" icon="gtk-edit"/>
|
||||
|
||||
<field name="delay_hours" widget="float_time"/>
|
||||
</group>
|
||||
@@ -264,7 +236,7 @@
|
||||
<field name="state" select="1"/>
|
||||
<button name="do_draft" states="open" string="Draft" type="object" icon="gtk-indent"/>
|
||||
<button name="do_open" states="pending,draft" string="Start Task" type="object" icon="gtk-execute"/>
|
||||
<button name="%(action_config_compute_remaining)d" states="done,cancelled" string="Reactivate" type="action" icon="gtk-convert" context="{'button_reactivate':True}" />
|
||||
<button name="%(action_project_task_reevaluate)d" states="done,cancelled" string="Reactivate" type="action" icon="gtk-convert" context="{'button_reactivate':True}" />
|
||||
<button name="do_pending" states="open" string="Pending" type="object" icon="gtk-media-pause"/>
|
||||
<button groups="base.group_extended" name="%(action_project_task_delegate)d" states="pending,open" string="Delegate" type="action" icon="gtk-sort-descending"/>
|
||||
<button name="%(action_project_task_close)d" states="pending,open" string="Done" type="action" icon="gtk-apply"/>
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
import project_task_close
|
||||
import project_task_delegate
|
||||
import project_task_reevaluate
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
@@ -67,6 +67,12 @@ class project_task_close(osv.osv_memory):
|
||||
res.update({'partner_email': partner.address[0].email})
|
||||
return res
|
||||
|
||||
def done(self, cr, uid, ids, context=None):
|
||||
task_pool = self.pool.get('project.task')
|
||||
task_id = context.get('active_id', False)
|
||||
res = task_pool.do_close(cr, uid, [task_id], context=context)
|
||||
return res
|
||||
|
||||
def confirm(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
@@ -79,7 +85,7 @@ class project_task_close(osv.osv_memory):
|
||||
for data in self.browse(cr, uid, ids, context=context):
|
||||
res = task_pool.do_close(cr, uid, [task.id], context=context)
|
||||
if res:
|
||||
# Send Acknowledgement by Email to Manager and Customer
|
||||
# Send Warn Message by Email to Manager and Customer
|
||||
if data.manager_warn and not data.manager_email:
|
||||
raise osv.except_osv(_('Error'), _("Please specify the email address of Project Manager."))
|
||||
|
||||
|
||||
@@ -20,9 +20,10 @@
|
||||
<separator string="" colspan="4"/>
|
||||
<group colspan="2" col="2">
|
||||
</group>
|
||||
<group colspan="2" col="2">
|
||||
<group colspan="2" col="3">
|
||||
<button icon="gtk-close" special="cancel" string="_Close"/>
|
||||
<button icon="gtk-jump-to" string="_Done" name="confirm" type="object"/>
|
||||
<button icon="gtk-jump-to" string="_Done" special="cancel" name="done" type="object"/>
|
||||
<button icon="terp-mail-message-new" string="_Send+Done" name="confirm" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from lxml import etree
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
|
||||
class project_task_reevaluate(osv.osv_memory):
|
||||
_name = 'project.task.reevaluate'
|
||||
|
||||
def _get_remaining(self,cr, uid, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
active_id = context.get('active_id', False)
|
||||
res = False
|
||||
if active_id:
|
||||
res = self.pool.get('project.task').browse(cr, uid, active_id, context=context).remaining_hours
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'remaining_hours' : fields.float('Remaining Hours', digits=(16,2), help="Put here the remaining hours required to close the task."),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'remaining_hours': _get_remaining,
|
||||
}
|
||||
|
||||
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
||||
res = super(project_task_reevaluate, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu=submenu)
|
||||
users_pool = self.pool.get('res.users')
|
||||
time_mode = users_pool.browse(cr, uid, uid, context).company_id.project_time_mode_id
|
||||
time_mode_name = time_mode and time_mode.name or 'Hours'
|
||||
if time_mode_name in ['Hours','Hour']:
|
||||
return res
|
||||
|
||||
eview = etree.fromstring(res['arch'])
|
||||
|
||||
def _check_rec(eview):
|
||||
if eview.attrib.get('widget','') == 'float_time':
|
||||
eview.set('widget','float')
|
||||
for child in eview:
|
||||
_check_rec(child)
|
||||
return True
|
||||
|
||||
_check_rec(eview)
|
||||
|
||||
res['arch'] = etree.tostring(eview)
|
||||
|
||||
for field in res['fields']:
|
||||
if 'Hours' in res['fields'][field]['string']:
|
||||
res['fields'][field]['string'] = res['fields'][field]['string'].replace('Hours',time_mode_name)
|
||||
return res
|
||||
|
||||
def compute_hours(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
data = self.browse(cr, uid, ids, context=context)[0]
|
||||
task_pool = self.pool.get('project.task')
|
||||
task_id = context.get('active_id', False)
|
||||
if task_id:
|
||||
task_pool.write(cr, uid, task_id, {'remaining_hours': data.remaining_hours})
|
||||
if context.get('button_reactivate', False):
|
||||
task_pool.do_reopen(cr, uid, [task_id], context=context)
|
||||
return {}
|
||||
project_task_reevaluate()
|
||||
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_project_task_reevaluate" model="ir.ui.view">
|
||||
<field name="name">Re-evaluate Task</field>
|
||||
<field name="model">project.task.reevaluate</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Reevaluate Task">
|
||||
<separator colspan="4" string="Reevaluation Task"/>
|
||||
<field name="remaining_hours" widget="float_time"/>
|
||||
<separator string="" colspan="4"/>
|
||||
<group col="2" colspan="2">
|
||||
</group>
|
||||
<group col="2" colspan="2">
|
||||
<button icon="gtk-close" special="cancel" string="_Close"/>
|
||||
<button icon="gtk-apply" name="compute_hours" string="_Evaluate" type="object" default_focus="1"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_project_task_reevaluate" model="ir.actions.act_window">
|
||||
<field name="name">Re-evaluate Task</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">project.task.reevaluate</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user