How to hide the edit button form based on state field of invoice Odoo v8?

試著忘記壹切 提交于 2019-11-30 22:43:43

Add a Record Rule for account.invoice object with Read permission alone. And a domain filter as [('state','=','paid')].

Soaad

Try replacing fields through inheritance and adding attrs to it. Using attrs, you can set the field invisible when state is paid like this,

        <field name="edit" attrs="{'invisible':[('state', '=', 'paid')]}"/>

You can do this by overriding load_record of FormView widget:

openerp.module_name = function(instance, local) {
    var instance = openerp;
    var FormView = instance.web.FormView;

    // override load_record
    FormView.include({
        load_record: function(record) {
        // disable only for purchase.order
        if (record){
            // allow this behavior only for purchase.order  
            if (this.model == 'purchase.order' & _.contains(['done', 'cancel'], record.state)){
                    $('button.oe_form_button_edit').hide()
                }else {
                    $('button.oe_form_button_edit').show()
                }
        }
        // call super
        return this._super(record);
        }
    });
}

Check this app if you looking for full code:

Disable edit button for paid invoice

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!