Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d4d09d0

Browse files
committedMay 17, 2021
[FIX] pad: copy the pad_content_field content in pad when genrate pad url
Before this commit, in Project App, when the "Collaborative Pads" is enabled in the Settings of this app, if the user create a task without project or in a project that has not the pad enabled and he writes a description for his new task and select (another) project in which the pads is enabled then the description field in the form view changed to have the collaborative pad and the problem is the description is not copied in the pad and seems erase/delete for the user. This commit checks if the pad_content_field is not empty after generating the pad url for the new task/record, if it is the case then we copy the content in the pad and the user can continue his edition before saving the task/record. 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 A" 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 B. With this change, the collaborative pad is actived for this task since the Project B has the pad, and then the description in the pad is empty rather than have the content that we have just written. task-2515150 closes odoo#70401 X-original-commit: d2b55c7
1 parent 2652737 commit d4d09d0

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed
 

‎addons/pad/models/pad.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,12 @@ def pad_generate_url(self):
6464
field = model._fields[self.env.context['field_name']]
6565
real_field = field.pad_content_field
6666

67+
res_id = self.env.context.get("object_id")
68+
record = model.browse(res_id)
6769
# get content of the real field
68-
for record in model.browse(self.env.context.get("object_id")):
69-
if record[real_field]:
70-
myPad.setHtmlFallbackText(path, record[real_field])
70+
real_field_value = record[real_field] or self.env.context.get('record', {}).get(real_field, '')
71+
if real_field_value:
72+
myPad.setHtmlFallbackText(path, real_field_value)
7173

7274
return {
7375
"server": pad["server"],

‎addons/pad/static/src/js/pad.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ var FieldPad = AbstractField.extend({
129129
context: {
130130
model: this.model,
131131
field_name: this.name,
132-
object_id: this.res_id
132+
object_id: this.res_id,
133+
record: this.recordData,
133134
},
134135
}, {
135136
shadow: true

0 commit comments

Comments
 (0)
Please sign in to comment.