From 7e2fa1016024635851215e8be009ad3a7473c35a Mon Sep 17 00:00:00 2001 From: Edwin Betancourt Date: Mon, 9 Jan 2023 19:23:54 -0400 Subject: [PATCH] fix: Overwrite parent values with empty child record. (#700) --- .../ADempiere/dictionary/window/getters.js | 11 +++ src/utils/ADempiere/dictionary/window.js | 71 ++++++++++--------- 2 files changed, 47 insertions(+), 35 deletions(-) diff --git a/src/store/modules/ADempiere/dictionary/window/getters.js b/src/store/modules/ADempiere/dictionary/window/getters.js index 24bf271ab0b..db46cb81660 100644 --- a/src/store/modules/ADempiere/dictionary/window/getters.js +++ b/src/store/modules/ADempiere/dictionary/window/getters.js @@ -16,6 +16,9 @@ * along with this program. If not, see . */ +// Constants +import { ACTIVE, PROCESSED, PROCESSING } from '@/utils/ADempiere/constants/systemColumns' + // Utils and Helpers Methods import { isEmptyValue } from '@/utils/ADempiere/valueUtils' import { isDisplayedField, isMandatoryField } from '@/utils/ADempiere/dictionary/window.js' @@ -234,6 +237,14 @@ export default { isForceSession: true }) } + // get value on parent tab + if ([ACTIVE, PROCESSED, PROCESSING].includes(columnName)) { + parsedDefaultValue = rootGetters.getValueOfField({ + parentUuid, + columnName + }) + } + attributesObject[columnName] = parsedDefaultValue // add display column to default diff --git a/src/utils/ADempiere/dictionary/window.js b/src/utils/ADempiere/dictionary/window.js index e2ceaa6d222..d181a26f2a4 100644 --- a/src/utils/ADempiere/dictionary/window.js +++ b/src/utils/ADempiere/dictionary/window.js @@ -1100,7 +1100,7 @@ export const containerManager = { }) }, - seekRecord: ({ row, parentUuid, containerUuid }) => { + seekRecord: ({ row = {}, parentUuid, containerUuid }) => { if (isEmptyValue(row)) { store.dispatch('setTabDefaultValues', { parentUuid, @@ -1250,49 +1250,50 @@ export const containerManager = { if (!field.isUpdateable) { return true } - - // record is inactive isReadOnlyFromForm - if (columnName !== ACTIVE) { - // is active value of record - const isActiveRecord = store.getters.getValueOfField({ - parentUuid, - containerUuid, - columnName: ACTIVE - }) - if (!convertStringToBoolean(isActiveRecord)) { - return true - } - } - // Button to process document - if (columnName === DOCUMENT_ACTION) { - return false - } - - // is processed value of record - const isProcessedRecord = store.getters.getValueOfField({ - parentUuid, - containerUuid, - columnName: PROCESSED - }) - if (convertStringToBoolean(isProcessedRecord)) { + } else { + // button not invoke (browser/process/report/workflow) without record + if (field.displayType === BUTTON.id) { return true } + } - // is processing value of record - const isProcessingRecord = store.getters.getValueOfField({ + // validate parent record and current record + // record is inactive isReadOnlyFromForm + if (columnName !== ACTIVE) { + // is active value of record + const isActiveRecord = store.getters.getValueOfField({ parentUuid, containerUuid, - columnName: PROCESSING + columnName: ACTIVE }) - if (convertStringToBoolean(isProcessingRecord)) { - return true - } - } else { - // button not invoke (browser/process/report/workflow) without record - if (field.displayType === BUTTON.id) { + if (!convertStringToBoolean(isActiveRecord)) { return true } } + // Button to process document + if (columnName === DOCUMENT_ACTION) { + return false + } + + // is processed value of record + const isProcessedRecord = store.getters.getValueOfField({ + parentUuid, + containerUuid, + columnName: PROCESSED + }) + if (convertStringToBoolean(isProcessedRecord)) { + return true + } + + // is processing value of record + const isProcessingRecord = store.getters.getValueOfField({ + parentUuid, + containerUuid, + columnName: PROCESSING + }) + if (convertStringToBoolean(isProcessingRecord)) { + return true + } if (field.isAlwaysUpdateable) { return false