diff options
| author | Denis Ledoux dle@openerp.com <> | 2012-11-08 10:28:38 +0100 |
|---|---|---|
| committer | Denis Ledoux dle@openerp.com <> | 2012-11-08 10:28:38 +0100 |
| commit | 981168dfc6d628c72d8469022c0b51e0f5ec00df (patch) | |
| tree | e7497e1366dcd0b7759ed6eae9d2fa8b50ff46c5 /addons/project_issue | |
| parent | 9e56b3b6a8a761e02099146b338225d29dbc8c8a (diff) | |
| parent | 29fffbc97d8970513114b7b76763f002aa73e395 (diff) | |
[ADD][MERGE]Add functionnalities, merge with trunk
bzr revid: dle@openerp.com-20121108092838-fe89ohg9za3ln6y1
Diffstat (limited to 'addons/project_issue')
| -rw-r--r-- | addons/project_issue/project_issue.py | 45 | ||||
| -rw-r--r-- | addons/project_issue/project_issue_data.xml | 16 | ||||
| -rw-r--r-- | addons/project_issue/project_issue_view.xml | 10 | ||||
| -rw-r--r-- | addons/project_issue/report/project_issue_report_view.xml | 1 |
4 files changed, 49 insertions, 23 deletions
diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index 770c226fc2f..90640363906 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -240,7 +240,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_ids': fields.many2many('project.category', string='Categories'), + 'categ_ids': fields.many2many('project.category', string='Tags'), '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', @@ -359,22 +359,49 @@ class project_issue(base_stage, osv.osv): return super(project_issue, self).copy(cr, uid, id, default=default, context=context) + def _subscribe_project_followers_to_issue(self, cr, uid, task_id, context=None): + """ TDE note: not the best way to do this, we could override _get_followers + of issue, and perform a better mapping of subtypes than a mapping + based on names. + However we will keep this implementation, maybe to be refactored + in 7.1 of future versions. """ + # task followers are project followers, with matching subtypes + task_record = self.browse(cr, uid, task_id, context=context) + subtype_obj = self.pool.get('mail.message.subtype') + follower_obj = self.pool.get('mail.followers') + if task_record.project_id: + # create mapping + task_subtype_ids = subtype_obj.search(cr, uid, ['|', ('res_model', '=', False), ('res_model', '=', self._name)], context=context) + task_subtypes = subtype_obj.browse(cr, uid, task_subtype_ids, context=context) + # fetch subscriptions + follower_ids = follower_obj.search(cr, uid, [('res_model', '=', 'project.project'), ('res_id', '=', task_record.project_id.id)], context=context) + # copy followers + for follower in follower_obj.browse(cr, uid, follower_ids, context=context): + if not follower.subtype_ids: + continue + project_subtype_names = [project_subtype.name for project_subtype in follower.subtype_ids] + task_subtype_ids = [task_subtype.id for task_subtype in task_subtypes if task_subtype.name in project_subtype_names] + self.message_subscribe(cr, uid, [task_id], [follower.partner_id.id], + subtype_ids=task_subtype_ids, 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'] if any([field in vals for field in logged_fields]): vals['date_action_last'] = time.strftime('%Y-%m-%d %H:%M:%S') + + # subscribe new project followers to the issue if vals.get('project_id'): - project_id = self.pool.get('project.project').browse(cr, uid, vals.get('project_id'), context=context) - vals['message_follower_ids'] = [(4, follower.id) for follower in project_id.message_follower_ids] + for id in ids: + self._subscribe_project_followers_to_issue(cr, uid, id, context=context) return super(project_issue, self).write(cr, uid, ids, vals, context) def onchange_task_id(self, cr, uid, ids, task_id, context=None): if not task_id: - return {'value':{}} + return {'value': {}} task = self.pool.get('project.task').browse(cr, uid, task_id, context=context) - return {'value':{'user_id': task.user_id.id,}} + return {'value': {'user_id': task.user_id.id, }} def case_reset(self, cr, uid, ids, context=None): """Resets case as draft @@ -385,11 +412,11 @@ class project_issue(base_stage, osv.osv): def create(self, cr, uid, vals, context=None): obj_id = super(project_issue, self).create(cr, uid, vals, context=context) - project_id = self.browse(cr, uid, obj_id, context=context).project_id - if project_id: - followers = [follower.id for follower in project_id.message_follower_ids] - self.message_subscribe(cr, uid, [obj_id], followers, context=context) + + # subscribe project follower to the issue + self._subscribe_project_followers_to_issue(cr, uid, obj_id, context=context) self.create_send_note(cr, uid, [obj_id], context=context) + return obj_id # ------------------------------------------------------- diff --git a/addons/project_issue/project_issue_data.xml b/addons/project_issue/project_issue_data.xml index edd44e52dd2..72f824715a8 100644 --- a/addons/project_issue/project_issue_data.xml +++ b/addons/project_issue/project_issue_data.xml @@ -44,17 +44,19 @@ Access all issues from the top Project menu, and access the issues of a specific <!-- Mail subtypes --> <record id="mail.mt_issue_new" model="mail.message.subtype"> - <field name="name">created</field> + <field name="name">New</field> <field name="res_model">project.issue</field> - <field name="default" eval="False"/> </record> - <record id="mail.mt_issue_new" model="mail.message.subtype"> - <field name="name">stage change</field> + <record id="mail.mt_issue_closed" model="mail.message.subtype"> + <field name="name">Closed</field> <field name="res_model">project.issue</field> - <field name="default" eval="False"/> </record> - <record id="mail.mt_issue_closed" model="mail.message.subtype"> - <field name="name">closed</field> + <record id="mail.mt_issue_canceled" model="mail.message.subtype"> + <field name="name">Canceled</field> + <field name="res_model">project.issue</field> + </record> + <record id="mail.mt_issue_change" model="mail.message.subtype"> + <field name="name">Stage Changed</field> <field name="res_model">project.issue</field> </record> diff --git a/addons/project_issue/project_issue_view.xml b/addons/project_issue/project_issue_view.xml index 9284322880d..e3105127c5d 100644 --- a/addons/project_issue/project_issue_view.xml +++ b/addons/project_issue/project_issue_view.xml @@ -125,15 +125,11 @@ <field name="progress" widget="progressbar" attrs="{'invisible':[('task_id','=',False)]}" class="oe_inline"/> </div> <field name="categ_ids" widget="many2many_tags"/> + <field name="version_id"/> </group> </group> <notebook> <page string="Description"> - <group> - <group> - <field name="version_id" widget="selection"/> - </group> - </group> <field name="description" placeholder="Add a description..."/> </page> <page string="Extra Info" groups="base.group_no_one"> @@ -380,7 +376,9 @@ <xpath expr="//div[contains(@class, 'oe_kanban_project_list')]" position="inside"> <a t-if="record.use_issues.raw_value" style="margin-right: 10px" name="%(act_project_project_2_project_issue_all)d" type="action"> - <field name="issue_count"/> Issues</a> + <span t-if="record.issue_count.raw_value gt 1"><field name="issue_count"/> Issues</span> + <span t-if="record.issue_count.raw_value lt 2"><field name="issue_count"/> Issue</span> + </a> </xpath> </field> </record> diff --git a/addons/project_issue/report/project_issue_report_view.xml b/addons/project_issue/report/project_issue_report_view.xml index 6bee4e38842..47ea91fad5f 100644 --- a/addons/project_issue/report/project_issue_report_view.xml +++ b/addons/project_issue/report/project_issue_report_view.xml @@ -63,7 +63,6 @@ <filter string="Sale Team" icon="terp-personal+" domain="[]" context="{'group_by':'section_id'}" /> <filter string="Project" name="project" icon="terp-folder-violet" context="{'group_by':'project_id'}" /> <filter string="Task" icon="terp-stock_align_left_24" domain="[]" context="{'group_by':'task_id'}"/> - <filter string="Category" icon="terp-stock_symbol-selection" domain="[]" context="{'group_by':'categ_id'}" /> <filter string="Version" icon="terp-stock_symbol-selection" domain="[]" context="{'group_by':'version_id'}"/> <filter string="Priority" icon="terp-rating-rated" domain="[]" context="{'group_by':'priority'}" /> <filter string="Stage" icon="terp-stage" domain="[]" context="{'group_by':'stage_id'}"/> |
