Skip to content

Commit

Permalink
fix: Overwrite parent values with empty child record. (adempiere#700)
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwinBetanc0urt committed Jan 9, 2023
1 parent fea8174 commit 7e2fa10
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 35 deletions.
11 changes: 11 additions & 0 deletions src/store/modules/ADempiere/dictionary/window/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

// 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'
Expand Down Expand Up @@ -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
Expand Down
71 changes: 36 additions & 35 deletions src/utils/ADempiere/dictionary/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,7 @@ export const containerManager = {
})
},

seekRecord: ({ row, parentUuid, containerUuid }) => {
seekRecord: ({ row = {}, parentUuid, containerUuid }) => {
if (isEmptyValue(row)) {
store.dispatch('setTabDefaultValues', {
parentUuid,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7e2fa10

Please sign in to comment.