Skip to content
Snippets Groups Projects
Commit d2707fa7 authored by Nicolas Martinelli's avatar Nicolas Martinelli
Browse files

[FIX] pad: initialize pad at creation

When a pad is created programmatically (e.g. through a project task or a
note), the pad is empty when it is first displayed. It is necessary to
edit the record and save it in order to be able to see the content.

This is because the pad is normally initialized by the JS layer, at the
first edition, thanks to a call to `pad_generate_url`. Therefore, a
programmatic pad creation won't initialize it.

opw-685826
parent 9413bafd
Branches
Tags
No related merge requests found
......@@ -91,7 +91,24 @@ class pad_common(osv.osv_memory):
def create(self, cr, uid, vals, context=None):
self._set_pad_value(cr, uid, vals, context)
return super(pad_common, self).create(cr, uid, vals, context=context)
res = super(pad_common, self).create(cr, uid, vals, context=context)
# In case the pad is created programmatically, the content is not filled in yet since it is
# normally initialized by the JS layer
pad_urls = {}
for k, field in self._fields.iteritems():
if hasattr(field, 'pad_content_field') and k not in vals:
ctx = dict(context or {})
ctx.update({
'model': self._name,
'field_name': k,
'object_id': res,
})
pad = self.pad_generate_url(cr, uid, ctx)
pad_urls[k] = pad.get('url')
if pad_urls:
self.write(cr, uid, res, pad_urls, context=context)
return res
# Set the pad content in vals
def _set_pad_value(self, cr, uid, vals, context=None):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment