the script is in python and i cant see the problem, i have attached the script and the error message:
import
for d in frappe.get_all(“Pranim”, fields=[“emri”,“vlera_tvsh”,“data_pranimit”]):
doc = frappe.get_doc(“Pranim”, d.emri)
n = (date.today() - doc.data_pranimit).days // 365
doc.amortizimi = doc.vlera_tvsh * (0.8 ** n)
doc.save()
I guess you have this in the “Server Script” UI. Imports are not permitted there. Here are all permitted commands within a server script.
Your code does not require any additional imports (no need to develop a custom app), for date handling you can use frappe.utils.
Just for your information, server scripts shared by AI models are intended to be used in python controller files in your custom Frappe app/fork. When you want to use them as customization layers via Server Script you must strip them of all imports (including import frappe) as these are already exposed in the safe environment.
Similarly hooks should also be stripped as it is set from within the UI (trigger field)