Search in sources :

Example 1 with PrintingSettings

use of com.axelor.apps.base.db.PrintingSettings in project axelor-open-suite by axelor.

the class SaleOrderController method filterPrintingSettings.

/**
 * Called on printing settings select. Set the domain for {@link SaleOrder#printingSettings}
 *
 * @param request
 * @param response
 */
public void filterPrintingSettings(ActionRequest request, ActionResponse response) {
    try {
        SaleOrder saleOrder = request.getContext().asType(SaleOrder.class);
        List<PrintingSettings> printingSettingsList = Beans.get(TradingNameService.class).getPrintingSettingsList(saleOrder.getTradingName(), saleOrder.getCompany());
        String domain = String.format("self.id IN (%s)", !printingSettingsList.isEmpty() ? StringTool.getIdListString(printingSettingsList) : "0");
        response.setAttr("printingSettings", "domain", domain);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : PrintingSettings(com.axelor.apps.base.db.PrintingSettings) SaleOrder(com.axelor.apps.sale.db.SaleOrder) TradingNameService(com.axelor.apps.base.service.TradingNameService) BirtException(org.eclipse.birt.core.exception.BirtException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException)

Example 2 with PrintingSettings

use of com.axelor.apps.base.db.PrintingSettings in project axelor-open-suite by axelor.

the class InvoiceController method filterPrintingSettings.

/**
 * Called on printing settings select. Set the domain for {@link Invoice#printingSettings}
 *
 * @param request
 * @param response
 */
public void filterPrintingSettings(ActionRequest request, ActionResponse response) {
    Invoice invoice = request.getContext().asType(Invoice.class);
    List<PrintingSettings> printingSettingsList = Beans.get(TradingNameService.class).getPrintingSettingsList(invoice.getTradingName(), invoice.getCompany());
    String domain = String.format("self.id IN (%s)", !printingSettingsList.isEmpty() ? StringTool.getIdListString(printingSettingsList) : "0");
    response.setAttr("printingSettings", "domain", domain);
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) PrintingSettings(com.axelor.apps.base.db.PrintingSettings) TradingNameService(com.axelor.apps.base.service.TradingNameService)

Example 3 with PrintingSettings

use of com.axelor.apps.base.db.PrintingSettings in project axelor-open-suite by axelor.

the class MessageServiceBaseImpl method printMessage.

@SuppressWarnings("unchecked")
@Override
public String printMessage(Message message) throws AxelorException {
    Company company = message.getCompany();
    if (company == null) {
        return null;
    }
    PrintingSettings printSettings = company.getPrintingSettings();
    if (printSettings == null || printSettings.getDefaultMailBirtTemplate() == null) {
        return null;
    }
    BirtTemplate birtTemplate = printSettings.getDefaultMailBirtTemplate();
    logger.debug("Default BirtTemplate : {}", birtTemplate);
    Templates templates = new StringTemplates('$', '$');
    Map<String, Object> templatesContext = Maps.newHashMap();
    try {
        Class<? extends Model> className = (Class<? extends Model>) Class.forName(message.getClass().getName());
        templatesContext.put("Message", JPA.find(className, message.getId()));
    } catch (ClassNotFoundException e) {
        TraceBackService.trace(e);
    }
    String fileName = "Message " + message.getSubject() + "-" + appBaseService.getTodayDate(company).format(DateTimeFormatter.BASIC_ISO_DATE);
    return Beans.get(TemplateMessageServiceBaseImpl.class).generateBirtTemplateLink(templates, templatesContext, fileName, birtTemplate.getTemplateLink(), birtTemplate.getFormat(), birtTemplate.getBirtTemplateParameterList());
}
Also used : Company(com.axelor.apps.base.db.Company) BirtTemplate(com.axelor.apps.base.db.BirtTemplate) Templates(com.axelor.text.Templates) StringTemplates(com.axelor.text.StringTemplates) StringTemplates(com.axelor.text.StringTemplates) PrintingSettings(com.axelor.apps.base.db.PrintingSettings) Model(com.axelor.db.Model)

Example 4 with PrintingSettings

use of com.axelor.apps.base.db.PrintingSettings in project axelor-open-suite by axelor.

the class PurchaseOrderController method filterPrintingSettings.

/**
 * Called on printing settings select. Set the domain for {@link PurchaseOrder#printingSettings}
 *
 * @param request
 * @param response
 */
public void filterPrintingSettings(ActionRequest request, ActionResponse response) {
    try {
        PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
        List<PrintingSettings> printingSettingsList = Beans.get(TradingNameService.class).getPrintingSettingsList(purchaseOrder.getTradingName(), purchaseOrder.getCompany());
        String domain = String.format("self.id IN (%s)", !printingSettingsList.isEmpty() ? StringTool.getIdListString(printingSettingsList) : "0");
        response.setAttr("printingSettings", "domain", domain);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : PrintingSettings(com.axelor.apps.base.db.PrintingSettings) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder) TradingNameService(com.axelor.apps.base.service.TradingNameService) AxelorException(com.axelor.exception.AxelorException)

Example 5 with PrintingSettings

use of com.axelor.apps.base.db.PrintingSettings in project axelor-open-suite by axelor.

the class StockMoveController method filterPrintingSettings.

/**
 * Called on printing settings select. Set the the domain for {@link StockMove#printingSettings}
 *
 * @param request
 * @param response
 */
public void filterPrintingSettings(ActionRequest request, ActionResponse response) {
    try {
        StockMove stockMove = request.getContext().asType(StockMove.class);
        List<PrintingSettings> printingSettingsList = Beans.get(TradingNameService.class).getPrintingSettingsList(stockMove.getTradingName(), stockMove.getCompany());
        String domain = String.format("self.id IN (%s)", !printingSettingsList.isEmpty() ? StringTool.getIdListString(printingSettingsList) : "0");
        response.setAttr("printingSettings", "domain", domain);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : StockMove(com.axelor.apps.stock.db.StockMove) PrintingSettings(com.axelor.apps.base.db.PrintingSettings) TradingNameService(com.axelor.apps.base.service.TradingNameService) AxelorException(com.axelor.exception.AxelorException)

Aggregations

PrintingSettings (com.axelor.apps.base.db.PrintingSettings)5 TradingNameService (com.axelor.apps.base.service.TradingNameService)4 AxelorException (com.axelor.exception.AxelorException)3 Invoice (com.axelor.apps.account.db.Invoice)1 BirtTemplate (com.axelor.apps.base.db.BirtTemplate)1 Company (com.axelor.apps.base.db.Company)1 PurchaseOrder (com.axelor.apps.purchase.db.PurchaseOrder)1 SaleOrder (com.axelor.apps.sale.db.SaleOrder)1 StockMove (com.axelor.apps.stock.db.StockMove)1 Model (com.axelor.db.Model)1 StringTemplates (com.axelor.text.StringTemplates)1 Templates (com.axelor.text.Templates)1 IOException (java.io.IOException)1 BirtException (org.eclipse.birt.core.exception.BirtException)1