summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorXavier BOL (xbo) <xbo@odoo.com>2021-05-10 07:37:22 +0000
committerXavier BOL (xbo) <xbo@odoo.com>2021-05-17 15:54:15 +0000
commit7873144a9f1e68943d14053c3e5d6a945a46e9d5 (patch)
tree2db877bc3c1d3d0b08a423bda62cd5222c0b12e6 /addons
parent7d49c251cb17d1254372e13e8d205a402cd3a3c0 (diff)
[FIX] pad_project: copy the content in the pad when use_pad=False
Before this commit, when the user edits the description of a task with use_pad=True and then change the project of this task to one with use_pads=False. The description written in the pad server is not copied in the description field of the task. This commit copies the content of the pad for this case when the use_pad changes to become False and description_pad is set. Step to reproduce: ----------------- 1. Go to Settings of the Project App and enable the Collaborative Pads 2. Go to the Project App, in the Projects dashboard (kanban view of projects) 3. Create two Projects (one called "Project A" and the other called "Project B") 4. Edit the Project B to activate the pad, that is, check the Use collaborative pads checkbox. 5. Go to the view list of tasks in the "Project B" 6. Click on "Create" button to create a task in the task form view. 7. Write a description for this task. 8. Change the project of this task by the "Project A". With this change, the collaborative pad is disabled for this task since the Project A has not the pad, and then the description field is empty rather than have the content that we have just written. task-2515150 closes #70401 closes odoo/odoo#70901 X-original-commit: 32a8f598d6a958f2a08b204524007cc075697fda Signed-off-by: LTU-Odoo <IT-Ideas@users.noreply.github.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/pad_project/models/project.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/addons/pad_project/models/project.py b/addons/pad_project/models/project.py
index abc0342671a..c3392a7d243 100644
--- a/addons/pad_project/models/project.py
+++ b/addons/pad_project/models/project.py
@@ -16,6 +16,18 @@ class ProjectTask(models.Model):
string="Availability of collaborative pads",
readonly=True)
+ @api.onchange('use_pad')
+ def _onchange_use_pads(self):
+ """ Copy the content in the pad when the user change the project of the task to the one with no pads enabled.
+
+ This case is when the use_pad becomes False and we have already generated the url pad,
+ that is the description_pad field contains the url of the pad.
+ """
+ if not self.use_pad and self.description_pad:
+ vals = {'description_pad': self.description_pad}
+ self._set_pad_to_field(vals)
+ self.description = vals['description']
+
@api.model
def create(self, vals):
# When using quick create, the project_id is in the context, not in the vals