From 9abc2c09e2b41471218a001cd0a5856f58cf4102 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 27 Oct 2021 15:14:03 +0200 Subject: [PATCH] IDEMPIERE-5018 Vendor changed to customer when edited using Quick Entry (#950) IDEMPIERE-3705 --- .../i8.2/oracle/202110271258_IDEMPIERE-5018.sql | 15 +++++++++++++++ .../postgresql/202110271258_IDEMPIERE-5018.sql | 12 ++++++++++++ .../model/CalloutBPartnerQuickEntry.java | 15 ++++++++++----- 3 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 migration/i8.2/oracle/202110271258_IDEMPIERE-5018.sql create mode 100644 migration/i8.2/postgresql/202110271258_IDEMPIERE-5018.sql diff --git a/migration/i8.2/oracle/202110271258_IDEMPIERE-5018.sql b/migration/i8.2/oracle/202110271258_IDEMPIERE-5018.sql new file mode 100644 index 0000000000..95dc71d0d8 --- /dev/null +++ b/migration/i8.2/oracle/202110271258_IDEMPIERE-5018.sql @@ -0,0 +1,15 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- IDEMPIERE-5018 Vendor changed to customer when edited using Quick Entry +-- Oct 27, 2021, 12:54:13 PM CEST +UPDATE AD_Field SET DisplayLogic='@_ParentIsSOTrx_@=N & @C_BPartner_ID@>0 | @_QUICK_ENTRY_MODE_@!Y', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, ReadOnlyLogic='@_ParentIsSOTrx_@=N & @IsVendor@=Y', IsToolbarButton=NULL,Updated=TO_DATE('2021-10-27 12:54:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=9623 +; + +-- Oct 27, 2021, 12:54:47 PM CEST +UPDATE AD_Field SET DisplayLogic='@_ParentIsSOTrx_@=Y & @C_BPartner_ID@>0 | @_QUICK_ENTRY_MODE_@!Y', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, ReadOnlyLogic='@_ParentIsSOTrx_@=Y & @IsCustomer@=Y', IsToolbarButton=NULL,Updated=TO_DATE('2021-10-27 12:54:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=9614 +; + +SELECT register_migration_script('202110271258_IDEMPIERE-5018.sql') FROM dual +; + diff --git a/migration/i8.2/postgresql/202110271258_IDEMPIERE-5018.sql b/migration/i8.2/postgresql/202110271258_IDEMPIERE-5018.sql new file mode 100644 index 0000000000..8b1a0bd1bc --- /dev/null +++ b/migration/i8.2/postgresql/202110271258_IDEMPIERE-5018.sql @@ -0,0 +1,12 @@ +-- IDEMPIERE-5018 Vendor changed to customer when edited using Quick Entry +-- Oct 27, 2021, 12:54:13 PM CEST +UPDATE AD_Field SET DisplayLogic='@_ParentIsSOTrx_@=N & @C_BPartner_ID@>0 | @_QUICK_ENTRY_MODE_@!Y', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, ReadOnlyLogic='@_ParentIsSOTrx_@=N & @IsVendor@=Y', IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-10-27 12:54:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=9623 +; + +-- Oct 27, 2021, 12:54:47 PM CEST +UPDATE AD_Field SET DisplayLogic='@_ParentIsSOTrx_@=Y & @C_BPartner_ID@>0 | @_QUICK_ENTRY_MODE_@!Y', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, ReadOnlyLogic='@_ParentIsSOTrx_@=Y & @IsCustomer@=Y', IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-10-27 12:54:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=9614 +; + +SELECT register_migration_script('202110271258_IDEMPIERE-5018.sql') FROM dual +; + diff --git a/org.adempiere.base.callout/src/org/adempiere/model/CalloutBPartnerQuickEntry.java b/org.adempiere.base.callout/src/org/adempiere/model/CalloutBPartnerQuickEntry.java index 61ba170096..da30ee834b 100644 --- a/org.adempiere.base.callout/src/org/adempiere/model/CalloutBPartnerQuickEntry.java +++ b/org.adempiere.base.callout/src/org/adempiere/model/CalloutBPartnerQuickEntry.java @@ -23,7 +23,7 @@ import org.compiere.model.MBPartner; import org.compiere.util.Env; import org.compiere.util.Util; -@Callout(tableName = MBPartner.Table_Name, columnName = "*") +@Callout(tableName = MBPartner.Table_Name, columnName = MBPartner.COLUMNNAME_C_BPartner_ID) public class CalloutBPartnerQuickEntry implements IColumnCallout { @Override @@ -31,13 +31,18 @@ public class CalloutBPartnerQuickEntry implements IColumnCallout { // this callout is just for quick entry window if ("Y".equals(Env.getContext(ctx, WindowNo, "_QUICK_ENTRY_MODE_"))) { int parent_windowNo = Integer.parseInt(Env.getContext(ctx, WindowNo, "_QUICK_ENTRY_CALLER_WINDOW_")); - + String docSOTrx = Env.getContext(ctx, parent_windowNo, "IsSOTrx", false); - + if (!Util.isEmpty(docSOTrx)) { boolean isSOTrx = "Y".equals(docSOTrx); - mTab.setValue(MBPartner.COLUMNNAME_IsCustomer, isSOTrx); - mTab.setValue(MBPartner.COLUMNNAME_IsVendor, !isSOTrx); + // set _ParentIsSOTrx_ used in DisplayLogic and ReadOnlyLogic of C_BPartner.IsCustomer and IsVendor + Env.setContext(ctx, WindowNo, "_ParentIsSOTrx_", isSOTrx); + Env.setContext(ctx, WindowNo, mTab.getTabNo(), "_ParentIsSOTrx_", isSOTrx); + if (value == null || ((Integer) value) == 0) { // new record + mTab.setValue(MBPartner.COLUMNNAME_IsCustomer, isSOTrx); + mTab.setValue(MBPartner.COLUMNNAME_IsVendor, !isSOTrx); + } } } return null;