[IMP]: Improved code for changing task type. It changes only to those types allowed in project.
bzr revid: uco@tinyerp.co.in-20100119113255-lyth4pwq12o43370
This commit is contained in:
@@ -41,7 +41,7 @@ works done on tasks, eso. It is able to render planning, order tasks, eso.
|
||||
"process/task_process.xml",
|
||||
"project_installer.xml",
|
||||
],
|
||||
'demo_xml': [#'project_demo.xml'
|
||||
'demo_xml': ['project_demo.xml'
|
||||
|
||||
],
|
||||
'installable': True,
|
||||
|
||||
+19
-11
@@ -336,7 +336,7 @@ class task(osv.osv):
|
||||
'description': fields.text('Description'),
|
||||
'priority' : fields.selection([('4','Very Low'), ('3','Low'), ('2','Medium'), ('1','Urgent'), ('0','Very urgent')], 'Importance'),
|
||||
'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of tasks."),
|
||||
'type': fields.many2one('project.task.type', 'Type'),
|
||||
'type': fields.many2one('project.task.type', 'Type', readonly=True),
|
||||
'state': fields.selection([('draft', 'Draft'),('open', 'In Progress'),('pending', 'Pending'), ('cancelled', 'Cancelled'), ('done', 'Done')], 'State', readonly=True, required=True,
|
||||
help='If the task is created the state \'Draft\'.\n If the task is started, the state becomes \'In Progress\'.\n If review is needed the task is in \'Pending\' state.\
|
||||
\n If the task is over, the states is set to \'Done\'.'),
|
||||
@@ -490,26 +490,34 @@ class task(osv.osv):
|
||||
|
||||
def next_type(self, cr, uid, ids, *args):
|
||||
type_obj = self.pool.get('project.task.type')
|
||||
type_ids = type_obj.search(cr,uid,[])
|
||||
types = []
|
||||
for typ in self.browse(cr, uid, ids):
|
||||
typeid = typ.type.id
|
||||
if typeid and type_ids.index(typeid) != len(type_ids)-1 :
|
||||
index = type_ids.index(typeid)
|
||||
types = map(lambda x:x.id, typ.project_id.allowed_task_type)
|
||||
if types:
|
||||
if typeid and typeid in types and types.index(typeid) != len(types)-1 :
|
||||
index = types.index(typeid)
|
||||
else:
|
||||
index = -1
|
||||
self.write(cr, uid, typ.id, {'type': types[index+1]})
|
||||
else:
|
||||
index = -1
|
||||
self.write(cr, uid, typ.id, {'type': type_ids[index+1]})
|
||||
self.write(cr, uid, typ.id, {'type': ''})
|
||||
return True
|
||||
|
||||
def prev_type(self, cr, uid, ids, *args):
|
||||
type_obj = self.pool.get('project.task.type')
|
||||
type_ids = type_obj.search(cr,uid,[])
|
||||
types = []
|
||||
for typ in self.browse(cr, uid, ids):
|
||||
typeid = typ.type.id
|
||||
if typeid and type_ids.index(typeid) != 0 :
|
||||
index = type_ids.index(typeid)
|
||||
types = map(lambda x:x.id, typ.project_id.allowed_task_type)
|
||||
if types:
|
||||
if typeid and typeid in types and types.index(typeid) != 0 :
|
||||
index = types.index(typeid)
|
||||
else:
|
||||
index = len(types)
|
||||
self.write(cr, uid, typ.id, {'type': types[index-1]})
|
||||
else:
|
||||
index = len(type_ids)
|
||||
self.write(cr, uid, typ.id, {'type': type_ids[index - 1]})
|
||||
self.write(cr, uid, typ.id, {'type': ''})
|
||||
return True
|
||||
|
||||
task()
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<field name="project_time_mode_id" ref="product.uom_hour"></field>
|
||||
</record>
|
||||
|
||||
<!-- Task Types -->
|
||||
<record id="project_tt_specification" model="project.task.type">
|
||||
<field name="sequence">1</field>
|
||||
<field name="name">Specification</field>
|
||||
@@ -25,11 +26,13 @@
|
||||
<field name="sequence">4</field>
|
||||
<field name="name">Merge</field>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- Projects -->
|
||||
<record id="project_project_9" model="project.project">
|
||||
<field name="warn_manager">1</field>
|
||||
<field name="name">Open ERP Integration</field>
|
||||
<field name="manager" ref="base.user_root"/>
|
||||
<field eval="[(6, 0, [ref('project_tt_specification'),ref('project_tt_development'),ref('project_tt_testing'),ref('project_tt_merge')])]" name="allowed_task_type"/>
|
||||
</record>
|
||||
<record id="project_project_21" model="project.project">
|
||||
<field name="warn_manager">1</field>
|
||||
@@ -38,6 +41,7 @@
|
||||
<field name="name">Study + Prototype</field>
|
||||
<field model="account.analytic.account" name="category_id" search="[('name','=', 'Seagate P1')]"/>
|
||||
<field name="manager" ref="base.user_root"/>
|
||||
<field eval="[(6, 0, [ref('project_tt_specification'),ref('project_tt_development')])]" name="allowed_task_type"/>
|
||||
</record>
|
||||
<record id="project_project_22" model="project.project">
|
||||
<field name="priority">20</field>
|
||||
@@ -45,6 +49,7 @@
|
||||
<field name="name">Specific Developements</field>
|
||||
<field model="account.analytic.account" name="category_id" search="[('name','=', 'Seagate P1')]"/>
|
||||
<field name="manager" ref="base.user_root"/>
|
||||
<field eval="[(6, 0, [ref('project_tt_specification'), ref('project_tt_development')])]" name="allowed_task_type"/>
|
||||
</record>
|
||||
<record id="project_project_23" model="project.project">
|
||||
<field name="priority">30</field>
|
||||
@@ -52,8 +57,10 @@
|
||||
<field name="name">Install, data import, configuration</field>
|
||||
<field model="account.analytic.account" name="category_id" search="[('name','=', 'Seagate P1')]"/>
|
||||
<field name="manager" ref="base.user_root"/>
|
||||
<field eval="[(6, 0, [ref('project_tt_development')])]" name="allowed_task_type"/>
|
||||
</record>
|
||||
|
||||
<!-- Tasks -->
|
||||
<record id="project_task_116" model="project.task">
|
||||
<field name="planned_hours">38.0</field>
|
||||
<field name="remaining_hours">38.0</field>
|
||||
|
||||
Reference in New Issue
Block a user