How to remove an application for a specific model in openrp?

I am developing my own model. I installed a document model. This model gives a snap button on top of the form. but i want this bind button only in my module. I want to hide another this button in a different form (different model). so I get the following code to remove the "create and save" for a particular model. but this encoding does not work on my side. tell me how to use the snap button for a specific model? and how to hide other models ?.

openerp.web_smile_hide_buttons = function(openerp) { // Models for which we'll hide create and duplicate buttons var MODELS_TO_HIDE = ['kit.lab']; // Hide the create button on all list views, which affect tree views and many2one pop-up search view 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, MODELS_TO_HIDE) != -1) { self.options.addable = false; }; return ret; }, }); // Hide the save button on form views openerp.web.FormView.include({ on_loaded: function(data) { var self = this; var ret = this._super.apply(this, arguments); var res_model = this.dataset.model; // if ($.inArray(res_model, MODELS_TO_HIDE) != -1) { this.$element.find('button.oe_dropdown_toggle.oe_dropdown_arrow').remove(); this.$element.find('button.oe_form_button_save').remove(); //}; return ret; }, }); // Hide the create and duplicate button on all page views (ie read-only form views) openerp.web.PageView.include({ on_loaded: function(data) { var self = this; var ret = this._super.apply(this, arguments); var res_model = this.dataset.model; if ($.inArray(res_model, MODELS_TO_HIDE) != -1) { this.$element.find('button.oe_form_button_create').remove(); this.$element.find('button.oe_form_button_duplicate').remove(); }; return ret; }, }); }; 
0
attachment openerp-7
source share
1 answer

This question is older, but I had the same problem and it turned out. This is most likely not the best solution, but it works. I assume that you know how to write a custom module, so just add a dependency to the "document" and create your own javascript (for example, static / src / js / document.js, do not forget to include it in your openerp .py) with the following contents :

  openerp.document = function (instance) { _t = instance.web._t; instance.web.Sidebar.include({ init : function(){ this._super.apply(this, arguments); if (window.location.href.indexOf('&model=res.partner') === -1) this.sections.splice(1, 0, { 'name' : 'files', 'label' : _t('Attachment(s)'), }); this.items['files'] = []; }, }); }; 

In this example, the Attach button will be hidden in the res.partner form view.

Maybe someone else knows a better way to search for the current model compared to my solution for finding a string in window.location.href

0
source share

All Articles