use of com.axelor.apps.project.db.Project in project axelor-open-suite by axelor.
the class ProjectPlanningTimeHRRepository method save.
@Override
public ProjectPlanningTime save(ProjectPlanningTime projectPlanningTime) {
super.save(projectPlanningTime);
Project project = projectPlanningTime.getProject();
project.setTotalPlannedHrs(planningTimeService.getProjectPlannedHrs(project));
Project parentProject = project.getParentProject();
if (parentProject != null) {
parentProject.setTotalPlannedHrs(planningTimeService.getProjectPlannedHrs(parentProject));
}
ProjectTask task = projectPlanningTime.getProjectTask();
if (task != null) {
task.setTotalPlannedHrs(planningTimeService.getTaskPlannedHrs(task));
}
return projectPlanningTime;
}
use of com.axelor.apps.project.db.Project in project axelor-open-suite by axelor.
the class SaleOrderLineProjectController method setProject.
/**
* Set project from context selected lines
*
* @param request
* @param response
*/
public void setProject(ActionRequest request, ActionResponse response) {
try {
Project project = request.getContext().asType(Project.class);
project = Beans.get(ProjectRepository.class).find(project.getId());
setProject(request, response, project);
} catch (Exception e) {
TraceBackService.trace(e);
}
}
use of com.axelor.apps.project.db.Project in project axelor-open-suite by axelor.
the class SaleOrderProjectController method generateProject.
public void generateProject(ActionRequest request, ActionResponse response) {
try {
SaleOrder saleOrder = request.getContext().asType(SaleOrder.class);
saleOrder = Beans.get(SaleOrderRepository.class).find(saleOrder.getId());
if (saleOrder.getSaleOrderLineList() == null || saleOrder.getSaleOrderLineList().isEmpty()) {
response.setAlert(I18n.get(IExceptionMessage.SALE_ORDER_GENERATE_FILL_PROJECT_ERROR_2));
return;
}
String generatorType = (String) request.getContext().get("_projectGeneratorType");
LocalDateTime startDate = getElementStartDate(request.getContext());
ProjectGeneratorType projectGeneratorType = ProjectGeneratorType.valueOf(generatorType);
ProjectGeneratorFactory factory = ProjectGeneratorFactory.getFactory(projectGeneratorType);
Project project;
if (projectGeneratorType.equals(ProjectGeneratorType.PROJECT_ALONE)) {
project = factory.create(saleOrder);
} else {
project = factory.generate(saleOrder, startDate);
}
response.setReload(true);
response.setView(ActionView.define("Project").model(Project.class.getName()).add("form", "project-form").param("forceEdit", "true").context(CONTEXT_SHOW_RECORD, String.valueOf(project.getId())).map());
} catch (Exception e) {
TraceBackService.trace(response, e, ResponseMessageType.ERROR);
response.setReload(true);
}
}
use of com.axelor.apps.project.db.Project in project axelor-open-suite by axelor.
the class ProjectController method generateQuotation.
public void generateQuotation(ActionRequest request, ActionResponse response) {
try {
Project project = request.getContext().asType(Project.class);
SaleOrder order = Beans.get(ProjectBusinessService.class).generateQuotation(project);
response.setView(ActionView.define(I18n.get("Sale quotation")).model(SaleOrder.class.getName()).add("form", "sale-order-form").param("forceTitle", "true").context("_showRecord", String.valueOf(order.getId())).map());
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.project.db.Project in project axelor-open-suite by axelor.
the class ProjectTemplateController method createProjectFromTemplate.
public void createProjectFromTemplate(ActionRequest request, ActionResponse response) {
ProjectTemplate projectTemplate = request.getContext().asType(ProjectTemplate.class);
AppProject appProject = Beans.get(AppProjectService.class).getAppProject();
if (appProject.getGenerateProjectSequence() && !projectTemplate.getIsBusinessProject()) {
Project project;
try {
project = Beans.get(ProjectService.class).createProjectFromTemplate(projectTemplate, null, null);
response.setView(ActionView.define(I18n.get("Project")).model(Project.class.getName()).add("form", "project-form").add("grid", "project-grid").param("search-filters", "project-filters").context("_showRecord", project.getId()).map());
} catch (AxelorException e) {
TraceBackService.trace(response, e);
}
} else {
response.setView(ActionView.define(I18n.get("Create project from this template")).model(Wizard.class.getName()).add("form", "project-template-wizard-form").param("popup", "reload").param("show-toolbar", "false").param("show-confirm", "false").param("width", "large").param("popup-save", "false").context("_projectTemplate", projectTemplate).context("_businessProject", projectTemplate.getIsBusinessProject()).map());
}
}
Aggregations