Script: Copy Vertec project

Copy Current Project

Product line

Standard

|

Expert

Operating mode

CLOUD ABO

|

ON-PREMISES

Modules

Services & CRM

Budget & Phases

Purchases

Resource Planning

Business Intelligence

Created: 27.09.2013
Updated: 10.10.2024 | Removed Member xResourcePlanPhases from Script 6.7.

Content

Creates a new project in Vertec and applies the values of an existing project.

The user who executes the script is inserted as the project leader.

All values except services, expenses and downpayments are applied. Content information such as folder references is also not applied.

Adopts the phases in the correct order, as well as the different assignments and user rights, and applies phase budgets (without Budgetchange objects).

The name of the new project can be entered. The new project will be set inactive.

Execute

On the project to be copied. Please use the script that fits your current Vertec version.

Versions

Vertec version Special features Version Scripting
From 6.1.0.10

Also copies editorlinks, keys and tags. The project code is queried via the input box.

The script must be registered and run executed with advanced user rights.

ProjectCopy61.py
From 6.7 Same as the script above, except that xResourcePlanPhases is no longer copied from the project presets (the member was removed with Vertec 6.7). ProjectCopy67.py

Script text

The (latest) script text is displayed here to enable the full text search.

# coding: windows-1252
#
#---Description: Copy Project
# Class: Project
#   CondExpression:
#   ObjectScript: Y
#   ContainerScript: N
#   EventType: –
#   EventClass: –
#   EventMembers: –
#   ExtendedRights: Y
#
#---Create a new project and copy the settings from the source project
#---2017-12-17, UOS: Created from template
#---09.08.2018, sth: Now also copies EditorLinks, CustomLinks, Keys and Tags.
#   The project code is queried via the input box.
#---29.11.2018, tka: Subphase handling: Project is only set when parent phase.
#---30.01.2019, sth: Bugfix when copying custom field items.
#---04.09.2020, sth: Bugfix when copying CustomLinks.
#---27.01.2022, sth: Script extracted from plug-in project templates. Budget values on editor phase links are also copied.
#---19.09.2023, sth: Member xResourcePlanPhases removed from project presets (deleted with Vertec 6.7).

def main(Vproject):

    def copySubPhases(phase, parentPhase, project):
        subphases = phase.subphases
        if len(subphases) > 0:
            for subPhase in subPhases:
                newPhase = copyPhase(subPhase, parentPhase, project)
                copySubPhase(subPhase, newPhase, project)

    def copyPhase(sourcePhase, parentPhase, project):

        # if there exists already an active phase with same code, do not copy, but return existing phase to copy subphases
        existingPhase = None
        if parentPhase:
            existingPhase = parentPhase.eval(“subphase->select(active)->select(code='{}')->first”.format(sourcePhase.code))
        elif project:
            existingPhase = project.eval(“phase->select(active)->select(code='{}')->first”.format(sourcePhase.code))
        if existingPhase:
            return existingPhase       
        else:
            newPhase = vtcapp.createobject(“Project Phase”)

        # set parentphase or project
        if parentPhase:
            newPhase.parentphase = parentPhase
        else:
            newPhase.projekt = project

        # set attributes    
        newPhase.code = sourcePhase.code
        newPhase.xActive = sourcePhase.Active
        newPhase.responsible = sourcePhase.responsible
        newPhase.accountable = sourcePhase.accountable
        newPhase.status = sourcePhase.status
        newPhase.Description = sourcePhase.Description
        newPhase.remark = sourcePhase.remark
        newPhase.pauschal = sourcePhase.pauschal
        newPhase.lump sum expenses = sourcePhase.lump sum expenses
        newPhase.lump sums = sourcePhase.lump sums
        newPhase.orderidx = sourcePhase.orderidx

        # budget
        newPhase.xplanMinutenInt = sourcePhase.xplanMinutenInt
        newPhase.xplanValueExt = sourcePhase.xplanValueExt
        newPhase.xplanVertInt = sourcePhase.xplanVertInt
        newPhase.xplanCostPerformance = sourcePhase.xplanCostPerformance
        newPhase.xplanExpenseValue = sourcePhase.xplanExpenseValue
        newPhase.xplanCostExpenses = sourcePhase.xplanCostExpenses
        newPhase.xplanExpenseValue = sourcePhase.xplanExpenseValue
        newPhase.xplanCostExpenses = sourcePhase.xplanCostExpenses

        # set prerequisites
        newPhase.approachtext = sourcePhase.approachtext
        newPhase.cost = sourcePhase.cost
        newPhase.processor = sourcePhase.processor
        newPhase.tagespauschaleext = sourcePhase.tagespauschaleext
        newPhase.processor assignment = sourcePhase.processor assignment
        newPhase.task assignment = sourcePhase.task assignment
        newPhase.expense type assignment = sourcePhase.expense type assignment
        newPhase.delivery type assignment = sourcePhase.delivery type assignment

        # accounting
        newPhase.revenue accounts = sourcePhase.revenue accounts
        newPhase.income account expenses = sourcePhase.income account expenses
        newPhase.income account expenses = sourcePhase.income account expenses
        newPhase.cost center services = sourcePhase.cost center services
        newPhase.cost center charges = sourcePhase.cost center charges
        newPhase.cost center expenses = sourcePhase.cost center expenses

        # left
        copyPhaseUserLink(sourcePhase, newPhase)
        copyPhaseServiceTypes(sourcePhase, newPhase)
        copyPhaseExpenseTypes(sourcePhase, newPhase)
        copyPhasePurchaseTypes(sourcePhase, newPhase)

        # additional fields
        copyAdditionalFields(sourcePhase, newPhase)

        return newPhase

    def copyPhaseExpenseTypes(sourcePhase, newPhase):
        phaseExpenseTypeList = sourcePhase.eval(“self.expenseTypehaselink”)
        for sourcePhaseExpenseType in phaseExpenseTypeList:
            newPhaseExpenseType = vtcapp.createobject(“ExpenseTypePhaseLink”)
            newPhaseExpenseType.minPlanValueExpenses = sourcePhaseExpenseType.minPlanValueExpenses
            newPhaseExpenseType.maxPlanValueExpense = sourcePhaseExpenseType.maxPlanValueExpense
            newPhaseExpenseType.planCostExpense = sourcePhaseExpenseType.planCostExpense
            newPhaseExpenseType.planValueExpense = sourcePhaseExpenseType.planValueExpense
            newPhaseExpenseType.valueprounittext = sourcePhaseExpenseType.valueprounittext
            newPhaseExpenseType.valueprounitint = sourcePhaseExpenseType.valueprounitint
            newPhaseExpenseType.valueperunitcost = sourcePhaseExpenseType.valueperunitcost
            newPhaseExpenseType.name = sourcePhaseExpenseType.name
            newPhaseExpenseType.offertText = sourcePhaseExpenseType.offertText
            newPhaseExpenseType.phasen = newPhase
            newPhaseExpenseType.expenseType = sourcePhaseExpenseType.expenseType
            newPhaseExpenseType.processor = sourcePhaseExpenseType.processor
            # additional fields
            copyAdditionalFields(sourcePhaseExpenseType, newPhaseExpenseType)

    def copyPhasePurchaseTypes(sourcePhase, newPhase):
        PhasePurchaseTypeList = sourcePhase.eval(“self.purchaseTypehaselink”)
        for sourcePhasePurchaseType in PhasePurchaseTypeList:
            newPhasePurchaseType = vtcapp.createobject(“PurchaseTypePhaseLink”)
            newPhasePurchaseType.minPlanValueExpenses = sourcePhasePurchaseType.minPlanValueExpenses
            newPhasePurchaseType.PlanVertExpenses = sourcePhasePurchaseType.PlanVertExpenses
            newPhasePurchaseType.maxPlanValueExpenses = sourcePhasePurchaseType.maxPlanValueExpenses
            newPhasePurchaseType.PlanCostExpenses = sourcePhasePurchaseType.PlanCostExpenses
            newPhasePurchaseType.maxPlanCostExpenses = sourcePhasePurchaseType.maxPlanCostExpenses
            newPhasePurchaseType.minPlanCostExpenses = sourcePhasePurchaseType.minPlanCostExpenses
            newPhasePurchaseType.valueprounittext = sourcePhasePurchaseType.valueprounittext
            newPhasePurchaseType.valueprounitint = sourcePhasePurchaseType.valueprounitint
            newPhasePurchaseType.valueperunit cost = sourcePhasePurchaseType.valueperunit cost
            newPhasePurchaseType.name = sourcePhasePurchaseType.name
            newPhasePurchaseType.offertText = sourcePhasePurchaseType.offertText
            newPhasePurchaseType.phasen = newPhase
            newPhasePurchaseType.purchaseType = sourcePhasePurchaseType.purchaseType
            newPhasePurchaseType.processor = sourcePhasePurchaseType.processor
            # additional fields
            copyAdditionalFields(sourcePhasePurchaseType, newPhasePurchaseType)

    def copyPhaseUserLink(sourcePhase, newPhase):
        PhaseUserList = sourcePhase.eval(“editor phases”)
        for sourcePhaseUser in PhaseUserList:
            newPhaseUser = vtcapp.createobject(“PhaseLink Editor”)
            newPhaseUser.Costrate = sourcePhaseUser.Costrate
            newPhaseUser.Userrate = sourcePhaseUser.Userrate
            newPhaseUser.TagesPauschaleExt = sourcePhaseUser.TagesPauschaleExt
            newPhaseUser.FeerateExt = sourcePhaseUser.FeerateExt
            newPhaseUser.User = sourcePhaseUser.User
            newPhaseUser.xplanVertExt = sourcePhaseUser.xplanVertExt
            newPhaseUser.xplanwertint = sourcePhaseUser.xplanwertint
            newPhaseUser.xplanminutenint = sourcePhaseUser.xplanminutenint
            newPhaseUser.xplanned value = sourcePhaseUser.xplanned value
            newPhaseUser.xplankcosts = sourcePhaseUser.xplankcosts
            newPhaseUser.xplanned cost performance = sourcePhaseUser.xplanned cost performance
            newPhaseUser.xplankostenspen = sourcePhaseUser.xplankostenspen
            newPhaseUser.xplansexpensevalue = sourcePhaseUser.xplansexpensevalue
            newPhaseUser.processor level = sourcePhaseUser.processor level

            newPhaseUser.Phase = newPhase
            # additional fields
            copyAdditionalFields(sourcePhaseUser, newPhaseUser)

    def copyPhaseServiceTypes(sourcePhase, newPhase):
        PhaseServiceTypeList = sourcePhase.eval(“activityphaselink”)
        for sourcePhaseServiceType in PhaseServiceTypeList:
            newPhaseServiceType = vtcapp.createobject(“ActivityPhaseLink”)
            newPhaseServiceType.planValueLeist = sourcePhaseServiceType.planValueLeist
            newPhaseServiceType.minPlanValueLeist = sourcePhaseServiceType.minPlanValueLeist
            newPhaseServiceType.unit value = sourcePhaseServiceType.unit value
            newPhaseServiceType.tagesPauschaleExt = sourcePhaseServiceType.tagesPauschaleExt
            newPhaseServiceType.name = sourcePhaseServiceType.name
            newPhaseServiceType.approachExt = sourcePhaseServiceType.approachExt
            newPhaseServiceType.planMinutenInt = sourcePhaseServiceType.planMinutenInt
            newPhaseServiceType.maxPlanValueLeist = sourcePhaseServiceType.maxPlanValueLeist
            newPhaseServiceType.approachCost = sourcePhaseServiceType.approachCost
            newPhaseServiceType.ApproachProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcessProcess
            newPhaseServiceType.offertText = sourcePhaseServiceType.offertText
            newPhaseServiceType.phasen = newPhase
            newPhaseServiceType.activities = sourcePhaseServiceType.activities
            newPhaseServiceType.processor = sourcePhaseServiceType.processor
            # additional fields
            copyAdditionalFields(sourcePhaseServiceType, newPhaseServiceType)

    def copyAdditionalFields (source, target):
        additionalFieldList = source.eval(“additionalfield.metaadditionalfield”)
        for additionalField in additionalFieldList:
            additionalFieldname = additionalField.eval(“fieldname”)
            sourceValue = getattr(source, additionalFieldname)
            setattr(target, additionalFieldname, sourceValue)

    def copyUserLink(source, target):
        # when a project Inf created, the current user Inf automatically assigned and has to be deleted manually
        for user in list(target.evalocl(“editor link”)):
            user.delete()

        userList = source.evalocl(“editor link”)
        for sourceUser in userList:
            newUser = vtcapp.createobject(“EditorLink”)
            newUser.Costrate = sourceUser.Costrate
            newUser.Userrate = sourceUser.Userrate
            newUser.TagesPauschaleExt = sourceUser.TagesPauschaleExt
            newUser.FeerateExt = sourceUser.FeerateExt
            newUser.User = sourceUser.User
            User level = sourceUser user level
            target.workerlinks.append(newUser)

    def copyCustomLinks(source, target):

        # customlink
        oldLinks = vtcapp.getwithsql(“Customlink,” “customlinks={}”.format(source.objid), ““)
        for oldLink in oldLinks:
            newLink = vtcapp.createobject(“Customlink”)
            newLink.linktype = oldLink.linktype
            newLink.customlinks = target
            newLink.fromcustomlinks = oldLink.fromcustomlinks

        # fromcustomlink
        oldLinks = vtcapp.getwithsql(“Customlink,” “fromcustomlinks={}”.format(source.objid), ““)
        for oldLink in oldLinks:
            newLink = vtcapp.createobject(“Customlink”)
            newLink.linktype = oldLink.linktype
            newLink.customlinks = oldLink.customlinks
            newLink.fromcustomlinks = target

    def copyProjectSettings(source, target):

        # set attributes
        target.customer = source.customer
        target.remark = source.remark
        target.concern = source.concern
        target.description = source.description
        target.tarifstufe = source.tarifstufe
        target.currency = source.currency
        target.invoiceinterval = source.invoiceinterval
        target.xinvoice address = source.xinvoice address
        target.language = source.language
        target.contactPerson = source.contactPerson
        target.xmwsttyp = source.xmwsttyp
        target.hb = source.hb
        target.hbstv = source.hbstv
        target.sekr = source.sekr
        target.keys = source.keys
        target.tags = source.tags
        target.interlections = source.interlections
        target.counterweaves = source.counterweaves

        # add counterparties
        adrlist = target.counterparties
        adrlist += source.counterparties
        
        # budget
        target.xplanMinutenInt = source.xplanMinutenInt
        target.xplanValueExt = source.xplanValueExt
        target.xplanVertInt = source.xplanVertInt
        target.xplanCostPerformance = source.xplanCostPerformance
        target.xplanExpenseValue = source.xplanExpenseValue
        target.xplanCostExpenses = source.xplanCostExpenses
        target.xplanExpenseValue = source.xplanExpenseValue
        target.xplanCostExpenses = source.xplanCostExpenses

        # invoice settings
        target.rechDiscount = source.rechDiscount
        target.rechPackage = source.rechPackage
        target.rechDiscountPercent = source.rechDiscountPercent
        target.rechFlatExpensePercent = source.rechFlatExpensePercent
        target.rechFlatAmount = source.rechFlatAmount
        target.rechFrequency = source.rechFrequency
        target.rechFrequencyAmount = source.rechFrequencyAmount
        target.rechProforma = source.rechProforma
        target.rechUseSpesen = source.rechUseSpesen
        target.rechDiscountAmount = source.rechDiscountAmount

        # prerequisites
        target.xansatzext = source.xansatzext
        target.xcost = source.xcost
        target.xsequence editor = source.xsequence editor
        target.xtagesPlatformExt = source.xtagesPlatformExt
        target.xExpensesForward = source.xExpensesForward
        target.xdebikondition = source.xdebikondition

        # payment conditions
        target.xDebiCondition = source.xDebiCondition

        # accounting
        target.xDatabaseFibu = source.xDatabaseFibu
        target.xLoginFibu = source.xLoginFibu
        target.xPasswordFibu = source.xPasswordFibu
        target.xpersonaccount =source.xpersonaccount
        target.xRevenue AccountServices = source.xRevenue AccountServices
        target.xIncome AccountExpenses = source.xIncome AccountExpenses
        target.xIncome AccountExpenses = source.xIncome AccountExpenses
        target.xDebtor Account = source.xDebtor Account
        target.xAdvance account = source.xAdvance account
        target.xCost of Services = source.xCost of Services
        target.xCostPointExpenses = source.xCostPointExpenses
        target.xCost CenterExpenses = source.xCost CenterExpenses
        target.xPayment Type = source.xPayment Type
        
        # additional fields
        copyAdditionalFields (source, target)

        # assigned users
        copyUserLink(source, target)

        # custom links
        copyCustomLinks(source, target)

    if not Vprojekt.eval(“oclistypeof(project)”):
        vtcapp.msgbox(“The script can only be executed on one project”)
        return

    projectcode = vtcapp.inputbox('Vertec’,'Enter the code of the new project’,'')
    if project code != ““:
        #Create the new project
        project = vtcapp.createobject(“project”)
        projekt.code = project code

        #Apply
        copyProjectSettings(Vproject, project)

        #Copy phases, if any
        if Vproject.eval(“allphases.list->size>0”):
            PhasesLevel1 = Vproject.phases
            for submissionPhase in PhasesLevel1:
                newPhase = copyPhase(templatePhase, templatePhase.parentPhase, project)
                copySubPhases(templatePhase, newPhase, project)

        #Apply keywords
        Keywords = Vproject.eval(“folder->select(parentfolder.keyword)”)
        for StOrdner in Stichwoerter:
            project.folder.append(Stfolder)

        vtcapp.showdetailform (project)

main(argobject)

 

 

Bitte wählen Sie Ihren Standort