IDEMPIERE-2501 Product Attribute displayed wrongly in formats and info window
This commit is contained in:
parent
a66dbb1ad8
commit
825c5e4941
|
@ -53,7 +53,7 @@ BEGIN
|
|||
IF (p_M_AttributeSetInstance_ID > 0) THEN
|
||||
SELECT asi.Lot, asi.SerNo, asi.GuaranteeDate,
|
||||
COALESCE(a.SerNoCharSOverwrite, TO_NCHAR('#')), COALESCE(a.SerNoCharEOverwrite, TO_NCHAR('')),
|
||||
COALESCE(a.LotCharSOverwrite, TO_NCHAR('«')), COALESCE(a.LotCharEOverwrite, TO_NCHAR('»'))
|
||||
COALESCE(a.LotCharSOverwrite, to_nchar(chr(49835))), COALESCE(a.LotCharEOverwrite, to_nchar(chr(49851)))
|
||||
INTO v_Lot, v_SerNo, v_GuaranteeDate,
|
||||
v_SerNoStart, v_SerNoEnd, v_LotStart, v_LotEnd
|
||||
FROM M_AttributeSetInstance asi
|
||||
|
|
|
@ -52,7 +52,7 @@ BEGIN
|
|||
IF (p_M_AttributeSetInstance_ID > 0) THEN
|
||||
SELECT asi.Lot, asi.SerNo, asi.GuaranteeDate,
|
||||
COALESCE(a.SerNoCharSOverwrite, '#'::CHAR(1)), COALESCE(a.SerNoCharEOverwrite, ''::CHAR(1)),
|
||||
COALESCE(a.LotCharSOverwrite, '«'::CHAR(1)), COALESCE(a.LotCharEOverwrite, '»'::CHAR(1))
|
||||
COALESCE(a.LotCharSOverwrite, chr(171)), COALESCE(a.LotCharEOverwrite, chr(187))
|
||||
INTO v_Lot, v_SerNo, v_GuaranteeDate,
|
||||
v_SerNoStart, v_SerNoEnd, v_LotStart, v_LotEnd
|
||||
FROM M_AttributeSetInstance asi
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
CREATE OR REPLACE FUNCTION productAttribute
|
||||
(
|
||||
p_M_AttributeSetInstance_ID IN NUMBER
|
||||
)
|
||||
RETURN VARCHAR2
|
||||
/*************************************************************************
|
||||
* The contents of this file are subject to the Compiere License. You may
|
||||
* obtain a copy of the License at http://www.compiere.org/license.html
|
||||
* Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
|
||||
* express or implied. See the License for details. Code: Compiere ERP+CRM
|
||||
* Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved.
|
||||
*************************************************************************
|
||||
* $Id: M_Attribute_Name.sql,v 1.1 2006/04/21 17:51:58 jjanke Exp $
|
||||
***
|
||||
* Title: Return Instance Attribute Info
|
||||
* Description:
|
||||
*
|
||||
* Test:
|
||||
SELECT M_Attribute_Name (M_AttributeSetInstance_ID)
|
||||
FROM M_InOutLine WHERE M_AttributeSetInstance_ID > 0
|
||||
--
|
||||
SELECT p.Name
|
||||
FROM C_InvoiceLine il LEFT OUTER JOIN M_Product p ON (il.M_Product_ID=p.M_Product_ID);
|
||||
SELECT p.Name || M_Attribute_Name (il.M_AttributeSetInstance_ID)
|
||||
FROM C_InvoiceLine il LEFT OUTER JOIN M_Product p ON (il.M_Product_ID=p.M_Product_ID);
|
||||
|
||||
************************************************************************/
|
||||
AS
|
||||
v_Name VARCHAR2(2000) := NULL;
|
||||
v_NameAdd VARCHAR2(2000) := '';
|
||||
--
|
||||
v_Lot M_AttributeSetInstance.Lot%TYPE;
|
||||
v_LotStart M_AttributeSet.LotCharSOverwrite%TYPE;
|
||||
v_LotEnd M_AttributeSet.LotCharEOverwrite%TYPE;
|
||||
v_SerNo M_AttributeSetInstance.SerNo%TYPE;
|
||||
v_SerNoStart M_AttributeSet.SerNoCharSOverwrite%TYPE;
|
||||
v_SerNoEnd M_AttributeSet.SerNoCharEOverwrite%TYPE;
|
||||
v_GuaranteeDate M_AttributeSetInstance.GuaranteeDate%TYPE;
|
||||
--
|
||||
CURSOR CUR_Attributes IS
|
||||
SELECT ai.Value, a.Name
|
||||
FROM M_AttributeInstance ai
|
||||
INNER JOIN M_Attribute a ON (ai.M_Attribute_ID=a.M_Attribute_ID AND a.IsInstanceAttribute='Y')
|
||||
WHERE ai.M_AttributeSetInstance_ID=p_M_AttributeSetInstance_ID;
|
||||
|
||||
BEGIN
|
||||
/* -- Get Product Name
|
||||
SELECT Name
|
||||
INTO v_Name
|
||||
FROM M_Product WHERE M_Product_ID=p_M_Product_ID;
|
||||
*/
|
||||
-- Get Product Attribute Set Instance
|
||||
IF (p_M_AttributeSetInstance_ID > 0) THEN
|
||||
SELECT asi.Lot, asi.SerNo, asi.GuaranteeDate,
|
||||
COALESCE(a.SerNoCharSOverwrite, TO_NCHAR('#')), COALESCE(a.SerNoCharEOverwrite, TO_NCHAR('')),
|
||||
COALESCE(a.LotCharSOverwrite, to_nchar(chr(49835))), COALESCE(a.LotCharEOverwrite, to_nchar(chr(49851)))
|
||||
INTO v_Lot, v_SerNo, v_GuaranteeDate,
|
||||
v_SerNoStart, v_SerNoEnd, v_LotStart, v_LotEnd
|
||||
FROM M_AttributeSetInstance asi
|
||||
INNER JOIN M_AttributeSet a ON (asi.M_AttributeSet_ID=a.M_AttributeSet_ID)
|
||||
WHERE asi.M_AttributeSetInstance_ID=p_M_AttributeSetInstance_ID;
|
||||
--
|
||||
IF (v_SerNo IS NOT NULL) THEN
|
||||
v_NameAdd := v_NameAdd || v_SerNoStart || v_SerNo || v_SerNoEnd || ' ';
|
||||
END IF;
|
||||
IF (v_Lot IS NOT NULL) THEN
|
||||
v_NameAdd := v_NameAdd || v_LotStart || v_Lot || v_LotEnd || ' ';
|
||||
END IF;
|
||||
IF (v_GuaranteeDate IS NOT NULL) THEN
|
||||
v_NameAdd := v_NameAdd || v_GuaranteeDate || ' ';
|
||||
END IF;
|
||||
--
|
||||
FOR a IN CUR_Attributes LOOP
|
||||
v_NameAdd := v_NameAdd || a.Name || ':' || a.Value || ' ';
|
||||
END LOOP;
|
||||
--
|
||||
IF (LENGTH(v_NameAdd) > 0) THEN
|
||||
v_Name := v_Name || ' (' || TRIM(v_NameAdd) || ')';
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
RETURN v_Name;
|
||||
END productAttribute;
|
||||
/
|
||||
|
||||
SELECT register_migration_script('201503041855_IDEMPIERE-2501.sql') FROM dual
|
||||
;
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
set client_encoding='LATIN1';
|
||||
|
||||
CREATE OR REPLACE FUNCTION ProductAttribute
|
||||
(
|
||||
p_M_AttributeSetInstance_ID NUMERIC
|
||||
)
|
||||
RETURNS VARCHAR AS $body$
|
||||
|
||||
/*************************************************************************
|
||||
* The contents of this file are subject to the Compiere License. You may
|
||||
* obtain a copy of the License at http://www.compiere.org/license.html
|
||||
* Software is on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
|
||||
* express or implied. See the License for details. Code: Compiere ERP+CRM
|
||||
* Copyright (C) 1999-2001 Jorg Janke, ComPiere, Inc. All Rights Reserved.
|
||||
*
|
||||
* converted to postgreSQL by Karsten Thiemann (Schaeffer AG),
|
||||
* kthiemann@adempiere.org
|
||||
*************************************************************************
|
||||
* Title: Return Instance Attribute Info
|
||||
* Description:
|
||||
*
|
||||
* Test:
|
||||
SELECT ProductAttribute (M_AttributeSetInstance_ID)
|
||||
FROM M_InOutLine WHERE M_AttributeSetInstance_ID > 0
|
||||
--
|
||||
SELECT p.Name
|
||||
FROM C_InvoiceLine il LEFT OUTER JOIN M_Product p ON (il.M_Product_ID=p.M_Product_ID);
|
||||
SELECT p.Name || ProductAttribute (il.M_AttributeSetInstance_ID)
|
||||
FROM C_InvoiceLine il LEFT OUTER JOIN M_Product p ON (il.M_Product_ID=p.M_Product_ID);
|
||||
|
||||
************************************************************************/
|
||||
|
||||
|
||||
DECLARE
|
||||
|
||||
v_Name VARCHAR(2000) := '';
|
||||
v_NameAdd VARCHAR(2000) := '';
|
||||
--
|
||||
v_Lot M_AttributeSetInstance.Lot%TYPE;
|
||||
v_LotStart M_AttributeSet.LotCharSOverwrite%TYPE;
|
||||
v_LotEnd M_AttributeSet.LotCharEOverwrite%TYPE;
|
||||
v_SerNo M_AttributeSetInstance.SerNo%TYPE;
|
||||
v_SerNoStart M_AttributeSet.SerNoCharSOverwrite%TYPE;
|
||||
v_SerNoEnd M_AttributeSet.SerNoCharEOverwrite%TYPE;
|
||||
v_GuaranteeDate M_AttributeSetInstance.GuaranteeDate%TYPE;
|
||||
|
||||
r RECORD;
|
||||
--
|
||||
|
||||
BEGIN
|
||||
-- Get Product Attribute Set Instance
|
||||
IF (p_M_AttributeSetInstance_ID > 0) THEN
|
||||
SELECT asi.Lot, asi.SerNo, asi.GuaranteeDate,
|
||||
COALESCE(a.SerNoCharSOverwrite, '#'::CHAR(1)), COALESCE(a.SerNoCharEOverwrite, ''::CHAR(1)),
|
||||
COALESCE(a.LotCharSOverwrite, chr(171)), COALESCE(a.LotCharEOverwrite, chr(187))
|
||||
INTO v_Lot, v_SerNo, v_GuaranteeDate,
|
||||
v_SerNoStart, v_SerNoEnd, v_LotStart, v_LotEnd
|
||||
FROM M_AttributeSetInstance asi
|
||||
INNER JOIN M_AttributeSet a ON (asi.M_AttributeSet_ID=a.M_AttributeSet_ID)
|
||||
WHERE asi.M_AttributeSetInstance_ID=p_M_AttributeSetInstance_ID;
|
||||
--
|
||||
IF (v_SerNo IS NOT NULL) THEN
|
||||
v_NameAdd := v_NameAdd || v_SerNoStart || v_SerNo || v_SerNoEnd || ' ';
|
||||
END IF;
|
||||
IF (v_Lot IS NOT NULL) THEN
|
||||
v_NameAdd := v_NameAdd || v_LotStart || v_Lot || v_LotEnd || ' ';
|
||||
END IF;
|
||||
IF (v_GuaranteeDate IS NOT NULL) THEN
|
||||
v_NameAdd := v_NameAdd || v_GuaranteeDate || ' ';
|
||||
END IF;
|
||||
--
|
||||
|
||||
FOR r IN
|
||||
SELECT ai.Value, a.Name
|
||||
FROM M_AttributeInstance ai
|
||||
INNER JOIN M_Attribute a ON (ai.M_Attribute_ID=a.M_Attribute_ID AND a.IsInstanceAttribute='Y')
|
||||
WHERE ai.M_AttributeSetInstance_ID=p_M_AttributeSetInstance_ID
|
||||
LOOP
|
||||
v_NameAdd := v_NameAdd || r.Name || ':' || r.Value || ' ';
|
||||
END LOOP;
|
||||
--
|
||||
IF (LENGTH(v_NameAdd) > 0) THEN
|
||||
v_Name := v_Name || ' (' || TRIM(v_NameAdd) || ')';
|
||||
ELSE
|
||||
v_Name := NULL;
|
||||
END IF;
|
||||
END IF;
|
||||
RETURN v_Name;
|
||||
END;
|
||||
|
||||
$body$ LANGUAGE plpgsql STABLE;
|
||||
|
||||
SELECT register_migration_script('201503041855_IDEMPIERE-2501.sql') FROM dual
|
||||
;
|
||||
|
Loading…
Reference in New Issue