3 Commits

3 changed files with 96 additions and 0 deletions

View File

@ -149,6 +149,10 @@
<boolean name="isDangerousProduct" title="Is dangerous" /> <boolean name="isDangerousProduct" title="Is dangerous" />
<boolean name="needDt1Validation" title="DT1 validation required" massUpdate="true"/>
<boolean name="needDt2Validation" title="DT2 validation required" massUpdate="true"/>
<boolean name="needQaQc1Validation" title="QAQC1 validation required" massUpdate="true"/>
<boolean name="needQaQc2Validation" title="QAQC2 validation required" massUpdate="true"/>
<many-to-one name="coaSpec" ref="com.axelor.meta.db.MetaFile" /> <many-to-one name="coaSpec" ref="com.axelor.meta.db.MetaFile" />
@ -209,6 +213,10 @@
<field name="shp" /> <field name="shp" />
<field name="stklim" /> <field name="stklim" />
<field name="ug" /> <field name="ug" />
<field name="needDt1Validation" />
<field name="needDt2Validation" />
<field name="needQaQc1Validation" />
<field name="needQaQc2Validation" />
<message if="true" on="UPDATE">Product updated</message> <message if="true" on="UPDATE">Product updated</message>
</track> </track>
</entity> </entity>

View File

@ -0,0 +1,81 @@
/*
* Axelor Business Solutions
*
* Copyright (C) 2019 Axelor (<http://axelor.com>).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.axelor.apps.message.job;
import com.axelor.apps.message.db.Message;
import com.axelor.apps.message.db.repo.MessageRepository;
import com.axelor.apps.message.service.MessageService;
import com.axelor.exception.service.TraceBackService;
import com.google.inject.Inject;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.LocalDate;
import java.util.List;
import javax.mail.MessagingException;
import com.axelor.exception.AxelorException;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** An example {@link Job} class that prints a some messages to the stderr. */
public class SendEmailJob implements Job {
private final Logger log = LoggerFactory.getLogger(SendEmailJob.class);
@Inject private MessageService messageService;
@Inject private MessageRepository messageRepository;
@Override
public void execute(JobExecutionContext context) {
LocalDate today = LocalDate.now();
LocalDateTime startOfDay = today.atStartOfDay();
List<Message> draftMessages = messageRepository
.all()
.filter("self.statusSelect = 1 AND self.createdOn >= :startOfDay")
.bind("startOfDay", startOfDay)
.fetch();
log.debug("Total of draft messages : {}", draftMessages.size());
for (Message message : draftMessages) {
try {
Message m = messageService.sendMessage(message);
} catch (AxelorException e) {
TraceBackService.trace(e);
}
}
List<Message> inProgressMessages = messageRepository
.all()
.filter("self.statusSelect = 2 AND self.createdOn >= :startOfDay")
.bind("startOfDay", startOfDay)
.fetch();
log.debug("Total of in progress messages : {}", inProgressMessages.size());
for (Message message : inProgressMessages) {
try {
Message m = messageService.sendMessage(message);
} catch (AxelorException e) {
TraceBackService.trace(e);
}
}
}
}

View File

@ -21,6 +21,8 @@
<many-to-many name="stockLocationList" ref="com.axelor.apps.stock.db.StockLocation" title="Stock locations"/> <many-to-many name="stockLocationList" ref="com.axelor.apps.stock.db.StockLocation" title="Stock locations"/>
<many-to-one name="picture" ref="com.axelor.meta.db.MetaFile" title="Photo" index="false"/> <many-to-one name="picture" ref="com.axelor.meta.db.MetaFile" title="Photo" index="false"/>
<boolean name="needCheckInVerification" title="Check-in verification required" default="false" massUpdate="true"/>
<finder-method name="findByCompany" using="company"/> <finder-method name="findByCompany" using="company"/>
<finder-method name="findByPartner" using="partner"/> <finder-method name="findByPartner" using="partner"/>
@ -41,6 +43,11 @@
]]></extra-code> ]]></extra-code>
<track on="UPDATE">
<field name="needCheckInVerification" />
</track>
</entity> </entity>
</domain-models> </domain-models>