Praise be to Allah.Praise be to Allaah.
Yes, that is permissible. Shaykh al-Islam [Ibn Taymiyah] (may Allaah have mercy on him) said: “It is not permissible to make a will leaving something to an heir without the consent of the other heirs. Heirs may be included in the will in general terms without mentioning them by name.” (al-Ikhtiyaaraat, p. 190).
What this means is that if a will is in general terms, i.e., it does not mention people by name, such as one that mentions categories, such as the poor, or students, or mujaahideen, etc., it is permissible for those who fall into those categories to take something from this bequest even if they are also heirs. But if the will mentions people by name, such as bequeathing wealth to relatives, the heirs cannot be included in this bequest.
And Allaah knows best.