Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0004864Openbravo ERP00. Application dictionarypublic2008-09-09 09:122008-12-16 13:10
rafaroda 
rafaroda 
highminoralways
closedfixed 
20Ubuntu 7.10
pi 
 
Core
No
0004864: AD_COLUMN_IDENTIFIER does not work correctly for 'M_Product' table
In some files [1] [2] [3], AD_COLUMN_IDENTIFIER is used, for instance, as:
AD_COLUMN_IDENTIFIER(TO_CHAR('M_Product'), TO_CHAR(T.M_PRODUCT_ID), TO_CHAR('es_ES')) in order to get the name of a product in Spanish, if this product has a translation to Spanish.

[1] https://dev.openbravo.com/websvn/openbravo/trunk/src/org/openbravo/erpCommon/ad_reports/ReportInvoiceCustomerDimensionalAnalysesJR.java [^]
[2] https://dev.openbravo.com/websvn/openbravo/trunk/src/org/openbravo/erpCommon/ad_reports/ReportInvoiceVendorDimensionalAnalysesJR.java [^]
[3] https://dev.openbravo.com/websvn/openbravo/trunk/src/org/openbravo/erpCommon/ad_reports/ReportMaterialDimensionalAnalysesJR.java [^]
1) Set a Spanish translation for the product with M_Product_Id = 1000001 (Telephone) inside 'Master Data Management || Product || Product >> Translation'

2) Execute (being 1000001 the ID of the product - M_Product_Id):
select AD_COLUMN_IDENTIFIER('M_Product', '1000001', 'es_ES') from dual;

You still get the name 'Telephone' in 'en_US'.
If you inspect AD_COLUMN_IDENTIFIER function, you find:
SELECT REPLACE(REPLACE(SQL_RECORD_IDENTIFIER, ':c_language', '''' || p_Language || ''''), ':c_ID', p_Record_ID)
  INTO v_SQL
  FROM AD_TABLE
  WHERE UPPER(TABLENAME)=UPPER(p_TableName) ;

If you execute:
SELECT REPLACE(REPLACE(SQL_RECORD_IDENTIFIER, ':c_language', '''' || 'es_ES' || ''''), ':c_ID', '1000001')
  FROM AD_TABLE
  WHERE UPPER(TABLENAME)=UPPER('M_Product') ;

You get the SQL:
SELECT TO_CHAR(COALESCE(TO_CHAR(T.Name),'')) AS COLUMN_IDENTIFIER FROM (SELECT AD_LANGUAGE FROM AD_LANGUAGE WHERE AD_LANGUAGE='es_ES') L, M_Product T WHERE M_Product_ID='1000001'

Then, inside AD_COLUMN_IDENTIFIER function, this SQL sentence is executed. You can notice that there is no reference to M_Product_Trl table so you will never get the Spanish translation of the product.
No tags attached.
depends on backport 0004890 closed rafaroda AD_COLUMN_IDENTIFIER does not work correctly for 'M_Product' table 
blocks defect 0004865 closed rafaroda 'es_ES' hardcoded in AD_COLUMN_IDENTIFIER 
Issue History
2008-09-09 09:12rafarodaNew Issue
2008-09-09 09:12rafarodaAssigned To => cromero
2008-09-09 09:12rafarodasf_bug_id0 => 2101536
2008-09-09 09:12rafarodaRegression testing => No
2008-09-09 09:23rafarodaRelationship addedblocks 0004865
2008-09-09 09:38rafarodaAssigned Tocromero => alostale
2008-09-09 17:07rafarodaNote Added: 0008950
2008-09-09 17:16rafarodaAssigned Toalostale => rafaroda
2008-09-09 17:16rafarodaSeveritymajor => minor
2008-09-09 17:16rafarodaSummaryAD_COLUMN_IDENTIFIER does not work => AD_COLUMN_IDENTIFIER does not work correctly for 'M_Product' table
2008-09-09 17:16rafarodaStatusnew => scheduled
2008-09-09 17:16rafarodafix_in_branch => trunk
2008-09-10 09:45svnbotCheckin
2008-09-10 09:45svnbotNote Added: 0008966
2008-09-10 09:45svnbotStatusscheduled => resolved
2008-09-10 09:45svnbotResolutionopen => fixed
2008-09-10 09:45svnbotsvn_revision => 7139
2008-12-16 13:10psarobeStatusresolved => closed

Notes
(0008950)
rafaroda   
2008-09-09 17:07   
In fact, the problem is in AD_COLUMN where 'Name' column for 'M_Product' table (ad_table_id = 208) has value 'IsTranslated' = 'N'.

A.1) select istranslated from ad_column where ad_Table_id = '208' and columnname ='Name';
Result = N

A.2) select ad_column_identifier_sql('M_Product') from dual;
Result = SELECT TO_CHAR(COALESCE(TO_CHAR(T.Name),'')) AS COLUMN_IDENTIFIER FROM (SELECT AD_LANGUAGE FROM AD_LANGUAGE WHERE AD_LANGUAGE=:c_language) L, M_Product T WHERE M_Product_ID=:c_ID

To solve this:

B.1) update ad_column set istranslated = 'Y' where ad_Table_id = '208' and columnname ='Name';

B.2) select ad_column_identifier_sql('M_Product') from dual;
Result = SELECT (SELECT COALESCE(TO_CHAR(MAX(TT.Name)), TO_CHAR(T.Name)) FROM M_Product_Trl TT WHERE TT.M_Product_ID=T.M_Product_ID AND TT.AD_LANGUAGE=L.AD_LANGUAGE) AS COLUMN_IDENTIFIER FROM (SELECT AD_LANGUAGE FROM AD_LANGUAGE WHERE AD_LANGUAGE=:c_language) L, M_Product T WHERE M_Product_ID=':c_ID'

B.3) select ad_update_table_identifier(null);

B.4) select SQL_RECORD_IDENTIFIER from ad_table where UPPER(TABLENAME)=UPPER('M_Product') ;
Result = SELECT (SELECT COALESCE(TO_CHAR(MAX(TT.Name)), TO_CHAR(T.Name)) FROM M_Product_Trl TT WHERE TT.M_Product_ID=T.M_Product_ID AND TT.AD_LANGUAGE=L.AD_LANGUAGE) AS COLUMN_IDENTIFIER FROM (SELECT AD_LANGUAGE FROM AD_LANGUAGE WHERE AD_LANGUAGE=:c_language) L, M_Product T WHERE M_Product_ID=:c_ID

B.5) select * from m_product_trl;

B.6) select AD_COLUMN_IDENTIFIER('M_Product', '1000001', 'es_ES') from dual;
Result = Teléfono
(0008966)
svnbot   
2008-09-10 09:45   
Repository: openbravo
Revision: 7139
Author: rafaroda
Date: 2008-09-10 09:45:26 +0200 (Wed, 10 Sep 2008)

Fixes bug 0004864 Changed to 'Y' the value 'Translation' of 'Name' column inside 'M_Product' table then run 'ad_update_table_identifier(null)' procedure.

---
U trunk/src-db/database/sourcedata/AD_COLUMN.xml
U trunk/src-db/database/sourcedata/AD_TABLE.xml
---

https://dev.openbravo.com/websvn/openbravo/?rev=7139&sc=1 [^]