Yes, if I understood correctly. Here is the script (witnesses.script):
[Gramps SuperTool script file]
version=1
[title]
witnesses
[description]
[category]
Families
[initial_statements]
@include witnesses.py
[statements]
move_witness()
[filter]
[expressions]
[scope]
selected
[unwind_lists]
False
[commit_changes]
False
[summary_only]
False
The actual code is in the separate file ‘witnesses.py’:
def move_witness():
husband = self.father
wedding = find_wedding_event(self)
if not wedding:
return
for witnessref in husband.obj.get_person_ref_list():
witness = db.get_person_from_handle(witnessref.ref)
evref = EventRef()
evref.set_role(EventRoleType.WITNESS)
evref.ref = wedding.handle
witness.add_event_ref(evref)
db.commit_person(witness, trans)
husband.obj.set_person_ref_list([]) # delete all associations
db.commit_person(husband.obj, trans)
def find_wedding_event(fam):
for event in fam.events:
if event.type == 'Marriage':
return event
return None
This code will always process ALL associations for the husband/groom (and delete them). So if there are other kinds of associations then the code must be amended.
The code will also do nothing if there is no marriage event.
The script should be run in the Families view. By default it only processes selected families.