diff options
| author | Thibault Delavallée <tde@openerp.com> | 2016-01-12 11:14:06 +0100 |
|---|---|---|
| committer | Thibault Delavallée <tde@openerp.com> | 2016-02-01 12:15:56 +0100 |
| commit | 0cf2ceca90fdcb59cdecea17ccd9aa40cdf575e0 (patch) | |
| tree | d93d3f5e2da6cbe55f170d2d6c0f53641f3287a0 | |
| parent | 9b43a8c8f6b9e6cd8279503aeac9f63448d29388 (diff) | |
[IMP] project, issue: template on stages
Added a mail_template_field on project stage model (project.task.type). This
fields is used to automatically send an email when a task or issue comes in
this stage.
Recruitment code has been updated to use the mixin method.
| -rw-r--r-- | addons/hr_recruitment/models/hr_recruitment.py | 14 | ||||
| -rw-r--r-- | addons/project/project.py | 18 | ||||
| -rw-r--r-- | addons/project/project_demo.xml | 15 | ||||
| -rw-r--r-- | addons/project/project_view.xml | 3 | ||||
| -rw-r--r-- | addons/project_issue/__init__.py | 1 | ||||
| -rw-r--r-- | addons/project_issue/models/__init__.py | 1 | ||||
| -rw-r--r-- | addons/project_issue/models/project_task_type.py | 12 | ||||
| -rw-r--r-- | addons/project_issue/project_issue.py | 9 |
8 files changed, 67 insertions, 6 deletions
diff --git a/addons/hr_recruitment/models/hr_recruitment.py b/addons/hr_recruitment/models/hr_recruitment.py index c8ae303f705..6c4cbac60da 100644 --- a/addons/hr_recruitment/models/hr_recruitment.py +++ b/addons/hr_recruitment/models/hr_recruitment.py @@ -289,11 +289,6 @@ class Applicant(models.Model): res = super(Applicant, self).write(vals) else: res = super(Applicant, self).write(vals) - - # post processing: if stage changed, post a message in the chatter - if vals.get('stage_id'): - if self.stage_id.template_id: - self.message_post_with_template(self.stage_id.template_id.id, notify=True, composition_mode='mass_mail') return res @api.model @@ -359,6 +354,15 @@ class Applicant(models.Model): return action @api.multi + def _track_template(self, tracking): + res = super(Applicant, self)._track_template(tracking) + applicant = self[0] + changes, dummy = tracking[applicant.id] + if 'stage_id' in changes and applicant.stage_id.template_id: + res['stage_id'] = (applicant.stage_id.template_id, {'composition_mode': 'mass_mail'}) + return res + + @api.multi def _track_subtype(self, init_values): record = self[0] if 'emp_id' in init_values and record.emp_id: diff --git a/addons/project/project.py b/addons/project/project.py index 46ba4ba1e5f..f9889a152cf 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -18,6 +18,10 @@ class project_task_type(osv.osv): _name = 'project.task.type' _description = 'Task Stage' _order = 'sequence' + + def _get_mail_template_id_domain(self): + return [('model', '=', 'project.task')] + _columns = { 'name': fields.char('Stage Name', required=True, translate=True), 'description': fields.text('Description', translate=True), @@ -35,6 +39,11 @@ class project_task_type(osv.osv): 'legend_normal': fields.char( 'Kanban Ongoing Explanation', translate=True, help='Override the default value displayed for the normal state for kanban selection, when the task or issue is in that stage.'), + 'mail_template_id': fields.many2one( + 'mail.template', + string='Email Template', + domain=lambda self: self._get_mail_template_id_domain(), + help="If set an email will be sent to the customer when the task or issue reaches this step."), 'fold': fields.boolean('Folded in Tasks Pipeline', help='This stage is folded in the kanban view when ' 'there are no records in that stage to display.'), @@ -713,6 +722,15 @@ class task(osv.osv): # Mail gateway # --------------------------------------------------- + @api.multi + def _track_template(self, tracking): + res = super(task, self)._track_template(tracking) + test_task = self[0] + changes, tracking_value_ids = tracking[test_task.id] + if 'stage_id' in changes and test_task.stage_id.mail_template_id: + res['stage_id'] = (test_task.stage_id.mail_template_id, {'composition_mode': 'mass_mail'}) + return res + def _track_subtype(self, cr, uid, ids, init_values, context=None): record = self.browse(cr, uid, ids[0], context=context) if 'kanban_state' in init_values and record.kanban_state == 'blocked': diff --git a/addons/project/project_demo.xml b/addons/project/project_demo.xml index bd2cd72cdb8..d424645c766 100644 --- a/addons/project/project_demo.xml +++ b/addons/project/project_demo.xml @@ -21,12 +21,27 @@ <field name="name">Usability</field> </record> + <!-- Email templates --> + <record id="mail_template_data_project_task" model="mail.template"> + <field name="name">Task: Reception Acknowledgment</field> + <field name="subject">Reception of ${object.name}</field> + <field name="model_id" ref="project.model_project_task"/> + <field name="use_default_to" eval="True"/> + <field name="body_html"><![CDATA[ +<p>Dear ${object.partner_id.name or 'customer'},</p> +<p>Thank you for your enquiry.<br /></p> +<p>If you have any questions, please let us know.</p> +<p>Best regards,</p>]]></field> + <field name="auto_delete" eval="True"/> + </record> + <!-- Stages --> <record id="project_stage_0" model="project.task.type"> <field name="sequence">1</field> <field name="name">To Do</field> <field name="legend_blocked">Not validated</field> <field name="legend_priority">Use the priority for tasks related to gold customers</field> + <field name="mail_template_id" ref="project.mail_template_data_project_task"/> </record> <record id="project_stage_1" model="project.task.type"> <field name="sequence">10</field> diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index 1a9fb973655..48876926d19 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -522,10 +522,11 @@ <group> <group> <field name="name"/> - <field name="sequence" groups="base.group_no_one"/> + <field name="mail_template_id"/> </group> <group> <field name="fold"/> + <field name="sequence" groups="base.group_no_one"/> </group> </group> <group string="Stage Description and Tooltips"> diff --git a/addons/project_issue/__init__.py b/addons/project_issue/__init__.py index bfc773a226d..91f590dfedd 100644 --- a/addons/project_issue/__init__.py +++ b/addons/project_issue/__init__.py @@ -1,5 +1,6 @@ # -*- encoding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. +import models import project_issue import report diff --git a/addons/project_issue/models/__init__.py b/addons/project_issue/models/__init__.py new file mode 100644 index 00000000000..50bd1232d2e --- /dev/null +++ b/addons/project_issue/models/__init__.py @@ -0,0 +1 @@ +import project_task_type diff --git a/addons/project_issue/models/project_task_type.py b/addons/project_issue/models/project_task_type.py new file mode 100644 index 00000000000..e214a2c7ef3 --- /dev/null +++ b/addons/project_issue/models/project_task_type.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- + +from openerp import models + + +class ProjectStage(models.Model): + _name = "project.task.type" + _inherit = ['project.task.type'] + + def _get_mail_template_id_domain(self): + domain = super(ProjectStage, self)._get_mail_template_id_domain() + return ['|'] + domain + [('model', '=', 'project.issue')] diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index 7e3698e9f05..45ed5b446fe 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -302,6 +302,15 @@ class project_issue(osv.Model): # Mail gateway # ------------------------------------------------------- + @api.multi + def _track_template(self, tracking): + res = super(project_issue, self)._track_template(tracking) + test_issue = self[0] + changes, dummy = tracking[test_issue.id] + if 'stage_id' in changes and test_issue.stage_id.mail_template_id: + res['stage_id'] = (test_issue.stage_id.mail_template_id, {'composition_mode': 'mass_mail'}) + return res + def _track_subtype(self, cr, uid, ids, init_values, context=None): record = self.browse(cr, uid, ids[0], context=context) if 'kanban_state' in init_values and record.kanban_state == 'blocked': |
