diff --git a/entity/Forecast_entity/Forecast_entity.aod b/entity/Forecast_entity/Forecast_entity.aod index d6a3a8231f161f09c2ed372c5d094f42be4542c1..a596f7e006fc85e895b9fa6c94b204c646819060 100644 --- a/entity/Forecast_entity/Forecast_entity.aod +++ b/entity/Forecast_entity/Forecast_entity.aod @@ -4,6 +4,7 @@ <title>${FORECAST_ENGLISH}</title> <majorModelMode>DISTRIBUTED</majorModelMode> <documentation>%aditoprj%/entity/Forecast_entity/documentation.adoc</documentation> + <afterSave>%aditoprj%/entity/Forecast_entity/afterSave.js</afterSave> <titlePlural>Forecasts</titlePlural> <recordContainer>db</recordContainer> <entityFields> diff --git a/entity/Forecast_entity/afterSave.js b/entity/Forecast_entity/afterSave.js new file mode 100644 index 0000000000000000000000000000000000000000..5465a06689922c673973a24fdfa5ba111c79d42d --- /dev/null +++ b/entity/Forecast_entity/afterSave.js @@ -0,0 +1,21 @@ +import("system.entities"); +import("Sql_lib"); +import("system.vars"); + +var objectType = vars.get("$field.OBJECT_TYPE"); +if(objectType == "Salesproject") +{ + var objectRowId = vars.get("$field.OBJECT_ROWID"); + var volume = newSelect("sum(VOLUME)") + .from("FORECAST") + .where("FORECAST.OBJECT_TYPE", "Salesproject") + .and("FORECAST.OBJECT_ROWID", objectRowId) + .cell(); + + var config = entities.createConfigForUpdatingRows() + .uid(objectRowId) + .addParameter("IgnoreChecklists_param", true) + .fieldValues({"VOLUME": volume}) + .entity("Salesproject_entity"); + entities.updateRow(config); +} \ No newline at end of file diff --git a/entity/Salesproject_entity/Salesproject_entity.aod b/entity/Salesproject_entity/Salesproject_entity.aod index b191f7fa4fc783031dc3d23e9621ab649ed023ee..f4603f8af45ec19aa7cb4b13d28c7e4552c80e8a 100644 --- a/entity/Salesproject_entity/Salesproject_entity.aod +++ b/entity/Salesproject_entity/Salesproject_entity.aod @@ -116,6 +116,7 @@ <outputFormat>#,##0.00</outputFormat> <inputFormat>#,##0.00</inputFormat> <groupable v="true" /> + <state>READONLY</state> </entityField> <entityConsumer> <name>Organisations</name> @@ -868,6 +869,7 @@ <outputFormat>#,##0.00</outputFormat> <inputFormat>#,##0.00</inputFormat> <groupable v="true" /> + <state>READONLY</state> <valueProcess>%aditoprj%/entity/Salesproject_entity/entityfields/volumeweighted/valueProcess.js</valueProcess> </entityField> <entityAggregateField>