from ppms import ppms
from ppms.module_subclasses.base_class import Base
from ppms.constants import MENU_FILTER, MENU_RESET, MENU_SAVE
class ModuleThatOverwritesSave(Base):
def menu_override(self, menu_id):
if menu_id == MENU_SAVE:
ppms.ui_message_box('No saving allowed!')
return self.MENU_OVERRIDE_SUCCESS
# Don't allow resetting as that brings up a save prompt
elif menu_id == MENU_RESET:
return self.MENU_OVERRIDE_SUCCESS
return super(ModuleThatOverwritesSave, self).menu_override(menu_id)GROUPINGS = {1:'customer', 2:'pr_manager_name', 3:'ht_pr_code_name', 4:'pr_group_1',
5:'pr_group_2', 6:'pr_group_3', 7:'ou_cctr_name', 8:'calculated_end_date',
9:'phase_name', 10:'ht_pr_plan_idea', 12:'product'}Example:
![]()
<Python ID> and <data item ID> serve as placeholders for the Python ID as well as for the ID of the hyperlink data item.
Notesdef computeOutput(di): hl_di = di.get_dtp_record().get_di('<Python-ID>') hl = hl_di.get_hyperlink() if (hl != None): ppms.ui_message_box(hl.get_uid()) return hl.get_uid() else: return "" computeOutput.deps = ('DI<Dataitem-ID>',)
| See also: OLE data item, Hyperlink Customizing |
mod_obj = ppms.get_target_module()
uid = mod_obj.get_uid()
ppms.client_exec("""
env = get_Env()
mod = env.ActivePanel.ModuleManager.__getitem__('%s')
doc = mod.CreateExcelExportDocument()
env.GenerateExcelFile(doc)
""" % uid)| See also: IronPython Api |
get_listboxvalue() from the Customizing Helper module only implements a mapping between actual values in data tables and the IDs of fixed listbox values in the corresponding table. However, it cannot read any arbitrary value from a listbox record. def computeOutput(di):
record = di.get_dtp_record()
key0 = record.get_di_by_id(<key0_numeric_di_no>).get_value()
# etc. for further DIs
multicol_key_template = '{0}|{1}|{2}'
multicol_key_value = multicol_key_template.format(key0, key1, key2)
return multicol_key_value
computeOutput.deps = ('DI<key0_textual_di_no>', 'DI<key1_textual_di_no>', ) # etc. for further DIsdef processInput(di, oldvalue):
record = di.get_dtp_record()
key0_di = record.get_di_by_id(<key0_numeric_di_no>)
# etc. for further DIs
new_value = di.get_value()
key_values = new_value.split('|', 3)
key0_di.set_value(key_values[0])
return new_value
processInput.deps = ('DI<key0_textual_di_no>', 'DI<key1_textual_di_no>', ) # etc. for further DIstextual_di_no is, for example, string 000123; a numeric_di_no, however, is the number 123
subject_text = "" body_text = ""
subject_text = subject of the e-mail
body_text = content of the e-mail
subject_text and body_text variables in the Data Field Configuration data field via Python.
subject_text = record.name.get_raw_value()
from ppms import ppms_cu
di_prefix = "DI: "
di_prefix_lenghth = len(di_prefix)
def get_df_cust_name(di):
df_name = di.get_dtp_record().df_customizing_name.get_value()
if df_name: return df_name # return name on DF level if set
return None
def get_di_cust_name(di):
di_nr = di.get_dtp_record().di.get_value()
di_cust_name = str()
if not di_nr: return None
di_record = ppms.search_record(412,[di_nr],[41035], True)
if di_record: di_cust_name = di_record.di_customizing_name.get_value()
else: return None
if di_cust_name: return di_cust_name
def computeOutput(di):
name = str()
if get_df_cust_name(di):
return get_df_cust_name(di)
elif get_di_cust_name(di):
return di_prefix + get_di_cust_name(di)
return ""
computeOutput.deps = ("DI041036","DI000213","DI000984")
def checkInput(di, old_value):
return ppms_cu.Helper.validate_python_id(di,di.get_value())
checkInput.deps=("DI001862",)
def processInput(di, old_value):
new_value = di.get_value()
rec = di.get_dtp_record()
#in case of copy
if new_value[:4]==di_prefix:
rec.df_customizing_name.set_string_value("")
return di_prefix + get_di_cust_name(di)
#in case of empty python ID
if not new_value.strip():
rec.df_customizing_name.set_string_value("")
if not get_di_cust_name(di):
return ""
return di_prefix + get_di_cust_name(di)
#in case of new value = old value
if new_value.strip() == old_value:
return ppms_cu.Helper.get_python_id_by_license(new_value)
rec.df_customizing_name.set_string_value(ppms_cu.Helper.get_python_id_by_license(new_value))
return ppms_cu.Helper.get_python_id_by_license(new_value)
processInput.deps = ("DI041036",)# get module object
mod_obj=ppms.get_target_module()
#mark all records of all datareas in the module
with ppms.echo_disabled():
[[mts_rec.mark() for mts_rec in mts_rec_list]for mts_rec_list in [da_obj.get_records() for da_obj in mod_obj.get_das()]]# get module object
mod_obj=ppms.get_target_module()
#unmark all marked records of all data areas in the module
with ppms.echo_disabled():
[[mts_rec.unmark() for mts_rec in mts_rec_list]for mts_rec_list in [da_obj.get_marked_records() for da_obj in mod_obj.get_das()]]# get module object mod_obj=ppms.get_target_module() #mark all records of all datareas in the module ppms.echo_off() [[mts_rec.mark() for mts_rec in mts_rec_list]for mts_rec_list in [da_obj.get_records() for da_obj in mod_obj.get_das()]] ppms.echo_on()
# get module object mod_obj=ppms.get_target_module() #unmark all marked records of all data areas in the module ppms.echo_off() [[mts_rec.unmark() for mts_rec in mts_rec_list]for mts_rec_list in [da_obj.get_marked_records() for da_obj in mod_obj.get_das()]] ppms.echo_on()
| See also: Splash Screen |
call_resource() function in the macro of the copied employee board as follows:
def call_resource(resource_id=ppms.get_target_module().get_current_L_var()[5]):
rec467=ppms.search_record(467, [resource_id[0]], [1218,3414], True)
if (hl != None):
message=ppms_cu.Helper.get_const_title("001247")
ppms.ui_message_box(message.replace("@user_id",resource_id[0]), blocking=1)
mod_obj.menu(49)
elif rec467.get_di("resource_type").get_value() == "2":
ppms.ui_message_id("0860")
mod_obj.menu(49)
else:
mod_obj.set_current_L_var(5, [resource_id[0]])from ppms import ppms_cu
mod_obj = ppms.get_target_module()
rm_modul=ppms_cu.Helper.get_global_setting("L100_employee_board_for_reporting").alpha120.get_value()
inv_rec=ppms.get_context_df().get_record()
res_id = inv_rec.res_id.get_raw_value()
mod_obj.set_new_L_var(5, [res_id])
mod_obj.open_module(rm_modul)def processInput (di, oldvalue):
rec = di.get_dtp_record()
rec.get_di ("L100_prognose_vom").set_value(ppms.uvar_get ("@15"))
rec.get_di ("L100_prognose_von").set_value(ppms.uvar_get ("@1"))
return di.get_value()
processInput.deps = ("DI100102","DI100103")mod_obj = ppms.get_target_module()
mod_obj.menu(12)
for rec in mod_obj.get_da ("Python_ID_DA_name").get_records():
rec.DF_Python_ID_planned_load_fixed.set_raw_value (rec.DF_Python_ID_planned_load.get_raw_value())
mod_obj.menu(34)
mod_obj.menu(49)PATH = r'C:\Program Files (x86)\Applikation\anwendung.exe'
# The string, which displays the path to the application is preceeded by "r",
# because otherwise the backslash \ is interpreted as an escape sign.
# see http://docs.python.org/reference/lexical_analysis.html#string-literals
ARGS = 'argument1=PLANTA argument2=Nocheins'
# declare the arguments, which are to be transferred to the application
# as a continuous string.
def execute_client_script(path, args):
ppms.client_exec("""import clr
clr.AddReference('System')
from System.Diagnostics import Process
Process.Start(r'{path}', r'{args}')""".format(path=path, args=args))
execute_client_script(PATH, ARGS)exp_path = save path of the created PDF file
file_name = name of the created PDF file
REPORT_MOD_ID = module, which is used for output (=report module). For status reports, e.g., the MOD009A52 Status Report default module
REPORT_VARIANT_ID = required variant of the report module
DA_PYTHON_ID = name of the source data area in selection mode
from ppms import ppms_cu
# module settings: Export path. Export file name, output module and variant to be used, Python ID of the source data area
exp_path = 'Exportpfad'.replace(chr(92),chr(92)+chr(92))
file_name = "name of the created PDF file"
REPORT_MOD_ID = "Modul-ID"
REPORT_VARIANT_ID = "Varianten-ID"
DA_PYTHON_ID = 'Python-ID'
#Reading out the print settings from the report module
module_customizing_record = ppms.search_record(405, [REPORT_MOD_ID], [25609,25610,1789,2947], True)
page_size = module_customizing_record.paper_format.get_value()
landscape = not bool(module_customizing_record.portrait_format.get_value())
zoom = float(module_customizing_record.zoom_print_preview.get_value())
fit_to_page = bool(module_customizing_record.default_zoom_col.get_value())
#Modulobjekte
macro_module = ppms.get_macro_module()
select_module = macro_module.get_invoker_module()
# composition of the Client command
CLIENT_CODE = """
e = get_Env()
pdf_list = e.PdfExportDocumentsList
list = e.PdfExportDocumentsList
page_size = '{page_size}'
landscape = {landscape}
zoom = {zoom}
fit_to_page = {fit_to_page}
for uid in {export_list}:
module = e.ActivePanel.ModuleManager[uid]
doc = module.CreatePdfExportDocument(pageSize=page_size, landscape=landscape, zoom=zoom, fitToPage=fit_to_page)
pdf_list.Add(doc)
e.ActivePanel.ModuleManager
e.GeneratePdfFile(pdf_list, '{exp_path}', '{file_name}')
"""
def get_selected_reports():
export_list =[]
modules_to_close = []
for pr_rec in select_module.get_da(DA_PYTHON_ID).get_records():
pr_id = pr_rec.pr_id.get_raw_value()
main_pr_id = pr_rec.main_pr_id.get_raw_value()
report_id = pr_rec.report_id.get_raw_value()
#Set all filter criteria used in the report module
select_module.set_new_L_var(30, [pr_id])
select_module.set_new_L_var(78, [report_id])
select_module.set_new_L_var(74, [main_pr_id])
#select_module.set_new_L_var(26, [report_id]) - is set in the macro of the status report
#select_module.set_new_L_var(25, [report_id]) - is empty in the standard
#Open the module variant (docked outside the screen display)
reporting_module=select_module.open_module(REPORT_MOD_ID,
dock_to_module=select_module.get_uid(),
forced_status=2,
dock_style=3,
dock_proportion=0.001,
foreground=0,
focus=0)
reporting_module.apply_mv_by_id(REPORT_VARIANT_ID)
reporting_module.menu(12)
modules_to_close.append(reporting_module)
#Internal number of the opened module
uid = str(reporting_module.get_uid())
#Add open modules to the PDF-interface list.
export_list.append((uid))
client_call = CLIENT_CODE.format(export_list=export_list, exp_path=exp_path, file_name=file_name,
page_size=page_size, landscape=landscape,
zoom=zoom, fit_to_page=fit_to_page)
ppms.client_exec(client_call)
for module in modules_to_close:
module.menu(49)
select_module.menu(49)
#Loop for module variant display
get_selected_reports() CreatePdfExportDocument(), the parameter names must be specified as well. doc = module.CreatePdfExportDocument(pageSize='A4',landscape=TRUE, zoom=100.0, fitToPage=TRUE) instead of doc = module.CreatePdfExportDocument('A4', TRUE, 100.0,TRUE)
def executeProcessAction(mts_rec=None,object_id=None): from ppms.processrules import copy_phase_into_model phase = mts_rec.phase.get_raw_value() copy_phase_into_model(object_id, mts_rec, <Process model ID>, <Phase ID>, phase) return True ppms.get_session_dict()["planta_functions"]=[executeProcessAction]
def executeProcessAction(mts_rec=None,object_id=None): from ppms.processrules import replace_phase_in_model replace_phase_in_model(project_id=object_id, prozess_templ_id=<Process model ID>, phase=<Phasen-ID>, forced_phase=<Zielphasen-ID>) return True ppms.get_session_dict()["planta_functions"]=[executeProcessAction]
ppms.module_subclasses.resource.ResourceDatasheet Python module subclass in the Python module subclass parameter in the Modules module.
ppms.get_target_module().on_save_check_person_resource()
| I | Attachment | History | Size | Date | Comment |
|---|---|---|---|---|---|
| |
AngemeldeteBenutzer.PNG | r2 r1 | 4.9 K | 2015-03-26 - 16:54 | |
| |
ColorPreviewItem.PNG | r2 r1 | 15.5 K | 2019-09-24 - 09:13 | |
| |
ModulBudgetinEarth.png | r1 | 15.8 K | 2014-10-15 - 12:08 | |
| |
ModulBudgetinVenus.png | r1 | 23.9 K | 2014-10-15 - 12:21 | |
| |
ModulCustomizingBudgetKostenartengruppen.png | r1 | 16.2 K | 2014-10-15 - 12:12 | |
| |
ModulCustomizingBudgetinVenus.png | r1 | 25.3 K | 2014-10-15 - 12:21 | |
| |
ProzentFormat.PNG | r1 | 6.6 K | 2013-06-25 - 12:47 | |
| |
UnterDataItemFarbe.png | r2 r1 | 9.5 K | 2019-09-24 - 09:14 | |
| |
VorschauFehlt.png | r1 | 15.4 K | 2019-09-24 - 09:06 | |
| |
addColorPreviewItemToDA.PNG | r2 r1 | 7.5 K | 2019-09-24 - 09:13 |