[REF] project_issue: type_id field is now called stage_id field, to be more coherent. Also moved some methods.

bzr revid: tde@openerp.com-20120523125523-2nfhittdixcu1191
This commit is contained in:
Thibault Delavallée 2012-05-23 14:55:23 +02:00
parent 82b314f661
commit 65a195861a
6 changed files with 74 additions and 82 deletions

View File

@ -35,7 +35,7 @@
<field name="type">graph</field>
<field name="arch" type="xml">
<graph orientation="vertical" string="Project Issue" type="bar">
<field name="type_id"/>
<field name="stage_id"/>
<field name="nbr" operator="+"/>
<field group="True" name="user_id"/>
</graph>
@ -96,7 +96,7 @@
<field name="partner_id"/>
<field name="project_id" />
<field name="priority" string="Priority"/>
<field name="type_id" widget="selection" readonly="1"/>
<field name="stage_id" widget="selection" readonly="1"/>
<button name="prev_type" string="Previous" type="object" icon="gtk-go-back" help="Change to Previous Stage"/>
<button name="next_type" string="Next" type="object" icon="gtk-go-forward" help="Change to Next Stage"/>
<field name="version_id" widget="selection"/>

View File

@ -175,7 +175,7 @@ class project_issue(crm.crm_case, osv.osv):
'partner_id': fields.many2one('res.partner', 'Partner', select=1),
'company_id': fields.many2one('res.company', 'Company'),
'description': fields.text('Description'),
'state': fields.related('type_id', 'state', type="selection", store=True,
'state': fields.related('stage_id', 'state', type="selection", store=True,
selection=_ISSUE_STATE, string="State", readonly=True,
help='The state is set to \'Draft\', when a case is created.\
If the case is in progress the state is set to \'Open\'.\
@ -192,7 +192,7 @@ class project_issue(crm.crm_case, osv.osv):
'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('object_id.model', '=', 'crm.project.bug')]"),
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority', select=True),
'version_id': fields.many2one('project.issue.version', 'Version'),
'type_id': fields.many2one ('project.task.type', 'Stages', domain="[('project_ids', '=', project_id)]"),
'stage_id': fields.many2one ('project.task.type', 'Stages', domain="[('project_ids', '=', project_id)]"),
'project_id':fields.many2one('project.project', 'Project'),
'duration': fields.float('Duration'),
'task_id': fields.many2one('project.task', 'Task', domain="[('project_id','=',project_id)]"),
@ -316,35 +316,22 @@ class project_issue(crm.crm_case, osv.osv):
def convert_to_bug(self, cr, uid, ids, context=None):
return self._convert(cr, uid, ids, 'bug_categ', context=context)
def next_type(self, cr, uid, ids, context=None):
for task in self.browse(cr, uid, ids):
typeid = task.type_id.id
types = map(lambda x:x.id, task.project_id.type_ids or [])
if types:
if not typeid:
self.write(cr, uid, [task.id], {'type_id': types[0]})
elif typeid and typeid in types and types.index(typeid) != len(types)-1 :
index = types.index(typeid)
self.write(cr, uid, [task.id], {'type_id': types[index+1]})
return True
def prev_type(self, cr, uid, ids, context=None):
for task in self.browse(cr, uid, ids):
typeid = task.type_id.id
types = map(lambda x:x.id, task.project_id and task.project_id.type_ids or [])
if types:
if typeid and typeid in types:
index = types.index(typeid)
self.write(cr, uid, [task.id], {'type_id': index and types[index-1] or False})
return True
def copy(self, cr, uid, id, default=None, context=None):
issue = self.read(cr, uid, id, ['name'], context=context)
if not default:
default = {}
default = default.copy()
default['name'] = issue['name'] + _(' (copy)')
return super(project_issue, self).copy(cr, uid, id, default=default,
context=context)
def write(self, cr, uid, ids, vals, context=None):
#Update last action date every time the user change the stage, the state or send a new email
logged_fields = ['type_id', 'state', 'message_ids']
logged_fields = ['stage_id', 'state', 'message_ids']
if any([field in vals for field in logged_fields]):
vals['date_action_last'] = time.strftime('%Y-%m-%d %H:%M:%S')
if vals.get('type_id', False):
stage = self.pool.get('project.task.type').browse(cr, uid, vals['type_id'], context=context)
if vals.get('stage_id', False):
stage = self.pool.get('project.task.type').browse(cr, uid, vals['stage_id'], context=context)
self.message_append_note(cr, uid, ids, body=_("Stage changed to <b>%s</b>.") % stage.name, context=context)
return super(project_issue, self).write(cr, uid, ids, vals, context)
@ -367,6 +354,32 @@ class project_issue(crm.crm_case, osv.osv):
self.create_send_note(cr, uid, [obj_id], context=context)
return obj_id
# -------------------------------------------------------
# Stage management
# -------------------------------------------------------
def next_type(self, cr, uid, ids, context=None):
for task in self.browse(cr, uid, ids):
typeid = task.type_id.id
types = map(lambda x:x.id, task.project_id.type_ids or [])
if types:
if not typeid:
self.write(cr, uid, [task.id], {'stage_id': types[0]})
elif typeid and typeid in types and types.index(typeid) != len(types)-1 :
index = types.index(typeid)
self.write(cr, uid, [task.id], {'stage_id': types[index+1]})
return True
def prev_type(self, cr, uid, ids, context=None):
for task in self.browse(cr, uid, ids):
typeid = task.type_id.id
types = map(lambda x:x.id, task.project_id and task.project_id.type_ids or [])
if types:
if typeid and typeid in types:
index = types.index(typeid)
self.write(cr, uid, [task.id], {'stage_id': index and types[index-1] or False})
return True
def case_open(self, cr, uid, ids, context=None):
res = super(project_issue, self).case_open(cr, uid, ids, context)
self.write(cr, uid, ids, {'date_open': time.strftime('%Y-%m-%d %H:%M:%S'), 'user_id' : uid})
@ -388,6 +401,10 @@ class project_issue(crm.crm_case, osv.osv):
self.case_escalate_send_note(cr, uid, [case.id], context)
return True
# -------------------------------------------------------
# Mail gateway
# -------------------------------------------------------
def message_new(self, cr, uid, msg, custom_values=None, context=None):
"""Automatically called when new email message arrives"""
if context is None:
@ -454,15 +471,6 @@ class project_issue(crm.crm_case, osv.osv):
self.write(cr, uid, ids, {'message_state':'unread'}, context=context)
self.message_append_dict(cr, uid, ids, msg, context=context)
return res
def copy(self, cr, uid, id, default=None, context=None):
issue = self.read(cr, uid, id, ['name'], context=context)
if not default:
default = {}
default = default.copy()
default['name'] = issue['name'] + _(' (copy)')
return super(project_issue, self).copy(cr, uid, id, default=default,
context=context)
# -------------------------------------------------------
# OpenChatter methods and notifications

View File

@ -7,7 +7,6 @@
<field eval="&quot;5&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field name="partner_id" ref="base.res_partner_agrolait"/>
<field eval="&quot;open&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
<field name="categ_id" ref="bug_categ"/>
@ -15,7 +14,7 @@
<field eval="15.0" name="duration"/>
<field eval="&quot;Bug in Accounts module&quot;" name="name"/>
<field eval="&quot;agr@agrolait.com&quot;" name="email_from"/>
<field name="type_id" ref="project.project_tt_specification"/>
<field name="stage_id" ref="project.project_tt_specification"/>
</record>
<record id="crm_case_programnotgivingproperoutput0" model="project.issue">
@ -23,28 +22,26 @@
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field name="partner_id" ref="base.res_partner_asus"/>
<field eval="&quot;done&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
<field eval="3.5" name="duration"/>
<field name="categ_id" ref="bug_categ"/>
<field eval="&quot;Program not giving proper output&quot;" name="name"/>
<field name="project_id" ref="project.project_project_22"/>
<field name="type_id" ref="project.project_tt_specification"/>
<field name="stage_id" ref="project.project_tt_specification"/>
</record>
<record id="crm_case_outputincorrect0" model="project.issue">
<field eval="time.strftime('%Y-%m-18 14:30:00')" name="date"/>
<field eval="&quot;4&quot;" name="priority"/>
<field name="user_id" ref="base.user_demo"/>
<field eval="&quot;cancel&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
<field eval="2.3" name="duration"/>
<field name="categ_id" ref="bug_categ"/>
<field name="project_id" ref="project.project_project_23"/>
<field eval="&quot;Output incorrect&quot;" name="name"/>
<field name="type_id" ref="project.project_tt_development"/>
<field name="stage_id" ref="project.project_tt_development"/>
</record>
<record id="crm_case_problemloadingpage0" model="project.issue">
@ -52,14 +49,13 @@
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field name="partner_id" ref="base.res_partner_14"/>
<field eval="&quot;cancel&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
<field eval="4.0" name="duration"/>
<field name="categ_id" ref="bug_categ"/>
<field name="project_id" ref="project.project_project_22"/>
<field eval="&quot;Problem loading page&quot;" name="name"/>
<field name="type_id" ref="project.project_tt_testing"/>
<field name="stage_id" ref="project.project_tt_testing"/>
</record>
<record id="crm_case_pagenotfound0" model="project.issue">
@ -67,14 +63,13 @@
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field name="partner_id" ref="base.res_partner_desertic_hispafuentes"/>
<field eval="&quot;draft&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
<field eval="1.0" name="duration"/>
<field name="categ_id" ref="bug_categ"/>
<field name="project_id" ref="project.project_project_22"/>
<field eval="&quot;Page not Found&quot;" name="name"/>
<field name="type_id" ref="project.project_tt_development"/>
<field name="stage_id" ref="project.project_tt_development"/>
</record>
<record id="crm_case_programmingerror0" model="project.issue">
@ -82,14 +77,13 @@
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field name="partner_id" ref="base.res_partner_5"/>
<field eval="&quot;pending&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
<field eval="4.0" name="duration"/>
<field name="categ_id" ref="bug_categ"/>
<field name="project_id" ref="project.project_project_22"/>
<field eval="&quot;Programming Error&quot;" name="name"/>
<field name="type_id" ref="project.project_tt_testing"/>
<field name="stage_id" ref="project.project_tt_testing"/>
</record>
<record id="crm_case_logicalerrorinprogram0" model="project.issue">
@ -97,14 +91,13 @@
<field eval="&quot;2&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field name="partner_id" ref="base.res_partner_6"/>
<field eval="&quot;pending&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
<field eval="2.0" name="duration"/>
<field name="categ_id" ref="bug_categ"/>
<field name="project_id" ref="project.project_project_9"/>
<field eval="&quot;Logical Error in Program&quot;" name="name"/>
<field name="type_id" ref="project.project_tt_testing"/>
<field name="stage_id" ref="project.project_tt_testing"/>
</record>
<record id="crm_case_constrainterror0" model="project.issue">
@ -112,14 +105,13 @@
<field eval="&quot;2&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field name="partner_id" ref="base.res_partner_6"/>
<field eval="&quot;pending&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
<field eval="7.3" name="duration"/>
<field name="categ_id" ref="bug_categ"/>
<field name="project_id" ref="project.project_project_9"/>
<field eval="&quot;Constraint Error&quot;" name="name"/>
<field name="type_id" ref="project.project_tt_testing"/>
<field name="stage_id" ref="project.project_tt_testing"/>
</record>
<record id="crm_case_errorinprogram0" model="project.issue">
@ -127,13 +119,12 @@
<field eval="&quot;2&quot;" name="priority"/>
<field name="user_id" ref="base.user_demo"/>
<field name="partner_id" ref="base.res_partner_5"/>
<field eval="&quot;open&quot;" name="state"/>
<field eval="1" name="active"/>
<field eval="1.3" name="duration"/>
<field name="categ_id" ref="feature_request_categ"/>
<field name="project_id" ref="project.project_project_22"/>
<field eval="&quot;Error in Program&quot;" name="name"/>
<field name="type_id" ref="project.project_tt_testing"/>
<field name="stage_id" ref="project.project_tt_testing"/>
</record>
<record id="crm_case_patcheserrorinprogram0" model="project.issue">
@ -141,14 +132,13 @@
<field eval="&quot;2&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field name="partner_id" ref="base.res_partner_2"/>
<field eval="&quot;open&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
<field eval="13.0" name="duration"/>
<field name="categ_id" ref="feature_request_categ"/>
<field name="project_id" ref="project.project_project_9"/>
<field eval="&quot;Patches Error in Program&quot;" name="name"/>
<field name="type_id" ref="project.project_tt_testing"/>
<field name="stage_id" ref="project.project_tt_testing"/>
</record>
<record id="crm_case_newfeaturestobeadded0" model="project.issue">
@ -156,14 +146,13 @@
<field eval="&quot;4&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field name="partner_id" ref="base.res_partner_maxtor"/>
<field eval="&quot;open&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
<field eval="3.2" name="duration"/>
<field name="categ_id" ref="feature_request_categ"/>
<field name="project_id" ref="project.project_project_21"/>
<field eval="&quot;New Features To Be Added&quot;" name="name"/>
<field name="type_id" ref="project.project_tt_merge"/>
<field name="stage_id" ref="project.project_tt_merge"/>
</record>
<record id="crm_case_addmenustothemodule0" model="project.issue">
@ -171,7 +160,6 @@
<field eval="&quot;1&quot;" name="priority"/>
<field name="user_id" ref="base.user_demo"/>
<field name="partner_id" ref="base.res_partner_9"/>
<field eval="&quot;done&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
<field eval="3.0" name="duration"/>
@ -179,7 +167,7 @@
<field name="project_id" ref="project.project_project_21"/>
<field eval="&quot;Add menus to the module&quot;" name="name"/>
<field eval="&quot;info@opensides.be&quot;" name="email_from"/>
<field name="type_id" ref="project.project_tt_development"/>
<field name="stage_id" ref="project.project_tt_development"/>
</record>
<record id="crm_case_includeattendancesheetinproject0" model="project.issue">
@ -187,7 +175,6 @@
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field name="partner_id" ref="base.res_partner_10"/>
<field eval="&quot;cancel&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
<field eval="2.0" name="duration"/>
@ -195,7 +182,7 @@
<field name="project_id" ref="project.project_project_9"/>
<field eval="&quot;Include Attendance sheet in Project&quot;" name="name"/>
<field eval="&quot;contact@tecsas.fr&quot;" name="email_from"/>
<field name="type_id" ref="project.project_tt_development"/>
<field name="stage_id" ref="project.project_tt_development"/>
</record>
<record id="crm_case_createnewobject0" model="project.issue">
@ -203,14 +190,13 @@
<field eval="&quot;3&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field name="partner_id" ref="base.res_partner_6"/>
<field eval="&quot;draft&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
<field eval="2.45" name="duration"/>
<field name="categ_id" ref="feature_request_categ"/>
<field name="project_id" ref="project.project_project_22"/>
<field eval="&quot;Create new object&quot;" name="name"/>
<field name="type_id" ref="project.project_tt_specification"/>
<field name="stage_id" ref="project.project_tt_specification"/>
</record>
<record id="crm_case_improvereportsinhrms0" model="project.issue">
@ -218,14 +204,13 @@
<field eval="&quot;4&quot;" name="priority"/>
<field name="user_id" ref="base.user_root"/>
<field name="partner_id" ref="base.res_partner_11"/>
<field eval="&quot;pending&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
<field eval="15.0" name="duration"/>
<field name="categ_id" ref="feature_request_categ"/>
<field name="project_id" ref="project.project_project_22"/>
<field eval="&quot;Improve Reports in HRMS&quot;" name="name"/>
<field name="type_id" ref="project.project_tt_development"/>
<field name="stage_id" ref="project.project_tt_development"/>
</record>
<record id="crm_case_improvereportsinpms0" model="project.issue">
@ -233,14 +218,13 @@
<field eval="&quot;2&quot;" name="priority"/>
<field name="user_id" ref="base.user_demo"/>
<field name="partner_id" ref="base.res_partner_11"/>
<field eval="&quot;pending&quot;" name="state"/>
<field name="section_id" ref="crm.section_sales_department"/>
<field eval="1" name="active"/>
<field eval="06.15" name="duration"/>
<field name="categ_id" ref="feature_request_categ"/>
<field name="project_id" ref="project.project_project_22"/>
<field eval="&quot;Improve Reports in PMS&quot;" name="name"/>
<field name="type_id" ref="project.project_tt_specification"/>
<field name="stage_id" ref="project.project_tt_specification"/>
</record>
</data>

View File

@ -75,8 +75,8 @@
</group>
<field name="user_id"/>
<field name="version_id" colspan="2" widget="selection"/>
<group colspan="2" col="4" attrs="{'invisible': [('type_id','=', False)]}">
<field name="type_id" string="Stages" />
<group colspan="2" col="4" attrs="{'invisible': [('stage_id','=', False)]}">
<field name="stage_id"/>
<button name="prev_type" string="Previous" type="object" icon="gtk-go-back" help="Change to Previous Stage"/>
<button name="next_type" string="Next" type="object" icon="gtk-go-forward" help="Change to Next Stage"/>
</group>
@ -138,9 +138,9 @@
<field name="partner_id"/>
<field name="project_id" />
<field name="priority" string="Priority"/>
<field name="type_id" widget="selection" readonly="1" string="Stages" />
<button name="prev_type" string="Previous" type="object" icon="gtk-go-back" help="Change to Previous Stage" attrs="{'invisible': [('type_id','=', False)]}"/>
<button name="next_type" string="Next" type="object" icon="gtk-go-forward" help="Change to Next Stage" attrs="{'invisible': [('type_id','=', False)]}"/>
<field name="stage_id" widget="selection" readonly="1"/>
<button name="prev_type" string="Previous" type="object" icon="gtk-go-back" help="Change to Previous Stage" attrs="{'invisible': [('stage_id','=', False)]}"/>
<button name="next_type" string="Next" type="object" icon="gtk-go-forward" help="Change to Next Stage" attrs="{'invisible': [('stage_id','=', False)]}"/>
<field name="version_id" widget="selection"/>
<field name="user_id"/>
<field name="progress" widget="progressbar" attrs="{'invisible':[('task_id','=',False)]}"/>
@ -193,7 +193,7 @@
<filter string="Priority" icon="terp-rating-rated" domain="[]"
context="{'group_by':'priority'}" />
<filter string="Stage" icon="terp-stage" domain="[]"
context="{'group_by':'type_id'}" />
context="{'group_by':'stage_id'}" />
<filter string="Status" icon="terp-stock_effects-object-colorize" domain="[]"
context="{'group_by':'state'}" />
<separator orientation="vertical" />
@ -225,7 +225,7 @@
<field name="model">project.issue</field>
<field name="type">kanban</field>
<field name="arch" type="xml">
<kanban default_group_by="type_id">
<kanban default_group_by="stage_id">
<field name="color"/>
<field name="state" groups="base.group_no_one"/>
<field name="priority"/>
@ -305,7 +305,7 @@
<field name="name" string="Feature description"/>
<field name="partner_id"/>
<field name="priority" string="Priority"/>
<field name="type_id" widget="selection" readonly="1"/>
<field name="stage_id" widget="selection" readonly="1"/>
<button name="prev_type" string="Previous" type="object" icon="gtk-go-back" help="Change to Previous Stage"/>
<button name="next_type" string="Next" type="object" icon="gtk-go-forward" help="Change to Next Stage"/>
<field name="version_id"/>

View File

@ -51,7 +51,7 @@ class project_issue_report(osv.osv):
'creation_date': fields.date('Creation Date', readonly=True),
'date_closed': fields.date('Date of Closing', readonly=True),
'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'project.issue')]"),
'type_id': fields.many2one('project.task.type', 'Stage'),
'stage_id': fields.many2one('project.task.type', 'Stage'),
'nbr': fields.integer('# of Issues', readonly=True),
'working_hours_open': fields.float('Avg. Working Hours to Open', readonly=True),
'working_hours_close': fields.float('Avg. Working Hours to Close', readonly=True),
@ -87,7 +87,7 @@ class project_issue_report(osv.osv):
c.working_hours_close,
c.section_id,
c.categ_id,
c.type_id,
c.stage_id,
to_char(c.date_closed, 'YYYY-mm-dd') as date_closed,
c.company_id as company_id,
c.priority as priority,

View File

@ -11,7 +11,7 @@
<field name="name" invisible="1"/>
<field name="month" invisible="1"/>
<field name="project_id" invisible="1"/>
<field name="type_id" invisible="1"/>
<field name="stage_id" invisible="1"/>
<field name="version_id" string="Version" invisible="1"/>
<field name="priority" invisible="1"/>
<field name="company_id" invisible="1" groups="base.group_multi_company"/>
@ -103,7 +103,7 @@
<filter string="Version" icon="terp-stock_symbol-selection" domain="[]" context="{'group_by':'version_id'}"/>
<separator orientation="vertical" />
<filter string="Priority" icon="terp-rating-rated" domain="[]" context="{'group_by':'priority'}" />
<filter string="Stage" icon="terp-stage" domain="[]" context="{'group_by':'type_id'}"/>
<filter string="Stage" icon="terp-stage" domain="[]" context="{'group_by':'stage_id'}"/>
<filter string="Status" icon="terp-stock_effects-object-colorize"
domain="[]" context="{'group_by':'state'}" />
<separator orientation="vertical"/>