[FIX] pad: Update the pad if the pad_content_field is modified

If the pad content field is modified in Odoo, the content of the pad should be modified too.

Example: When merging tasks, the tasks descriptions are concatenated into the target record. But the taregt pad is not modified if it already exists.
This commit is contained in:
Yannick Tivisse
2017-07-26 16:01:09 +02:00
parent 8354efde0a
commit c5bd509274
+8
View File
@@ -115,6 +115,14 @@ class PadCommon(models.AbstractModel):
# Set the pad content in vals
def _set_pad_value(self, vals):
# Update the pad if the `pad_content_field` is modified
for k, field in self._fields.iteritems():
if hasattr(field, 'pad_content_field') and vals.get(field.pad_content_field):
company = self.env.user.sudo().company_id
myPad = EtherpadLiteClient(company.pad_key, company.pad_server + '/api')
path = self[k].split('/p/')[1]
myPad.setText(path, (html2plaintext(vals[field.pad_content_field]).encode('utf-8')))
# Update the `pad_content_field` if the pad is modified
for k, v in vals.items():
field = self._fields[k]
if hasattr(field, 'pad_content_field'):