[CLEAN] project: cleaned code and branch modifications before merging.

bzr revid: tde@openerp.com-20120601084050-880kxdqcubyuknqs
This commit is contained in:
Thibault Delavallée 2012-06-01 10:40:50 +02:00
parent 1a009c8f84
commit 34569d4303
5 changed files with 54 additions and 81 deletions

View File

@ -17,11 +17,16 @@
<field name="planned_hours" widget="float_time"/>
<field name="effective_hours" widget="float_time"/>
<field name="progress" widget="progressbar"/>
<field name="stage_id" invisible="context.get('set_visible',False)"/>
<field name="state" invisible="context.get('set_visible',False)" groups="base.group_no_one"/>
<button name="do_cancel" states="draft,open,pending" string="Cancel" type="object" icon="gtk-cancel" help="For cancelling the task" groups="base.group_no_one"/>
<button name="do_open" states="pending,draft,done,cancel" string="Start Task" type="object" icon="gtk-execute" help="For changing to open state" invisible="context.get('set_visible',False)" groups="base.group_no_one"/>
<button name="%(action_project_task_delegate)d" states="pending,open,draft" string="Delegate" type="action" icon="gtk-sort-descending" help="For changing to delegate state"/>
<button name="action_close" states="draft,pending,open" string="Done" type="object" icon="terp-dialog-close" help="For changing to done state" groups="base.group_no_one"/>
<button name="do_open" string="Start Task" type="object"
states="draft,pending" icon="gtk-go-forward" invisible="context.get('set_visible',False)"/>
<button name="action_close" string="Done" type="object"
states="draft,open,pending" icon="gtk-apply" invisible="context.get('set_visible',False)"/>
<button name="do_cancel" string="Cancel" type="object"
states="open,draft,pending" icon="gtk-cancel" invisible="context.get('set_visible',False)"/>
<button name="%(action_project_task_delegate)d" string="Delegate" type="action"
states="pending,open,draft" icon="gtk-sort-descending"/>
</tree>
</field>
</record>
@ -39,10 +44,14 @@
<field name="date_deadline"/>
<field name="total_hours" widget="float_time"/>
<field name="progress" widget="progressbar"/>
<field name="stage_id" invisible="context.get('set_visible',False)"/>
<field name="state" invisible="context.get('set_visible',False)" groups="base.group_no_one"/>
<button name="do_cancel" states="draft,open,pending" string="Cancel" type="object" icon="gtk-cancel" help="For cancelling the task" groups="base.group_no_one"/>
<button name="do_open" states="pending,draft,done,cancel" string="Start Task" type="object" icon="gtk-execute" help="For changing to open state" invisible="context.get('set_visible',False)" groups="base.group_no_one"/>
<button name="action_close" states="draft,pending,open" string="Done" type="object" icon="gtk-apply" help="For changing to done state" groups="base.group_no_one"/>
<button name="do_open" string="Start Task" type="object"
states="draft,pending" icon="gtk-go-forward" invisible="context.get('set_visible',False)"/>
<button name="action_close" string="Done" type="object"
states="draft,open,pending" icon="gtk-apply" invisible="context.get('set_visible',False)"/>
<button name="do_cancel" string="Cancel" type="object"
states="open,draft,pending" icon="gtk-cancel" invisible="context.get('set_visible',False)"/>
</tree>
</field>
</record>

View File

@ -46,8 +46,8 @@ class project_task_type(osv.osv):
help="This stage is not visible, for example in status bar or kanban view, when there are no records in that stage to display."),
}
_defaults = {
'state': 'draft',
'sequence': 1,
'state': 'draft',
'fold': False,
}
_order = 'sequence'
@ -243,7 +243,6 @@ class project(osv.osv):
task_obj = self.pool.get('project.task')
task_ids = task_obj.search(cr, uid, [('project_id', 'in', ids), ('state', 'not in', ('cancelled', 'done'))])
task_obj.case_close(cr, uid, task_ids, context=context)
#task_obj.write(cr, uid, task_ids, {'state': 'done', 'date_end':time.strftime('%Y-%m-%d %H:%M:%S'), 'remaining_hours': 0.0})
self.write(cr, uid, ids, {'state':'close'}, context=context)
self.set_close_send_note(cr, uid, ids, context=context)
return True
@ -252,7 +251,6 @@ class project(osv.osv):
task_obj = self.pool.get('project.task')
task_ids = task_obj.search(cr, uid, [('project_id', 'in', ids), ('state', '!=', 'done')])
task_obj.case_cancel(cr, uid, task_ids, context=context)
#task_obj.write(cr, uid, task_ids, {'state': 'cancelled', 'date_end':time.strftime('%Y-%m-%d %H:%M:%S'), 'remaining_hours': 0.0})
self.write(cr, uid, ids, {'state':'cancelled'}, context=context)
self.set_cancel_send_note(cr, uid, ids, context=context)
return True
@ -522,7 +520,7 @@ class task(base_stage, osv.osv):
def _get_default_stage_id(self, cr, uid, context=None):
""" Gives default stage_id """
project_id = self._get_default_project_id(cr, uid, context=context)
return self.stage_find(cr, uid, [], False, [('state', '=', 'draft')], context=context)
return self.stage_find(cr, uid, [], project_id, [('state', '=', 'draft')], context=context)
def _resolve_project_id_from_context(self, cr, uid, context=None):
""" Returns ID of project based on the value of 'default_project_id'
@ -531,8 +529,7 @@ class task(base_stage, osv.osv):
"""
if context is None: context = {}
if type(context.get('default_project_id')) in (int, long):
project_id = context['default_project_id']
return project_id
return context['default_project_id']
if isinstance(context.get('default_project_id'), basestring):
project_name = context['default_project_id']
project_ids = self.pool.get('project.project').name_search(cr, uid, name=project_name, context=context)
@ -581,7 +578,7 @@ class task(base_stage, osv.osv):
_group_by_full = {
'stage_id': _read_group_stage_ids,
'user_id': _read_group_user_id
'user_id': _read_group_user_id,
}
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False):
@ -752,7 +749,7 @@ class task(base_stage, osv.osv):
'sequence': 10,
'active': True,
'user_id': lambda obj, cr, uid, context: uid,
'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'project.task', context=c)
'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'project.task', context=c),
}
_order = "priority, sequence, date_start, name, id"
@ -1130,9 +1127,9 @@ class task(base_stage, osv.osv):
vals_reset_kstate = dict(vals, kanban_state='normal')
for t in self.browse(cr, uid, ids, context=context):
#TO FIX:Kanban view doesn't raise warning
# stages = [stage.id for stage in t.project_id.type_ids]
# if new_stage not in stages:
# raise osv.except_osv(_('Warning !'), _('Stage is not defined in the project.'))
#stages = [stage.id for stage in t.project_id.type_ids]
#if new_stage not in stages:
#raise osv.except_osv(_('Warning !'), _('Stage is not defined in the project.'))
write_vals = vals_reset_kstate if t.stage_id != new_stage else vals
super(task,self).write(cr, uid, [t.id], write_vals, context=context)
result = True
@ -1140,7 +1137,6 @@ class task(base_stage, osv.osv):
result = super(task,self).write(cr, uid, ids, vals, context=context)
if ('stage_id' in vals) or ('remaining_hours' in vals) or ('user_id' in vals) or ('state' in vals) or ('kanban_state' in vals):
self._store_history(cr, uid, ids, context=context)
self.state_change_send_note(cr, uid, ids, context)
return result
def unlink(self, cr, uid, ids, context=None):
@ -1200,6 +1196,11 @@ class task(base_stage, osv.osv):
sub_ids.append(obj.manager_id.id)
return self.pool.get('res.users').read(cr, uid, sub_ids, context=context)
def stage_set_send_note(self, cr, uid, ids, stage_id, context=None):
""" Override of the (void) default notification method. """
stage_name = self.pool.get('project_task_type').name_get(cr, uid, [stage_id], context=context)[0][1]
return self.message_append_note(cr, uid, ids, body= _("Stage changed to <b>%s</b>.") % (stage_name), context=context)
def create_send_note(self, cr, uid, ids, context=None):
return self.message_append_note(cr, uid, ids, body=_("Task has been <b>created</b>."), context=context)
@ -1207,48 +1208,12 @@ class task(base_stage, osv.osv):
msg = _('Task has been set as <b>draft</b>.')
return self.message_append_note(cr, uid, ids, body=msg, context=context)
def case_open_send_note(self, cr, uid, ids, context=None):
#for id in ids:
#msg = _('%s has been <b>opened</b>.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context))
#self.message_append_note(cr, uid, [id], body=msg, context=context)
return True
def case_close_send_note(self, cr, uid, ids, context=None):
#for id in ids:
#msg = _('%s has been <b>closed</b>.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context))
#self.message_append_note(cr, uid, [id], body=msg, context=context)
return True
def case_cancel_send_note(self, cr, uid, ids, context=None):
#for id in ids:
#msg = _('%s has been <b>canceled</b>.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context))
#self.message_append_note(cr, uid, [id], body=msg, context=context)
return True
def case_pending_send_note(self, cr, uid, ids, context=None):
#for id in ids:
#msg = _('%s is now <b>pending</b>.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context))
#self.message_append_note(cr, uid, [id], body=msg, context=context)
return True
def case_reset_send_note(self, cr, uid, ids, context=None):
#for id in ids:
#msg = _('%s has been <b>renewed</b>.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context))
#self.message_append_note(cr, uid, [id], body=msg, context=context)
return True
def do_delegation_send_note(self, cr, uid, ids, context=None):
for task in self.browse(cr, uid, ids, context=context):
msg = _('Task has been <b>delegated</b> to <em>%s</em>.') % (task.user_id.name)
self.message_append_note(cr, uid, [task.id], body=msg, context=context)
return True
def state_change_send_note(self, cr, uid, ids, context=None):
for task in self.browse(cr, uid, ids, context=context):
msg = _('Stage changed to <b>%s</b>') % (task.stage_id.name)
self.message_append_note(cr, uid, [task.id], body=msg, context=context)
return True
class project_work(osv.osv):
_name = "project.task.work"

View File

@ -1,9 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<!--
<data noupdate="1">
-->
<data>
<!-- Requests Links -->
<record id="req_link_project" model="res.request.link">
@ -28,37 +25,38 @@
<field name="sequence">1</field>
<field name="name">Design</field>
<field name="state">draft</field>
<field name="case_default" eval="1"/>
<field name="case_default" eval="True"/>
</record>
<record id="project_tt_development" model="project.task.type">
<field name="sequence">2</field>
<field name="name">Development</field>
<field name="state">open</field>
<field name="case_default" eval="1"/>
<field name="case_default" eval="True"/>
</record>
<record id="project_tt_testing" model="project.task.type">
<field name="sequence">3</field>
<field name="name">Testing</field>
<field name="state">open</field>
<field name="case_default" eval="1"/>
<field name="case_default" eval="True"/>
</record>
<record id="project_tt_pending" model="project.task.type">
<field name="sequence">4</field>
<field name="name">Pending</field>
<field name="state">pending</field>
<field name="case_default" eval="1"/>
<field name="case_default" eval="True"/>
<field name="fold" eval="True"/>
</record>
<record id="project_tt_merge" model="project.task.type">
<field name="sequence">5</field>
<field name="name">Deployment</field>
<field name="state">done</field>
<field name="case_default" eval="1"/>
<field name="case_default" eval="True"/>
</record>
<record id="project_tt_cancel" model="project.task.type">
<field name="sequence">6</field>
<field name="name">Cancelled</field>
<field name="state">cancelled</field>
<field name="case_default" eval="1"/>
<field name="case_default" eval="True"/>
<field name="fold" eval="True"/>
</record>
</data>

View File

@ -306,9 +306,9 @@
<form string="Project" layout="manual">
<div class="oe_form_topbar">
<button name="do_open" string="Start Task" type="object"
states="pending,draft"/>
<button name="%(action_project_task_reevaluate)d" string="Reactivate" type="action" context="{'button_reactivate':True}"
states="done,cancelled"/>
states="draft,pending"/>
<button name="%(action_project_task_reevaluate)d" string="Reactivate" type="action"
states="done,cancelled" context="{'button_reactivate':True}"/>
<button name="do_pending" string="Pending" type="object"
states="open"/>
<button name="action_close" string="Done" type="object"
@ -319,10 +319,10 @@
states="pending,open,draft"/>
<button name="do_cancel" string="Cancel" type="object"
states="draft,open,pending" />
<button name="stage_previous" string="Previous" type="object"
states="open" icon="gtk-go-back"/>
<button name="stage_next" string="Next" type="object"
states="open" icon="gtk-go-forward"/>
<button name="stage_previous" string="Previous Stage" type="object"
states="open,pending" icon="gtk-go-back" attrs="{'invisible': [('stage_id','=', False)]}"/>
<button name="stage_next" string="Next Stage" type="object"
states="open,pending" icon="gtk-go-forward" attrs="{'invisible': [('stage_id','=', False)]}"/>
<div class="oe_right">
<field name="stage_id" nolabel="1" widget="statusbar"/>
</div>
@ -472,7 +472,7 @@
type="object" class="oe_kanban_button"><t t-esc="time[0]"/></a
><b t-if="time[1]" class="oe_kanban_button oe_kanban_button_active"><t t-esc="Math.round(hours)"/></b
></t>
<a name="do_open" states="draft" string="Validate planned time and open task" type="object" class="oe_kanban_button oe_kanban_button_active" groups="base.group_no_one">!</a>
<a name="do_open" states="draft" string="Validate planned time and open task" type="object" class="oe_kanban_button oe_kanban_button_active">!</a>
</span>
</div>
<div class="oe_kanban_clear"/>
@ -482,7 +482,7 @@
<a string="Edit" icon="gtk-edit" type="edit"/>
<a string="Change Color" icon="color-picker" type="color" name="color"/>
<a name="%(action_project_task_delegate)d" states="pending,open,draft" string="Delegate" type="action" icon="terp-personal"/>
<a name="action_close" states="draft,pending,open" string="Done" type="object" icon="terp-dialog-close" groups="base.group_no_one"/>
<a name="action_close" states="draft,pending,open" string="Done" type="object" icon="terp-dialog-close"/>
</div>
<div class="oe_kanban_right">
<a name="set_kanban_state_blocked" string="Mark as Blocked" kanban_states="normal,done" type="object" icon="kanban-stop"/>
@ -518,16 +518,16 @@
<field name="remaining_hours" widget="float_time" sum="Remaining Hours" on_change="onchange_remaining(remaining_hours,planned_hours)" invisible="context.get('set_visible',False)" groups="project.group_time_work_estimation_tasks"/>
<field name="date_deadline" invisible="context.get('deadline_visible',True)"/>
<button name="do_open" string="Start Task" type="object"
icon="gtk-media-play" states="pending,draft"/>
states="draft,pending" icon="gtk-go-forward"/>
<button name="action_close" string="Done" type="object"
icon="terp-dialog-close" states="draft,open,pending"/>
states="draft,open,pending" icon="gtk-apply"/>
<button name="%(action_project_task_delegate)d" string="Delegate" type="action"
icon="terp-personal" states="pending,open,draft"/>
states="pending,open,draft" icon="terp-personal"/>
<field name="stage_id" invisible="context.get('set_visible',False)"/>
<button name="stage_previous" string="Previous" type="object"
icon="gtk-go-back" states="open" attrs="{'invisible': [('stage_id','=', False)]}"/>
<button name="stage_next" string="Next" type="object"
icon="gtk-go-forward" states="open" attrs="{'invisible': [('stage_id','=', False)]}"/>
<button name="stage_previous" string="Previous Stage" type="object"
states="open,pending" icon="gtk-go-back" attrs="{'invisible': [('stage_id','=', False)]}"/>
<button name="stage_next" string="Next Stage" type="object"
states="open,pending" icon="gtk-go-forward" attrs="{'invisible': [('stage_id','=', False)]}"/>
<field name="state" invisible="context.get('set_visible',False)" groups="base.group_no_one"/>
<field name="date_start" invisible="1" groups="base.group_no_one"/>
<field name="date_end" invisible="1" groups="base.group_no_one"/>
@ -724,7 +724,7 @@
<menuitem id="menu_project_config_project" name="Stages" parent="project.menu_definitions" sequence="1"/>
<menuitem action="open_task_type_form" name="Issue Stages" id="menu_task_types_view" parent="menu_project_config_project" sequence="2"/>
<menuitem action="open_task_type_form" name="Task Stages" id="menu_task_types_view" parent="menu_project_config_project" sequence="2"/>
<menuitem action="open_view_project_all" id="menu_projects" name="Projects" parent="menu_project_management" sequence="1" groups="base.group_no_one"/>
<act_window context="{'search_default_user_id': [active_id], 'default_user_id': active_id}" id="act_res_users_2_project_project" name="User's projects" res_model="project.project" src_model="res.users" view_mode="tree,form" view_type="form"/>

View File

@ -15,6 +15,7 @@
<field name="user_id"/>
<field name="remaining_hours"/>
<field name="kanban_state"/>
<field name="stage_id"/>
<field name="state" groups="base.group_no_one"/>
</tree>
</field>