Skip to Content
Menu
This question has been flagged

I want to remove the edit button on the purchase.order view when the state is 'purchase'.

I have a big problem with the bounce effect on the edit button. It's located in here: 

\https://github.com/odoo/odoo/blob/10.0/addons/web/static/src/js/views/form_view.js

// Add bounce effect on button 'Edit' when click on readonly page view. this.$(".oe_title,.o_group").on('click', function (e) { if(self.get("actual_mode") === "view" && self.$buttons && !$(e.target).is('[data-toggle]')) { self.$buttons.find(".o_form_button_edit").openerpBounce(); core.bus.trigger('click', e); } });

I have made a module to hide the 'edit' button on the state purchase. Inside my javascript, I have this to handle that:

if (this.model=='purchase.order'){     if (this.get_fields_values().state=='purchase'){     this.$buttons.find('.o_form_button_edit').hide();     }     else{ this.$buttons.find('.o_form_button_edit').show();     }     var self = this;     this.$(".oe_title,.o_group").on('click', function (e) {         if(self.get("actual_mode") === "view" && self.$buttons && !$(e.target).is('[data-toggle]')) {     self.$buttons.find(".o_form_button_edit").hide();     //core.bus.trigger('click', e);         }     }); }

Here I hide it with the if/else part, then I try to remove the bounce effect.

The problem is that when you click on any part at the form, the edit button shows up because of that bounce effect.

Is there any solution for this?


Thank you very much.

Avatar
Discard
Best Answer

Hello,

It may be too late but for the sake of others who have the same problem I have found a solution to bypass.

You can disable the button with Javascript:


        ...
	Formview.include({
            ...
            load_record:function(){
	        ...
		if(/*your condition*/){

                    var $button = self.$buttons.find(".o_form_button_edit");

                    $button.prop("disabled", true);

                }
	    }
	});

 

I hope this helps!

Avatar
Discard
Author

Hi, thank you

I will test this soon.

Related Posts Replies Views Activity
2
Jul 18
2357
1
Jul 17
2382
0
Mar 24
245
2
Jun 23
40693
1
Jul 22
1839