This question has been flagged
4905 Views

 I have created a view for an action window. I want to execute it from a custom button from javascript.

I read about how to use Javascript in odoo, but I am not clear enough. Besides, I need to add that javascript function on a custom button in the Employees' sheet to open the action window.

The action view contains a button as well, and I need to execute a python method and in turn, add another HTML element to the view (In this case an <img/> tag) clicking to that button.

Do I need to create a QWeb template inside the group tag where the image will be located?

How can I do all this using the only javascript?

Action view code:

<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<template id="assets_backend" name="static_resources assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/mymodel/static/src/js/load_captcha.js"/>
</xpath>
</template>

<record id="captcha_view" model="ir.ui.view">
<field name="name">captcha.view</field>
<field name="model">captcha.window</field>
<field name="arch" type="xml">
<form>
<group name="group_top">
<group name="group_left">
<field name="captcha_code"/>
<button name="load_captcha" string="Cargar código"
type="object" class="oe_highlight load_captcha" icon="fa-refresh"/>
</group>
<group name="group_right">
<!-- Here I want to appear the image when I click the button above -->
</group>
</group>
<footer>
<button name="main" string="Actualizar" type="object" class="oe_highlight"/>
</footer>
</form>
</field>
</record>
</data>
</odoo>

Avatar
Discard