Fix field rename feature

Instead of considering the field at position ord, which is somehow buggy, let's consider the already existing old name.

Fixes #4487 , also more manual test seems to indicate nothing more is added
This commit is contained in:
Arthur Milchior 2026-01-06 09:48:33 +01:00
parent 8f2144534b
commit 20cebfd225

View file

@ -130,9 +130,7 @@ class FieldDialog(QDialog):
self.saveField()
self.loadField(idx)
def _uniqueName(
self, prompt: str, ignoreOrd: int | None = None, old: str = ""
) -> str | None:
def _uniqueName(self, prompt: str, old: str = "") -> str | None:
txt = getOnlyText(prompt, default=old).replace('"', "").strip()
if not txt:
return None
@ -143,9 +141,9 @@ class FieldDialog(QDialog):
if letter in txt:
show_warning(tr.fields_name_invalid_letter())
return None
if txt == old:
return None
for f in self.model["flds"]:
if ignoreOrd is not None and f["ord"] == ignoreOrd:
continue
if f["name"] == txt:
show_warning(tr.fields_that_field_name_is_already_used())
return None
@ -157,7 +155,7 @@ class FieldDialog(QDialog):
idx = self.currentIdx
f = self.model["flds"][idx]
name = self._uniqueName(tr.actions_new_name(), self.currentIdx, f["name"])
name = self._uniqueName(tr.actions_new_name(), f["name"])
if not name:
return