From c5bd50927441ba98ae99d56ff765111cf4f6d2f3 Mon Sep 17 00:00:00 2001 From: Yannick Tivisse Date: Wed, 26 Jul 2017 15:27:36 +0200 Subject: [PATCH] [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. --- addons/pad/models/pad.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/pad/models/pad.py b/addons/pad/models/pad.py index dfa1dbf859b..eb6267ee389 100644 --- a/addons/pad/models/pad.py +++ b/addons/pad/models/pad.py @@ -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'):