details: https://code.openbravo.com/erp/devel/pi/rev/e3220d26e44f changeset: 28250:e3220d26e44f user: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com> date: Mon Jan 11 17:23:56 2016 +0100 summary: Fixes issue 31835: Not possible to change product to stocked
Stocked flag in Product window will not be updatable in case product is present in any order, invoice or warehouse document. details: https://code.openbravo.com/erp/devel/pi/rev/8d9510cd867e changeset: 28251:8d9510cd867e user: Víctor Martínez Romanos <victor.martinez <at> openbravo.com> date: Wed Jan 13 15:31:26 2016 +0100 summary: Related to issue 31835: code review improvements The old messages have been reverted because it could be used by external modules, so it could be considered as a functional API Change. Create a new message instead and improve it to be more descriptive. Modified pl/sql comment to reflect the new behavior and to avoid confusions in the future diffstat: src-db/database/model/triggers/M_PRODUCT_TRG.xml | 29 +++++++++-------------- src-db/database/sourcedata/AD_MESSAGE.xml | 12 +++++++++ 2 files changed, 24 insertions(+), 17 deletions(-) diffs (86 lines): diff -r afa165be3e59 -r 8d9510cd867e src-db/database/model/triggers/M_PRODUCT_TRG.xml --- a/src-db/database/model/triggers/M_PRODUCT_TRG.xml Wed Jan 13 15:33:23 2016 +0100 +++ b/src-db/database/model/triggers/M_PRODUCT_TRG.xml Wed Jan 13 15:31:26 2016 +0100 @@ -17,7 +17,7 @@ * parts created by ComPiere are Copyright (C) ComPiere, Inc.; * All Rights Reserved. * Contributor(s): Openbravo SLU - * Contributions are Copyright (C) 2001-2015 Openbravo, S.L.U. + * Contributions are Copyright (C) 2001-2016 Openbravo, S.L.U. * * Specifically, this derivative work is based upon the following Compiere * file and version. @@ -62,23 +62,21 @@ UPDATE M_PRODUCT_ACCT SET AD_ORG_ID = :new.AD_ORG_ID WHERE M_PRODUCT_ID = :new.M_PRODUCT_ID; - -- Do not allow to set the product as stocked if it appears in - -- processed documents which generate inventory transactions - IF (:old.isStocked = 'N' AND :new.isStocked = 'Y') THEN + -- Do not allow to change the product stocked flag if it appears in + -- any core's document (processed or not) + IF (:old.isStocked <> :new.isStocked) THEN SELECT count(*) INTO v_Count FROM dual - WHERE EXISTS ( SELECT 1 FROM M_Inventory iv JOIN M_InventoryLine ivl ON iv.m_inventory_id = ivl.m_inventory_id - WHERE ivl.m_product_id = :new.m_product_id AND iv.processed = 'Y' ) - OR EXISTS ( SELECT 1 FROM M_Movement mv JOIN M_MovementLine mvl ON mv.m_movement_id = mvl.m_movement_id - WHERE mvl.m_product_id = :new.m_product_id AND mv.processed = 'Y' ) - OR EXISTS ( SELECT 1 FROM M_Inout io JOIN M_InoutLine iol ON io.m_inout_id = iol.m_inout_id - WHERE iol.m_product_id = :new.m_product_id AND io.docstatus = 'CO' ) - OR EXISTS ( SELECT 1 FROM M_Production pr JOIN M_ProductionPlan pp ON pr.m_production_id = pp.m_production_id - JOIN M_ProductionLine prl ON pp.m_productionplan_id = prl.m_productionplan_id - WHERE prl.m_product_id = :new.m_product_id AND pr.processed = 'Y' ); + WHERE EXISTS ( SELECT 1 FROM C_OrderLine WHERE m_product_id = :new.m_product_id ) + OR EXISTS ( SELECT 1 FROM C_InvoiceLine WHERE m_product_id = :new.m_product_id ) + OR EXISTS ( SELECT 1 FROM M_InventoryLine WHERE m_product_id = :new.m_product_id ) + OR EXISTS ( SELECT 1 FROM M_MovementLine WHERE m_product_id = :new.m_product_id ) + OR EXISTS ( SELECT 1 FROM M_InoutLine WHERE m_product_id = :new.m_product_id ) + OR EXISTS ( SELECT 1 FROM M_ProductionLine WHERE m_product_id = :new.m_product_id ) + OR EXISTS ( SELECT 1 FROM M_Internal_ConsumptionLine WHERE m_product_id = :new.m_product_id ); IF (v_count > 0) THEN - RAISE_APPLICATION_ERROR(-20000, '@NonStockedProductWithTransactions@'); + RAISE_APPLICATION_ERROR(-20000, '@StockedFlagWithDocuments@'); END IF; END IF; @@ -87,7 +85,6 @@ IF ((:new.IsActive='N' AND :old.IsActive='Y') OR (COALESCE(:new.m_attributeset_id,'null') <> COALESCE(:old.m_attributeset_id,'null')) OR (COALESCE(:new.c_uom_id,'null') <> COALESCE(:old.c_uom_id,'null')) - OR (:old.isStocked='Y' AND :new.isStocked='N') OR (:old.Production <> :new.Production)) THEN SELECT COALESCE(SUM(QtyOnHand)+SUM(QtyReserved)*.111+SUM(QtyOrdered)*999, 0) , COALESCE(sum(QtyOnHand),0), COALESCE(SUM(QtyReserved),0) , COALESCE(SUM(QtyOrdered),0) @@ -105,8 +102,6 @@ RAISE_APPLICATION_ERROR(-20000, '@20633@'); ELSIF (COALESCE(:new.c_uom_id,'null') <> COALESCE(:old.c_uom_id,'null')) THEN RAISE_APPLICATION_ERROR(-20000, '@20634@'); - ELSIF (:old.isStocked = 'Y' AND :new.isStocked = 'N') THEN - RAISE_APPLICATION_ERROR(-20000, '@StockedProductWithMovements@'); ELSIF (:old.Production <> :new.Production) THEN RAISE_APPLICATION_ERROR(-20000, '@ManufacturingFlagWithStock@'); ELSE diff -r afa165be3e59 -r 8d9510cd867e src-db/database/sourcedata/AD_MESSAGE.xml --- a/src-db/database/sourcedata/AD_MESSAGE.xml Wed Jan 13 15:33:23 2016 +0100 +++ b/src-db/database/sourcedata/AD_MESSAGE.xml Wed Jan 13 15:31:26 2016 +0100 @@ -24076,6 +24076,18 @@ <!--B6CDB7D04FD249579A48D26C0ED48F45--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> <!--B6CDB7D04FD249579A48D26C0ED48F45--></AD_MESSAGE> +<!--B6FF3853FDD949709EA0742E2443F1C3--><AD_MESSAGE> +<!--B6FF3853FDD949709EA0742E2443F1C3--> <AD_MESSAGE_ID><![CDATA[B6FF3853FDD949709EA0742E2443F1C3]]></AD_MESSAGE_ID> +<!--B6FF3853FDD949709EA0742E2443F1C3--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> +<!--B6FF3853FDD949709EA0742E2443F1C3--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> +<!--B6FF3853FDD949709EA0742E2443F1C3--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> +<!--B6FF3853FDD949709EA0742E2443F1C3--> <VALUE><![CDATA[StockedFlagWithDocuments]]></VALUE> +<!--B6FF3853FDD949709EA0742E2443F1C3--> <MSGTEXT><![CDATA[You cannot change the Stocked flag because the product has been linked to transactional documents. See Linked Items for details.]]></MSGTEXT> +<!--B6FF3853FDD949709EA0742E2443F1C3--> <MSGTYPE><![CDATA[E]]></MSGTYPE> +<!--B6FF3853FDD949709EA0742E2443F1C3--> <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID> +<!--B6FF3853FDD949709EA0742E2443F1C3--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N> +<!--B6FF3853FDD949709EA0742E2443F1C3--></AD_MESSAGE> + <!--B72BC899534F4943B0A158FA4E5A5936--><AD_MESSAGE> <!--B72BC899534F4943B0A158FA4E5A5936--> <AD_MESSAGE_ID><![CDATA[B72BC899534F4943B0A158FA4E5A5936]]></AD_MESSAGE_ID> <!--B72BC899534F4943B0A158FA4E5A5936--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID> ------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits