From 740be5842c29a9e3e557d7789dbaca6e5ee9e4f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Maes?= Date: Thu, 13 Oct 2016 13:31:58 +0200 Subject: [PATCH] [FIX] rating_*: domain on m2o for rating mail template Rating is implemented for project.issue, but it is impossible to set a template on the stage since the domain force the mail.template to be declared on project.task. We use the same mecanism as `mail_template_id` declared on project.stage.task in project module. The list of available template on the stage form view will be the ones for issue and task like mail_template_id. --- addons/rating_project/models/project.py | 5 ++++- addons/rating_project_issue/models/project_issue.py | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/addons/rating_project/models/project.py b/addons/rating_project/models/project.py index 49f1a4414d2..69fb394e93a 100644 --- a/addons/rating_project/models/project.py +++ b/addons/rating_project/models/project.py @@ -7,10 +7,13 @@ class ProjectTaskType(models.Model): _inherit = 'project.task.type' + def _default_domain_rating_template_id(self): + return [('model', '=', 'project.task')] + rating_template_id = fields.Many2one( 'mail.template', string='Rating Email Template', - domain=[('model', '=', 'project.task')], + domain=lambda self: self._default_domain_rating_template_id(), help="Select an email template. An email will be sent to the customer when the task reach this step.") auto_validation_kanban_state = fields.Boolean('Automatic kanban status', default=False, help="Automatically modify the kanban state when the customer reply to the feedback for this stage.\n" diff --git a/addons/rating_project_issue/models/project_issue.py b/addons/rating_project_issue/models/project_issue.py index 32b5c149df7..15c29839449 100644 --- a/addons/rating_project_issue/models/project_issue.py +++ b/addons/rating_project_issue/models/project_issue.py @@ -25,6 +25,16 @@ class ProjectIssue(models.Model): return super(ProjectIssue, self).rating_apply(rate, token=token, feedback=feedback, subtype="rating_project_issue.mt_issue_rating") + +class Stage(models.Model): + + _inherit = ['project.task.type'] + + def _default_domain_rating_template_id(self): + domain = super(Stage, self)._default_domain_rating_template_id() + return ['|'] + domain + [('model', '=', 'project.issue')] + + class Project(models.Model): _inherit = "project.project"