[WIP] replace previous categ (inherited from crm.case.categ - using m2o relation...
authorAntonin Bourguignon <abo@openerp.com>
Wed, 11 Jul 2012 13:21:30 +0000 (15:21 +0200)
committerAntonin Bourguignon <abo@openerp.com>
Wed, 11 Jul 2012 13:21:30 +0000 (15:21 +0200)
the idea is to give the opportunity to 'tag' a project's tasks and issues instead of classifying them in a single category

- display in the kanban view isn't ready yet
- demo data will have to be updated accordingly
- some code in project_issue/project_issue.py has been commented out: probably dead code, will be reviewed

bzr revid: abo@openerp.com-20120711132130-uwlom1xu8rl4cr3k

addons/portal_project_issue/portal_project_issue_view.xml
addons/project/project.py
addons/project_issue/board_project_issue_view.xml
addons/project_issue/project_issue.py
addons/project_issue/project_issue_demo.xml
addons/project_issue/project_issue_view.xml
addons/project_issue/report/project_issue_report.py
addons/project_issue/report/project_issue_report_view.xml

index 7c0e2a3..f1f5578 100644 (file)
@@ -13,6 +13,7 @@
                     <field name="user_id"/>
                     <field name="date_deadline"/>
                     <field name="create_date"/>
+                    <field name="categ_ids"/>
                     <templates>
                         <t t-name="kanban-box">
                             <div class="oe_kanban_card oe_kanban_global_click">
@@ -24,7 +25,8 @@
                                     </div>
                                     <div class="oe_kanban_footer_left">
                                         <div class="oe_left">
-                                            <field name="categ_id"/>
+                                            <!-- <field name="categ_ids" widget="many2many_tags"/> -->
+                                            <t t-raw="record.categ_ids.raw_value"/>
                                         </div>
                                         <div class="oe_right">
                                             Creation: <field name="create_date"/>
index 5810f34..2a4bdfa 100644 (file)
@@ -220,7 +220,7 @@ class project(osv.osv):
         'followers': fields.function(_get_followers, method=True, fnct_search=_search_followers,
                         type='many2many', relation='res.users', string='Followers'),
      }
-    
+
     def dummy(self, cr, uid, ids, context):
         return True
 
@@ -566,7 +566,7 @@ class task(base_stage, osv.osv):
         # restore order of the search
         result.sort(lambda x,y: cmp(stage_ids.index(x[0]), stage_ids.index(y[0])))
         return result
-    
+
     def _read_group_user_id(self, cr, uid, ids, domain, read_group_order=None, access_rights_uid=None, context=None):
         res_users = self.pool.get('res.users')
         project_id = self._resolve_project_id_from_context(cr, uid, context=context)
@@ -903,7 +903,7 @@ class task(base_stage, osv.osv):
         return True
 
     def action_close(self, cr, uid, ids, context=None):
-        """ This action closes the task 
+        """ This action closes the task
         """
         task_id = len(ids) and ids[0] or False
         self._check_child_task(cr, uid, ids, context=context)
@@ -913,7 +913,7 @@ class task(base_stage, osv.osv):
     def do_close(self, cr, uid, ids, context=None):
         """ Compatibility when changing to case_close. """
         return self.case_close(cr, uid, ids, context=context)
-    
+
     def case_close(self, cr, uid, ids, context=None):
         """ Closes Task """
         if not isinstance(ids, list): ids = [ids]
@@ -946,7 +946,7 @@ class task(base_stage, osv.osv):
     def do_cancel(self, cr, uid, ids, context=None):
         """ Compatibility when changing to case_cancel. """
         return self.case_cancel(cr, uid, ids, context=context)
-    
+
     def case_cancel(self, cr, uid, ids, context=None):
         tasks = self.browse(cr, uid, ids, context=context)
         self._check_child_task(cr, uid, ids, context=context)
@@ -958,7 +958,7 @@ class task(base_stage, osv.osv):
     def do_open(self, cr, uid, ids, context=None):
         """ Compatibility when changing to case_open. """
         return self.case_open(cr, uid, ids, context=context)
-    
+
     def case_open(self, cr, uid, ids, context=None):
         if not isinstance(ids,list): ids = [ids]
         self.case_set(cr, uid, ids, 'open', {'date_start': fields.datetime.now()}, context=context)
@@ -968,7 +968,7 @@ class task(base_stage, osv.osv):
     def do_draft(self, cr, uid, ids, context=None):
         """ Compatibility when changing to case_draft. """
         return self.case_draft(cr, uid, ids, context=context)
-    
+
     def case_draft(self, cr, uid, ids, context=None):
         self.case_set(cr, uid, ids, 'draft', {}, context=context)
         self.case_draft_send_note(cr, uid, ids, context=context)
@@ -977,11 +977,11 @@ class task(base_stage, osv.osv):
     def do_pending(self, cr, uid, ids, context=None):
         """ Compatibility when changing to case_pending. """
         return self.case_pending(cr, uid, ids, context=context)
-    
+
     def case_pending(self, cr, uid, ids, context=None):
         self.case_set(cr, uid, ids, 'pending', {}, context=context)
         return self.case_pending_send_note(cr, uid, ids, context=context)
-    
+
     def _delegate_task_attachments(self, cr, uid, task_id, delegated_task_id, context=None):
         attachment = self.pool.get('ir.attachment')
         attachment_ids = attachment.search(cr, uid, [('res_model', '=', self._name), ('res_id', '=', task_id)], context=context)
@@ -1083,7 +1083,7 @@ class task(base_stage, osv.osv):
             new_stage = vals.get('stage_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 
+                #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.'))
@@ -1129,7 +1129,7 @@ class task(base_stage, osv.osv):
 
         result += "\n"
         return result
-    
+
     # ---------------------------------------------------
     # OpenChatter methods and notifications
     # ---------------------------------------------------
@@ -1359,3 +1359,11 @@ class project_task_history_cumulative(osv.osv):
         )
         """)
 
+
+class project_category(osv.osv):
+    """ Category of project's task (or issue) """
+    _name = "project.category"
+    _description = "Category of project's task, issue, ..."
+    _columns = {
+        'name': fields.char('Name', size=64, required=True, translate=True),
+    }
index cedcd85..8bc3417 100644 (file)
@@ -18,7 +18,7 @@
                     <field name="progress" widget="progressbar" attrs="{'invisible':[('task_id','=',False)]}"/>
                     <field name="stage_id" widget="selection" readonly="1"/>
                     <field name="state" groups="base.group_no_one"/>
-                    <field name="categ_id" invisible="1"/>
+                    <field name="categ_ids" invisible="1"/>
                     <field name="task_id" invisible="1"/>
                 </tree>
             </field>
index 5f9b0a3..ff98ef2 100644 (file)
@@ -236,7 +236,7 @@ class project_issue(base_stage, osv.osv):
         'date_closed': fields.datetime('Closed', readonly=True,select=True),
         'date': fields.datetime('Date'),
         'channel_id': fields.many2one('crm.case.channel', 'Channel', help="Communication channel."),
-        'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('object_id.model', '=', 'crm.project.bug')]"),
+        'categ_ids': fields.many2many('project.category', 'project_issue_categ_rel', 'project_issue_id', 'project_category_id', 'Categories'),
         'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority', select=True),
         'version_id': fields.many2one('project.issue.version', 'Version'),
         'stage_id': fields.many2one ('project.task.type', 'Stage',
@@ -279,7 +279,6 @@ class project_issue(base_stage, osv.osv):
         'section_id': lambda s, cr, uid, c: s._get_default_section_id(cr, uid, c),
         'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.helpdesk', context=c),
         'priority': crm.AVAILABLE_PRIORITIES[2][0],
-        'categ_id' : lambda *a: False,
          }
 
     _group_by_full = {
@@ -304,11 +303,11 @@ class project_issue(base_stage, osv.osv):
     def convert_issue_task(self, cr, uid, ids, context=None):
         if context is None:
             context = {}
-        
+
         case_obj = self.pool.get('project.issue')
         data_obj = self.pool.get('ir.model.data')
         task_obj = self.pool.get('project.task')
-        
+
         result = data_obj._get_id(cr, uid, 'project', 'view_task_search_form')
         res = data_obj.read(cr, uid, result, ['res_id'])
         id2 = data_obj._get_id(cr, uid, 'project', 'view_task_form2')
@@ -352,21 +351,21 @@ class project_issue(base_stage, osv.osv):
         }
 
 
-    def _convert(self, cr, uid, ids, xml_id, context=None):
-        data_obj = self.pool.get('ir.model.data')
-        id2 = data_obj._get_id(cr, uid, 'project_issue', xml_id)
-        categ_id = False
-        if id2:
-            categ_id = data_obj.browse(cr, uid, id2, context=context).res_id
-        if categ_id:
-            self.write(cr, uid, ids, {'categ_id': categ_id})
-        return True
+    # def _convert(self, cr, uid, ids, xml_id, context=None):
+    #     data_obj = self.pool.get('ir.model.data')
+    #     id2 = data_obj._get_id(cr, uid, 'project_issue', xml_id)
+    #     categ_id = False
+    #     if id2:
+    #         categ_id = data_obj.browse(cr, uid, id2, context=context).res_id
+    #     if categ_id:
+    #         self.write(cr, uid, ids, {'categ_id': categ_id})
+    #     return True
 
-    def convert_to_feature(self, cr, uid, ids, context=None):
-        return self._convert(cr, uid, ids, 'feature_request_categ', context=context)
+    # def convert_to_feature(self, cr, uid, ids, context=None):
+    #     return self._convert(cr, uid, ids, 'feature_request_categ', context=context)
 
-    def convert_to_bug(self, cr, uid, ids, context=None):
-        return self._convert(cr, uid, ids, 'bug_categ', context=context)
+    # def convert_to_bug(self, cr, uid, ids, context=None):
+    #     return self._convert(cr, uid, ids, 'bug_categ', context=context)
 
     def copy(self, cr, uid, id, default=None, context=None):
         issue = self.read(cr, uid, id, ['name'], context=context)
@@ -376,7 +375,7 @@ class project_issue(base_stage, osv.osv):
         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 = ['stage_id', 'state', 'message_ids']
@@ -463,7 +462,7 @@ class project_issue(base_stage, osv.osv):
     # -------------------------------------------------------
     # Mail gateway
     # -------------------------------------------------------
-    
+
     def message_new(self, cr, uid, msg, custom_values=None, context=None):
         """ Overrides mail_thread message_new that is called by the mailgateway
             through message_process.
@@ -485,7 +484,7 @@ class project_issue(base_stage, osv.osv):
         custom_values.update(self.message_partner_by_email(cr, uid, msg.get('from'), context=context))
 
         res_id = super(project_issue, self).message_new(cr, uid, msg, custom_values=custom_values, context=context)
-        self.convert_to_bug(cr, uid, [res_id], context=context)
+        # self.convert_to_bug(cr, uid, [res_id], context=context)
         return res_id
 
     def message_update(self, cr, uid, ids, msg, update_vals=None, context=None):
@@ -515,11 +514,11 @@ class project_issue(base_stage, osv.osv):
                 update_vals[key] = res.group(2).lower()
 
         return super(project_issue, self).message_update(cr, uid, ids, update_vals=update_vals, context=context)
-    
+
     # -------------------------------------------------------
     # OpenChatter methods and notifications
     # -------------------------------------------------------
-    
+
     def message_get_subscribers(self, cr, uid, ids, context=None):
         """ Override to add responsible user. """
         user_ids = super(project_issue, self).message_get_subscribers(cr, uid, ids, context=context)
@@ -588,11 +587,11 @@ project()
 class account_analytic_account(osv.osv):
     _inherit = 'account.analytic.account'
     _description = 'Analytic Account'
-    
+
     _columns = {
         'use_issues' : fields.boolean('Issues Tracking', help="Check this field if this project manages issues"),
     }
-    
+
     def _trigger_project_creation(self, cr, uid, vals, context=None):
         res = super(account_analytic_account, self)._trigger_project_creation(cr, uid, vals, context=context)
         return res or vals.get('use_issues')
index b3fb458..2cda2e1 100644 (file)
@@ -9,12 +9,11 @@
         <field name="partner_id" ref="base.res_partner_agrolait"/>
         <field name="section_id" ref="crm.section_sales_department"/>
         <field eval="1" name="active"/>
-        <field name="categ_id" ref="bug_categ"/>
         <field name="project_id" ref="project.project_project_22"/>
         <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="stage_id" ref="project.project_tt_specification"/>        
+        <field name="stage_id" ref="project.project_tt_specification"/>
     </record>
 
     <record id="crm_case_programnotgivingproperoutput0" model="project.issue">
@@ -25,7 +24,6 @@
         <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="stage_id" ref="project.project_tt_specification"/>
@@ -38,7 +36,6 @@
         <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="stage_id" ref="project.project_tt_development"/>
@@ -52,7 +49,6 @@
         <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="stage_id" ref="project.project_tt_testing"/>
@@ -66,7 +62,6 @@
         <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="stage_id" ref="project.project_tt_development"/>
@@ -80,7 +75,6 @@
         <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="stage_id" ref="project.project_tt_testing"/>
@@ -94,7 +88,6 @@
         <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="stage_id" ref="project.project_tt_testing"/>
         <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="stage_id" ref="project.project_tt_testing"/>
         <field name="partner_id" ref="base.res_partner_5"/>
         <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="stage_id" ref="project.project_tt_testing"/>
         <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="stage_id" ref="project.project_tt_testing"/>
         <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="stage_id" ref="project.project_tt_merge"/>
         <field name="section_id" ref="crm.section_sales_department"/>
         <field eval="1" name="active"/>
         <field eval="3.0" name="duration"/>
-        <field name="categ_id" ref="feature_request_categ"/>
         <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="stage_id" ref="project.project_tt_development"/> 
+        <field name="stage_id" ref="project.project_tt_development"/>
     </record>
 
     <record id="crm_case_includeattendancesheetinproject0" model="project.issue">
         <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="feature_request_categ"/>
         <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="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="stage_id" ref="project.project_tt_specification"/>
         <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="stage_id" ref="project.project_tt_development"/>
         <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="stage_id" ref="project.project_tt_specification"/>
index 860a115..eeed1fb 100644 (file)
                             <field name="user_id"/>
                             <field name="partner_id"  on_change="onchange_partner_id(partner_id, email_from)"/>
                             <field name="email_from"/>
-                        </group><group>
+                        </group>
+                        <group>
                             <field name="task_id" on_change="onchange_task_id(task_id)"/>
-                            <field name="categ_id" widget="selection" domain="[('object_id.model', '=', 'project.issue')]"/>
+                            <field name="categ_ids" widget="many2many_tags"/>
                             <field name="version_id" widget="selection"/>
                             <field name="priority"/>
                             <field name="progress" widget="progressbar" attrs="{'invisible':[('task_id','=',False)]}"/>
                     <field name="progress" widget="progressbar" attrs="{'invisible':[('task_id','=',False)]}"/>
                     <field name="stage_id" widget="selection" readonly="1"/>
                     <field name="state" groups="base.group_no_one"/>
-                    <field name="categ_id" invisible="1"/>
+                    <field name="categ_ids" invisible="1"/>
                     <field name="task_id" invisible="1"/>
                 </tree>
             </field>
                             domain="[]" context="{'group_by':'version_id'}"/>
                         <separator orientation="vertical"/>
                         <filter string="Category" icon="terp-stock_symbol-selection" domain="[]"
-                            context="{'group_by':'categ_id'}"/>
+                            context="{'group_by':'categ_ids'}"/>
                         <filter string="Priority" icon="terp-rating-rated" domain="[]"
                             context="{'group_by':'priority'}"/>
                         <filter string="Stage" icon="terp-stage" domain="[]"
                         <t t-name="kanban-tooltip">
                            <ul class="oe_kanban_tooltip">
                               <li><b>Project:</b> <field name="project_id"/></li>
-                              <li><b>Category:</b> <field name="categ_id"/></li>
+                              <li><b>Category:</b> <field name="categ_ids"/></li>
                            </ul>
                         </t>
                         <t t-name="kanban-box">
index be3309d..df874e7 100644 (file)
@@ -50,7 +50,7 @@ class project_issue_report(osv.osv):
         'opening_date': fields.date('Date of Opening', readonly=True),
         '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')]"),
+        'categ_ids': fields.many2many('project.category', 'project_issue_categ_rel', 'project_issue_id', 'project_category_id', 'Categories'),
         '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),
index 862f52b..c891b7e 100644 (file)
                     <field name="company_id" invisible="1" groups="base.group_multi_company"/>
                     <field name="section_id" invisible="1"/>
                     <field name="user_id" invisible="1"/>
-                    <field name="categ_id" invisible="1"/>
+                    <field name="categ_ids" invisible="1"/>
                     <field name="channel_id" invisible="1"/>
                     <field name="partner_id" invisible="1"/>
-                    <field name="task_id" invisible="1"/>                    
+                    <field name="task_id" invisible="1"/>
                     <field name="date_closed" invisible="1"/>
                     <field name="state" invisible="1"/>
                     <field name="day" invisible="1"/>