use of com.axelor.apps.stock.db.PartnerStockSettings in project axelor-open-suite by axelor.
the class PartnerStockSettingsServiceImpl method createMailSettings.
@Override
@Transactional(rollbackOn = { Exception.class })
public PartnerStockSettings createMailSettings(Partner partner, Company company) throws AxelorException {
PartnerStockSettings mailSettings = new PartnerStockSettings();
mailSettings.setCompany(company);
StockConfig stockConfig = Beans.get(StockConfigService.class).getStockConfig(company);
mailSettings.setPlannedStockMoveAutomaticMail(stockConfig.getPlannedStockMoveAutomaticMail());
mailSettings.setPlannedStockMoveMessageTemplate(stockConfig.getPlannedStockMoveMessageTemplate());
mailSettings.setRealStockMoveAutomaticMail(stockConfig.getRealStockMoveAutomaticMail());
mailSettings.setRealStockMoveMessageTemplate(stockConfig.getRealStockMoveMessageTemplate());
partner.addPartnerStockSettingsListItem(mailSettings);
return Beans.get(PartnerStockSettingsRepository.class).save(mailSettings);
}
use of com.axelor.apps.stock.db.PartnerStockSettings in project axelor-open-suite by axelor.
the class SaleOrderStockServiceImpl method setDefaultAutoMailSettings.
/**
* Set automatic mail configuration from the partner.
*
* @param stockMove
*/
protected void setDefaultAutoMailSettings(StockMove stockMove) throws AxelorException {
Partner partner = stockMove.getPartner();
Company company = stockMove.getCompany();
PartnerStockSettings mailSettings = Beans.get(PartnerStockSettingsService.class).getOrCreateMailSettings(partner, company);
stockMove.setRealStockMoveAutomaticMail(mailSettings.getRealStockMoveAutomaticMail());
stockMove.setRealStockMoveMessageTemplate(mailSettings.getRealStockMoveMessageTemplate());
stockMove.setPlannedStockMoveAutomaticMail(mailSettings.getPlannedStockMoveAutomaticMail());
stockMove.setPlannedStockMoveMessageTemplate(mailSettings.getPlannedStockMoveMessageTemplate());
}
use of com.axelor.apps.stock.db.PartnerStockSettings in project axelor-open-suite by axelor.
the class StockLocationSaveService method removeForbiddenDefaultStockLocation.
/**
* Remove default stock locations in partner that are not linked with this stock location anymore.
*
* @param defaultStockLocation
*/
@Transactional
public void removeForbiddenDefaultStockLocation(StockLocation defaultStockLocation) {
Partner currentPartner = defaultStockLocation.getPartner();
Company currentCompany = defaultStockLocation.getCompany();
Long partnerId = currentPartner != null ? currentPartner.getId() : 0L;
Long companyId = currentCompany != null ? currentCompany.getId() : 0L;
PartnerStockSettingsRepository partnerStockSettingsRepo = Beans.get(PartnerStockSettingsRepository.class);
List<PartnerStockSettings> partnerStockSettingsToRemove = partnerStockSettingsRepo.all().filter("(self.partner.id != :partnerId OR self.company.id != :companyId)" + " AND (self.defaultStockLocation.id = :stockLocationId)").bind("partnerId", partnerId).bind("companyId", companyId).bind("stockLocationId", defaultStockLocation.getId()).fetch();
for (PartnerStockSettings partnerStockSettings : partnerStockSettingsToRemove) {
Partner partnerToClean = partnerStockSettings.getPartner();
partnerToClean.removePartnerStockSettingsListItem(partnerStockSettings);
}
}
Aggregations