IDEMPIERE-5888 Login Preferences are created on System tenant (#2067)
* IDEMPIERE-5888 Login Preferences are created on System tenant * - migration script to fix the current data
This commit is contained in:
parent
860e35cb08
commit
e83bb49935
|
@ -0,0 +1,11 @@
|
||||||
|
-- IDEMPIERE-5888 Login Preferences are created on System tenant
|
||||||
|
SELECT register_migration_script('202310191513_IDEMPIERE-5888.sql') FROM dual;
|
||||||
|
|
||||||
|
-- 19/10/2023, 3:13:51 p. m. GMT+02:00
|
||||||
|
UPDATE AD_Preference
|
||||||
|
SET AD_Client_ID=(SELECT AD_Client_ID FROM AD_User WHERE AD_User_ID=AD_Preference.AD_User_ID),
|
||||||
|
AD_Org_ID=0
|
||||||
|
WHERE AD_Client_ID!=(SELECT AD_Client_ID FROM AD_User WHERE AD_User_ID=AD_Preference.AD_User_ID)
|
||||||
|
AND Attribute IN ('Language','Role','Client','Organization','Warehouse')
|
||||||
|
;
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
-- IDEMPIERE-5888 Login Preferences are created on System tenant
|
||||||
|
SELECT register_migration_script('202310191513_IDEMPIERE-5888.sql') FROM dual;
|
||||||
|
|
||||||
|
-- 19/10/2023, 3:13:51 p. m. GMT+02:00
|
||||||
|
UPDATE AD_Preference
|
||||||
|
SET AD_Client_ID=(SELECT AD_Client_ID FROM AD_User WHERE AD_User_ID=AD_Preference.AD_User_ID),
|
||||||
|
AD_Org_ID=0
|
||||||
|
WHERE AD_Client_ID!=(SELECT AD_Client_ID FROM AD_User WHERE AD_User_ID=AD_Preference.AD_User_ID)
|
||||||
|
AND Attribute IN ('Language','Role','Client','Organization','Warehouse')
|
||||||
|
;
|
||||||
|
|
|
@ -21,7 +21,9 @@ import org.compiere.model.MPreference;
|
||||||
*
|
*
|
||||||
* @author hengsin
|
* @author hengsin
|
||||||
*
|
*
|
||||||
|
* @deprecated - is not required anymore, for login preferences the client is being set now as the user client
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public class MUserPreference extends MPreference {
|
public class MUserPreference extends MPreference {
|
||||||
|
|
||||||
private static final long serialVersionUID = -3424015890197944847L;
|
private static final long serialVersionUID = -3424015890197944847L;
|
||||||
|
|
|
@ -18,6 +18,7 @@ import java.util.Properties;
|
||||||
|
|
||||||
import org.compiere.model.I_AD_Preference;
|
import org.compiere.model.I_AD_Preference;
|
||||||
import org.compiere.model.MPreference;
|
import org.compiere.model.MPreference;
|
||||||
|
import org.compiere.model.MUser;
|
||||||
import org.compiere.model.PO;
|
import org.compiere.model.PO;
|
||||||
import org.compiere.model.Query;
|
import org.compiere.model.Query;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
|
@ -114,13 +115,12 @@ public final class UserPreference implements Serializable {
|
||||||
if (!Util.isEmpty(value)) {
|
if (!Util.isEmpty(value)) {
|
||||||
MPreference preference = query.setParameters(new Object[]{m_AD_User_ID, attribute}).firstOnly();
|
MPreference preference = query.setParameters(new Object[]{m_AD_User_ID, attribute}).firstOnly();
|
||||||
if (preference == null) {
|
if (preference == null) {
|
||||||
preference = new MUserPreference(Env.getCtx(), 0, null);
|
preference = new MPreference(Env.getCtx(), 0, null);
|
||||||
|
MUser user = MUser.get(m_AD_User_ID);
|
||||||
|
preference.set_ValueNoCheck("AD_Client_ID", user.getAD_Client_ID());
|
||||||
|
preference.setAD_Org_ID(0);
|
||||||
preference.setAD_User_ID(m_AD_User_ID);
|
preference.setAD_User_ID(m_AD_User_ID);
|
||||||
preference.setAttribute(attribute);
|
preference.setAttribute(attribute);
|
||||||
} else {
|
|
||||||
if (preference.getAD_Client_ID() > 0 || preference.getAD_Org_ID() > 0) {
|
|
||||||
preference = new MUserPreference(Env.getCtx(), preference.getAD_Preference_ID(), null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue