fixed BUG-42614: Discount Organization can add rows to incorrect header
authorAsier Lostalé <asier.lostale@openbravo.com>
Wed, 04 Dec 2019 16:04:05 +0100
changeset 36897 7a648e0c57d3
parent 36896 005eb39e9993
child 36898 eb0ebb3512ec
fixed BUG 42614: Discount Organization can add rows to incorrect header

If parent Discount header is inactive, when adding rows to Organization tab,
they were added to the first active Discount instead of to the proper parent.

This was caused because M_Offer_Organization.AD_Org_ID column is used to store
the organization the discount is applicable for instead of just row's organization.

AD_Org columns have an special treatment, when they are changed, a
virtual callout is executed to refresh all combos. Mandatory combos
take the first available value in case their default is not available,
which is the case if it is inactive. As M_Offer_ID column had a
TableDir reference, it was treated as a combo, if its parent was
inactive, first active record was taken in place.

A proper solution would be not to use AD_Org_ID column to store the
actual value but to use instead a new column. This change would be
much more aggressive being an API change that would require of
updating existing data. That's why, the problem has been fixed by
replaciing TableDir reference with Search without selector, in this
way FK reltionship is preserved, but only the value is used in UI
instead of creating a combo.
src-db/database/sourcedata/AD_COLUMN.xml
--- a/src-db/database/sourcedata/AD_COLUMN.xml	Wed Dec 18 13:15:18 2019 +0100
+++ b/src-db/database/sourcedata/AD_COLUMN.xml	Wed Dec 04 16:04:05 2019 +0100
@@ -357864,7 +357864,7 @@
 <!--B059926E49A94F68963E064C270F5C33-->  <HELP><![CDATA[Promotion or Discount applied to a particular line (product) automatically by the system.]]></HELP>
 <!--B059926E49A94F68963E064C270F5C33-->  <COLUMNNAME><![CDATA[M_Offer_ID]]></COLUMNNAME>
 <!--B059926E49A94F68963E064C270F5C33-->  <AD_TABLE_ID><![CDATA[CBF045D2539A4249B091CCE4B1F5EEDB]]></AD_TABLE_ID>
-<!--B059926E49A94F68963E064C270F5C33-->  <AD_REFERENCE_ID><![CDATA[19]]></AD_REFERENCE_ID>
+<!--B059926E49A94F68963E064C270F5C33-->  <AD_REFERENCE_ID><![CDATA[30]]></AD_REFERENCE_ID>
 <!--B059926E49A94F68963E064C270F5C33-->  <FIELDLENGTH><![CDATA[32]]></FIELDLENGTH>
 <!--B059926E49A94F68963E064C270F5C33-->  <ISKEY><![CDATA[N]]></ISKEY>
 <!--B059926E49A94F68963E064C270F5C33-->  <ISPARENT><![CDATA[Y]]></ISPARENT>