Duplicate citations with Supertool

You can copy a citation with something like:

from gramps.gen.lib import SrcAttribute
c = Citation()
c.set_reference_handle(source.handle)
c.set_page(page)
c.set_date_object(obj.get_date_object())
c.set_confidence_level(confidence)
for n in notes:
    c.add_note(n.handle)
for mediaref in obj.get_media_list():
    c.add_media_reference(mediaref)
for attrtype, attrvalue in attributes:
    a = SrcAttribute()
    a.set_type(attrtype)
    a.set_value(attrvalue)
    c.add_attribute(a)
db.add_citation(c, trans)

Put the code in the “Statements executed for each object” section. Use option “Selected objects” and select the citation you want to copy. To create multiple copies, just execute the script multiple times.

Note that notes and media are not actually duplicated, the new citation just refers to the original note and media objects.

Hope this helps
Kari

type or paste code here
3 Likes