Hello,
I am trying to hide "Edit" button in specific view by specific record state. Now I extended base.xml and can hide "Edit" button in specific view by view name like this:
<templates>
<t t-extend="FormView.buttons">
<t t-jquery="button.oe_form_button_create" t-operation="replace">
<t t-if="widget.fields_view.name == 'purchase.request.form'">
<button t-if="widget.is_action_enabled('edit')"
type="button"
class="oe_form_button_edit btn btn-default btn-sm" accesskey="E">
Edit
</button>
</t>
</templates>
But is it possible to hide "Edit" button depend on specific record state in specific view. I tired to add <t t-if="widget.datarecord.state !== 'to_approve_first'"></t> to my extended xml:
<templates>
<t t-extend="FormView.buttons">
<t t-jquery="button.oe_form_button_create" t-operation="replace">
<t t-if="widget.fields_view.name == 'purchase.request.form'">
<t t-if="widget.datarecord.state !== 'to_approve_first'">
<button t-if="widget.is_action_enabled('edit')"
type="button"
class="oe_form_button_edit btn btn-default btn-sm" accesskey="E">
Edit
</button>
</t>
</t>
</templates>
But nothing happens. Is it something wrong with my code or I can't do that by changing base.xml view?
How else can I solve this problem? By changing javascript code?
I haven't tried it through xml , but through Jquery it's possible.
you want to hide that button for specific model only right?