Odoo Help


How can I show a field only when a particular key is pressed in odoo9?

Sebin Siby
on 9/1/16, 4:56 AM 142 views


I want to show a field only when a particular key is pressed (eg: Alt+p). How could I achieve this in odoo9?

Jerome Guerriat
On 9/6/16, 11:02 AM

- load your own javascript file with something like:

<?xml version="1.0" encoding="UTF-8"?>
<template id="assets_backend" name="mis_builder" inherit_id="web.assets_backend">
  <xpath expr="." position="inside">
 <script type="text/javascript" src="/path_to_your_js.js">

Then in that javascript file, do something like

var map = {x: false, y: false, z: false};

where X, Y and Z are the value of the keypress event of the key you want the user to press (for exemple, "enter" is 13)

then something 

$(document).keydown(function(e) {
 if (e.keyCode in map) {
         map[e.keyCode] = true;
         if (map[x] && map[y] && map[z]) {
          //code to execute when X, Y and Z are pressed. Again, X Y and Z are the value of the keypress event
}).keyup(function(e) {
     if (e.keyCode in map) {
         map[e.keyCode] = false;


The code to execute should, in some way, hide or display the field you want. You'll need to find a solution to use a CSS selector to find that field exactly, but that should not be hard ;).

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 9/1/16, 4:56 AM
Seen: 142 times
Last updated: 9/6/16, 11:02 AM