IDEMPIERE-337 zkwebui - Improve Info Product window - enforce only one current vendor per product rule
This commit is contained in:
parent
901d215f3a
commit
838af05634
|
|
@ -0,0 +1,18 @@
|
||||||
|
SET SQLBLANKLINES ON
|
||||||
|
SET DEFINE OFF
|
||||||
|
|
||||||
|
-- IDEMPIERE-337 zkwebui - Improve Info Product window
|
||||||
|
UPDATE M_Product_PO po
|
||||||
|
SET IsCurrentVendor='N'
|
||||||
|
WHERE po.IsActive='Y'
|
||||||
|
AND po.IsCurrentVendor='Y'
|
||||||
|
AND po.C_BPartner_ID NOT IN (
|
||||||
|
SELECT MAX(ppo.C_BPartner_ID)
|
||||||
|
FROM M_Product_PO ppo
|
||||||
|
WHERE ppo.IsActive='Y'
|
||||||
|
AND ppo.IsCurrentVendor='Y'
|
||||||
|
AND ppo.M_Product_ID = po.M_Product_ID
|
||||||
|
);
|
||||||
|
|
||||||
|
SELECT register_migration_script('201312051535_IDEMPIERE-337') FROM dual
|
||||||
|
;
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
-- IDEMPIERE-337 zkwebui - Improve Info Product window
|
||||||
|
UPDATE M_Product_PO po
|
||||||
|
SET IsCurrentVendor='N'
|
||||||
|
WHERE po.IsActive='Y'
|
||||||
|
AND po.IsCurrentVendor='Y'
|
||||||
|
AND po.C_BPartner_ID NOT IN (
|
||||||
|
SELECT MAX(ppo.C_BPartner_ID)
|
||||||
|
FROM M_Product_PO ppo
|
||||||
|
WHERE ppo.IsActive='Y'
|
||||||
|
AND ppo.IsCurrentVendor='Y'
|
||||||
|
AND ppo.M_Product_ID = po.M_Product_ID
|
||||||
|
);
|
||||||
|
|
||||||
|
SELECT register_migration_script('201312051535_IDEMPIERE-337') FROM dual
|
||||||
|
;
|
||||||
|
|
@ -19,6 +19,9 @@ package org.compiere.model;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.compiere.util.DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Product PO Model
|
* Product PO Model
|
||||||
|
|
@ -31,8 +34,7 @@ public class MProductPO extends X_M_Product_PO
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -747761340543484440L;
|
private static final long serialVersionUID = -1883198806060209516L;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get current PO of Product
|
* Get current PO of Product
|
||||||
|
|
@ -84,4 +86,31 @@ public class MProductPO extends X_M_Product_PO
|
||||||
super(ctx, rs, trxName);
|
super(ctx, rs, trxName);
|
||||||
} // MProductPO
|
} // MProductPO
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Before Save
|
||||||
|
* @param newRecord new
|
||||||
|
* @return true
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected boolean beforeSave(boolean newRecord)
|
||||||
|
{
|
||||||
|
if ((newRecord && isActive() && isCurrentVendor()) ||
|
||||||
|
(!newRecord &&
|
||||||
|
(
|
||||||
|
(is_ValueChanged("IsActive") && isActive()) // now active
|
||||||
|
|| (is_ValueChanged("IsCurrentVendor") && isCurrentVendor()) // now current vendor
|
||||||
|
|| is_ValueChanged("C_BPartner_ID")
|
||||||
|
|| is_ValueChanged("M_Product_ID")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
String sql = "UPDATE M_Product_PO SET IsCurrentVendor='N' WHERE IsActive='Y' AND IsCurrentVendor='Y' AND C_BPartner_ID!=? AND M_Product_ID=?";
|
||||||
|
int no = DB.executeUpdate(sql, new Object[] {getC_BPartner_ID(), getM_Product_ID()}, false, get_TrxName());
|
||||||
|
if (log.isLoggable(Level.FINEST)) log.finest("Updated M_Product_PO.IsCurrentVendor #" + no);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
} // MProductPO
|
} // MProductPO
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue