Search in sources :

Example 6 with Project

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;
}
Also used : Project(com.axelor.apps.project.db.Project) ProjectTask(com.axelor.apps.project.db.ProjectTask)

Example 7 with Project

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);
    }
}
Also used : Project(com.axelor.apps.project.db.Project) AxelorException(com.axelor.exception.AxelorException)

Example 8 with Project

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);
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) ProjectGeneratorFactory(com.axelor.apps.businessproject.service.projectgenerator.ProjectGeneratorFactory) Project(com.axelor.apps.project.db.Project) ProjectGeneratorType(com.axelor.apps.project.db.ProjectGeneratorType) SaleOrder(com.axelor.apps.sale.db.SaleOrder)

Example 9 with Project

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);
    }
}
Also used : InvoicingProject(com.axelor.apps.businessproject.db.InvoicingProject) Project(com.axelor.apps.project.db.Project) ProjectBusinessService(com.axelor.apps.businessproject.service.ProjectBusinessService) SaleOrder(com.axelor.apps.sale.db.SaleOrder) AxelorException(com.axelor.exception.AxelorException)

Example 10 with Project

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());
    }
}
Also used : AppProject(com.axelor.apps.base.db.AppProject) Project(com.axelor.apps.project.db.Project) AxelorException(com.axelor.exception.AxelorException) AppProject(com.axelor.apps.base.db.AppProject) AppProjectService(com.axelor.apps.project.service.app.AppProjectService) Wizard(com.axelor.apps.base.db.Wizard) ProjectTemplate(com.axelor.apps.project.db.ProjectTemplate)

Aggregations

Project (com.axelor.apps.project.db.Project)64 AxelorException (com.axelor.exception.AxelorException)15 InvoicingProject (com.axelor.apps.businessproject.db.InvoicingProject)12 Transactional (com.google.inject.persist.Transactional)12 BigDecimal (java.math.BigDecimal)11 ArrayList (java.util.ArrayList)9 Product (com.axelor.apps.base.db.Product)8 User (com.axelor.auth.db.User)8 HashMap (java.util.HashMap)7 TimesheetLine (com.axelor.apps.hr.db.TimesheetLine)6 ProjectTask (com.axelor.apps.project.db.ProjectTask)6 Map (java.util.Map)6 Partner (com.axelor.apps.base.db.Partner)5 AppProject (com.axelor.apps.base.db.AppProject)4 ProjectRepository (com.axelor.apps.project.db.repo.ProjectRepository)4 Invoice (com.axelor.apps.account.db.Invoice)3 File (java.io.File)3 LocalDate (java.time.LocalDate)3 Company (com.axelor.apps.base.db.Company)2 PriceList (com.axelor.apps.base.db.PriceList)2