2
votes

I made some changes in my core module to hide some buttons using javascript. I put this code below in my view_list_editable.js

openerp.web.ListView.include({
  start: function() {
    var self = this;
    var ret = this._super.apply(this, arguments);
    var res_model = this.dataset.model;
    if ($.inArray(res_model, ['inno.open.lab.report']) != -1) {
      self.options.addable = false; /* create button */
      self.options.deletable = false; /* delete button */
    };
    return ret;
  },
});

and it works. But when I try to inherit it, by put it doesn't work at all I did it like this

  1. I make a new javascript file that contain this code below:

    instance.web.ListView = instance.web.ListView.extend({ start: function() { var self = this; var ret = this._super.apply(this, arguments); var res_model = this.dataset.model; if ($.inArray(res_model, ['inno.open.lab.report']) != -1) { self.options.addable = false; /* create button / self.options.deletable = false; / delete button */ }; return ret; }, });

  2. I put it my_module/static/src/js

  3. I also add javascript in terp like this:

    'js' : ['static/src/js/view_list_editable.js',],

2

2 Answers

0
votes

I believe you have to have 'web' in the dependencies section of terp as well:

'depends': [
         'web',
         ],
0
votes

Yes, you are doing write put there is still one more step to do.

Add this below code in your views/xml file at top.

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <template id="assets_backend" name="your-module-name" inherit_id="web.assets_backend">
            <xpath expr="." position="inside">
                <script type="text/javascript" src="/module-ame/static/src/js/view_list_editable.js"></script>
            </xpath>
        </template>
    </data>
</openerp>

Try this one.!