Skip to content

Commit

Permalink
91006: Check configurator is activated
Browse files Browse the repository at this point in the history
  • Loading branch information
kra-axelor committed Feb 17, 2025
1 parent 4a21ad2 commit 297bac6
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,7 @@ private SaleExceptionMessage() {}
"Sale order does not have configurator to duplicate." /*)*/;
public static final String CONFIGURATOR_VERSION_IS_DIFFERENT = /*$$(*/
"Configurator version is different than its configurator creator." /*)*/;

public static final String CONFIGURATOR_IS_NOT_ACTIVATED = /*$$(*/
"Configurator is not activated." /*)*/;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ public interface ConfiguratorCheckService {
void checkHaveConfigurator(SaleOrder saleOrder) throws AxelorException;

boolean isConfiguratorVersionDifferent(Configurator configurator);

void checkConfiguratorActivated(Configurator configurator) throws AxelorException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,15 @@ public boolean isConfiguratorVersionDifferent(Configurator configurator) {
.getConfiguratorVersion()
.equals(configurator.getConfiguratorCreator().getConfiguratorVersion());
}

@Override
public void checkConfiguratorActivated(Configurator configurator) throws AxelorException {
if (configurator != null) {
if (!configurator.getConfiguratorCreator().getIsActive()) {
throw new AxelorException(
TraceBackRepository.CATEGORY_INCONSISTENCY,
I18n.get(SaleExceptionMessage.CONFIGURATOR_IS_NOT_ACTIVATED));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ public void fillProductFields(
Long saleOrderId)
throws AxelorException {

configuratorCheckService.checkConfiguratorActivated(configurator);
configuratorCheckService.checkLinkedSaleOrderLine(configurator, product);
if (configuratorCheckService.isConfiguratorVersionDifferent(configurator)) {
throw new AxelorException(
Expand Down Expand Up @@ -399,6 +400,7 @@ public SaleOrderLine generateSaleOrderLine(
JsonContext jsonAttributes,
JsonContext jsonIndicators)
throws AxelorException {
configuratorCheckService.checkConfiguratorActivated(configurator);
var newSaleOrderLine =
generateSaleOrderLine(configurator, jsonAttributes, jsonIndicators, saleOrder);
saleOrderLineRepository.save(newSaleOrderLine);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,18 +387,28 @@ public void configuratorDuplicateSaleOrderLine(ActionRequest request, ActionResp
}
}

public void checkDuplicationSaleOrderLine(ActionRequest request, ActionResponse response) {
@ErrorException
public void checkDuplicationSaleOrderLine(ActionRequest request, ActionResponse response)
throws AxelorException {
SaleOrderLine saleOrderLine = request.getContext().asType(SaleOrderLine.class);

Beans.get(ConfiguratorCheckService.class)
.checkConfiguratorActivated(saleOrderLine.getConfigurator());

if (Beans.get(ConfiguratorCheckService.class)
.isConfiguratorVersionDifferent(saleOrderLine.getConfigurator())) {
response.setAlert(I18n.get(ITranslation.CONFIGURATOR_VERSION_IS_DIFFERENT));
}
}

public void checkEditConfiguratorSaleOrderLine(ActionRequest request, ActionResponse response) {
@ErrorException
public void checkEditConfiguratorSaleOrderLine(ActionRequest request, ActionResponse response)
throws AxelorException {
SaleOrderLine saleOrderLine = request.getContext().asType(SaleOrderLine.class);

Beans.get(ConfiguratorCheckService.class)
.checkConfiguratorActivated(saleOrderLine.getConfigurator());

if (Beans.get(ConfiguratorCheckService.class)
.isConfiguratorVersionDifferent(saleOrderLine.getConfigurator())) {
response.setError(I18n.get(SaleExceptionMessage.CONFIGURATOR_VERSION_IS_DIFFERENT));
Expand Down
1 change: 1 addition & 0 deletions axelor-sale/src/main/resources/i18n/messages.csv
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
"Configurator creator name",,,
"Configurator creators",,,
"Configurator formula list",,,
"Configurator is not activated.",,,
"Configurator model",,,
"Configurator version is different than its configurator creator.",,,
"Configurator version is different than the version of its configurator creator, therefore only a simple duplicate will be created, proceed ?",,,
Expand Down
1 change: 1 addition & 0 deletions axelor-sale/src/main/resources/i18n/messages_en.csv
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
"Configurator creator name",,,
"Configurator creators",,,
"Configurator formula list",,,
"Configurator is not activated.",,,
"Configurator model",,,
"Configurator version is different than its configurator creator.",,,
"Configurator version is different than the version of its configurator creator, therefore only a simple duplicate will be created, proceed ?",,,
Expand Down
1 change: 1 addition & 0 deletions axelor-sale/src/main/resources/i18n/messages_fr.csv
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
"Configurator creator name",,,
"Configurator creators",,,
"Configurator formula list","Liste des formules",,
"Configurator is not activated.","Le configurator n'est pas activé.",,
"Configurator model","Modèle de configurateur",,
"Configurator version is different than its configurator creator.","La version du configurateur est différente de celle de son modèle.",,
"Configurator version is different than the version of its configurator creator, therefore only a simple duplicate will be created, proceed ?","La version du configurateur est différente de celle de son modèle, une simple copie sera générer, confirmer ? ",,
Expand Down

0 comments on commit 297bac6

Please sign in to comment.