@Override
@Transactional(readOnly = true)
public void prepareCreationFrom(OrderTemplate template, Desktop desktop) {
loadNeededDataForConversation();
Order newOrder = createOrderFrom((OrderTemplate) templateDAO
.findExistingEntity(template.getId()));
newOrder.setCode(getOrder().getCode());
newOrder.setCodeAutogenerated(true);
newOrder.setName(getOrder().getName());
newOrder.setCustomer(((Order) getOrder()).getCustomer());
newOrder.setCalendar(getCalendar());
newOrder.setInitDate(getOrder().getInitDate());
if (getOrder().getDeadline() != null) {
newOrder.setDeadline(getOrder().getDeadline());
}
planningState = planningStateCreator.createOn(desktop, newOrder);
forceLoadAdvanceAssignmentsAndMeasurements(planningState.getOrder());
initializeOrder();