What I mean, is it possible to file taxes in Panama, while living in Spain? The activities would be performed within Spain for a company outside of Spain.
Would it still be within the limits?
Read the DTA text in link I sent or link bellow. As Spain is a place no sane person with ambition or money would ever want to live or make their tax residence I have not looked into it personally in any detail. You may need to utilize a Spanish tax advisor for help in this area
https://www.boe.es/eli/es/ai/2010/10/07/(1)/con
--- quote (using google translate)
Article 14. Provision of services.
1. Income obtained by a resident of one Contracting State for the provision of services performed in the other Contracting State may be taxed in the Contracting State mentioned first. However, such income may also be taxed in the other Contracting State, provided that the services are professional services, consulting services, industrial or commercial advice, technical or management services or other similar services. However, the tax thus required may not exceed 7.5 percent of the gross amount of said payments when the effective beneficiary of said payments is a resident of the other Contracting State.
2. The expression « professional services » includes independent, scientific, literary, artistic, educational or teaching activities, as well as the independent activities of doctors, lawyers, engineers, architects, dentists and accountants.
3. The provisions of paragraph 1 do not apply if the person providing the services, resident of one Contracting State, performs in the other Contracting State, activities through a permanent establishment located in that other State, and the payments received for its services are effectively linked to said permanent establishment. In such cases, the provisions of article 7 shall apply.
4. When the payer of said income, whether or not he is a resident of a Contracting State, have in one of the Contracting States a permanent establishment in relation to which the obligation to pay for the services derives and that it assumes the burden thereof, said income from services will be considered coming from the State where the permanent establishment is located.
5. When, due to the special relationships existing between the service provider and the payer thereof, or those that one and the other maintain with third parties, the amount of the income for services exceeds that which the provider and the payer would have agreed in the absence of such relationships, the provisions of this article shall apply only to the latter amount. In such case, the excess may be taxed in accordance with the legislation of each Contracting State, taking into account the other provisions of this Agreement.
--- quote end