Hi,
Here, if the two menus have got different actions, you can pass some default value for any of the field in the view from the action and then based on that field you can make button visible and invisible.
Suppose we have two menus named menu_1 and menu_2, then we will add a dummy invisible field into our model and view, let it be a Boolean field named menu_1 , then in the context of the action of menu menu_1 will set the field value of menu_1 as true.
So once we come from menu_1 the value of the field menu_1(newly added boolean will be True) and value of this field will be False while we coming from the menu2.
You can pass default value for a field from the context like this,
<record id="act_values_form_action" model="ir.actions.act_window">
<field name="name">Action Bindings</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">ir.values</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="values_view_search_action"/>
<field name="domain">[('key','=','action')]</field>
<field name="context">{'default_menu_1':True}</field>
</record>
Then based on this field you can hide the button using attrs.
attrs="{'invisible':[('menu_1','=',False)]}"
You can see a similar logic in this OCA module: https://apps.odoo.com/apps/modules/10.0/purchase_hide_report_print_menu/
Thanks