[MERGE, IMP] project, project_issue:merge mdi branch and update data for project
authorPurnendu Singh (OpenERP) <psi@tinyerp.com>
Thu, 19 Apr 2012 11:52:19 +0000 (17:22 +0530)
committerPurnendu Singh (OpenERP) <psi@tinyerp.com>
Thu, 19 Apr 2012 11:52:19 +0000 (17:22 +0530)
bzr revid: psi@tinyerp.com-20120419115219-mqfwp9f898vya1wh

addons/project/project.py
addons/project/project_data.xml
addons/project_issue/project_issue.py

index 9a128d2..7751a46 100644 (file)
@@ -677,12 +677,11 @@ class task(osv.osv):
         return result.keys()
 
     def _save_state(self, cr, uid, task_id, field_name, field_value, arg, context=None):
-        stage_obj = self.pool.get('project.task.type')
-        stage_ids = stage_obj.search(cr, uid, [('state', '=', field_value)], context=context)
+        stage_ids = self.pool.get('project.task.type').search(cr, uid, [('state', '=', field_value)], context=context)
         if stage_ids:
             self.write(cr, uid, task_id, {'type_id': stage_ids[0]}, context=context)
         else:
-            cr.execute("""update project_task set state=%s where id=%s""", (field_value, task_id, ))
+            cr.execute("""UPDATE project_task SET state=%s WHERE id=%s""", (field_value, task_id, ))
         return True
 
     _columns = {
@@ -693,11 +692,13 @@ class task(osv.osv):
         'sequence': fields.integer('Sequence', select=True, help="Gives the sequence order when displaying a list of tasks."),
         'type_id': fields.many2one('project.task.type', 'Stage'),
         'state': fields.function(_get_state, fnct_inv=_save_state, type='selection', selection=_TASK_STATE, string="State", readonly=True,
-        store = {
+            store = {
                 'project.task': (lambda self, cr, uid, ids, c={}: ids, ['type_id'], 10),
                 'project.task.type': (_get_stage, ['state'], 10)
-        }, help='If the task is created the state is \'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\'.'),
+            }, help='If the task is created the state is \'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\'.'),
         'kanban_state': fields.selection([('normal', 'Normal'),('blocked', 'Blocked'),('done', 'Ready To Pull')], 'Kanban State',
                                          help="A task's kanban state indicates special situations affecting it:\n"
                                               " * Normal is the default situation\n"
@@ -1116,6 +1117,10 @@ class task(osv.osv):
             new_stage = vals.get('type_id')
             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.'))
                 write_vals = vals_reset_kstate if t.type_id != new_stage else vals
                 super(task,self).write(cr, uid, [t.id], write_vals, context=context)
             result = True
index b7b5991..48bc343 100644 (file)
         <record id="project_tt_specification" model="project.task.type">
             <field name="sequence">1</field>
             <field name="name">Design</field>
+            <field name="state">draft</field>
             <field name="project_default" eval="1"/>
         </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="project_default" eval="1"/>
         </record>
         <record id="project_tt_testing" model="project.task.type">
             <field name="sequence">3</field>
             <field name="name">Testing</field>
+            <field name="state">pending</field>
             <field name="project_default" eval="1"/>
         </record>
         <record id="project_tt_merge" model="project.task.type">
             <field name="sequence">4</field>
             <field name="name">Deployment</field>
+            <field name="state">done</field>
             <field name="project_default" eval="1"/>
         </record>
     </data>
index 38d948c..90697d4 100644 (file)
@@ -184,12 +184,11 @@ class project_issue(crm.crm_case, osv.osv):
         return result.keys()
 
     def _save_state(self, cr, uid, issue_id, field_name, field_value, arg, context=None):
-        stage_obj = self.pool.get('project.task.type')
-        stage_ids = stage_obj.search(cr, uid, [('state', '=', field_value)], context=context)
+        stage_ids = self.pool.get('project.task.type').search(cr, uid, [('state', '=', field_value)], context=context)
         if stage_ids:
             self.write(cr, uid, [issue_id], {'type_id': stage_ids[0]}, context=context)
         else:
-            cr.execute("""update project_issue set state=%s where id=%s""", (field_value, issue_id, ))
+            cr.execute("""UPDATE project_issue SET state=%s WHERE id=%s""", (field_value, issue_id, ))
         return True
 
     _columns = {
@@ -208,13 +207,13 @@ class project_issue(crm.crm_case, osv.osv):
         'company_id': fields.many2one('res.company', 'Company'),
         'description': fields.text('Description'),
         'state': fields.function(_get_state, fnct_inv=_save_state, type='selection', selection=_ISSUE_STATE, string="State", readonly=True,
-        store = {
+            store = {
                 'project.issue': (lambda self, cr, uid, ids, c={}: ids, ['type_id'], 10),
                 'project.task.type': (_get_stage, ['state'], 10)
-        }, help='The state is set to \'Draft\', when a case is created.\
-                                  \nIf the case is in progress the state is set to \'Open\'.\
-                                  \nWhen the case is over, the state is set to \'Done\'.\
-                                  \nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
+            }, help='The state is set to \'Draft\', when a case is created.\
+                    \nIf the case is in progress the state is set to \'Open\'.\
+                    \nWhen the case is over, the state is set to \'Done\'.\
+                    \nIf the case needs to be reviewed then the state is set to \'Pending\'.'),
         'email_from': fields.char('Email', size=128, help="These people will receive email.", select=1),
         'email_cc': fields.char('Watchers Emails', size=256, help="These email addresses will be added to the CC field of all inbound and outbound emails for this record before being sent. Separate multiple email addresses with a comma"),
         'date_open': fields.datetime('Opened', readonly=True,select=True),