summaryrefslogtreecommitdiff
path: root/addons/pad_project/models/project.py
diff options
context:
space:
mode:
authorYannick Tivisse <yti@odoo.com>2017-11-27 10:15:17 +0100
committerYannick Tivisse <yti@odoo.com>2017-11-27 12:26:44 +0100
commitd3efda05fda0cb11939d4d8a3f26acc72c9d1435 (patch)
tree7e99861879047a75a3725be98385d3c4710ea72d /addons/pad_project/models/project.py
parentac5ba4a2b0ab75a42d86a5aa04a0e837de64ffff (diff)
[FIX] (project_)pad: Don't create/copy pads on tasks that don't use them
Purpose ======= Currently if a project doesn't use pads, the created and duplicated tasks will initialize/copy them. That could be a real issue when migrating customers if we create a task for all the existing issues, since the models have been merged. Specification ============= Avoid this falsy behavior. We're forced to crappy fix with a context key as the project.task model 'inherit' from pad.common.
Diffstat (limited to 'addons/pad_project/models/project.py')
-rw-r--r--addons/pad_project/models/project.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/addons/pad_project/models/project.py b/addons/pad_project/models/project.py
index 113a32b9b68..eae27a4f6a7 100644
--- a/addons/pad_project/models/project.py
+++ b/addons/pad_project/models/project.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
-from odoo import fields, models
+from odoo import api, fields, models
class ProjectTask(models.Model):
@@ -11,6 +11,20 @@ class ProjectTask(models.Model):
description_pad = fields.Char('Pad URL', pad_content_field='description')
use_pad = fields.Boolean(related="project_id.use_pads", string="Use collaborative pad")
+ @api.model
+ def create(self, vals):
+ # When using quick create, the project_id is in the context, not in the vals
+ project_id = vals.get('project_id', False) or self.default_get(['project_id'])['project_id']
+ if not self.env['project.project'].browse(project_id).use_pads:
+ self = self.with_context(pad_no_create=True)
+ return super(ProjectTask, self).create(vals)
+
+ @api.multi
+ def copy(self, default=None):
+ if not self.use_pad:
+ self = self.with_context(pad_no_create=True)
+ return super(ProjectTask, self).copy(default)
+
class ProjectProject(models.Model):
_inherit = "project.project"