@@ -10,27 +10,34 @@ def open_forretningspartner(session, fp: str) -> None:
1010 fp: The forretningspartner number.
1111
1212 Raises:
13- ValueError : If the forretningspartner wasn't found.
13+ LookupError : If the forretningspartner wasn't found.
1414 """
1515 session .StartTransaction ('fmcacov' )
1616
1717 # Find forretningspartner
1818 session .findById ("wnd[0]/usr/ctxtGPART_DYN" ).text = fp
1919 session .findById ("wnd[0]" ).sendVKey (0 )
2020
21- # Detect window "Forretningspartner * Entries"
22- if session .findById ('wnd[1]/usr' , False ) is not None :
23- # Pop-up detected
24- for row_id in range (3 , 5 ):
21+ # Detect popup
22+ popup = session .findById ('wnd[1]' , False )
23+
24+ # Inactive FP popup
25+ if popup and popup .Text == "BP inactive" :
26+ # Click 'OK'
27+ session .FindById ("wnd[1]/tbar[0]/btn[25]" ).press ()
28+
29+ # "Forretningspartner 2 Entries" popup
30+ elif popup and popup .Text == 'Forretningspartner 2 Entries' :
31+ # Look for matching fp number
32+ for row_id in (3 , 4 ):
2533 fp_row = session .FindById (f'wnd[1]/usr/lbl[103,{ row_id } ]' )
2634 if fp_row .text == fp :
2735 fp_row .SetFocus ()
2836 # Press 'Accept' button.
2937 session .FindById ('wnd[1]/tbar[0]/btn[0]' ).press ()
3038 break
3139 else :
32- # Range exhausted
33- raise ValueError (f"Forretningspartner '{ fp } ' was not found in pop-up." )
40+ raise LookupError (f"Forretningspartner '{ fp } ' was not found in pop-up." )
3441
3542
3643def dismiss_key_popup (session , fp : str = "25564617" ) -> None :
0 commit comments