diff --git a/src/api/ADempiere/userInterface/entities.ts b/src/api/ADempiere/userInterface/entities.ts
index 00da09f911..3b79f1a3df 100644
--- a/src/api/ADempiere/userInterface/entities.ts
+++ b/src/api/ADempiere/userInterface/entities.ts
@@ -79,12 +79,13 @@ export function createEntity({
* Update Tab Entity
* @param {number} tabId
* @param {object} recordAttributes
+ * @param {object} keyColumns
*/
export function updateEntity({
reccordId,
tabId,
recordAttributes,
- keyColumnsList
+ keyColumns
}) {
return request({
url: `/user-interface/entities/${tabId}/${reccordId}`,
@@ -92,7 +93,7 @@ export function updateEntity({
data: {
attributes: {
...recordAttributes,
- ...keyColumnsList
+ ...keyColumns
}
}
})
diff --git a/src/components/ADempiere/FieldDefinition/FieldAccountingCombination/Fields/SelectAccounting.vue b/src/components/ADempiere/FieldDefinition/FieldAccountingCombination/Fields/SelectAccounting.vue
index daed5c2431..d36338e162 100644
--- a/src/components/ADempiere/FieldDefinition/FieldAccountingCombination/Fields/SelectAccounting.vue
+++ b/src/components/ADempiere/FieldDefinition/FieldAccountingCombination/Fields/SelectAccounting.vue
@@ -126,7 +126,9 @@ export default defineComponent({
*/
function showList(isShow) {
- if (isShow && isEmptyValue(optionsList.value)) filterSearch(displayValue.value)
+ if (isShow && isEmptyValue(optionsList.value)) {
+ filterSearch(displayValue.value)
+ }
}
/**
@@ -157,7 +159,9 @@ export default defineComponent({
})
.then(response => {
const { records } = response
- if (isEmptyValue(records)) return
+ if (isEmptyValue(records)) {
+ return
+ }
optionsList.value = records.map(list => {
return {
...list,
@@ -198,7 +202,9 @@ export default defineComponent({
})
.then(response => {
const { records } = response
- if (isEmptyValue(records)) return
+ if (isEmptyValue(records)) {
+ return
+ }
optionsList.value = records.map(list => {
return {
...list,
diff --git a/src/components/ADempiere/FieldDefinition/FieldAccountingCombination/mixinAccountingCombination.js b/src/components/ADempiere/FieldDefinition/FieldAccountingCombination/mixinAccountingCombination.js
index b8b4ab8cf7..4b915344cd 100644
--- a/src/components/ADempiere/FieldDefinition/FieldAccountingCombination/mixinAccountingCombination.js
+++ b/src/components/ADempiere/FieldDefinition/FieldAccountingCombination/mixinAccountingCombination.js
@@ -28,6 +28,11 @@ import {
DISPLAY_COLUMN_PREFIX
} from '@/utils/ADempiere/dictionaryUtils'
+// Utils and Helper Methods
+import {
+ generateDisplayedValue
+} from '@/utils/ADempiere/dictionary/field/accoutingCombination.js'
+
export default {
name: 'mixinAccountingCombination',
@@ -102,12 +107,7 @@ export default {
* Get custom displayed value
* @returns {string}
*/
- generateDisplayedValue(recordRow) {
- // generate with standard columns
- const { Combination } = recordRow
-
- return Combination
- },
+ generateDisplayedValue,
/**
* @overwrite
* Set custom row on fields values
@@ -115,12 +115,13 @@ export default {
*/
setValues(rowData) {
const { C_ValidCombination_ID: value, UUID: uuid } = rowData
- const displayedValue = this.generateDisplayedValue(rowData)
+ const displayValue = this.generateDisplayedValue(rowData)
// set ID value
this.value = value
// set display column (name) value
- this.displayedValue = displayedValue
+ this.displayedValue = displayValue
+
// set UUID value
this.uuidValue = uuid
diff --git a/src/components/ADempiere/FieldDefinition/FieldAccountingCombination/tableQueryCriteria2.vue b/src/components/ADempiere/FieldDefinition/FieldAccountingCombination/tableQueryCriteria2.vue
index a6d39b8938..18352d59f1 100644
--- a/src/components/ADempiere/FieldDefinition/FieldAccountingCombination/tableQueryCriteria2.vue
+++ b/src/components/ADempiere/FieldDefinition/FieldAccountingCombination/tableQueryCriteria2.vue
@@ -171,6 +171,7 @@ import {
ref
} from '@vue/composition-api'
+import language from '@/lang'
import store from '@/store'
// Api
@@ -179,8 +180,14 @@ import {
} from '@/api/ADempiere/fields/generalGedger'
// Constants
+import {
+ DISPLAY_COLUMN_PREFIX,
+ UNIVERSALLY_UNIQUE_IDENTIFIER_COLUMN_SUFFIX
+} from '@/utils/ADempiere/dictionaryUtils'
import { TEXT } from '@/utils/ADempiere/references'
-import { ACCOUTING_COMBINATIONS_LIST_FORM, COLUMN_NAME } from '@/utils/ADempiere/dictionary/field/accoutingCombination.js'
+import {
+ ACCOUTING_COMBINATIONS_LIST_FORM, COLUMN_NAME
+} from '@/utils/ADempiere/dictionary/field/accoutingCombination.js'
// Components and Mixins
import CellDisplayInfo from '@/components/ADempiere/DataTable/Components/CellDisplayInfo.vue'
@@ -192,9 +199,11 @@ import { ORGANIZATION } from '@/utils/ADempiere/constants/systemColumns'
// Utils and Helper Methods
import { isEmptyValue, isSameValues } from '@/utils/ADempiere/valueUtils'
+import {
+ generateDisplayedValue
+} from '@/utils/ADempiere/dictionary/field/accoutingCombination.js'
import { containerManager as containerManagerForm } from '@/utils/ADempiere/dictionary/form'
import { showMessage } from '@/utils/ADempiere/notification'
-import language from '@/lang'
export default defineComponent({
name: 'TableQueryCriteria',
@@ -245,7 +254,9 @@ export default defineComponent({
// Computed
const title = computed(() => {
let title = props.metadata.panelName
- if (!isEmptyValue(props.metadata.panelName) && !isSameValues(props.metadata.panelName, props.metadata.name)) title += ` (${props.metadata.name})`
+ if (!isEmptyValue(props.metadata.panelName) && !isSameValues(props.metadata.panelName, props.metadata.name)) {
+ title += ` (${props.metadata.name})`
+ }
return title
})
@@ -275,7 +286,9 @@ export default defineComponent({
})
const organizationId = computed(() => {
- if (isEmptyValue(fieldsListElements.value)) return setValuesCombinations.value['AD_Org_ID']
+ if (isEmptyValue(fieldsListElements.value)) {
+ return setValuesCombinations.value[ORGANIZATION]
+ }
return store.getters.getFieldsValue(ORGANIZATION)
})
@@ -290,7 +303,9 @@ export default defineComponent({
})
const filtersAccount = computed(() => {
- if (isEmptyValue(store.getters.getFiltersAccount)) return null
+ if (isEmptyValue(store.getters.getFiltersAccount)) {
+ return null
+ }
return JSON.stringify(store.getters.getFiltersAccount)
})
@@ -413,11 +428,12 @@ export default defineComponent({
}
function saveAccoutingCombination() {
+ const currentValue = store.getters.getValueOfField({
+ containerUuid: props.metadata.containerUuid,
+ columnName: props.metadata.columnName
+ })
store.dispatch('saveAccountCombinations', {
- id: store.getters.getValueOfField({
- containerUuid: props.metadata.containerUuid,
- columnName: props.metadata.columnName
- }),
+ id: currentValue,
organizationId: store.getters.getFieldsValue(ORGANIZATION),
accountId: store.getters.getFieldsValue('Account_ID'),
parentUuid: props.metadata.parentUuid,
@@ -507,21 +523,66 @@ export default defineComponent({
}
function changeRecord() {
- // if (!isEmptyValue(currentRow.value)) {
- // store.dispatch('notifyFieldChange', {
- // containerUuid: this.metadata.containerUuid,
- // containerManager: this.containerManager,
- // field: this.metadata,
- // columnName: this.metadata.column_name,
- // newValue: value
- // })
- // }
+ const {
+ parentUuid, containerUuid,
+ columnName, elementName, isSameColumnElement
+ } = props.metadata
+
+ const recordRow = currentRow.value
+ const {
+ UUID: uuid,
+ [COLUMN_NAME]: id
+ } = recordRow
+
+ const displayValue = generateDisplayedValue(recordRow)
+ // console.log(displayValue)
+
+ store.commit('updateValueOfField', {
+ parentUuid,
+ containerUuid,
+ columnName,
+ value: id
+ })
+ // set display column (name) value
+ store.commit('updateValueOfField', {
+ parentUuid,
+ containerUuid,
+ // DisplayColumn_'ColumnName'
+ columnName: DISPLAY_COLUMN_PREFIX + columnName,
+ value: displayValue
+ })
+ // set UUID value
+ store.commit('updateValueOfField', {
+ parentUuid,
+ containerUuid,
+ columnName: columnName + UNIVERSALLY_UNIQUE_IDENTIFIER_COLUMN_SUFFIX,
+ value: uuid
+ })
+
+ // update element column name (smart browse)
+ if (!isSameColumnElement) {
+ store.commit('updateValueOfField', {
+ parentUuid,
+ containerUuid,
+ columnName: elementName,
+ value: id
+ })
+ // set display column (name) value
+ store.commit('updateValueOfField', {
+ parentUuid,
+ containerUuid,
+ // DisplayColumn_'ColumnName'
+ columnName: DISPLAY_COLUMN_PREFIX + elementName,
+ value: displayValue
+ })
+ }
+
store.dispatch('notifyFieldChange', {
- containerUuid: props.metadata.containerUuid,
+ containerUuid: containerUuid,
containerManager: props.containerManager,
field: props.metadata,
- columnName: props.metadata.columnName,
- newValue: currentRow.value[tableNameAccounting.value + '_ID']
+ columnName: columnName,
+ newValue: id
})
closeList()
}
@@ -544,11 +605,12 @@ export default defineComponent({
function loadCombinations() {
isLoadingPanel.value = true
+ const currentValue = store.getters.getValueOfField({
+ containerUuid: props.metadata.containerUuid,
+ columnName: props.metadata.columnName
+ })
getAccountingCombination({
- id: store.getters.getValueOfField({
- containerUuid: props.metadata.containerUuid,
- columnName: props.metadata.columnName
- })
+ id: currentValue
})
.then(response => {
const { values, table_name } = response
@@ -579,18 +641,24 @@ export default defineComponent({
}
function valuesCombinations(field) {
- if (isEmptyValue(setValuesCombinations.value)) return ''
+ if (isEmptyValue(setValuesCombinations.value)) {
+ return ''
+ }
return setValuesCombinations.value[field.columnName]
// return setValuesCombinations.value['DisplayColumn_' + field.columnName]
}
function setPageNumber(pageNumber) {
- if (isEmptyValue(pageNumber)) return
+ if (isEmptyValue(pageNumber)) {
+ return
+ }
searchRecordsList(pageNumber)
}
watch(isLoadingTable, (newValue, oldValue) => {
- if (newValue && newValue !== oldValue) searchRecordsList()
+ if (newValue && newValue !== oldValue) {
+ searchRecordsList()
+ }
})
getAccoutingElements()
diff --git a/src/store/modules/ADempiere/persistence.js b/src/store/modules/ADempiere/persistence.js
index 4eed51164b..2d662d9a37 100644
--- a/src/store/modules/ADempiere/persistence.js
+++ b/src/store/modules/ADempiere/persistence.js
@@ -43,6 +43,7 @@ import { getContextAttributes } from '@/utils/ADempiere/contextUtils/contextAttr
import {
isDateField, isDecimalField, isSupportLookup
} from '@/utils/ADempiere/references'
+import { getTableKeyValues } from '@/utils/ADempiere/recordUtil'
const persistence = {
state: {
@@ -307,11 +308,21 @@ const persistence = {
recordAttributes[columnName] = currentValue
})
+ // table multi-keys
+ let keyColumns = {}
+ if (key_columns.length > 1) {
+ keyColumns = getTableKeyValues({
+ parentUuid,
+ containerUuid,
+ keyColumns: key_columns
+ })
+ }
return updateEntity({
reccordId,
tabId,
recordUuid,
- recordAttributes
+ recordAttributes,
+ keyColumns
})
.then(response => {
// TODO: Get list record log
diff --git a/src/utils/ADempiere/dictionary/field/accoutingCombination.js b/src/utils/ADempiere/dictionary/field/accoutingCombination.js
index 4928b29ae8..11769a97b4 100644
--- a/src/utils/ADempiere/dictionary/field/accoutingCombination.js
+++ b/src/utils/ADempiere/dictionary/field/accoutingCombination.js
@@ -1,6 +1,6 @@
/**
* ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution
- * Copyright (C) 2017-Present E.R.P. Consultores y Asociados, C.A. www.erpya.com
+ * Copyright (C) 2018-Present E.R.P. Consultores y Asociados, C.A. www.erpya.com
* Contributor(s): Edwin Betancourt EdwinBetanc0urt@outlook.com https://github.com/EdwinBetanc0urt
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -16,8 +16,32 @@
* along with this program. If not, see .
*/
+// Utils and Helper Methods
+import { isEmptyValue } from '@/utils/ADempiere/valueUtils'
+
export const TABLE_NAME = 'C_ValidCombination'
export const COLUMN_NAME = 'C_ValidCombination_ID'
-export const ACCOUTING_COMBINATIONS_LIST_FORM = 'Accouting-Combination-List'
+export const ACCOUTING_COMBINATIONS_LIST_FORM = 'Accouting-Combinations-List'
+
+/**
+ * Generate displayed value from values
+ * @param {Object} recordRow
+ * @returns {String}
+ */
+export function generateDisplayedValue(recordRow) {
+ const {
+ DisplayColumn_C_ValidCombination_ID: display_value
+ } = recordRow
+ let displayValue = display_value
+ if (!isEmptyValue(displayValue)) {
+ return displayValue
+ }
+
+ // generate with standard columns
+ const { Combination } = recordRow
+ displayValue = Combination
+
+ return displayValue
+}
diff --git a/src/utils/ADempiere/recordUtil.js b/src/utils/ADempiere/recordUtil.js
index 6036348933..3b68f8a92b 100644
--- a/src/utils/ADempiere/recordUtil.js
+++ b/src/utils/ADempiere/recordUtil.js
@@ -16,6 +16,8 @@
* along with this program. If not, see .
*/
+import store from '@/store'
+
export const UUID_PATTERN = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/
/**
@@ -27,3 +29,29 @@ export function getUuidv4() {
(+c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +c / 4).toString(16)
)
}
+
+/**
+ * Get a List with the values of the key Columns of the Tab
+ * @param {string} parentUuid
+ * @param {string} containerUuid
+ * @param {Array[String]} keyColumns
+ * return {object} keyColumnsList
+ */
+export function getTableKeyValues({
+ parentUuid,
+ containerUuid,
+ keyColumns = []
+}) {
+ const keyColumnValues = {}
+ if (keyColumns) {
+ keyColumns.forEach(keyColumnName => {
+ const value = store.getters.getValueOfField({
+ parentUuid,
+ containerUuid,
+ columnName: keyColumnName
+ })
+ keyColumnValues[keyColumnName] = value
+ })
+ }
+ return keyColumnValues
+}
diff --git a/src/utils/ADempiere/valueUtils.js b/src/utils/ADempiere/valueUtils.js
index 23910bbdad..69ba28a585 100644
--- a/src/utils/ADempiere/valueUtils.js
+++ b/src/utils/ADempiere/valueUtils.js
@@ -956,32 +956,6 @@ export function getValidInteger(value, is_identifier = false) {
return 0
}
-/**
- * Get a List with the values of the key Columns of the Tab
- * @param {string} parentUuid
- * @param {string} containerUuid
- * @param {Array[String]} keyColumns
- * return {object} keyColumnsList
- */
-export function getListKeyColumnsTab({
- parentUuid,
- containerUuid,
- keyColumns
-}) {
- const keyColumnsList = {}
- if (keyColumns) {
- keyColumns.forEach(elementColumnName => {
- const value = store.getters.getValueOfField({
- parentUuid,
- containerUuid,
- columnName: elementColumnName
- })
- keyColumnsList[elementColumnName] = value
- })
- }
- return keyColumnsList
-}
-
/**
* Assign record id to path
* @param {string} tab