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:
Carlos Ruiz 2023-10-22 11:33:19 +02:00 committed by GitHub
parent 860e35cb08
commit e83bb49935
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 5 deletions

View File

@ -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')
;

View File

@ -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')
;

View File

@ -21,7 +21,9 @@ import org.compiere.model.MPreference;
*
* @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 {
private static final long serialVersionUID = -3424015890197944847L;

View File

@ -18,6 +18,7 @@ import java.util.Properties;
import org.compiere.model.I_AD_Preference;
import org.compiere.model.MPreference;
import org.compiere.model.MUser;
import org.compiere.model.PO;
import org.compiere.model.Query;
import org.compiere.util.CLogger;
@ -114,13 +115,12 @@ public final class UserPreference implements Serializable {
if (!Util.isEmpty(value)) {
MPreference preference = query.setParameters(new Object[]{m_AD_User_ID, attribute}).firstOnly();
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.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 {