From b0555e027eb4b9dcba85beeeed7396e5ad0de511 Mon Sep 17 00:00:00 2001 From: EdwinBetanc0urt Date: Wed, 17 Mar 2021 00:04:21 -0400 Subject: [PATCH] fix: Is read only record with different client id. --- src/components/ADempiere/Field/index.vue | 28 ++++++++++++++----- .../ADempiere/Panel/mainPanelMixin.js | 20 +++++++++++-- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/src/components/ADempiere/Field/index.vue b/src/components/ADempiere/Field/index.vue index 8ba4ab2f076..faef7954587 100644 --- a/src/components/ADempiere/Field/index.vue +++ b/src/components/ADempiere/Field/index.vue @@ -207,6 +207,15 @@ export default { } return this.field.isMandatory || this.field.isMandatoryFromLogic }, + isPanelWindow() { + return this.field.panelType === 'window' + }, + preferenceClientId() { + if (this.isPanelWindow) { + return this.$store.getters.getPreferenceClientId + } + return undefined + }, /** * Idicate if field is read only * TODO: Create common method to evaluate isReadOnly @@ -228,7 +237,15 @@ export default { const isUpdateableAllFields = this.field.isReadOnly || this.field.isReadOnlyFromLogic - if (this.field.panelType === 'window') { + if (this.isPanelWindow) { + // TODO: Evaluate record uuid without route.action + // edit mode is diferent to create new + let isWithRecord = this.field.recordUuid !== 'create-new' + // evaluate context + if ((this.preferenceClientId !== this.metadataField.clientId) && isWithRecord) { + return true + } + if (isLogColumns) { return true } @@ -240,9 +257,6 @@ export default { return true } - // TODO: Evaluate record uuid without route.action - // edit mode is diferent to create new - let isWithRecord = this.field.recordUuid !== 'create-new' if (this.inTable) { isWithRecord = !this.isEmptyValue(this.field.recordUuid) } @@ -315,7 +329,7 @@ export default { return newSizes } - if (this.field.panelType === 'window') { + if (this.isPanelWindow) { // TODO: Add FieldYesNo and name.length > 12 || 14 if (this.field.componentPath === 'FieldTextLong') { return sizeField @@ -353,7 +367,7 @@ export default { return this.$store.getters.getOrders }, isDocuemntStatus() { - if (this.field.panelType === 'window' && !this.isAdvancedQuery) { + if (this.isPanelWindow && !this.isAdvancedQuery) { if (this.field.columnName === 'DocStatus' && !this.isEmptyValue(this.processOrderUuid)) { return true } @@ -361,7 +375,7 @@ export default { return false }, isContextInfo() { - if (this.field.panelType !== 'window') { + if (!this.isPanelWindow) { return false } return Boolean(this.field.contextInfo && this.field.contextInfo.isActive) || diff --git a/src/components/ADempiere/Panel/mainPanelMixin.js b/src/components/ADempiere/Panel/mainPanelMixin.js index 44aa9166a90..c3257044407 100644 --- a/src/components/ADempiere/Panel/mainPanelMixin.js +++ b/src/components/ADempiere/Panel/mainPanelMixin.js @@ -80,22 +80,38 @@ export default { recordUuid: this.uuidRecord, optionCRUD: this.optionCRUD, isShowedRecordNavigation: this.isShowedRecordNavigation, + clientId: this.getContainerClientId, isProcessingContext: this.getContainerProcessing, isProcessedContext: this.getContainerProcessed } }, getContainerProcessing() { - if (this.panelType === 'window' && !this.isAdvancedQuery) { + if (this.isPanelWindow && !this.isAdvancedQuery) { return this.$store.getters.getContainerProcessing(this.parentUuid) } return false }, getContainerProcessed() { - if (this.panelType === 'window' && !this.isAdvancedQuery) { + if (this.isPanelWindow && !this.isAdvancedQuery) { return this.$store.getters.getContainerProcessed(this.parentUuid) } return false }, + getContainerClientId() { + let clientId = null + if (this.isPanelWindow && !this.isAdvancedQuery) { + // client id from current record + clientId = this.$store.getters.getValueOfField({ + parentUuid: this.parentUuid, + containerUuid: this.containerUuid, + columnName: 'AD_Client_ID' + }) + if (!this.isEmptyValue(clientId)) { + return parseInt(clientId, 10) + } + } + return clientId + }, getterPanel() { return this.$store.getters.getPanel(this.containerUuid) },