This question has been flagged
3 Replies
4979 Views

I have the following Snippet code :

    <template id="snippet_colact_id" name="ColAct snippet">
<section class="oe_snippet_body snippet_colact_id">
<h3>Actions</h3>
<div t-esc="res_company.textHarvey()"/>
<div t-set="teachers" t-value="res_company.menusHarvey()"/>
<t t-foreach="teachers" t-as="teacher">
<p><t t-esc="teacher.id"/> <t t-esc="teacher.name"/></p>
</t>
</section>
</template>


class res_company(models.Model):
def textHarvey(req):
return "hello harvey"
def menusHarvey(req):
id_colacts = openerp.pooler.get_pool(http.request.cr.dbname).get('a_colact_collaborativeaction').search(http.request.cr, http.request.uid, [])
colacts = openerp.pooler.get_pool(http.request.cr.dbname).get('a_colact_collaborativeaction').browse(http.request.cr, http.request.uid, id_colacts)
return colacts


When I drag my snippet onto the page the values are correctly extracted from the DB, but when I later change the values in Odoo and then refersh the page the values don't change. It looks like the values are retrieved when the Snippet is dropped onto the page and that they never change after?

Avatar
Discard
Author

Great ! That worked (copying my code into the HTML editor)... it's a shame the designer doens't just leave the Snippet as it is all the same...

Best Answer

hi. When you drop the snippet, you drop the rendered content. so if you want something of dynamic, you should add the snippets code in html editor. Like that, it will be rendered at fly and not only at drop. If you want to make it with drag and drop, you need to drop a placeholder and do it in Javascript.

Avatar
Discard