Cells not recomputed between two macro calls

Hello !

In Calc, I put a button which calls a python macro :

# Get the name of the students's class
def getClassName(*args):
	global DOC
	nameClass=str(DOC.getValue("class.A1"))
	DOC.setValue("class.A2",nameClass)

At first, the macro reads the content af A1 cell, in the sheet “class”. It displays the result in A2.
I use the button. It works.
I write something else in A1, press return, and push the button again. The result un A2 doesn’t change.

How can I force the refresh ?

LibreOffice infos :
Version: 25.8.2.2 (X86_64)
Build ID: d401f2107ccab8f924a8e2df40f573aab7605b6f
CPU threads: 8; OS: Windows 11 X86_64 (build 26200); UI render: Skia/Raster; VCL: win
Locale: fr-FR (fr_FR); UI: fr-FR
Calc: CL threaded

Hallo

def getClassName(*_):
    doc = XSCRIPTCONTEXT.getDocument()
    sheet = doc.Sheets["class"]
    sheet["A2"].String = sheet["A1"].String

YOU DONT NEED SCRIPTFORGE