Quintiq file version 2.0
#parent: #root
Method New (
  ProductInStockingPoint_MP pisp,
  FormSafetyStocks formSafetyStocks
) id:Method_DialogCreateEditSafetyStock_New
{
  #keys: '[136682.2.38964853]'
  Body:
  [*
    //New
    owner := guard( pisp.Product_MP(), select( DataHolderProduct.Data(), Elements, e, not e.IsSystem() and e.IsLeaf() ) );
    stockingpoint := guard(pisp.StockingPoint_MP(),null( StockingPoint_MP ) );
    
    data := owner.SafetyStock( relshadow, 
                               ProductID := owner.ID(),
                               StockingPointID := stockingpoint.ID(),
                               StockingPoint_MP := stockingpoint,
                               HasUserTarget := true,
                               Start := guard( MacroPlan.StartOfPlanningPeriod().StartDate(), MacroPlan.Start().Date() ) );
    DataHolderForm.Data( formSafetyStocks );
    DataHolderDialogData.Data( &data );
    //Enable disable component
    Form.EnableDisabledComponent( guard( DataHolderDialogData.Data().HasUserTarget(), false ) );
    Form.ShowHideComponent( false );
    ApplicationMacroPlanner.ShowFormModal( Form );
  *]
}
