[DS Based Tables] Merge with pi
authorAugusto Mauch <augusto.mauch@openbravo.com>
Thu, 09 May 2013 12:06:37 +0200
changeset 20401 6d780839aba6
parent 20400 b76656fecb90 (current diff)
parent 20347 d1a049df1795 (diff)
child 20402 17377e2ff260
[DS Based Tables] Merge with pi
modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_TABLE.xml
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_TABLE.xml
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-parameter-window-view.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-grid.js
modules/org.openbravo.client.kernel/src-db/database/sourcedata/AD_TABLE.xml
modules/org.openbravo.client.myob/src-db/database/sourcedata/AD_TABLE.xml
modules/org.openbravo.client.querylist/src-db/database/sourcedata/AD_TABLE.xml
modules/org.openbravo.service.datasource/src-db/database/sourcedata/AD_TABLE.xml
modules/org.openbravo.service.integration.google/src-db/database/sourcedata/AD_TABLE.xml
modules/org.openbravo.service.integration.openid/src-db/database/sourcedata/AD_TABLE.xml
modules/org.openbravo.userinterface.selector/src-db/database/sourcedata/AD_TABLE.xml
src-db/database/model/tables/AD_TABLE.xml
src-db/database/sourcedata/AD_COLUMN.xml
src-db/database/sourcedata/AD_ELEMENT.xml
src-db/database/sourcedata/AD_FIELD.xml
src-db/database/sourcedata/AD_MESSAGE.xml
src-db/database/sourcedata/AD_REFERENCE.xml
src-db/database/sourcedata/AD_TABLE.xml
src-db/database/sourcedata/OBUISEL_SELECTOR.xml
src-db/database/sourcedata/OBUISEL_SELECTOR_FIELD.xml
src/org/openbravo/dal/core/DalUtil.java
src/org/openbravo/service/system/DatabaseValidator.java
web/js/jscalendar/lang/calendar-al.js
--- a/.hgsigs	Wed May 08 16:26:46 2013 +0200
+++ b/.hgsigs	Thu May 09 12:06:37 2013 +0200
@@ -106,3 +106,6 @@
 cd9fe4727ba89b6fc108d9e7e48cc222c24016e4 0 iEYEABECAAYFAlEkZrgACgkQCX/oGf+2qkNMEgCfVeNFe/nvgxNXwEUvbbIp6tqdAJ0AoK+83WD/fS6bRKK2xEgc5gwYlFJP
 2eb40756a1ed20c690c9158cd84aa62ea34ac339 0 iEYEABECAAYFAlEjW+AACgkQCX/oGf+2qkNupQCgz0W/xoRPzBsfhdSFgcD+vJy9aPAAoNfJeFhJ+psPdkmsZmz8fYvRg8DT
 1983af93019a75c0f0b130181b3ed8bb7d83bd8c 0 iEYEABECAAYFAlE42u0ACgkQCX/oGf+2qkNZQgCeKbV0dJ/m8Mcri1w7Xw3bB2dzAU0An02XW44EzaErkug0oKK6bkYmDmRA
+d7e04c9b010fd0b52464f9b846278b415ff066cc 0 iEYEABECAAYFAlFrxIQACgkQCX/oGf+2qkPu7ACgofS8PV7CLsmpDNO8nNMkrs++JIcAoL69XxrlYHRfCM6aue8q5srbLm/R
+bea15e1decb29501b4124110009787f2dca70cf9 0 iEYEABECAAYFAlFue8kACgkQCX/oGf+2qkMvfACgjbPubrgVAbVnotRRgGAgQancNqsAoMRke06L5J+RtPYdeU3wRSx2YNqt
+dc219eb12d7e3a434b4d3151a93597d5292f2c06 0 iEYEABECAAYFAlGCVCkACgkQCX/oGf+2qkPi6gCeJKtfZ58WQOqlRHoY0X3K+6yxpwcAoJr+iFJrxNhzylyJuAiZx1Ewsdti
--- a/.hgtags	Wed May 08 16:26:46 2013 +0200
+++ b/.hgtags	Thu May 09 12:06:37 2013 +0200
@@ -117,3 +117,6 @@
 42352a2a7b5be48801784583817c082e2ec11af2 3.0MP19.4
 60f345bac02b65b2e09ad4e540c70875197ce76f 3.0MP20
 79ef7f4b625d71d1c8a6520648e528f9a722ab60 3.0MP21
+383173cf8e316d135eb0d216ab091602955b1daf 3.0MP22
+ce76fa45acc0de59a2743e001aa3e00764b9b7b1 3.0MP22.1
+56826f5230e456121cf043d90513707beaf6b473 3.0MP22.2
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/model/views/APRM_FINACC_TRANSACTION_V.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/model/views/APRM_FINACC_TRANSACTION_V.xml	Thu May 09 12:06:37 2013 +0200
@@ -1,4 +1,4 @@
 <?xml version="1.0"?>
   <database name="VIEW APRM_FINACC_TRANSACTION_V">
-    <view name="APRM_FINACC_TRANSACTION_V"><![CDATA[SELECT trx.fin_finacc_transaction_id AS aprm_finacc_transaction_v_id, trx.fin_finacc_transaction_id, trx.ad_client_id, trx.ad_org_id, trx.isactive, trx.created, trx.createdby, trx.updated, trx.updatedby, trx.fin_financial_account_id, trx.line, trx.description, trx.statementdate, trx.trxtype, trx.fin_payment_id, trx.c_glitem_id, trx.depositamt, trx.paymentamt, trx.c_currency_id, trx.fin_reconciliation_id, trx.status, trx.createdbyalgorithm, trx.posted, trx.dateacct, trx.processed, trx.processing, trx.user1_id, trx.user2_id, trx.c_activity_id, trx.c_campaign_id, trx.c_project_id, trx.foreign_currency_id, trx.foreign_amount, trx.em_aprm_modify, trx.foreign_convert_rate,  CASE trx.status WHEN 'RPPC' THEN 'Y' ELSE 'N' END AS cleared, COALESCE(trx.c_bpartner_id, p.c_bpartner_id) AS c_bpartner_id, trx.m_product_id, trx.c_salesregion_id, p.documentno AS paymentdocno, COALESCE(r.processed, 'N') AS reconciled, 'N' AS delete_btn, (SELECT ad_table.ad_table_id FROM ad_table WHERE lower(ad_table.tablename) = 'fin_finacc_transaction') AS forced_table_id, trx.c_costcenter_id FROM fin_finacc_transaction trx LEFT JOIN fin_payment p ON trx.fin_payment_id = p.fin_payment_id LEFT JOIN fin_reconciliation r ON trx.fin_reconciliation_id = r.fin_reconciliation_id]]></view>
+    <view name="APRM_FINACC_TRANSACTION_V"><![CDATA[SELECT trx.fin_finacc_transaction_id AS aprm_finacc_transaction_v_id, trx.fin_finacc_transaction_id, trx.ad_client_id, trx.ad_org_id, trx.isactive, trx.created, trx.createdby, trx.updated, trx.updatedby, trx.fin_financial_account_id, trx.line, trx.description, trx.statementdate, trx.trxtype, trx.fin_payment_id, trx.c_glitem_id, trx.depositamt, trx.paymentamt, trx.c_currency_id, trx.fin_reconciliation_id, trx.status, trx.createdbyalgorithm, trx.posted, trx.dateacct, trx.processed, trx.processing, trx.user1_id, trx.user2_id, trx.c_activity_id, trx.c_campaign_id, trx.c_project_id, trx.foreign_currency_id, trx.foreign_amount, trx.em_aprm_modify, trx.foreign_convert_rate,  CASE trx.status WHEN 'RPPC' THEN 'Y' ELSE 'N' END AS cleared, COALESCE(trx.c_bpartner_id, p.c_bpartner_id) AS c_bpartner_id, trx.m_product_id, trx.c_salesregion_id, p.documentno AS paymentdocno, COALESCE(r.processed, 'N') AS reconciled, to_char('N') AS delete_btn, (SELECT ad_table.ad_table_id FROM ad_table WHERE lower(ad_table.tablename) = 'fin_finacc_transaction') AS forced_table_id, trx.c_costcenter_id FROM fin_finacc_transaction trx LEFT JOIN fin_payment p ON trx.fin_payment_id = p.fin_payment_id LEFT JOIN fin_reconciliation r ON trx.fin_reconciliation_id = r.fin_reconciliation_id]]></view>
   </database>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_FIELD.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_FIELD.xml	Thu May 09 12:06:37 2013 +0200
@@ -446,7 +446,7 @@
 <!--07EC2EF3577B4AAC84EBABCC8DA7C292-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
 <!--07EC2EF3577B4AAC84EBABCC8DA7C292-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--07EC2EF3577B4AAC84EBABCC8DA7C292-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--07EC2EF3577B4AAC84EBABCC8DA7C292-->  <NAME><![CDATA[Fin_Financial_Account_ID]]></NAME>
+<!--07EC2EF3577B4AAC84EBABCC8DA7C292-->  <NAME><![CDATA[Financial Account]]></NAME>
 <!--07EC2EF3577B4AAC84EBABCC8DA7C292-->  <DESCRIPTION><![CDATA[Financial account used to deposit / withdrawal money such as bank accounts or petty cash]]></DESCRIPTION>
 <!--07EC2EF3577B4AAC84EBABCC8DA7C292-->  <HELP><![CDATA[Financial account used to deposit / withdrawal money such as bank accounts or petty cash]]></HELP>
 <!--07EC2EF3577B4AAC84EBABCC8DA7C292-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
@@ -7878,7 +7878,7 @@
 <!--7DFD1BBEC2F60C48E040007F01004674-->  <AD_COLUMN_ID><![CDATA[7DC34559B3F2B45BE040007F0100784A]]></AD_COLUMN_ID>
 <!--7DFD1BBEC2F60C48E040007F01004674-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
 <!--7DFD1BBEC2F60C48E040007F01004674-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
-<!--7DFD1BBEC2F60C48E040007F01004674-->  <DISPLAYLOGIC><![CDATA[@Processed@='Y' & @Status@!'RPVOID']]></DISPLAYLOGIC>
+<!--7DFD1BBEC2F60C48E040007F01004674-->  <DISPLAYLOGIC><![CDATA[@Processed@='Y' & @Status@!'RPVOID' & @FIN_Rev_Payment_ID@ = '']]></DISPLAYLOGIC>
 <!--7DFD1BBEC2F60C48E040007F01004674-->  <DISPLAYLENGTH><![CDATA[60]]></DISPLAYLENGTH>
 <!--7DFD1BBEC2F60C48E040007F01004674-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
 <!--7DFD1BBEC2F60C48E040007F01004674-->  <SEQNO><![CDATA[130]]></SEQNO>
@@ -12457,7 +12457,7 @@
 <!--A135CD50436C4E97808E6F7ABAC1E1E8-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
 <!--A135CD50436C4E97808E6F7ABAC1E1E8-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--A135CD50436C4E97808E6F7ABAC1E1E8-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--A135CD50436C4E97808E6F7ABAC1E1E8-->  <NAME><![CDATA[LastPaymentDate]]></NAME>
+<!--A135CD50436C4E97808E6F7ABAC1E1E8-->  <NAME><![CDATA[Last Payment Date]]></NAME>
 <!--A135CD50436C4E97808E6F7ABAC1E1E8-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
 <!--A135CD50436C4E97808E6F7ABAC1E1E8-->  <AD_TAB_ID><![CDATA[7A8D43541F8C49F1BD8A431A0041BF89]]></AD_TAB_ID>
 <!--A135CD50436C4E97808E6F7ABAC1E1E8-->  <AD_COLUMN_ID><![CDATA[AECA45F025F14E6DBA669E12DDA55D17]]></AD_COLUMN_ID>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MESSAGE.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MESSAGE.xml	Thu May 09 12:06:37 2013 +0200
@@ -294,7 +294,7 @@
 <!--48898A3B7F9141C0B9BFBDD9AE5FCF8F-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--48898A3B7F9141C0B9BFBDD9AE5FCF8F-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--48898A3B7F9141C0B9BFBDD9AE5FCF8F-->  <VALUE><![CDATA[APRM_PeriodNotAvailableClearedItem]]></VALUE>
-<!--48898A3B7F9141C0B9BFBDD9AE5FCF8F-->  <MSGTEXT><![CDATA[The period of the cleared item (%s) is not open or available.]]></MSGTEXT>
+<!--48898A3B7F9141C0B9BFBDD9AE5FCF8F-->  <MSGTEXT><![CDATA[The reconciliation cannot be completed because it contains one or more items in a closed period.<BR>The period of the cleared item (%s) is not open or available.]]></MSGTEXT>
 <!--48898A3B7F9141C0B9BFBDD9AE5FCF8F-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
 <!--48898A3B7F9141C0B9BFBDD9AE5FCF8F-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
 <!--48898A3B7F9141C0B9BFBDD9AE5FCF8F-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MODULE.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MODULE.xml	Thu May 09 12:06:37 2013 +0200
@@ -6,7 +6,7 @@
 <!--A918E3331C404B889D69AA9BFAFB23AC-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--A918E3331C404B889D69AA9BFAFB23AC-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--A918E3331C404B889D69AA9BFAFB23AC-->  <NAME><![CDATA[Advanced Payables and Receivables Mngmt]]></NAME>
-<!--A918E3331C404B889D69AA9BFAFB23AC-->  <VERSION><![CDATA[3.0.20056]]></VERSION>
+<!--A918E3331C404B889D69AA9BFAFB23AC-->  <VERSION><![CDATA[3.0.20252]]></VERSION>
 <!--A918E3331C404B889D69AA9BFAFB23AC-->  <DESCRIPTION><![CDATA[Managing your finances with an ERP does not have to be difficult. Enjoy a radically improved user experience that combines the power of an enterprise grade financial application with the simplicity and ease of a web 2.0 personal accounting service.]]></DESCRIPTION>
 <!--A918E3331C404B889D69AA9BFAFB23AC-->  <HELP><![CDATA[Advanced Payables and Receivables Management simplifies and automates the business processes around the management of financial accounts, from the receipt and issue of payment, to the reconciliation of those events with bank statements.
 If you would like to help shape this module you are welcome to take part in the forum discussions or register feature requests or issues in the corresponding (Forum and Bug Tracking) sections in the Advanced Payables and Receivable project in the OB Forge.]]></HELP>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Thu May 09 12:06:37 2013 +0200
@@ -7,7 +7,7 @@
 <!--89326AE95DAD449D85DFAB2C5B1C6683-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--89326AE95DAD449D85DFAB2C5B1C6683-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
 <!--89326AE95DAD449D85DFAB2C5B1C6683-->  <AD_DEPENDENT_MODULE_ID><![CDATA[5EB4F15C80684ACA904756BDC12ADBE5]]></AD_DEPENDENT_MODULE_ID>
-<!--89326AE95DAD449D85DFAB2C5B1C6683-->  <STARTVERSION><![CDATA[2.1.20056]]></STARTVERSION>
+<!--89326AE95DAD449D85DFAB2C5B1C6683-->  <STARTVERSION><![CDATA[2.1.20252]]></STARTVERSION>
 <!--89326AE95DAD449D85DFAB2C5B1C6683-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--89326AE95DAD449D85DFAB2C5B1C6683-->  <DEPENDANT_MODULE_NAME><![CDATA[User Interface Selector]]></DEPENDANT_MODULE_NAME>
 <!--89326AE95DAD449D85DFAB2C5B1C6683-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
@@ -21,7 +21,7 @@
 <!--B97FC854C6DD41E692161585645A900F-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--B97FC854C6DD41E692161585645A900F-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
 <!--B97FC854C6DD41E692161585645A900F-->  <AD_DEPENDENT_MODULE_ID><![CDATA[0]]></AD_DEPENDENT_MODULE_ID>
-<!--B97FC854C6DD41E692161585645A900F-->  <STARTVERSION><![CDATA[3.0.20056]]></STARTVERSION>
+<!--B97FC854C6DD41E692161585645A900F-->  <STARTVERSION><![CDATA[3.0.20252]]></STARTVERSION>
 <!--B97FC854C6DD41E692161585645A900F-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--B97FC854C6DD41E692161585645A900F-->  <DEPENDANT_MODULE_NAME><![CDATA[core]]></DEPENDANT_MODULE_NAME>
 <!--B97FC854C6DD41E692161585645A900F-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_REFERENCE.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_REFERENCE.xml	Thu May 09 12:06:37 2013 +0200
@@ -157,6 +157,18 @@
 <!--DB71FC312327430EAEACF42918405BF9-->  <ISVALUEDISPLAYED><![CDATA[N]]></ISVALUEDISPLAYED>
 <!--DB71FC312327430EAEACF42918405BF9--></AD_REFERENCE>
 
+<!--E1C0B1C7D7C84E85903409A39A53E855--><AD_REFERENCE>
+<!--E1C0B1C7D7C84E85903409A39A53E855-->  <AD_REFERENCE_ID><![CDATA[E1C0B1C7D7C84E85903409A39A53E855]]></AD_REFERENCE_ID>
+<!--E1C0B1C7D7C84E85903409A39A53E855-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--E1C0B1C7D7C84E85903409A39A53E855-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--E1C0B1C7D7C84E85903409A39A53E855-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--E1C0B1C7D7C84E85903409A39A53E855-->  <NAME><![CDATA[FIN_Payment no combo]]></NAME>
+<!--E1C0B1C7D7C84E85903409A39A53E855-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--E1C0B1C7D7C84E85903409A39A53E855-->  <ISBASEREFERENCE><![CDATA[N]]></ISBASEREFERENCE>
+<!--E1C0B1C7D7C84E85903409A39A53E855-->  <PARENTREFERENCE_ID><![CDATA[95E2A8B50A254B2AAE6774B8C2F28120]]></PARENTREFERENCE_ID>
+<!--E1C0B1C7D7C84E85903409A39A53E855-->  <ISVALUEDISPLAYED><![CDATA[N]]></ISVALUEDISPLAYED>
+<!--E1C0B1C7D7C84E85903409A39A53E855--></AD_REFERENCE>
+
 <!--E91B038ABF4F4A2280264C4A475852A4--><AD_REFERENCE>
 <!--E91B038ABF4F4A2280264C4A475852A4-->  <AD_REFERENCE_ID><![CDATA[E91B038ABF4F4A2280264C4A475852A4]]></AD_REFERENCE_ID>
 <!--E91B038ABF4F4A2280264C4A475852A4-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_TAB.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_TAB.xml	Thu May 09 12:06:37 2013 +0200
@@ -55,7 +55,7 @@
 <!--1EA4A3F31A27483A8C6E93176AE912D3-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
 <!--1EA4A3F31A27483A8C6E93176AE912D3-->  <UIPATTERN><![CDATA[SR]]></UIPATTERN>
 <!--1EA4A3F31A27483A8C6E93176AE912D3-->  <HQLWHERECLAUSE><![CDATA[e.table.id = '30721072789F410E9606D2235CB2A226' and e.recordID = @FIN_Doubtful_Debt.id@]]></HQLWHERECLAUSE>
-<!--1EA4A3F31A27483A8C6E93176AE912D3-->  <HQLORDERBYCLAUSE><![CDATA[accountingSchema.name, accountingDate, debit desc, credit desc, value]]></HQLORDERBYCLAUSE>
+<!--1EA4A3F31A27483A8C6E93176AE912D3-->  <HQLORDERBYCLAUSE><![CDATA[accountingSchema.name, accountingDate, abs(debit) desc, credit desc, value]]></HQLORDERBYCLAUSE>
 <!--1EA4A3F31A27483A8C6E93176AE912D3-->  <SHOWPARENTBUTTONS><![CDATA[Y]]></SHOWPARENTBUTTONS>
 <!--1EA4A3F31A27483A8C6E93176AE912D3-->  <EM_OBUIAPP_CAN_ADD><![CDATA[N]]></EM_OBUIAPP_CAN_ADD>
 <!--1EA4A3F31A27483A8C6E93176AE912D3-->  <EM_OBUIAPP_CAN_DELETE><![CDATA[N]]></EM_OBUIAPP_CAN_DELETE>
@@ -85,7 +85,7 @@
 <!--2A9BA5FDA0F8470D881F8EA9DEDCC598-->  <ISSORTTAB><![CDATA[N]]></ISSORTTAB>
 <!--2A9BA5FDA0F8470D881F8EA9DEDCC598-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
 <!--2A9BA5FDA0F8470D881F8EA9DEDCC598-->  <UIPATTERN><![CDATA[RO]]></UIPATTERN>
-<!--2A9BA5FDA0F8470D881F8EA9DEDCC598-->  <HQLORDERBYCLAUSE><![CDATA[-accountingDate,financialAccountTransaction,groupID,-sequenceNumber]]></HQLORDERBYCLAUSE>
+<!--2A9BA5FDA0F8470D881F8EA9DEDCC598-->  <HQLORDERBYCLAUSE><![CDATA[accountingSchema.name, accountingDate, abs(debit) desc, credit desc, value]]></HQLORDERBYCLAUSE>
 <!--2A9BA5FDA0F8470D881F8EA9DEDCC598-->  <SHOWPARENTBUTTONS><![CDATA[Y]]></SHOWPARENTBUTTONS>
 <!--2A9BA5FDA0F8470D881F8EA9DEDCC598-->  <EM_OBUIAPP_CAN_ADD><![CDATA[N]]></EM_OBUIAPP_CAN_ADD>
 <!--2A9BA5FDA0F8470D881F8EA9DEDCC598-->  <EM_OBUIAPP_CAN_DELETE><![CDATA[N]]></EM_OBUIAPP_CAN_DELETE>
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_VAL_RULE.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_VAL_RULE.xml	Thu May 09 12:06:37 2013 +0200
@@ -51,7 +51,7 @@
 <!--575E470ABADB4C278132C957A78C47E3-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--575E470ABADB4C278132C957A78C47E3-->  <NAME><![CDATA[Process Payment valid actions]]></NAME>
 <!--575E470ABADB4C278132C957A78C47E3-->  <TYPE><![CDATA[S]]></TYPE>
-<!--575E470ABADB4C278132C957A78C47E3-->  <CODE><![CDATA[((@EM_APRM_Process_Payment@ = 'P' AND AD_Ref_List.value='P') OR (@EM_APRM_Process_Payment@ in ('R','RE') AND AD_Ref_List.value IN ('RE','R')) OR (@EM_APRM_Process_Payment@ in ('R','RE') AND AD_Ref_List.value IN ('V') AND @Status@='RPAE') OR (@EM_APRM_Process_Payment@ is null)) AND AD_Ref_List.IsActive = 'Y']]></CODE>
+<!--575E470ABADB4C278132C957A78C47E3-->  <CODE><![CDATA[((@EM_APRM_Process_Payment@ = 'P' AND AD_Ref_List.value='P') OR (@EM_APRM_Process_Payment@ in ('R','RE') AND AD_Ref_List.value IN ('RE','R') AND NOT EXISTS (SELECT 1 FROM FIN_PAYMENT WHERE FIN_Rev_Payment_ID = @FIN_Payment_ID@)) OR (@EM_APRM_Process_Payment@ in ('R','RE') AND AD_Ref_List.value IN ('R') AND EXISTS (SELECT 1 FROM FIN_PAYMENT WHERE FIN_Rev_Payment_ID = @FIN_Payment_ID@)) OR (@EM_APRM_Process_Payment@ in ('R','RE') AND AD_Ref_List.value IN ('V') AND @Status@='RPAE') OR (@EM_APRM_Process_Payment@ is null)) AND AD_Ref_List.IsActive = 'Y']]></CODE>
 <!--575E470ABADB4C278132C957A78C47E3-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
 <!--575E470ABADB4C278132C957A78C47E3--></AD_VAL_RULE>
 
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUISEL_SELECTOR.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUISEL_SELECTOR.xml	Thu May 09 12:06:37 2013 +0200
@@ -38,6 +38,21 @@
 <!--9FAD469CE4414A25974CF45C0AD22D35-->  <CUSTOM_QUERY><![CDATA[N]]></CUSTOM_QUERY>
 <!--9FAD469CE4414A25974CF45C0AD22D35--></OBUISEL_SELECTOR>
 
+<!--A021037EAFFA49D299E4B6886E6A811C--><OBUISEL_SELECTOR>
+<!--A021037EAFFA49D299E4B6886E6A811C-->  <OBUISEL_SELECTOR_ID><![CDATA[A021037EAFFA49D299E4B6886E6A811C]]></OBUISEL_SELECTOR_ID>
+<!--A021037EAFFA49D299E4B6886E6A811C-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--A021037EAFFA49D299E4B6886E6A811C-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--A021037EAFFA49D299E4B6886E6A811C-->  <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID>
+<!--A021037EAFFA49D299E4B6886E6A811C-->  <NAME><![CDATA[FIN_Payment no combo]]></NAME>
+<!--A021037EAFFA49D299E4B6886E6A811C-->  <AD_REFERENCE_ID><![CDATA[E1C0B1C7D7C84E85903409A39A53E855]]></AD_REFERENCE_ID>
+<!--A021037EAFFA49D299E4B6886E6A811C-->  <AD_TABLE_ID><![CDATA[D1A97202E832470285C9B1EB026D54E2]]></AD_TABLE_ID>
+<!--A021037EAFFA49D299E4B6886E6A811C-->  <OBCLKER_TEMPLATE_ID><![CDATA[9314DE8599AD44E7BFC4CC50699042AB]]></OBCLKER_TEMPLATE_ID>
+<!--A021037EAFFA49D299E4B6886E6A811C-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--A021037EAFFA49D299E4B6886E6A811C-->  <SUGGESTIONTEXTMATCHSTYLE><![CDATA[substring]]></SUGGESTIONTEXTMATCHSTYLE>
+<!--A021037EAFFA49D299E4B6886E6A811C-->  <POPUPTEXTMATCHSTYLE><![CDATA[substring]]></POPUPTEXTMATCHSTYLE>
+<!--A021037EAFFA49D299E4B6886E6A811C-->  <CUSTOM_QUERY><![CDATA[N]]></CUSTOM_QUERY>
+<!--A021037EAFFA49D299E4B6886E6A811C--></OBUISEL_SELECTOR>
+
 <!--A98899B1C75A4F4EBD3414F1B654EFAB--><OBUISEL_SELECTOR>
 <!--A98899B1C75A4F4EBD3414F1B654EFAB-->  <OBUISEL_SELECTOR_ID><![CDATA[A98899B1C75A4F4EBD3414F1B654EFAB]]></OBUISEL_SELECTOR_ID>
 <!--A98899B1C75A4F4EBD3414F1B654EFAB-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/AddPaymentFromInvoice.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/AddPaymentFromInvoice.java	Thu May 09 12:06:37 2013 +0200
@@ -230,6 +230,15 @@
           // parameters.add(null);
           String strDocTypeId = (String) CallStoredProcedure.getInstance().call("AD_GET_DOCTYPE",
               parameters, null);
+          String strDocBaseType = parameters.get(2).toString();
+
+          if (!FIN_Utility.isPeriodOpen(vars.getClient(), strDocBaseType, strOrgId, strPaymentDate)) {
+            final OBError myMessage = Utility.translateError(this, vars, vars.getLanguage(),
+                Utility.messageBD(this, "PeriodNotAvailable", vars.getLanguage()));
+            vars.setMessage(strTabId, myMessage);
+            printPageClosePopUp(response, vars);
+            return;
+          }
 
           if (strPaymentDocumentNo.startsWith("<")) {
             // get DocumentNo
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/ExecutePayments.html	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/ExecutePayments.html	Thu May 09 12:06:37 2013 +0200
@@ -53,10 +53,6 @@
    // window.close();
     return true;
   }
-  function closeThisPage() {
-	submitCommandForm('CLOSE', true, frmMain, null);
-    return true;
-  }
 
   function onloadFunctions() {
   }
@@ -288,7 +284,7 @@
                 <td class="Button_CenterAlign_ContentCell">
                   <div>
                     <button type="button" id="buttonCancel" class="ButtonLink"
-                      onclick="closeThisPage();return false;"
+                      onclick="closePage();return false;"
                       onfocus="buttonEvent('onfocus', this); window.status='Cancel'; return true;"
                       onblur="buttonEvent('onblur', this);"
                       onkeyup="buttonEvent('onkeyup', this);"
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/ExecutePayments.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/ExecutePayments.java	Thu May 09 12:06:37 2013 +0200
@@ -97,8 +97,6 @@
           IsIDFilter.instance);
       processAndClose(response, vars, strWindowId, executionProcess, payments,
           dao.getObject(Organization.class, strOrganizationId));
-    } else if (vars.commandIn("CLOSE")) {
-      printPageClosePopUp(response, vars);
     }
   }
 
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/MatchTransaction.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/MatchTransaction.java	Thu May 09 12:06:37 2013 +0200
@@ -40,6 +40,7 @@
 import org.openbravo.advpaymentmngt.dao.MatchTransactionDao;
 import org.openbravo.advpaymentmngt.dao.TransactionsDao;
 import org.openbravo.advpaymentmngt.process.FIN_AddPayment;
+import org.openbravo.advpaymentmngt.process.FIN_ReconciliationProcess;
 import org.openbravo.advpaymentmngt.process.FIN_TransactionProcess;
 import org.openbravo.advpaymentmngt.utility.FIN_MatchedTransaction;
 import org.openbravo.advpaymentmngt.utility.FIN_MatchingTransaction;
@@ -317,12 +318,21 @@
           .getBankStatementLineMaxDate(financialAccount));
       reconciliation.setTransactionDate(MatchTransactionDao
           .getBankStatementLineMaxDate(financialAccount));
-      reconciliation.setProcessed(process);
-      reconciliation.setDocumentStatus(process ? "CO" : "DR");
-      reconciliation.setAPRMProcessReconciliation(process ? "R" : "P");
-      reconciliation.setAprmProcessRec(process ? "R" : "P");
+      if (!process) {
+        reconciliation.setProcessed(false);
+        reconciliation.setDocumentStatus("DR");
+        reconciliation.setAPRMProcessReconciliation("P");
+        reconciliation.setAprmProcessRec("P");
+      }
       OBDal.getInstance().save(reconciliation);
       OBDal.getInstance().flush();
+      if (process) {
+        // Process Reconciliation
+        OBError myError = processReconciliation(this, "P", reconciliation);
+        if (myError != null && myError.getType().equalsIgnoreCase("error")) {
+          throw new OBException(myError.getMessage());
+        }
+      }
     } catch (Exception ex) {
       OBError menssage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
       vars.setMessage(strTabId, menssage);
@@ -1267,6 +1277,19 @@
     return false;
   }
 
+  private OBError processReconciliation(ConnectionProvider conn, String strAction,
+      FIN_Reconciliation reconciliation) throws Exception {
+    ProcessBundle pb = new ProcessBundle("FF8080812E2F8EAE012E2F94CF470014", vars).init(conn);
+    HashMap<String, Object> parameters = new HashMap<String, Object>();
+    parameters.put("action", strAction);
+    parameters.put("FIN_Reconciliation_ID", reconciliation.getId());
+    pb.setParams(parameters);
+    OBError myMessage = null;
+    new FIN_ReconciliationProcess().execute(pb);
+    myMessage = (OBError) pb.getResult();
+    return myMessage;
+  }
+
   public String getServletInfo() {
     return "This servlet match imported bank statement lines for a financial account";
   }
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/ProcessInvoice.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/ProcessInvoice.java	Thu May 09 12:06:37 2013 +0200
@@ -200,6 +200,7 @@
             if (strWindowPath.equals(""))
               strWindowPath = strDefaultServlet;
             printPageClosePopUp(response, vars, strWindowPath);
+            return;
           }
         } finally {
           OBContext.restorePreviousMode();
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/Reconciliation.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/Reconciliation.java	Thu May 09 12:06:37 2013 +0200
@@ -216,10 +216,10 @@
         Calendar tomorrow = Calendar.getInstance();
         tomorrow.add(Calendar.DATE, 1);
         tomorrow.setTime(DateUtils.truncate(tomorrow.getTime(), Calendar.DATE));
-        // if (calCurrent.after(tomorrow)) {
-        // strMessage = "@APRM_ReconcileInFutureOrPast@";
-        // raiseException = true;
-        // }
+        if (calCurrent.after(tomorrow)) {
+          strMessage = "@APRM_ReconcileInFutureOrPast@";
+          raiseException = true;
+        }
         if (raiseException) {
           msg.setType("Error");
           msg.setTitle(Utility.messageBD(this, "Error", vars.getLanguage()));
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/algorithm/StandardMatchingAlgorithm.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/algorithm/StandardMatchingAlgorithm.java	Thu May 09 12:06:37 2013 +0200
@@ -19,6 +19,7 @@
 
 package org.openbravo.advpaymentmngt.algorithm;
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -41,7 +42,22 @@
     Date transactionDate = (algorithm.isMatchtransactiondate()) ? line.getTransactionDate() : null;
     String reference = (algorithm.isMatchreference()) ? line.getReferenceNo() : "";
 
-    List<FIN_FinaccTransaction> transactions;
+    List<FIN_FinaccTransaction> transactions = new ArrayList<FIN_FinaccTransaction>();
+    if (line.getGLItem() != null) {
+      transactions = MatchTransactionDao.getMatchingGLItemTransaction(line.getBankStatement()
+          .getAccount().getId(), line.getGLItem(), line.getTransactionDate(),
+          (line.getCramount().subtract(line.getDramount())), excluded);
+      if (transactions.isEmpty()) {
+        transactions = MatchTransactionDao.getMatchingGLItemTransaction(line.getBankStatement()
+            .getAccount().getId(), line.getGLItem(), null,
+            (line.getCramount().subtract(line.getDramount())), excluded);
+        if (!transactions.isEmpty()) {
+          return new FIN_MatchedTransaction(transactions.get(0), FIN_MatchedTransaction.WEAK);
+        }
+      } else {
+        return new FIN_MatchedTransaction(transactions.get(0), FIN_MatchedTransaction.STRONG);
+      }
+    }
     if (algorithm.isMatchbpname()) {
       transactions = MatchTransactionDao.getMatchingFinancialTransaction(line.getBankStatement()
           .getAccount().getId(), transactionDate, reference,
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/dao/AdvPaymentMngtDao.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/dao/AdvPaymentMngtDao.java	Thu May 09 12:06:37 2013 +0200
@@ -604,7 +604,6 @@
    *          accounting dimension
    * @param user2
    *          accounting dimension
-   * @return
    */
   public FIN_PaymentScheduleDetail getNewPaymentScheduleDetail(Organization organization,
       BigDecimal amount, BusinessPartner businessPartner, Product product, Project project,
@@ -640,7 +639,6 @@
    *          accounting dimension
    * @param salesRegion
    *          accounting dimension
-   * @return
    */
   public FIN_PaymentScheduleDetail getNewPaymentScheduleDetail(Organization organization,
       BigDecimal amount, BusinessPartner businessPartner, Product product, Project project,
@@ -800,6 +798,9 @@
     finTrans.setCurrency(account.getCurrency());
     finTrans.setAccount(account);
     finTrans.setLineNo(line);
+    if (payment != null) {
+      OBDal.getInstance().refresh(payment);
+    }
     finTrans.setFinPayment(payment);
     String truncateDescription = null;
     if (description != null) {
@@ -823,7 +824,6 @@
       finTrans.setForeignConversionRate(convertRate);
       finTrans.setForeignAmount(sourceAmount);
     }
-
     OBDal.getInstance().save(finTrans);
     OBDal.getInstance().flush();
 
@@ -1813,16 +1813,17 @@
         strInvoiceId).getFINPaymentScheduleList();
     OBCriteria<FIN_PaymentScheduleDetail> psdCriteria = OBDal.getInstance().createCriteria(
         FIN_PaymentScheduleDetail.class);
-    if (!paySchedList.isEmpty())
+    if (!paySchedList.isEmpty()) {
       psdCriteria.add(Restrictions.in(FIN_PaymentScheduleDetail.PROPERTY_INVOICEPAYMENTSCHEDULE,
           paySchedList));
-    for (FIN_PaymentScheduleDetail psd : psdCriteria.list()) {
-      if (psd.getPaymentDetails() != null) {
-        FIN_Payment payment = psd.getPaymentDetails().getFinPayment();
-        if ("RPAE".equals(payment.getStatus())
-            && hasNotDeferredExecutionProcess(payment.getAccount(), payment.getPaymentMethod(),
-                payment.isReceipt()))
-          payments.add(payment);
+      for (FIN_PaymentScheduleDetail psd : psdCriteria.list()) {
+        if (psd.getPaymentDetails() != null) {
+          FIN_Payment payment = psd.getPaymentDetails().getFinPayment();
+          if ("RPAE".equals(payment.getStatus())
+              && hasNotDeferredExecutionProcess(payment.getAccount(), payment.getPaymentMethod(),
+                  payment.isReceipt()))
+            payments.add(payment);
+        }
       }
     }
 
@@ -1907,11 +1908,6 @@
   /**
    * Returns the list of credit payments for the selected business partner that belongs to the legal
    * entity's natural tree of the given organization
-   * 
-   * @param org
-   * @param bp
-   * @param isReceipt
-   * @return
    */
   public List<FIN_Payment> getCustomerPaymentsWithCredit(Organization org, BusinessPartner bp,
       boolean isReceipt) {
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java	Thu May 09 12:06:37 2013 +0200
@@ -604,7 +604,7 @@
           return;
         }
         // Reverse Payment
-        if (FIN_Utility.isReversePayment(payment)) {
+        if (strAction.equals("RE") && FIN_Utility.isReversePayment(payment)) {
           msg.setType("Error");
           msg.setTitle(Utility.messageBD(conProvider, "Error", language));
           msg.setMessage(Utility.parseTranslation(conProvider, vars, language,
@@ -793,6 +793,10 @@
                   && BigDecimal.ZERO.compareTo(psd.getWriteoffAmount()) == 0) {
                 paymentDetail.getFINPaymentScheduleDetailList().remove(psd);
                 OBDal.getInstance().getSession().refresh(paymentDetail);
+                psd.getInvoicePaymentSchedule()
+                    .getFINPaymentScheduleDetailInvoicePaymentScheduleList().remove(psd);
+                psd.getOrderPaymentSchedule().getFINPaymentScheduleDetailOrderPaymentScheduleList()
+                    .remove(psd);
                 OBDal.getInstance().remove(psd);
               }
             }
@@ -1189,6 +1193,7 @@
       newConversionRateDoc.setRate(payment.getFinancialTransactionConvertRate());
       newConversionRateDoc.setForeignAmount(payment.getFinancialTransactionAmount());
       newConversionRateDoc.setPayment(payment);
+      newConversionRateDoc.setClient(payment.getClient());
       OBDal.getInstance().save(newConversionRateDoc);
       OBDal.getInstance().flush();
       return newConversionRateDoc;
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_ReconciliationProcess.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_ReconciliationProcess.java	Thu May 09 12:06:37 2013 +0200
@@ -29,10 +29,13 @@
 import org.openbravo.dal.service.OBCriteria;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.database.ConnectionProvider;
+import org.openbravo.erpCommon.ad_forms.AcctServer;
+import org.openbravo.erpCommon.utility.OBDateUtils;
 import org.openbravo.erpCommon.utility.OBError;
 import org.openbravo.erpCommon.utility.Utility;
 import org.openbravo.model.financialmgmt.payment.FIN_BankStatement;
 import org.openbravo.model.financialmgmt.payment.FIN_Reconciliation;
+import org.openbravo.model.financialmgmt.payment.FIN_ReconciliationLine_v;
 import org.openbravo.scheduling.ProcessBundle;
 
 public class FIN_ReconciliationProcess implements org.openbravo.scheduling.Process {
@@ -74,6 +77,26 @@
               "@APRM_ReconciliationNoLines@" + ": " + reconciliation.getDocumentNo()));
           bundle.setResult(msg);
           return;
+        } else {
+          for (FIN_ReconciliationLine_v recLine : reconciliation.getFINReconciliationLineVList()) {
+            boolean orgLegalWithAccounting = FIN_Utility.periodControlOpened(recLine
+                .getFinancialAccountTransaction().getReconciliation().TABLE_NAME, recLine
+                .getFinancialAccountTransaction().getReconciliation().getId(), recLine
+                .getFinancialAccountTransaction().getReconciliation().TABLE_NAME + "_ID", "LE");
+            if (!FIN_Utility.isPeriodOpen(recLine.getFinancialAccountTransaction().getClient()
+                .getId(), AcctServer.DOCTYPE_Reconciliation, recLine
+                .getFinancialAccountTransaction().getOrganization().getId(),
+                OBDateUtils.formatDate(recLine.getFinancialAccountTransaction().getDateAcct()))
+                && orgLegalWithAccounting) {
+              msg.setType("Error");
+              msg.setTitle(Utility.messageBD(conProvider, "Error", language));
+              msg.setMessage(String.format(Utility.parseTranslation(conProvider, vars, language,
+                  "@APRM_PeriodNotAvailableClearedItem@"), recLine.getIdentifier()));
+              bundle.setResult(msg);
+              OBDal.getInstance().rollbackAndClose();
+              return;
+            }
+          }
         }
         reconciliation.setProcessed(true);
         reconciliation.setAPRMProcessReconciliation("R");
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/FIN_Utility.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/FIN_Utility.java	Thu May 09 12:06:37 2013 +0200
@@ -600,10 +600,6 @@
 
   /**
    * Returns the amount of days between two given dates
-   * 
-   * @param endDate
-   * @param beginDate
-   * @return
    */
   public static Long getDaysBetween(Date beginDate, Date endDate) {
     final TimeZone tz = TimeZone.getDefault();
@@ -887,8 +883,6 @@
    *          Currency to convert from
    * @param toCurrency
    *          Currency being converted to
-   * @param conversionDate
-   *          Date conversion is being performed
    * @param documentId
    *          DocumentId to find the value in table c_conversion_rate_document
    * @param entity
@@ -1016,8 +1010,6 @@
    * @param organization
    *          to get its configuration. In case no configuration is available, the invoice's
    *          document number is returned
-   * @param invoice
-   * @return
    */
   public static String getDesiredDocumentNo(final Organization organization, final Invoice invoice) {
     String invoiceDocNo;
@@ -1126,6 +1118,19 @@
     }
   }
 
+  /**
+   * Return true if the period is open for a client, document type, organization and accounting date
+   * 
+   * @param client
+   *          the client for which it wants to know if the period is open
+   * @param documentType
+   *          It is the docbasetype from the document type
+   * @param org
+   *          the Organization for which it wants to know if the period is open
+   * @param dateAcct
+   *          The accounting date from the document
+   * @return boolean
+   */
   public static boolean isPeriodOpen(String client, String documentType, String org, String dateAcct) {
     final Session session = OBDal.getInstance().getSession();
 
--- a/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/FIN_Utilities.js	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/FIN_Utilities.js	Thu May 09 12:06:37 2013 +0200
@@ -286,11 +286,17 @@
   var actualConverted = frm.inpActualConverted;
   var expectedPayment = frm.inpExpectedPayment;
   var actualPayment = frm.inpActualPayment;
+  var exchangeRateValue = exchangeRate.value;
 
   if (actualConverted && expectedConverted && exchangeRate) {
+	   actualConverted.value = formattedNumberOpTemp(actualConverted.value, 'round', precision, roundedMask, globalDecSeparator, globalGroupSeparator, globalGroupInterval);
     if (recalcExchangeRate) {
       if (actualConverted.value && actualPayment.value) {
         if (compare(actualPayment.value, '!=', 0)) {
+          var actualConvertedValue = OB.Utilities.Number.OBMaskedToJS(actualConverted.value, globalDecSeparator, globalGroupSeparator);
+          var actualPaymentValue = OB.Utilities.Number.OBMaskedToJS(actualPayment.value, globalDecSeparator, globalGroupSeparator);
+          exchangeRateValue = (actualConvertedValue/actualPaymentValue).toString();
+          exchangeRateValue = exchangeRateValue.replace('.', globalDecSeparator);
           exchangeRate.value = formattedNumberOpTemp(actualConverted.value, '/', actualPayment.value, roundedMask, globalDecSeparator, globalGroupSeparator, globalGroupInterval);
         }
       } else {
@@ -298,13 +304,13 @@
       }
     } else {
       if (exchangeRate.value) {
-        actualConverted.value = formattedNumberOpTemp(actualPayment.value, '*', exchangeRate.value, roundedMask, globalDecSeparator, globalGroupSeparator, globalGroupInterval);
+        actualConverted.value = formattedNumberOpTemp(actualPayment.value, '*', exchangeRateValue, roundedMask, globalDecSeparator, globalGroupSeparator, globalGroupInterval);
       } else {
         actualConverted.value = applyFormat('0');
       }
     }
     if (exchangeRate.value && expectedPayment.value) {
-      expectedConverted.value = formattedNumberOpTemp(expectedPayment.value, '*', exchangeRate.value, roundedMask, globalDecSeparator, globalGroupSeparator, globalGroupInterval);
+      expectedConverted.value = formattedNumberOpTemp(expectedPayment.value, '*', exchangeRateValue, roundedMask, globalDecSeparator, globalGroupSeparator, globalGroupInterval);
     } else {
       expectedConverted.value = applyFormat('0');
     }
--- a/modules/org.openbravo.base.weld/src-db/database/sourcedata/AD_MODULE.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.base.weld/src-db/database/sourcedata/AD_MODULE.xml	Thu May 09 12:06:37 2013 +0200
@@ -6,7 +6,7 @@
 <!--C70732EA90A14EC0916078B85CC33D2D-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--C70732EA90A14EC0916078B85CC33D2D-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--C70732EA90A14EC0916078B85CC33D2D-->  <NAME><![CDATA[JBoss Weld]]></NAME>
-<!--C70732EA90A14EC0916078B85CC33D2D-->  <VERSION><![CDATA[1.1.20056]]></VERSION>
+<!--C70732EA90A14EC0916078B85CC33D2D-->  <VERSION><![CDATA[1.1.20252]]></VERSION>
 <!--C70732EA90A14EC0916078B85CC33D2D-->  <DESCRIPTION><![CDATA[JBoss Weld]]></DESCRIPTION>
 <!--C70732EA90A14EC0916078B85CC33D2D-->  <HELP><![CDATA[Provides the JBoss Weld framework: Java Contexts and Dependency Injection for the Java EE platform (CDI). For more information see http://seamframework.org/Weld]]></HELP>
 <!--C70732EA90A14EC0916078B85CC33D2D-->  <URL><![CDATA[http://forge.openbravo.com/projects/weld]]></URL>
--- a/modules/org.openbravo.base.weld/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.base.weld/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Thu May 09 12:06:37 2013 +0200
@@ -7,7 +7,7 @@
 <!--8BDE81545C1A43EAAC4BA3C5ED754DC8-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--8BDE81545C1A43EAAC4BA3C5ED754DC8-->  <AD_MODULE_ID><![CDATA[C70732EA90A14EC0916078B85CC33D2D]]></AD_MODULE_ID>
 <!--8BDE81545C1A43EAAC4BA3C5ED754DC8-->  <AD_DEPENDENT_MODULE_ID><![CDATA[0]]></AD_DEPENDENT_MODULE_ID>
-<!--8BDE81545C1A43EAAC4BA3C5ED754DC8-->  <STARTVERSION><![CDATA[3.0.20056]]></STARTVERSION>
+<!--8BDE81545C1A43EAAC4BA3C5ED754DC8-->  <STARTVERSION><![CDATA[3.0.20252]]></STARTVERSION>
 <!--8BDE81545C1A43EAAC4BA3C5ED754DC8-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--8BDE81545C1A43EAAC4BA3C5ED754DC8-->  <DEPENDANT_MODULE_NAME><![CDATA[Core]]></DEPENDANT_MODULE_NAME>
 <!--8BDE81545C1A43EAAC4BA3C5ED754DC8-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
--- a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_COLUMN.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_COLUMN.xml	Thu May 09 12:06:37 2013 +0200
@@ -622,7 +622,7 @@
 <!--178D324AD10947149B7F79F140AA6832-->  <AD_REFERENCE_ID><![CDATA[19]]></AD_REFERENCE_ID>
 <!--178D324AD10947149B7F79F140AA6832-->  <FIELDLENGTH><![CDATA[32]]></FIELDLENGTH>
 <!--178D324AD10947149B7F79F140AA6832-->  <ISKEY><![CDATA[N]]></ISKEY>
-<!--178D324AD10947149B7F79F140AA6832-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--178D324AD10947149B7F79F140AA6832-->  <ISPARENT><![CDATA[Y]]></ISPARENT>
 <!--178D324AD10947149B7F79F140AA6832-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
 <!--178D324AD10947149B7F79F140AA6832-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
 <!--178D324AD10947149B7F79F140AA6832-->  <ISIDENTIFIER><![CDATA[Y]]></ISIDENTIFIER>
--- a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MESSAGE.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MESSAGE.xml	Thu May 09 12:06:37 2013 +0200
@@ -96,6 +96,18 @@
 <!--04E5DFD5293748308CF3ED2848CE8AE4-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--04E5DFD5293748308CF3ED2848CE8AE4--></AD_MESSAGE>
 
+<!--050A887278BB4AF0A40D7FBEC4BFED0D--><AD_MESSAGE>
+<!--050A887278BB4AF0A40D7FBEC4BFED0D-->  <AD_MESSAGE_ID><![CDATA[050A887278BB4AF0A40D7FBEC4BFED0D]]></AD_MESSAGE_ID>
+<!--050A887278BB4AF0A40D7FBEC4BFED0D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--050A887278BB4AF0A40D7FBEC4BFED0D-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--050A887278BB4AF0A40D7FBEC4BFED0D-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--050A887278BB4AF0A40D7FBEC4BFED0D-->  <VALUE><![CDATA[OBUIAPP_WantToCloneRecord]]></VALUE>
+<!--050A887278BB4AF0A40D7FBEC4BFED0D-->  <MSGTEXT><![CDATA[Do you want to clone the selected record?]]></MSGTEXT>
+<!--050A887278BB4AF0A40D7FBEC4BFED0D-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--050A887278BB4AF0A40D7FBEC4BFED0D-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--050A887278BB4AF0A40D7FBEC4BFED0D-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--050A887278BB4AF0A40D7FBEC4BFED0D--></AD_MESSAGE>
+
 <!--07272FCDEEA64054AF2F983D9814EE00--><AD_MESSAGE>
 <!--07272FCDEEA64054AF2F983D9814EE00-->  <AD_MESSAGE_ID><![CDATA[07272FCDEEA64054AF2F983D9814EE00]]></AD_MESSAGE_ID>
 <!--07272FCDEEA64054AF2F983D9814EE00-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -783,6 +795,18 @@
 <!--7410A9E707384D369419188644A31430-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--7410A9E707384D369419188644A31430--></AD_MESSAGE>
 
+<!--744877846A1D4E3EAD6F4BFF308C148D--><AD_MESSAGE>
+<!--744877846A1D4E3EAD6F4BFF308C148D-->  <AD_MESSAGE_ID><![CDATA[744877846A1D4E3EAD6F4BFF308C148D]]></AD_MESSAGE_ID>
+<!--744877846A1D4E3EAD6F4BFF308C148D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--744877846A1D4E3EAD6F4BFF308C148D-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--744877846A1D4E3EAD6F4BFF308C148D-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--744877846A1D4E3EAD6F4BFF308C148D-->  <VALUE><![CDATA[OBUIAPP_FillMandatoryFields]]></VALUE>
+<!--744877846A1D4E3EAD6F4BFF308C148D-->  <MSGTEXT><![CDATA[Few mandatory fields have not been filled. Refer lines]]></MSGTEXT>
+<!--744877846A1D4E3EAD6F4BFF308C148D-->  <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--744877846A1D4E3EAD6F4BFF308C148D-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--744877846A1D4E3EAD6F4BFF308C148D-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--744877846A1D4E3EAD6F4BFF308C148D--></AD_MESSAGE>
+
 <!--75E47FA30B8D438E9569B4C688E863EB--><AD_MESSAGE>
 <!--75E47FA30B8D438E9569B4C688E863EB-->  <AD_MESSAGE_ID><![CDATA[75E47FA30B8D438E9569B4C688E863EB]]></AD_MESSAGE_ID>
 <!--75E47FA30B8D438E9569B4C688E863EB-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MODULE.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MODULE.xml	Thu May 09 12:06:37 2013 +0200
@@ -6,7 +6,7 @@
 <!--9BA0836A3CD74EE4AB48753A47211BCC-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--9BA0836A3CD74EE4AB48753A47211BCC-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--9BA0836A3CD74EE4AB48753A47211BCC-->  <NAME><![CDATA[User Interface Application]]></NAME>
-<!--9BA0836A3CD74EE4AB48753A47211BCC-->  <VERSION><![CDATA[2.1.20056]]></VERSION>
+<!--9BA0836A3CD74EE4AB48753A47211BCC-->  <VERSION><![CDATA[2.1.20252]]></VERSION>
 <!--9BA0836A3CD74EE4AB48753A47211BCC-->  <DESCRIPTION><![CDATA[Provides the main application components for the openbravo user interface]]></DESCRIPTION>
 <!--9BA0836A3CD74EE4AB48753A47211BCC-->  <HELP><![CDATA[Provides the main application components for the openbravo user interface. The main layout incorporates a navigation bar and a main view area.]]></HELP>
 <!--9BA0836A3CD74EE4AB48753A47211BCC-->  <URL><![CDATA[http://forge.openbravo.com/projects/clientapplication]]></URL>
--- a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Thu May 09 12:06:37 2013 +0200
@@ -7,7 +7,7 @@
 <!--15D7CE8D95D043189162DBABA54A1F61-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--15D7CE8D95D043189162DBABA54A1F61-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
 <!--15D7CE8D95D043189162DBABA54A1F61-->  <AD_DEPENDENT_MODULE_ID><![CDATA[A44B9BA75C354D8FB2E3F7D6EB6BFDC4]]></AD_DEPENDENT_MODULE_ID>
-<!--15D7CE8D95D043189162DBABA54A1F61-->  <STARTVERSION><![CDATA[2.1.20056]]></STARTVERSION>
+<!--15D7CE8D95D043189162DBABA54A1F61-->  <STARTVERSION><![CDATA[2.1.20252]]></STARTVERSION>
 <!--15D7CE8D95D043189162DBABA54A1F61-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--15D7CE8D95D043189162DBABA54A1F61-->  <DEPENDANT_MODULE_NAME><![CDATA[JSON Datasource]]></DEPENDANT_MODULE_NAME>
 <!--15D7CE8D95D043189162DBABA54A1F61-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
@@ -21,7 +21,7 @@
 <!--60A170212F36499D83B8AD38D01F46B3-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--60A170212F36499D83B8AD38D01F46B3-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
 <!--60A170212F36499D83B8AD38D01F46B3-->  <AD_DEPENDENT_MODULE_ID><![CDATA[4B828F4D03264080AA1D2057B13F613C]]></AD_DEPENDENT_MODULE_ID>
-<!--60A170212F36499D83B8AD38D01F46B3-->  <STARTVERSION><![CDATA[2.1.20056]]></STARTVERSION>
+<!--60A170212F36499D83B8AD38D01F46B3-->  <STARTVERSION><![CDATA[2.1.20252]]></STARTVERSION>
 <!--60A170212F36499D83B8AD38D01F46B3-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--60A170212F36499D83B8AD38D01F46B3-->  <DEPENDANT_MODULE_NAME><![CDATA[User Interface Client Kernel]]></DEPENDANT_MODULE_NAME>
 <!--60A170212F36499D83B8AD38D01F46B3-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
@@ -35,7 +35,7 @@
 <!--824D60CB352E4099B1D8C903CA139DAE-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--824D60CB352E4099B1D8C903CA139DAE-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
 <!--824D60CB352E4099B1D8C903CA139DAE-->  <AD_DEPENDENT_MODULE_ID><![CDATA[0]]></AD_DEPENDENT_MODULE_ID>
-<!--824D60CB352E4099B1D8C903CA139DAE-->  <STARTVERSION><![CDATA[3.0.20056]]></STARTVERSION>
+<!--824D60CB352E4099B1D8C903CA139DAE-->  <STARTVERSION><![CDATA[3.0.20252]]></STARTVERSION>
 <!--824D60CB352E4099B1D8C903CA139DAE-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--824D60CB352E4099B1D8C903CA139DAE-->  <DEPENDANT_MODULE_NAME><![CDATA[core]]></DEPENDANT_MODULE_NAME>
 <!--824D60CB352E4099B1D8C903CA139DAE-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
@@ -49,7 +49,7 @@
 <!--E8FD820AFE3D4FE08C02FC47769026AD-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--E8FD820AFE3D4FE08C02FC47769026AD-->  <AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
 <!--E8FD820AFE3D4FE08C02FC47769026AD-->  <AD_DEPENDENT_MODULE_ID><![CDATA[EC356CEE3D46416CA1EBEEB9AB82EDB9]]></AD_DEPENDENT_MODULE_ID>
-<!--E8FD820AFE3D4FE08C02FC47769026AD-->  <STARTVERSION><![CDATA[8.1.20056]]></STARTVERSION>
+<!--E8FD820AFE3D4FE08C02FC47769026AD-->  <STARTVERSION><![CDATA[8.1.20252]]></STARTVERSION>
 <!--E8FD820AFE3D4FE08C02FC47769026AD-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--E8FD820AFE3D4FE08C02FC47769026AD-->  <DEPENDANT_MODULE_NAME><![CDATA[Smartclient]]></DEPENDANT_MODULE_NAME>
 <!--E8FD820AFE3D4FE08C02FC47769026AD-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/AlertActionHandler.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/AlertActionHandler.java	Thu May 09 12:06:37 2013 +0200
@@ -40,6 +40,7 @@
 import org.openbravo.erpCommon.utility.UsedByLink;
 import org.openbravo.model.ad.alert.AlertRecipient;
 import org.openbravo.model.ad.alert.AlertRule;
+import org.openbravo.portal.PortalAccessible;
 import org.openbravo.service.db.DalConnectionProvider;
 import org.openbravo.service.json.JsonConstants;
 
@@ -52,7 +53,7 @@
  * @see StaticResourceComponent
  */
 @ApplicationScoped
-public class AlertActionHandler extends BaseActionHandler {
+public class AlertActionHandler extends BaseActionHandler implements PortalAccessible {
   private static final Logger log4j = Logger.getLogger(AlertActionHandler.class);
 
   /*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/GlobalMenu.java	Thu May 09 12:06:37 2013 +0200
@@ -0,0 +1,289 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2013 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.client.application;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.enterprise.context.ApplicationScoped;
+
+import org.hibernate.Query;
+import org.hibernate.criterion.Restrictions;
+import org.openbravo.client.application.MenuManager.MenuEntryType;
+import org.openbravo.client.application.MenuManager.MenuOption;
+import org.openbravo.dal.service.OBCriteria;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.ad.access.Role;
+import org.openbravo.model.ad.domain.ModelImplementation;
+import org.openbravo.model.ad.domain.ModelImplementationMapping;
+import org.openbravo.model.ad.ui.Menu;
+import org.openbravo.model.ad.ui.Process;
+import org.openbravo.model.ad.ui.Tab;
+import org.openbravo.model.ad.utility.Tree;
+import org.openbravo.model.ad.utility.TreeNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 
+ * Caches in memory generic global menus per language and tree to be consumed by {@link MenuManager}
+ * 
+ * @author alostale
+ * 
+ */
+@ApplicationScoped
+public class GlobalMenu {
+  private static final Logger log = LoggerFactory.getLogger(GlobalMenu.class);
+
+  private Map<String, List<MenuOption>> menuOptionsByLangAndTree = null;
+
+  private long cacheTimeStamp = 0;
+
+  /**
+   * Returns the menu for current role's tree and language looking in the application scoped cached
+   * ones. If it is not present there, it is generated and cached.
+   * 
+   */
+  synchronized List<MenuOption> getMenuOptions(String roleId, String language) {
+    long t = System.currentTimeMillis();
+
+    if (menuOptionsByLangAndTree == null) {
+      invalidateCache();
+    }
+
+    Role role = OBDal.getInstance().get(Role.class, roleId);
+    final Tree tree;
+    if (role.getPrimaryTreeMenu() != null) {
+      tree = role.getPrimaryTreeMenu();
+    } else {
+      tree = OBDal.getInstance().get(Tree.class, "10");
+    }
+
+    String menuKey = language + tree.getId();
+    if (menuOptionsByLangAndTree.get(menuKey) == null) {
+      menuOptionsByLangAndTree.put(menuKey, createInitialMenuList(tree, language));
+      log.info("Generating menu took " + (System.currentTimeMillis() - t));
+      t = System.currentTimeMillis();
+    } else {
+      log.debug("Using cached menu for tree and language");
+    }
+
+    ArrayList<MenuOption> newOptions = new ArrayList<MenuOption>();
+    final Map<String, MenuOption> menuOptionsByMenuId = new HashMap<String, MenuOption>();
+    for (MenuOption option : menuOptionsByLangAndTree.get(menuKey)) {
+      final MenuOption clonedMenuOption = new MenuOption(option);
+
+      if (clonedMenuOption.getMenu() != null) {
+        menuOptionsByMenuId.put(clonedMenuOption.getMenu().getId(), clonedMenuOption);
+      }
+      newOptions.add(clonedMenuOption);
+    }
+
+    // Tree is generated in the cloned instances to refer to itself and not to the pristine one
+    for (MenuOption menuOption : newOptions) {
+      menuOption.setParentMenuOption(menuOptionsByMenuId);
+    }
+
+    log.debug("Getting a copy of globally cached menu took {} ms", System.currentTimeMillis());
+    return newOptions;
+  }
+
+  private List<MenuOption> createInitialMenuList(Tree tree, String language) {
+    List<MenuOption> menuOptions = new ArrayList<MenuOption>();
+    OBCriteria<TreeNode> treeNodes = OBDal.getInstance().createCriteria(TreeNode.class);
+    treeNodes.add(Restrictions.eq(TreeNode.PROPERTY_TREE, tree));
+    treeNodes.setFilterOnActive(false);
+
+    // Cache in DAL session all menu entries in a single query, so no need to query one by one
+    // afterwards
+    final String menuHql = "select m from ADMenu m left join fetch m.aDMenuTrlList where m.module.enabled=true";
+    final Query menuQry = OBDal.getInstance().getSession().createQuery(menuHql);
+    @SuppressWarnings("unchecked")
+    List<Menu> menus = (List<Menu>) menuQry.list();
+
+    List<TreeNode> nodes = treeNodes.list();
+
+    for (TreeNode treeNode : nodes) {
+      boolean addOption = treeNode.isActive();
+
+      if (!addOption) {
+        Menu menuEntry = OBDal.getInstance().get(Menu.class, treeNode.getNode());
+        if (menuEntry != null) {
+          addOption = menuEntry.isSummaryLevel();
+        }
+      }
+
+      if (addOption) {
+        final MenuOption menuOption = new MenuOption();
+        menuOption.setTreeNode(treeNode);
+        menuOption.setDbId(treeNode.getId());
+        Menu menuEntry = OBDal.getInstance().get(Menu.class, treeNode.getNode());
+        if (menuEntry != null && !menuEntry.isActive()) {
+          menuOption.setVisible(false);
+        }
+        menuOptions.add(menuOption);
+      }
+    }
+
+    linkMenus(menus, menuOptions, language);
+
+    // sort them by sequencenumber of the treenode
+    Collections.sort(menuOptions, new MenuSequenceComparator());
+
+    return menuOptions;
+  }
+
+  /**
+   * Each menu option is configured with additional paramters
+   * 
+   */
+  private void linkMenus(List<Menu> menus, List<MenuOption> menuOptions, String language) {
+    final Map<String, MenuOption> menuOptionsByNodeId = new HashMap<String, MenuOption>();
+    for (MenuOption menuOption : menuOptions) {
+      menuOptionsByNodeId.put(menuOption.getTreeNode().getNode(), menuOption);
+    }
+
+    for (Menu menu : menus) {
+      final MenuOption foundOption = menuOptionsByNodeId.get(menu.getId());
+      if (menu.isActive() || menu.isSummaryLevel()) {
+        if (foundOption != null) {
+          foundOption.setMenu(menu, language);
+          if (menu.getURL() != null) {
+            foundOption.setType(MenuEntryType.External);
+            foundOption.setId(menu.getURL());
+          } else if (menu.getObuiappView() != null && menu.getObuiappView().isActive()) {
+            foundOption.setType(MenuEntryType.View);
+            foundOption.setId(menu.getObuiappView().getName());
+            foundOption.setObjectId(menu.getObuiappView().getId());
+          } else if (menu.getSpecialForm() != null && menu.getSpecialForm().isActive()) {
+            boolean found = false;
+            for (ModelImplementation mi : menu.getSpecialForm().getADModelImplementationList()) {
+              if (found) {
+                break;
+              }
+              for (ModelImplementationMapping mim : mi.getADModelImplementationMappingList()) {
+                if (mim.isDefault()) {
+                  found = true;
+                  foundOption.setType(MenuEntryType.Form);
+                  foundOption.setForm(menu.getSpecialForm());
+                  foundOption.setId(mim.getMappingName());
+                  foundOption.setObjectId(menu.getSpecialForm().getId());
+                  break;
+                }
+              }
+            }
+          } else if (menu.getProcess() != null && menu.getProcess().isActive()) {
+            Process process = menu.getProcess();
+            boolean found = false;
+
+            for (ModelImplementation mi : process.getADModelImplementationList()) {
+              if (found) {
+                break;
+              }
+              for (ModelImplementationMapping mim : mi.getADModelImplementationMappingList()) {
+                if (mim.isDefault()) {
+                  found = true;
+                  foundOption.setId(mim.getMappingName());
+                  foundOption.setObjectId(process.getId());
+                  if (process.getUIPattern().equals("Standard")) {
+                    foundOption.setType(MenuEntryType.Process);
+                  } else if (process.isReport() || process.isJasperReport()) {
+                    foundOption.setType(MenuEntryType.Report);
+                    foundOption.setReport(true);
+                  } else {
+                    foundOption.setType(MenuEntryType.ProcessManual);
+                  }
+                  break;
+                }
+              }
+            }
+            if (!found && "P".equals(menu.getAction())) {
+              foundOption.setType(MenuEntryType.Process);
+              foundOption.setObjectId(process.getId());
+              if (process.isExternalService() != null && process.isExternalService()
+                  && "PS".equals(process.getServiceType())) {
+                foundOption.setId("/utility/OpenPentaho.html?inpadProcessId=" + process.getId());
+              } else if ("S".equals(process.getUIPattern()) && !process.isJasperReport()
+                  && process.getProcedure() == null) {
+                // see the MenuData.isGenericJavaProcess method
+                foundOption.setId("/ad_actionButton/ActionButtonJava_Responser.html");
+              } else {
+                foundOption.setId("/ad_actionButton/ActionButton_Responser.html");
+              }
+            }
+          } else if (menu.getOBUIAPPProcessDefinition() != null
+              && menu.getOBUIAPPProcessDefinition().isActive()) {
+            foundOption.setType(MenuEntryType.ProcessDefinition);
+            foundOption.setObjectId(menu.getOBUIAPPProcessDefinition().getId());
+          } else if (menu.getWindow() != null && menu.getWindow().isActive()) {
+            boolean found = false;
+            for (Tab tab : menu.getWindow().getADTabList()) {
+              if (tab.getTabLevel() == 0) {
+                found = true;
+                foundOption.setType(MenuEntryType.Window);
+                foundOption.setId(tab.getId());
+                foundOption.setObjectId(menu.getWindow().getId());
+                foundOption.setTab(tab);
+                break;
+              }
+            }
+            if (!found) {
+              log.warn("Not found tab with level 0 for window {}", menu.getWindow());
+            }
+          }
+        }
+      }
+    }
+  }
+
+  /**
+   * Sorts menu based on its nodes sequence
+   * 
+   */
+  private static class MenuSequenceComparator implements Comparator<MenuOption> {
+    @Override
+    public int compare(MenuOption o1, MenuOption o2) {
+      TreeNode tn1 = o1.getTreeNode();
+      TreeNode tn2 = o2.getTreeNode();
+      return (int) (tn1.getSequenceNumber() - tn2.getSequenceNumber());
+    }
+  }
+
+  /**
+   * Invalidates menu cache. To be invoked when the menu changes.
+   */
+  public void invalidateCache() {
+    log.info("Invalidating menu cache");
+    menuOptionsByLangAndTree = new HashMap<String, List<MenuOption>>();
+    cacheTimeStamp = System.currentTimeMillis();
+  }
+
+  /**
+   * Whenever the cache is regenerated time stamp is changed to check differences
+   * 
+   */
+  public long getCacheTimeStamp() {
+    return cacheTimeStamp;
+  }
+}
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/HeartBeatPopupActionHandler.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/HeartBeatPopupActionHandler.java	Thu May 09 12:06:37 2013 +0200
@@ -43,6 +43,7 @@
 import org.openbravo.erpCommon.businessUtility.Preferences;
 import org.openbravo.erpCommon.utility.PropertyException;
 import org.openbravo.model.ad.module.Module;
+import org.openbravo.portal.PortalAccessible;
 import org.openbravo.service.db.DalConnectionProvider;
 
 /**
@@ -52,7 +53,7 @@
  * @see StaticResourceComponent
  */
 @ApplicationScoped
-public class HeartBeatPopupActionHandler extends BaseActionHandler {
+public class HeartBeatPopupActionHandler extends BaseActionHandler implements PortalAccessible {
   private static final Logger log = Logger.getLogger(HeartBeatPopupActionHandler.class);
   private static final String APRM_MIGRATION_TOOL_ID = "4BD3D4B262B048518FE62496EF09D549";
 
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/LogOutActionHandler.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/LogOutActionHandler.java	Thu May 09 12:06:37 2013 +0200
@@ -25,9 +25,10 @@
 
 import org.codehaus.jettison.json.JSONObject;
 import org.openbravo.client.kernel.BaseActionHandler;
+import org.openbravo.client.kernel.BaseKernelServlet.KernelHttpServletResponse;
 import org.openbravo.client.kernel.RequestContext;
 import org.openbravo.client.kernel.StaticResourceComponent;
-import org.openbravo.client.kernel.BaseKernelServlet.KernelHttpServletResponse;
+import org.openbravo.portal.PortalAccessible;
 
 /**
  * Is responsible for logging out from the application.
@@ -36,7 +37,7 @@
  * @see StaticResourceComponent
  */
 @ApplicationScoped
-public class LogOutActionHandler extends BaseActionHandler {
+public class LogOutActionHandler extends BaseActionHandler implements PortalAccessible {
 
   /*
    * (non-Javadoc)
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/MenuManager.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/MenuManager.java	Thu May 09 12:06:37 2013 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2012 Openbravo SLU
+ * All portions are Copyright (C) 2010-2013 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -22,68 +22,79 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 import javax.enterprise.context.SessionScoped;
+import javax.inject.Inject;
 
 import org.hibernate.Hibernate;
 import org.hibernate.Query;
-import org.hibernate.criterion.Restrictions;
 import org.openbravo.base.session.SessionFactoryController;
 import org.openbravo.dal.core.DalUtil;
 import org.openbravo.dal.core.OBContext;
-import org.openbravo.dal.service.OBCriteria;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.erpCommon.obps.ActivationKey;
 import org.openbravo.erpCommon.obps.ActivationKey.FeatureRestriction;
 import org.openbravo.erpCommon.utility.Utility;
-import org.openbravo.model.ad.access.Role;
-import org.openbravo.model.ad.domain.ModelImplementationMapping;
 import org.openbravo.model.ad.ui.Form;
 import org.openbravo.model.ad.ui.Menu;
 import org.openbravo.model.ad.ui.MenuTrl;
 import org.openbravo.model.ad.ui.Tab;
-import org.openbravo.model.ad.ui.Window;
-import org.openbravo.model.ad.utility.Tree;
 import org.openbravo.model.ad.utility.TreeNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
- * Reads the menu from the database and caches it in memory for easy consumption by components.
+ * Configures cached global menu (@see {@link GlobalMenu}) to adapt it to the current session's
+ * permissions and caches it in memory for easy consumption by components. Reads the menu from the
  * 
  * @author mtaal
  */
 @SessionScoped
 public class MenuManager implements Serializable {
-
+  private static final Logger log = LoggerFactory.getLogger(MenuManager.class);
   private static final long serialVersionUID = 1L;
 
   public static enum MenuEntryType {
     Window, Process, ProcessManual, Report, Form, External, Summary, View, ProcessDefinition
   };
 
+  /**
+   * Points to globally cached generic menu
+   */
+  @Inject
+  private GlobalMenu globalMenuOptions;
+
   private MenuOption cachedMenu;
   private List<MenuOption> selectableMenuOptions;
   private String roleId;
   private List<MenuOption> menuOptions;
 
+  private long cacheTimeStamp = 0;
+
   public synchronized MenuOption getMenu() {
+    long t = System.currentTimeMillis();
     if (cachedMenu == null || roleId == null
-        || !roleId.equals(OBContext.getOBContext().getRole().getId())) {
+        || !roleId.equals(OBContext.getOBContext().getRole().getId())
+        || cacheTimeStamp != globalMenuOptions.getCacheTimeStamp()) {
 
       // set the current RoleId
       roleId = OBContext.getOBContext().getRole().getId();
 
       OBContext.setAdminMode();
       try {
+        // take from global menus the one for current role and language
+        menuOptions = globalMenuOptions.getMenuOptions(roleId, OBContext.getOBContext()
+            .getLanguage().getId());
+        cacheTimeStamp = globalMenuOptions.getCacheTimeStamp();
 
-        createInitialMenuList();
-
+        // configure global menu with role permissions
         linkWindows();
         linkProcesses();
         linkForms();
         linkProcessDefinition();
+        linkViewDefinition();
 
         removeInvisibleNodes();
         removeInaccessibleNodes();
@@ -107,256 +118,124 @@
       } finally {
         OBContext.restorePreviousMode();
       }
+    } else {
+      log.debug("Cached menu");
     }
+    log.debug("getMenu took {} ms", System.currentTimeMillis() - t);
     return cachedMenu;
   }
 
   @SuppressWarnings("unchecked")
-  private void linkMenus() {
-    final String menuHql = "select m from ADMenu m left join fetch m.aDMenuTrlList where m.module.enabled=true";
-    final Query menuQry = OBDal.getInstance().getSession().createQuery(menuHql);
-    final Map<String, MenuOption> menuOptionsByNodeId = new HashMap<String, MenuOption>();
-    for (MenuOption menuOption : menuOptions) {
-      menuOptionsByNodeId.put(menuOption.getTreeNode().getNode(), menuOption);
-    }
-    for (Menu menu : (List<Menu>) menuQry.list()) {
-      final MenuOption foundOption = menuOptionsByNodeId.get(menu.getId());
-      if (menu.isActive() || menu.isSummaryLevel()) {
-        if (foundOption != null) {
-          foundOption.setMenu(menu);
-          if (menu.getURL() != null) {
-            foundOption.setType(MenuEntryType.External);
-            foundOption.setId(menu.getURL());
-          }
-          if (menu.getObuiappView() != null && menu.getObuiappView().isActive()
-              && isValidForCurrentUserRole(menu.getObuiappView())) {
-            foundOption.setType(MenuEntryType.View);
-            foundOption.setId(menu.getObuiappView().getName());
-          }
-        }
+  private void linkForms() {
+    final String formsHql = "select fa.specialForm.id " + //
+        " from ADFormAccess fa " + //
+        "where fa.role.id=:roleId";
+
+    final Query formsQry = OBDal.getInstance().getSession().createQuery(formsHql);
+    formsQry.setParameter("roleId", OBContext.getOBContext().getRole().getId());
+
+    for (String formId : (List<String>) formsQry.list()) {
+      MenuOption option = getMenuOptionByType(MenuEntryType.Form, formId);
+      if (option != null) {
+        // allow access if not running in a webcontainer as then the config file can not be checked
+        boolean hasAccess = !SessionFactoryController.isRunningInWebContainer()
+            || ActivationKey.getInstance().hasLicenseAccess("X", formId) == FeatureRestriction.NO_RESTRICTION;
+        option.setAccessGranted(hasAccess);
       }
     }
   }
 
-  private boolean isValidForCurrentUserRole(OBUIAPPViewImplementation view) {
-    for (ViewRoleAccess access : view.getObuiappViewRoleAccessList()) {
-      final String accessRoleId = (String) DalUtil.getId(access.getRole());
-      if (access.isActive() && roleId.equals(accessRoleId)) {
-        return true;
-      }
-    }
-    return false;
-  }
+  @SuppressWarnings("unchecked")
+  private void linkProcesses() {
+    final String allowedProcessHql = "select pa.process.id " + //
+        " from ADProcessAccess pa " + //
+        "where pa.role = :role";
 
-  private void linkForms() {
-    final String formsHql = "select f, amim from ADForm f, ADModelImplementation ami, ADModelImplementationMapping amim, ADFormAccess afa "
-        + "where afa.role.id=:roleId and f.active = true and afa.specialForm = f and ami.specialForm=f and amim.modelObject=ami and amim.default=true";
-    final Query formsQry = OBDal.getInstance().getSession().createQuery(formsHql);
-    formsQry.setParameter("roleId", OBContext.getOBContext().getRole().getId());
-    // force a load
-    final List<?> list = formsQry.list();
+    final Query allowedProcessQry = OBDal.getInstance().getSession().createQuery(allowedProcessHql);
+    allowedProcessQry.setParameter("role", OBContext.getOBContext().getRole());
 
-    final Map<String, MenuOption> menuOptionsByFormId = new HashMap<String, MenuOption>();
-    for (MenuOption menuOption : menuOptions) {
-      if (menuOption.getMenu() != null && menuOption.getMenu().getSpecialForm() != null) {
+    for (String processId : (List<String>) allowedProcessQry.list()) {
+      MenuOption option = getMenuOptionByType(MenuEntryType.Process, processId);
+      if (option != null) {
         // allow access if not running in a webcontainer as then the config file can not be checked
         boolean hasAccess = !SessionFactoryController.isRunningInWebContainer()
-            || ActivationKey.getInstance().hasLicenseAccess("X",
-                menuOption.getMenu().getSpecialForm().getId()) == FeatureRestriction.NO_RESTRICTION;
-        if (hasAccess) {
-          menuOptionsByFormId.put(menuOption.getMenu().getSpecialForm().getId(), menuOption);
-        }
-      }
-    }
-
-    for (Object object : list) {
-      final Object[] values = (Object[]) object;
-      final Form form = (Form) values[0];
-      final ModelImplementationMapping mim = (ModelImplementationMapping) values[1];
-      final MenuOption menuOption = menuOptionsByFormId.get(form.getId());
-      if (menuOption != null) {
-        menuOption.setType(MenuEntryType.Form);
-        menuOption.setId(mim.getMappingName());
-        menuOption.setForm(form);
-      }
-    }
-  }
-
-  private void linkProcesses() {
-
-    // collect the valid tabs/windows
-    final String allowedProcessHql = "select p from ADProcess p, ADProcessAccess apa "
-        + "where apa.role.id=:roleId and p.active = true and apa.process = p";
-    final Query allowedProcessQry = OBDal.getInstance().getSession().createQuery(allowedProcessHql);
-    allowedProcessQry.setParameter("roleId", OBContext.getOBContext().getRole().getId());
-    final Map<String, org.openbravo.model.ad.ui.Process> allowedProcesses = new HashMap<String, org.openbravo.model.ad.ui.Process>();
-    for (Object processObj : allowedProcessQry.list()) {
-      // allow access if not running in a web container
-      boolean hasAccess = !SessionFactoryController.isRunningInWebContainer()
-          || ActivationKey.getInstance().hasLicenseAccess("P",
-              ((org.openbravo.model.ad.ui.Process) processObj).getId()) == FeatureRestriction.NO_RESTRICTION;
-      if (hasAccess) {
-        allowedProcesses.put(((org.openbravo.model.ad.ui.Process) processObj).getId(),
-            (org.openbravo.model.ad.ui.Process) processObj);
-      }
-    }
-
-    final String processHql = "select p, amim from ADProcess p, ADModelImplementation ami, ADModelImplementationMapping amim, ADProcessAccess apa "
-        + "where apa.role.id=:roleId and p.active = true and apa.process = p and ami.process=p and ami.default=true and amim.modelObject=ami and amim.default=true";
-    final Query processQry = OBDal.getInstance().getSession().createQuery(processHql);
-    processQry.setParameter("roleId", OBContext.getOBContext().getRole().getId());
-    // force a load
-    final List<?> list = processQry.list();
-
-    final Map<String, MenuOption> menuOptionsByProcessId = new HashMap<String, MenuOption>();
-    for (MenuOption menuOption : menuOptions) {
-      if (menuOption.getMenu() != null && menuOption.getMenu().getProcess() != null
-          && allowedProcesses.containsKey(menuOption.getMenu().getProcess().getId())) {
-        menuOptionsByProcessId.put(menuOption.getMenu().getProcess().getId(), menuOption);
-      }
-    }
-
-    for (Object object : list) {
-      final Object[] values = (Object[]) object;
-      final org.openbravo.model.ad.ui.Process process = (org.openbravo.model.ad.ui.Process) values[0];
-      final ModelImplementationMapping mim = (ModelImplementationMapping) values[1];
-      final MenuOption menuOption = menuOptionsByProcessId.get(process.getId());
-      if (menuOption != null) {
-        if (process.getUIPattern().equals("Standard")) {
-          menuOption.setType(MenuEntryType.Process);
-        } else if (process.isReport() || process.isJasperReport()) {
-          menuOption.setType(MenuEntryType.Report);
-          menuOption.setReport(true);
-        } else {
-          menuOption.setType(MenuEntryType.ProcessManual);
-        }
-        menuOption.setId(mim.getMappingName());
-      }
-    }
-
-    // note this logic is based on the VerticalMenu.getUrlString method:
-    // } else if (action.equals("P")) {
-    // if (isExternalService.equals("Y") && externalType.equals("PS"))
-    // strResultado.append("/utility/OpenPentaho.html?inpadProcessId=").append(adProcessId);
-    // else {
-    // try {
-    // if (MenuData.isGenericJavaProcess(this, adProcessId))
-    // strResultado.append(
-    // "/ad_actionButton/ActionButtonJava_Responser.html?inpadProcessId=").append(
-    // adProcessId);
-    // else
-    // strResultado.append("/ad_actionButton/ActionButton_Responser.html?inpadProcessId=")
-    // .append(adProcessId);
-    // } catch (final Exception e) {
-    // e.printStackTrace();
-    // strResultado.append("/ad_actionButton/ActionButton_Responser.html?inpadProcessId=")
-    // .append(adProcessId);
-    // }
-    // }
-
-    for (String processId : menuOptionsByProcessId.keySet()) {
-      final MenuOption menuOption = menuOptionsByProcessId.get(processId);
-      final org.openbravo.model.ad.ui.Process process = allowedProcesses.get(processId);
-
-      if (menuOption.getId() == null && menuOption.getMenu() != null
-          && menuOption.getMenu().getAction().equals("P")) {
-        if (process.isExternalService() != null && process.isExternalService()
-            && "PS".equals(process.getServiceType())) {
-          menuOption.setType(MenuEntryType.Process);
-          menuOption.setId("/utility/OpenPentaho.html?inpadProcessId=" + processId);
-        } else if ("S".equals(process.getUIPattern()) && !process.isJasperReport()
-            && process.getProcedure() == null) {
-          // see the MenuData.isGenericJavaProcess method
-          menuOption.setType(MenuEntryType.Process);
-          menuOption.setId("/ad_actionButton/ActionButtonJava_Responser.html");
-        } else {
-          menuOption.setType(MenuEntryType.Process);
-          menuOption.setId("/ad_actionButton/ActionButton_Responser.html");
-        }
+            || ActivationKey.getInstance().hasLicenseAccess("P", processId) == FeatureRestriction.NO_RESTRICTION;
+        option.setAccessGranted(hasAccess);
       }
     }
   }
 
   @SuppressWarnings("unchecked")
   private void linkProcessDefinition() {
-    String processHql = "select p " + //
-        " from OBUIAPP_Process p, OBUIAPP_Process_Access pa " + //
-        "where pa.obuiappProcess = p " + //
-        "  and p.active = true " + //
-        "  and pa.active = true " + //
-        "  and pa.role = :role";
+    final String processHql = "select pa.obuiappProcess.id " + //
+        " from OBUIAPP_Process_Access pa " + //
+        "where pa.role = :role" + //
+        "  and pa.active = true ";
     final Query processQry = OBDal.getInstance().getSession().createQuery(processHql);
     processQry.setParameter("role", OBContext.getOBContext().getRole());
-    final List<?> list = processQry.list();
-    // force load
 
-    final Map<String, MenuOption> menuOptionsProcessId = new HashMap<String, MenuOption>();
-    for (MenuOption menuOption : menuOptions) {
-      if (menuOption.getMenu() != null
-          && menuOption.getMenu().getOBUIAPPProcessDefinition() != null) {
-        menuOptionsProcessId.put(menuOption.getMenu().getOBUIAPPProcessDefinition().getId(),
-            menuOption);
+    for (String processId : (List<String>) processQry.list()) {
+      MenuOption option = getMenuOptionByType(MenuEntryType.ProcessDefinition, processId);
+      if (option != null) {
+        option.setAccessGranted(true);
       }
     }
+  }
 
-    for (org.openbravo.client.application.Process process : (List<org.openbravo.client.application.Process>) list) {
-      MenuOption option = menuOptionsProcessId.get(process.getId());
+  @SuppressWarnings("unchecked")
+  private void linkViewDefinition() {
+    final String processHql = "select va.viewImplementation.id " + //
+        " from obuiapp_ViewRoleAccess va " + //
+        "where va.role = :role" + //
+        "  and va.active = true ";
+    final Query processQry = OBDal.getInstance().getSession().createQuery(processHql);
+    processQry.setParameter("role", OBContext.getOBContext().getRole());
+
+    for (String processId : (List<String>) processQry.list()) {
+      MenuOption option = getMenuOptionByType(MenuEntryType.View, processId);
       if (option != null) {
-        option.setType(MenuEntryType.ProcessDefinition);
+        option.setAccessGranted(true);
       }
     }
   }
 
   @SuppressWarnings("unchecked")
   private void linkWindows() {
-    // collect the valid tabs/windows
-    final String tabsHql = "select t from ADTab t join fetch t.window w join fetch t.table, ADWindowAccess awa "
-        + "where awa.role.id=:roleId and t.active = true and w.active = true and w = awa.window and t.tabLevel = 0";
-    final Query tabsQry = OBDal.getInstance().getSession().createQuery(tabsHql);
-    tabsQry.setParameter("roleId", OBContext.getOBContext().getRole().getId());
-    // force a load
-    final List<?> list = tabsQry.list();
+    final String windowsHql = "select wa.window.id " + //
+        " from ADWindowAccess wa " + //
+        "where wa.role = :role" + //
+        "  and wa.active = true ";
+    final Query windowsQry = OBDal.getInstance().getSession().createQuery(windowsHql);
+    windowsQry.setParameter("role", OBContext.getOBContext().getRole());
 
-    final Map<String, List<MenuOption>> menuOptionsByWindowId = new HashMap<String, List<MenuOption>>();
-    for (MenuOption menuOption : menuOptions) {
-      if (menuOption.getMenu() != null && menuOption.getMenu().getWindow() != null) {
-        // allow access if not running in a web container
+    for (String windowId : (List<String>) windowsQry.list()) {
+      MenuOption option = getMenuOptionByType(MenuEntryType.Window, windowId);
+      if (option != null) {
         boolean hasAccess = !SessionFactoryController.isRunningInWebContainer()
-            || ActivationKey.getInstance().hasLicenseAccess("MW",
-                menuOption.getMenu().getWindow().getId()) == FeatureRestriction.NO_RESTRICTION;
-        if (hasAccess) {
-          final String windowId = menuOption.getMenu().getWindow().getId();
-          if (menuOptionsByWindowId.containsKey(windowId)) {
-            menuOptionsByWindowId.get(windowId).add(menuOption);
-          } else {
-            List<MenuOption> option = new ArrayList<MenuOption>();
-            option.add(menuOption);
-            menuOptionsByWindowId.put(windowId, option);
-          }
-        }
-        // make sure that the important parts are read into mem
-        for (Tab windowTab : menuOption.getMenu().getWindow().getADTabList()) {
-          Hibernate.initialize(windowTab);
-          Hibernate.initialize(windowTab.getTable());
-        }
-      }
-    }
-
-    for (Tab tab : (List<Tab>) list) {
-      final Window window = tab.getWindow();
-      final List<MenuOption> options = menuOptionsByWindowId.get(window.getId());
-      if (options != null) {
-        for (MenuOption menuOption : options) {
-          menuOption.setType(MenuEntryType.Window);
-          menuOption.setId(tab.getId());
-          menuOption.setTab(tab);
-        }
+            || ActivationKey.getInstance().hasLicenseAccess("MW", windowId) == FeatureRestriction.NO_RESTRICTION;
+        option.setAccessGranted(hasAccess);
       }
     }
   }
 
+  private MenuOption getMenuOptionByType(MenuEntryType type, String objectId) {
+    for (MenuOption option : menuOptions) {
+      if (option.getType() == type && objectId.equals(option.objectId)) {
+        return option;
+      }
+
+      // Process is special case, there are several types of processes
+      if (type == MenuEntryType.Process && objectId.equals(option.objectId)) {
+        if (option.getType() == MenuEntryType.Process || option.getType() == MenuEntryType.Report
+            || option.getType() == MenuEntryType.ProcessManual) {
+          return option;
+        }
+      }
+    }
+    return null;
+  }
+
   private void removeInvisibleNodes() {
-
     final List<MenuOption> toRemove = new ArrayList<MenuOption>();
     for (MenuOption menuOption : menuOptions) {
       if (!menuOption.isVisible()) {
@@ -386,60 +265,6 @@
     menuOptions.removeAll(toRemove);
   }
 
-  private void createInitialMenuList() {
-    Role role = OBDal.getInstance().get(Role.class, roleId);
-    final Tree tree;
-    if (role.getPrimaryTreeMenu() != null) {
-      tree = role.getPrimaryTreeMenu();
-    } else {
-      tree = OBDal.getInstance().get(Tree.class, "10");
-    }
-    menuOptions = new ArrayList<MenuOption>();
-    OBCriteria<TreeNode> treeNodes = OBDal.getInstance().createCriteria(TreeNode.class);
-    treeNodes.add(Restrictions.eq(TreeNode.PROPERTY_TREE, tree));
-    treeNodes.setFilterOnActive(false);
-
-    final Map<String, MenuOption> menuOptionsByMenuId = new HashMap<String, MenuOption>();
-    for (TreeNode treeNode : treeNodes.list()) {
-      boolean addOption = treeNode.isActive();
-      boolean inactiveSummary = false;
-
-      if (!addOption) {
-        Menu menuEntry = OBDal.getInstance().get(Menu.class, treeNode.getNode());
-        if (menuEntry != null) {
-          addOption = menuEntry.isSummaryLevel();
-          inactiveSummary = true;
-        }
-      }
-
-      if (addOption) {
-        final MenuOption menuOption = new MenuOption();
-        menuOption.setTreeNode(treeNode);
-        menuOption.setDbId(treeNode.getId());
-        Menu menuEntry = OBDal.getInstance().get(Menu.class, treeNode.getNode());
-        if (menuEntry != null && !menuEntry.isActive()) {
-          menuOption.setVisible(false);
-        }
-        menuOptions.add(menuOption);
-      }
-    }
-    linkMenus();
-
-    for (MenuOption menuOption : menuOptions) {
-      if (menuOption.getMenu() != null) {
-        menuOptionsByMenuId.put(menuOption.getMenu().getId(), menuOption);
-      }
-    }
-
-    // sort them by sequencenumber of the treenode
-    Collections.sort(menuOptions, new MenuSequenceComparator());
-
-    // now put the menuOptions in a tree structure
-    for (MenuOption menuOption : menuOptions) {
-      menuOption.setParentMenuOption(menuOptionsByMenuId);
-    }
-  }
-
   public static class MenuOption implements Serializable {
     private static final long serialVersionUID = 1L;
     private TreeNode treeNode;
@@ -455,6 +280,28 @@
     private List<MenuOption> children = new ArrayList<MenuOption>();
     private Boolean visible = null;
     private boolean showInClassicMode = false;
+    private String objectId;
+
+    private boolean accessGranted = false;
+
+    public MenuOption() {
+      // Default constructor, just sets all the defaults
+    }
+
+    public MenuOption(MenuOption option) {
+      this();
+      this.treeNode = option.treeNode;
+      this.label = option.label;
+      this.type = option.type;
+      this.id = option.id;
+      this.dbId = option.dbId;
+      this.menu = option.menu;
+      this.tab = option.tab;
+      this.form = option.form;
+      this.isReport = option.isReport;
+      this.showInClassicMode = option.showInClassicMode;
+      this.objectId = option.objectId;
+    }
 
     public boolean isSingleRecord() {
       return getTab() != null && getTab().getUIPattern().equals("SR");
@@ -508,8 +355,10 @@
         visible = localVisible;
       } else if (type == MenuEntryType.Summary) {
         visible = false;
+      } else if (type == MenuEntryType.External) {
+        visible = true;
       } else {
-        visible = true;
+        visible = accessGranted;
       }
       return visible;
     }
@@ -587,6 +436,10 @@
       this.form = form;
     }
 
+    public void setParentMenuOption(MenuOption parentMenuOption) {
+      this.parentMenuOption = parentMenuOption;
+    }
+
     public void setParentMenuOption(Map<String, MenuOption> menuOptionsByMenuId) {
       if (treeNode.getReportSet() != null) {
         parentMenuOption = menuOptionsByMenuId.get(treeNode.getReportSet());
@@ -600,9 +453,15 @@
       return menu;
     }
 
+    /**
+     * @deprecated Use instead setMenu(Menu menu, String userLanguageId)
+     */
     public void setMenu(Menu menu) {
+      setMenu(menu, OBContext.getOBContext().getLanguage().getId());
+    }
+
+    public void setMenu(Menu menu, String userLanguageId) {
       this.menu = menu;
-      final String userLanguageId = OBContext.getOBContext().getLanguage().getId();
       for (MenuTrl menuTrl : menu.getADMenuTrlList()) {
         final String trlLanguageId = (String) DalUtil.getId(menuTrl.getLanguage());
         if (trlLanguageId.equals(userLanguageId)) {
@@ -686,6 +545,14 @@
     public void setDbId(String dbId) {
       this.dbId = dbId;
     }
+
+    public void setAccessGranted(boolean accessGranted) {
+      this.accessGranted = accessGranted;
+    }
+
+    public void setObjectId(String objectId) {
+      this.objectId = objectId;
+    }
   }
 
   private static class MenuComparator implements Comparator<MenuOption> {
@@ -694,18 +561,6 @@
     public int compare(MenuOption o1, MenuOption o2) {
       return o1.getLabel().compareTo(o2.getLabel());
     }
-
-  }
-
-  private static class MenuSequenceComparator implements Comparator<MenuOption> {
-
-    @Override
-    public int compare(MenuOption o1, MenuOption o2) {
-      TreeNode tn1 = o1.getTreeNode();
-      TreeNode tn2 = o2.getTreeNode();
-      return (int) (tn1.getSequenceNumber() - tn2.getSequenceNumber());
-    }
-
   }
 
   public List<MenuOption> getSelectableMenuOptions() {
@@ -714,4 +569,13 @@
 
     return selectableMenuOptions;
   }
+
+  /**
+   * Sets globalMenuOptions. This method is intended to be used only when running out of a context;
+   * 
+   * @param globalMenuOptions
+   */
+  public void setGlobalMenuOptions(GlobalMenu globalMenuOptions) {
+    this.globalMenuOptions = globalMenuOptions;
+  }
 }
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/ParametersActionHandler.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/ParametersActionHandler.java	Thu May 09 12:06:37 2013 +0200
@@ -32,6 +32,7 @@
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.dal.service.OBQuery;
 import org.openbravo.erpCommon.utility.OBError;
+import org.openbravo.portal.PortalAccessible;
 
 /**
  * Responsible of retrieving/storing Parameter values
@@ -39,7 +40,7 @@
  * @author iperdomo
  */
 @ApplicationScoped
-public class ParametersActionHandler extends BaseActionHandler {
+public class ParametersActionHandler extends BaseActionHandler implements PortalAccessible {
   private static Logger log = Logger.getLogger(ParametersActionHandler.class);
 
   @Override
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/StorePropertyActionHandler.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/StorePropertyActionHandler.java	Thu May 09 12:06:37 2013 +0200
@@ -34,6 +34,7 @@
 import org.openbravo.model.ad.system.Client;
 import org.openbravo.model.ad.ui.Window;
 import org.openbravo.model.common.enterprise.Organization;
+import org.openbravo.portal.PortalAccessible;
 
 /**
  * Is responsible for storing a preference.
@@ -42,7 +43,7 @@
  * @see StaticResourceComponent
  */
 @ApplicationScoped
-public class StorePropertyActionHandler extends BaseActionHandler {
+public class StorePropertyActionHandler extends BaseActionHandler implements PortalAccessible {
   private static final Logger log = Logger.getLogger(StorePropertyActionHandler.class);
 
   protected JSONObject execute(Map<String, Object> parameters, String data) {
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/WindowSettingsActionHandler.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/WindowSettingsActionHandler.java	Thu May 09 12:06:37 2013 +0200
@@ -137,15 +137,20 @@
       } catch (PropertyException e) {
         // do nothing, property is not set so securedProcess is false
       }
-
       if (securedProcess) {
-        OBQuery<Field> q = OBDal.getInstance().createQuery(
-            Field.class,
-            " as f where  tab.window = :window " + "and ( (column.oBUIAPPProcess is not null"
-                + " and not exists (select 1 from " + " OBUIAPP_Process_Access a"
-                + " where a.obuiappProcess = f.column.oBUIAPPProcess"
-                + " and a.role.id = :role and a.active=true))" + "or (column.process is not null))"
-                + " order by f.tab");
+        OBQuery<Field> q = OBDal
+            .getInstance()
+            .createQuery(
+                Field.class,
+                " as f where  tab.window = :window "
+                    + "and ( (column.oBUIAPPProcess is not null"
+                    + " and not exists (select 1 from "
+                    + " OBUIAPP_Process_Access a"
+                    + " where a.obuiappProcess = f.column.oBUIAPPProcess"
+                    + " and a.role.id = :role and a.active=true))"
+                    + "or (column.process is not null and "
+                    + " not exists (select 1 from ADProcessAccess a where a.process = f.column.process and "
+                    + " a.role.id = :role and a.active=true)))" + " order by f.tab");
 
         q.setNamedParameter("window", window);
         q.setNamedParameter("role", OBContext.getOBContext().getRole().getId());
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/businesslogic/CloneOrderActionHandler.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/businesslogic/CloneOrderActionHandler.java	Thu May 09 12:06:37 2013 +0200
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2011 Openbravo SLU 
+ * All portions are Copyright (C) 2011-2013 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  Mallikarjun M
  ************************************************************************
@@ -20,6 +20,7 @@
 
 import java.math.BigDecimal;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -28,8 +29,10 @@
 import org.openbravo.base.exception.OBException;
 import org.openbravo.client.kernel.BaseActionHandler;
 import org.openbravo.dal.core.DalUtil;
+import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.dal.service.OBQuery;
+import org.openbravo.model.ad.access.User;
 import org.openbravo.model.common.order.Order;
 import org.openbravo.model.common.order.OrderLine;
 import org.openbravo.model.pricing.pricelist.PriceListVersion;
@@ -52,7 +55,8 @@
     final DataToJsonConverter jsonConverter = new DataToJsonConverter();
     JSONObject json = null;
     try {
-      String orderId = (String) parameters.get("orderId");
+      String orderId = (String) parameters.get("recordId");
+      User currentUser = OBContext.getOBContext().getUser();
       Order objOrder = OBDal.getInstance().get(Order.class, orderId);
       Order objCloneOrder = (Order) DalUtil.copy(objOrder, false);
       BigDecimal bLineNetAmt = getLineNetAmt(orderId);
@@ -64,6 +68,11 @@
       objCloneOrder.setSalesTransaction(true);
       objCloneOrder.setDocumentNo(null);
       objCloneOrder.setSalesTransaction(objOrder.isSalesTransaction());
+      objCloneOrder.setCreationDate(new Date());
+      objCloneOrder.setUpdated(new Date());
+      objCloneOrder.setCreatedBy(currentUser);
+      objCloneOrder.setUpdatedBy(currentUser);
+
       // save the cloned order object
       OBDal.getInstance().save(objCloneOrder);
 
@@ -84,6 +93,10 @@
             || !bdPriceList.equals(BigDecimal.ZERO.setScale(bdPriceList.scale()))) {
           objCloneOrdLine.setListPrice(bdPriceList);
         }
+        objCloneOrdLine.setCreationDate(new Date());
+        objCloneOrdLine.setUpdated(new Date());
+        objCloneOrdLine.setCreatedBy(currentUser);
+        objCloneOrdLine.setUpdatedBy(currentUser);
         objCloneOrder.getOrderLineList().add(objCloneOrdLine);
         objCloneOrdLine.setSalesOrder(objCloneOrder);
       }
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/event/ElementValueEventHandler.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/event/ElementValueEventHandler.java	Thu May 09 12:06:37 2013 +0200
@@ -193,7 +193,7 @@
     obc.setFilterOnReadableClients(false);
     obc.setFilterOnReadableOrganization(false);
     List<TreeNode> nodes = obc.list();
-    if (nodes.size() > 0) {
+    if (nodes.size() > 0 && obc.list().get(0).getSequenceNumber() != null) {
       return obc.list().get(0).getSequenceNumber() + 10l;
     } else {
       return 10l;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/event/MenuCacheHandler.java	Thu May 09 12:06:37 2013 +0200
@@ -0,0 +1,104 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2013 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.client.application.event;
+
+import javax.enterprise.event.Observes;
+import javax.inject.Inject;
+
+import org.openbravo.base.model.Entity;
+import org.openbravo.base.model.ModelProvider;
+import org.openbravo.client.application.GlobalMenu;
+import org.openbravo.client.kernel.event.EntityDeleteEvent;
+import org.openbravo.client.kernel.event.EntityNewEvent;
+import org.openbravo.client.kernel.event.EntityPersistenceEventObserver;
+import org.openbravo.client.kernel.event.EntityUpdateEvent;
+
+/**
+ * EntityPersistenceEventObserver to listen to modifications in entities that are used to compose
+ * the menu. In case they are modified cached global menu is invalidated to generate it again.
+ * 
+ * @see GlobalMenu
+ * 
+ * @author alostale
+ * 
+ */
+public class MenuCacheHandler extends EntityPersistenceEventObserver {
+  @Inject
+  private GlobalMenu menu;
+
+  private static final String MENU_TABLE_ID = "116";
+  private static final String TREENODE_TABLE_ID = "289";
+
+  private static final String WINDOW_TABLE_ID = "105";
+  private static final String VIEWDEFINITION_TABLE_ID = "79127717F4514B459D9014C91E793CE9";
+  private static final String FORM_TABLE_ID = "376";
+  private static final String PROCESS_TABLE_ID = "284";
+  private static final String PROCESSDEFINITION_TABLE_ID = "FF80818132D7FB620132D8129D1A0028";
+
+  private static final String WINDOW_ACCESS_TABLE_ID = "201";
+  private static final String VIEWDEFINITION_ACCESS_TABLE_ID = "E6F29F8A30BC4603B1D1195051C4F3A6";
+  private static final String FORM_ACCESS_TABLE_ID = "378";
+  private static final String PROCESS_ACCESS_TABLE_ID = "197";
+  private static final String PROCESSDEFINITION_ACCESS_TABLE_ID = "FF80818132D85DB50132D860924E0004";
+
+  private static Entity[] entities = {
+      ModelProvider.getInstance().getEntityByTableId(MENU_TABLE_ID),
+      ModelProvider.getInstance().getEntityByTableId(TREENODE_TABLE_ID),
+
+      ModelProvider.getInstance().getEntityByTableId(WINDOW_TABLE_ID),
+      ModelProvider.getInstance().getEntityByTableId(VIEWDEFINITION_TABLE_ID),
+      ModelProvider.getInstance().getEntityByTableId(FORM_TABLE_ID),
+      ModelProvider.getInstance().getEntityByTableId(PROCESS_TABLE_ID),
+      ModelProvider.getInstance().getEntityByTableId(PROCESSDEFINITION_TABLE_ID),
+
+      ModelProvider.getInstance().getEntityByTableId(WINDOW_ACCESS_TABLE_ID),
+      ModelProvider.getInstance().getEntityByTableId(VIEWDEFINITION_ACCESS_TABLE_ID),
+      ModelProvider.getInstance().getEntityByTableId(FORM_ACCESS_TABLE_ID),
+      ModelProvider.getInstance().getEntityByTableId(PROCESS_ACCESS_TABLE_ID),
+      ModelProvider.getInstance().getEntityByTableId(PROCESSDEFINITION_ACCESS_TABLE_ID) };
+
+  public void onNew(@Observes EntityNewEvent event) {
+    if (!isValidEvent(event)) {
+      return;
+    }
+    menu.invalidateCache();
+  }
+
+  public void onUpdate(@Observes EntityUpdateEvent event) {
+    if (!isValidEvent(event)) {
+      return;
+    }
+    menu.invalidateCache();
+  }
+
+  public void onDelete(@Observes EntityDeleteEvent event) {
+    if (!isValidEvent(event)) {
+      return;
+    }
+    menu.invalidateCache();
+  }
+
+  @Override
+  protected Entity[] getObservedEntities() {
+
+    return entities;
+  }
+
+}
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/navigationbarcomponents/UserInfoWidgetActionHandler.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/navigationbarcomponents/UserInfoWidgetActionHandler.java	Thu May 09 12:06:37 2013 +0200
@@ -57,6 +57,7 @@
 import org.openbravo.model.ad.system.SystemInformation;
 import org.openbravo.model.common.enterprise.Organization;
 import org.openbravo.model.common.enterprise.Warehouse;
+import org.openbravo.portal.PortalAccessible;
 import org.openbravo.service.db.DalConnectionProvider;
 import org.openbravo.service.json.JsonConstants;
 import org.openbravo.utils.FormatUtilities;
@@ -70,7 +71,7 @@
  * @see StaticResourceComponent
  */
 @ApplicationScoped
-public class UserInfoWidgetActionHandler extends BaseActionHandler {
+public class UserInfoWidgetActionHandler extends BaseActionHandler implements PortalAccessible {
 
   /*
    * (non-Javadoc)
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java	Thu May 09 12:06:37 2013 +0200
@@ -1077,7 +1077,7 @@
         }
       }
     } catch (Exception e) {
-      log.error("Couldn't get the value for column " + columnName);
+      log.error("Couldn't get the value for column " + columnName, e);
     }
   }
 
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ImagesActionHandler.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/ImagesActionHandler.java	Thu May 09 12:06:37 2013 +0200
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2011 Openbravo SLU 
+ * All portions are Copyright (C) 2011-2013 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -33,6 +33,7 @@
 import org.openbravo.model.ad.datamodel.Table;
 import org.openbravo.model.ad.ui.Tab;
 import org.openbravo.model.ad.utility.Image;
+import org.openbravo.portal.PortalAccessible;
 
 /**
  * This ActionHandler implements the DELETE and GETSIZE actions which are used by the ImageBLOB
@@ -46,7 +47,7 @@
  * MIME type if it hasn't yet been computed
  * 
  */
-public class ImagesActionHandler extends BaseActionHandler {
+public class ImagesActionHandler extends BaseActionHandler implements PortalAccessible {
 
   private static final Logger log = Logger.getLogger(ImagesActionHandler.class);
 
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFieldHandler.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFieldHandler.java	Thu May 09 12:06:37 2013 +0200
@@ -67,7 +67,6 @@
   private static final String IMAGEBLOB_AD_REFERENCE_ID = "4AA6C3BE9D3B4D84A3B80489505A23E5";
 
   private static final String AUDIT_GROUP_ID = "1000100001";
-  private static final String MORE_INFO_GROUP_ID = "402880E72F1C15A5012F1C7AA98B00E8";
 
   private Tab tab;
   private List<String> statusBarFields;
@@ -1564,11 +1563,7 @@
     }
 
     public void setFieldGroup(FieldGroup fieldGroup) {
-      if (AUDIT_GROUP_ID.equals(fieldGroup.getId())
-          || MORE_INFO_GROUP_ID.equals(fieldGroup.getId())) {
-        expanded = false;
-      }
-
+      expanded = (fieldGroup.isCollapsed() == null) ? true : !fieldGroup.isCollapsed();
       this.fieldGroup = fieldGroup;
     }
 
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/alert-management/ob-alert-grid.js	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/alert-management/ob-alert-grid.js	Thu May 09 12:06:37 2013 +0200
@@ -173,6 +173,36 @@
     requestProperties.params[OB.Constants.WHERE_PARAMETER] = this.getFilterClause();
   },
 
+  getAlertsWithFilterClause: function (alertRule) {
+    var filterClause, alerts = alertRule.alerts.split(','),
+        alertsNum = alerts.length,
+        i, chunksOfAlerts = [],
+        j, chunkSize = 1000;
+    filterClause = ' and (e.alertRule.id != \'' + alertRule.alertRuleId + '\'';
+
+    if (alertsNum <= chunkSize) {
+      filterClause += ' or e.id in (' + alertRule.alerts + '))';
+      return filterClause;
+    }
+
+    // there are more than 1000 alerts to include in the where clause, Oracle doesn't
+    // support it, so let's split them in chunks with <=1000 elements each
+    for (i = 0; i < alertsNum; i += chunkSize) {
+      chunksOfAlerts.push(alerts.slice(i, i + chunkSize));
+    }
+
+    for (i = 0; i < chunksOfAlerts.length; i++) {
+      filterClause += ' or e.id in (';
+      for (j = 0; j < chunksOfAlerts[i].length; j++) {
+        filterClause += j > 0 ? ',' : '';
+        filterClause += chunksOfAlerts[i][j];
+      }
+      filterClause += ')';
+    }
+    filterClause += ')';
+    return filterClause;
+  },
+
   getFilterClause: function () {
     var i, filterClause = '',
         alertRuleIds = '',
@@ -188,8 +218,7 @@
       // alerts are of a different alertRule or only the alerts predefined
       // this only happens if the alertRule has an SQL filter expression defined
       if (OB.AlertManagement.alertRules[i].alerts) {
-        filterClause += ' and (e.alertRule.id != \'' + OB.AlertManagement.alertRules[i].alertRuleId + '\'';
-        filterClause += ' or e.id in (' + OB.AlertManagement.alertRules[i].alerts + '))';
+        filterClause += this.getAlertsWithFilterClause(OB.AlertManagement.alertRules[i]);
       }
     }
     if (alertRuleIds !== '') {
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/calendar/ob-calendar.js	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/calendar/ob-calendar.js	Thu May 09 12:06:37 2013 +0200
@@ -459,10 +459,10 @@
         if (!calendar.isInitialScrollAlreadyBeenSet && tabNum <= 1) {
           calendar.isInitialScrollAlreadyBeenSet = true;
           // Timeout to allow new selected tab grid be fully loaded
-          if (calendar.initialScrollTo) {
+          if (calendar.initialScrollTime) {
             setTimeout(function () {
               try {
-                calendar.scrollToTime(calendar.initialScrollTo);
+                calendar.scrollToTime(calendar.initialScrollTime);
               } catch (e) {}
             }, 100);
           }
@@ -471,10 +471,10 @@
       };
     }
     // Timeout to allow the tab grid be fully loaded
-    if (calendar.initialScrollTo) {
+    if (calendar.initialScrollTime) {
       setTimeout(function () {
         try {
-          calendar.scrollToTime(calendar.initialScrollTo);
+          calendar.scrollToTime(calendar.initialScrollTime);
         } catch (e) {}
       }, 100);
     }
@@ -486,7 +486,13 @@
   },
 
   filterData: function (criteria) {
-    return this.Super('filterData', [this.getCriteria(criteria)]);
+    var newCriteria, ret;
+    newCriteria = this.getCriteria(criteria);
+    ret = this.Super('filterData', [newCriteria]);
+    if (this.doPreFilterData) {
+      this.doPreFilterData(newCriteria);
+    }
+    return ret;
   },
 
   // read the dates for the current month
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/calendar/ob-multicalendar.js	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/calendar/ob-multicalendar.js	Thu May 09 12:06:37 2013 +0200
@@ -594,6 +594,9 @@
         }
       }
     }
+    if (typeof this.calendarProps.customParseCalendarData === 'function') {
+      calendarData = this.calendarProps.customParseCalendarData(calendarData);
+    }
 
     return calendarData;
   },
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-date.js	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-date.js	Thu May 09 12:06:37 2013 +0200
@@ -153,6 +153,18 @@
         break;
       }
     }
+
+    if (partIndex === 0 && parts[partIndex] !== '') {
+      // Only one or two digits have been entered, they represent the number of days
+      if (this.dateParts[1] === 'D') {
+        parts[1] = parts[0];
+        parts[0] = '';
+      } else if (this.dateParts[2] === 'D') {
+        parts[2] = parts[0];
+        parts[0] = '';
+      }
+    }
+
     for (i = 0; i < 3; i++) {
       if ((parts[i] === '0' || parts[i] === '00') && (this.dateParts[i] === 'D' || this.dateParts[i] === 'M')) {
         return str;
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-fk-filter.js	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-fk-filter.js	Thu May 09 12:06:37 2013 +0200
@@ -58,8 +58,8 @@
 
     // the data from the datasource will contain the id and the identifier
     // the value for the filter and the display are the same: the identifier
-    this.displayField = OB.Constants.IDENTIFIER;
-    this.valueField = OB.Constants.IDENTIFIER;
+    this.displayField = this.criteriaDisplayField || OB.Constants.IDENTIFIER;
+    this.valueField = this.criteriaDisplayField || OB.Constants.IDENTIFIER;
 
     this.pickListProperties = {
 
@@ -82,12 +82,12 @@
         var i, values = this.formItem.getValue();
         if (values.length) {
           for (i = 0; i < values.length; i++) {
-            if (record[OB.Constants.IDENTIFIER] === values[i]) {
+            if (record[me.displayField] === values[i]) {
               return true;
             }
           }
         }
-        return record[OB.Constants.IDENTIFIER] === values;
+        return record[me.displayField] === values;
       },
 
       // override data arrived to prevent the first entry from being
@@ -109,7 +109,7 @@
           }
           for (rowNum = startRow; rowNum < (endRow + 1); rowNum++) {
             record = this.getRecord(rowNum);
-            if (record && values.contains(record[OB.Constants.IDENTIFIER])) {
+            if (record && values.contains(record[me.displayField])) {
               this.selectRecord(record, true);
             }
           }
@@ -122,11 +122,7 @@
       requestProperties: {
         params: {
           // distinct forces the distinct query on the server side
-          _distinct: gridField.valueField || gridField.name,
-          // identifier is not listed here as it is always send, actually
-          // the id is also always send, but setting _selectedProperties
-          // prevents other fields from coming over
-          _selectedProperties: 'id'
+          _distinct: gridField.valueField || gridField.name
         }
       },
       fields: this.pickListFields
@@ -240,7 +236,7 @@
   },
 
   canEditCriterion: function (criterion) {
-    return criterion && criterion.fieldName === this.name;
+    return criterion && (criterion.fieldName === this.name || criterion.fieldName === this.criteriaField);
   },
 
   getCriterion: function (textMatchStyle) {
@@ -291,7 +287,7 @@
   // see also the setValuesAsCriteria in ob-grid-js which again translates
   // back
   getCriteriaFieldName: function () {
-    return this.name + OB.Constants.FIELDSEPARATOR + OB.Constants.IDENTIFIER;
+    return this.criteriaField || this.name + OB.Constants.FIELDSEPARATOR + OB.Constants.IDENTIFIER;
   },
 
   // solve a small bug in the value expressions
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-fk.js	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-fk.js	Thu May 09 12:06:37 2013 +0200
@@ -40,5 +40,12 @@
       form.grid.setEditValue(form.grid.getEditRow(), identifierFieldName, display);
     }
     return this.Super('changed', arguments);
+  },
+
+  setValue: function (val) {
+    if (this._clearingValue) {
+      this._editorEnterValue = null;
+    }
+    this.Super('setValue', arguments);
   }
 });
\ No newline at end of file
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-minidaterange.js	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-minidaterange.js	Thu May 09 12:06:37 2013 +0200
@@ -457,7 +457,7 @@
         operator: 'notNull'
       };
     }
-    if (value === '') {
+    if (value === '' || value === null) {
       return {};
     }
     if (this.singleDateValue) {
@@ -657,4 +657,4 @@
   formatDate: function (dt) {
     return OB.Utilities.Date.JSToOB(dt, OB.Format.date);
   }
-});
\ No newline at end of file
+});
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Thu May 09 12:06:37 2013 +0200
@@ -1348,9 +1348,8 @@
     OB.KeyboardManager.Shortcuts.set('ViewGrid_CancelEditing', ['OBViewGrid.body', 'OBViewGrid.editForm'], ksAction_CancelEditing);
 
     ksAction_DeleteSelectedRecords = function () {
-      var isDeletingEnabled = !me.view.toolBar.getLeftMember(isc.OBToolbar.TYPE_DELETE).disabled;
-      if (me.getSelectedRecords().length > 0 && isDeletingEnabled) {
-        me.view.deleteSelectedRows();
+      var isRecordDeleted = me.deleteSelectedRowsByToolbarIcon();
+      if (isRecordDeleted) {
         return false; // To avoid keyboard shortcut propagation
       } else {
         return true;
@@ -2178,14 +2177,43 @@
         title: OB.I18N.getLabel('OBUIAPP_Delete'),
         keyTitle: OB.KeyboardManager.Shortcuts.getProperty('keyComb.text', 'ToolBar_Eliminate', 'id'),
         click: function () {
-          grid.view.deleteSelectedRows();
+          grid.deleteSelectedRowsByToolbarIcon();
         }
       });
     }
-
     return menuItems;
   },
 
+  deleteSelectedRowsByToolbarIcon: function () {
+    // The deleteSelectedRows action trigger should be the same than the toolbar button, so if this last one is overwritten,
+    // this delete rows logic should perform the same action than the toolbar button.
+    var grid = this,
+        isToolbarButtonFound = false,
+        toolbarButton, i;
+    if (grid.getSelectedRecords().length < 1) {
+      return false;
+    }
+    if (grid.view.toolBar && grid.view.toolBar.leftMembers && isc.OBToolbar.TYPE_DELETE) {
+      for (i = 0; i < grid.view.toolBar.leftMembers.length; i++) {
+        if (grid.view.toolBar.leftMembers[i].buttonType === isc.OBToolbar.TYPE_DELETE) {
+          isToolbarButtonFound = true;
+          toolbarButton = grid.view.toolBar.leftMembers[i];
+          if (!toolbarButton.disabled) {
+            toolbarButton.action();
+            return true;
+          }
+          break;
+        }
+      }
+    }
+    // But if the toolbar button is not found, do the default action
+    if (!isToolbarButtonFound) {
+      grid.view.deleteSelectedRows();
+      return true;
+    }
+    return false;
+  },
+
   // +++++++++++++++++++++++++++++ Record Selection Handling +++++++++++++++++++++++
   updateSelectedCountDisplay: function () {
     var selection = this.getSelection(),
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js	Thu May 09 12:06:37 2013 +0200
@@ -250,7 +250,7 @@
       length = this.iconToolbarButtons.length;
       for (i = 0; i < length; i++) {
         // note create a somewhat unique id by concatenating the tabid and the index
-        OB.ToolbarRegistry.registerButton(this.tabId + '_' + i, isc.OBToolbarIconButton, this.iconToolbarButtons[i], 200 + (i * 10), this.tabId);
+        OB.ToolbarRegistry.registerButton(this.tabId + '_' + i, isc.OBToolbarIconButton, this.iconToolbarButtons[i], 200 + (i * 10), this.tabId, null, false);
       }
     }
 
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/personalization/ob-manage-views-toolbar.js	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/personalization/ob-manage-views-toolbar.js	Thu May 09 12:06:37 2013 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2011-2012 Openbravo SLU
+ * All portions are Copyright (C) 2011-2013 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s): ___________
  ************************************************************************
@@ -228,6 +228,6 @@
     keyboardShortcutId: 'ToolBar_ManageViews'
   };
 
-  OB.ToolbarRegistry.registerButton(manageViewButtonProperties.buttonType, isc.OBToolbarIconButton, manageViewButtonProperties, 320, null);
+  OB.ToolbarRegistry.registerButton(manageViewButtonProperties.buttonType, isc.OBToolbarIconButton, manageViewButtonProperties, 320, null, null, false);
 
 }());
\ No newline at end of file
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/personalization/ob-personalize-form-toolbar-button.js	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/personalization/ob-personalize-form-toolbar-button.js	Thu May 09 12:06:37 2013 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2011-2012 Openbravo SLU
+ * All portions are Copyright (C) 2011-2013 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s): ___________
  ************************************************************************
@@ -71,7 +71,7 @@
     keyboardShortcutId: 'ToolBar_Personalization'
   };
 
-  OB.ToolbarRegistry.registerButton(personalizationButtonProperties.buttonType, isc.OBToolbarIconButton, personalizationButtonProperties, 310, null);
+  OB.ToolbarRegistry.registerButton(personalizationButtonProperties.buttonType, isc.OBToolbarIconButton, personalizationButtonProperties, 310, null, null, false);
 
   // and register the toolbar button the window personalization tab  
   windowPersonalizationTabButtonProperties = {
@@ -147,6 +147,6 @@
   };
 
   // register only for the window personalization tab
-  OB.ToolbarRegistry.registerButton(windowPersonalizationTabButtonProperties.buttonType, isc.OBToolbarIconButton, windowPersonalizationTabButtonProperties, 320, 'FF8081813157AED2013157BF6D810023');
+  OB.ToolbarRegistry.registerButton(windowPersonalizationTabButtonProperties.buttonType, isc.OBToolbarIconButton, windowPersonalizationTabButtonProperties, 320, 'FF8081813157AED2013157BF6D810023', null, false);
 
 }());
\ No newline at end of file
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-parameter-window-view.js	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-parameter-window-view.js	Thu May 09 12:06:37 2013 +0200
@@ -56,15 +56,43 @@
     // Buttons
 
     function actionClick() {
+      var hasErrors = false,
+          grid, fields, selection, len, allRows, lineNumbers, i, j, record, undef;
       view.messageBar.hide();
-      if (view.validate()) {
-        view.doProcess(this._buttonValue);
+      if (view.grid && view.grid.viewGrid) {
+        grid = view.grid.viewGrid;
+        fields = grid.getFields();
+        selection = grid.getSelectedRecords() || [];
+        len = selection.length;
+        allRows = grid.data.allRows || grid.data.localData || grid.data;
+        for (i = 0; i < len; i++) {
+          record = grid.getEditedRecord(grid.getRecordIndex(selection[i]));
+          for (j = 0; j < fields.length; j++) {
+            if (fields[j].required) {
+              if (record[fields[j].name] === null || record[fields[j] === undef]) {
+                hasErrors = true;
+                if (lineNumbers === undef) {
+                  lineNumbers = grid.getRecordIndex(selection[i]).toString();
+                } else {
+                  lineNumbers = lineNumbers + "," + grid.getRecordIndex(selection[i]).toString();
+                }
+              }
+            }
+          }
+        }
+      }
+      if (!hasErrors) {
+        if (view.validate()) {
+          view.doProcess(this._buttonValue);
+        } else {
+          // If the messageBar is visible, it means that it has been set due to a custom validation inside view.validate()
+          // so we don't want to overwrite it with the generic OBUIAPP_ErrorInFields message
+          if (!view.messageBar.isVisible()) {
+            view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null, OB.I18N.getLabel('OBUIAPP_ErrorInFields'));
+          }
+        }
       } else {
-        // If the messageBar is visible, it means that it has been set due to a custom validation inside view.validate()
-        // so we don't want to overwrite it with the generic OBUIAPP_ErrorInFields message
-        if (!view.messageBar.isVisible()) {
-          view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null, OB.I18N.getLabel('OBUIAPP_ErrorInFields'));
-        }
+        view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null, OB.I18N.getLabel('OBUIAPP_FillMandatoryFields') + " " + lineNumbers);
       }
     }
 
@@ -255,13 +283,21 @@
     if (message) {
       if (this.popup) {
         if (!retryExecution) {
-          this.buttonOwnerView.messageBar.setMessage(message.severity, message.text);
+          if (message.title) {
+            this.buttonOwnerView.messageBar.setMessage(message.severity, message.title, message.text);
+          } else {
+            this.buttonOwnerView.messageBar.setMessage(message.severity, message.text);
+          }
         } else {
           // Popup has no message bar, showing the message in a warn popup
           isc.warn(message.text);
         }
       } else {
-        this.messageBar.setMessage(message.severity, message.text);
+        if (message.title) {
+          this.messageBar.setMessage(message.severity, message.title, message.text);
+        } else {
+          this.messageBar.setMessage(message.severity, message.text);
+        }
       }
     }
 
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-grid.js	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-pick-and-execute-grid.js	Thu May 09 12:06:37 2013 +0200
@@ -226,6 +226,21 @@
     this.Super('selectionUpdated', arguments);
   },
 
+  cellEditEnd: function (editCompletionEvent, newValue, ficCallDone, autoSaveDone) {
+    var rowNum = this.getEditRow(),
+        colNum = this.getEditCol(),
+        editField = this.getEditField(colNum),
+        undef;
+    if (editField.required) {
+      if (newValue === null || newValue === undef) {
+        this.setFieldError(rowNum, editField.name, "Invalid Value");
+      } else {
+        this.clearFieldError(rowNum, editField.name);
+      }
+    }
+    this.Super('cellEditEnd', arguments);
+  },
+
   handleFilterEditorSubmit: function (criteria, context) {
     var ids = [],
         crit = {},
@@ -297,9 +312,9 @@
     for (i = 0; i < selectedLen; i++) {
       record = this.data.findByKey(this.selectedIds[i]);
       if (record) {
+        record[this.selectionProperty] = true;
         if (this.data.savedData) {
           savedRecord = this.data.savedData.find('id', this.selectedIds[i]);
-          record[this.selectionProperty] = true;
           //Setting editable fields from saved Data to retain values.
           for (j = 0; j < fields.length; j++) {
             if (fields[j].canEdit !== false) {
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-clone-order.js	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-clone-order.js	Thu May 09 12:06:37 2013 +0200
@@ -11,45 +11,11 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2011-2012 Openbravo SLU
+ * All portions are Copyright (C) 2011-2013 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):   Sreedhar Sirigiri (TDS), Mallikarjun M (TDS)
  ************************************************************************
  */
 
-// Registers a button to clone an order
-// put within a function to hide local vars etc.
-(function () {
-  var cloneButtonProps = isc.addProperties({}, isc.OBToolbar.CLONE_BUTTON_PROPERTIES);
-
-  cloneButtonProps.action = function () {
-    var view = this.view,
-        callback;
-
-    callback = function (ok) {
-      var requestParams;
-
-      if (ok) {
-        requestParams = {
-          orderId: view.viewGrid.getSelectedRecord().id
-        };
-        OB.RemoteCallManager.call('org.openbravo.client.application.businesslogic.CloneOrderActionHandler', {}, requestParams, function (rpcResponse, data, rpcRequest) {
-
-          var recordIndex = view.viewGrid.getRecordIndex(view.viewGrid.getSelectedRecord()) + 1;
-          // takes care of transforming dates etc.
-          data = view.viewGrid.getDataSource().recordsFromObjects(data)[0];
-          view.viewGrid.addToCacheData(data, recordIndex);
-          view.viewGrid.scrollToRow(recordIndex);
-          view.viewGrid.markForRedraw();
-          var visibleRows = view.viewGrid.body.getVisibleRows();
-          view.editRecord(view.viewGrid.getRecord(recordIndex), false);
-        });
-      }
-    };
-    isc.ask(OB.I18N.getLabel('OBUIAPP_WantToCloneOrder'), callback);
-  };
-
-  // register the button for the sales order tab
-  OB.ToolbarRegistry.registerButton(cloneButtonProps.buttonType, isc.OBToolbarIconButton, cloneButtonProps, 100, ['186', '294']);
-
-}());
\ No newline at end of file
+// Create a button to clone a sales order ('Sales Order' tab)
+OB.ToolbarUtils.createCloneButton('org.openbravo.client.application.businesslogic.CloneOrderActionHandler', null, ['186', '294'], OB.I18N.getLabel('OBUIAPP_WantToCloneOrder'));
\ No newline at end of file
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js	Thu May 09 12:06:37 2013 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2012 Openbravo SLU
+ * All portions are Copyright (C) 2010-2013 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):   Sreedhar Sirigiri (TDS), Mallikarjun M (TDS)
  ************************************************************************
@@ -38,6 +38,7 @@
     },
     disabled: true,
     buttonType: 'save',
+    sortPosition: 30,
     prompt: OB.I18N.getLabel('OBUIAPP_SaveRow'),
     updateState: function () {
       var view = this.view,
@@ -78,6 +79,7 @@
     },
 
     buttonType: 'savecloseX',
+    sortPosition: 40,
     prompt: OB.I18N.getLabel('OBUIAPP_CLOSEBUTTON'),
     updateState: function () {
       var view = this.view,
@@ -116,6 +118,7 @@
       }
     },
     buttonType: 'newRow',
+    sortPosition: 20,
     prompt: OB.I18N.getLabel('OBUIAPP_NewRow'),
     updateState: function () {
       var view = this.view,
@@ -130,6 +133,7 @@
       this.view.newDocument();
     },
     buttonType: 'newDoc',
+    sortPosition: 10,
     prompt: OB.I18N.getLabel('OBUIAPP_NewDoc'),
     updateState: function () {
       var view = this.view,
@@ -149,6 +153,7 @@
     },
     disabled: true,
     buttonType: 'eliminate',
+    sortPosition: 60,
     prompt: OB.I18N.getLabel('OBUIAPP_DeleteRow'),
     updateState: function () {
       var view = this.view,
@@ -186,6 +191,7 @@
     },
     disabled: false,
     buttonType: 'refresh',
+    sortPosition: 70,
     prompt: OB.I18N.getLabel('OBUIAPP_RefreshData'),
     updateState: function () {
       this.setDisabled(!this.view.hasNotChanged());
@@ -202,6 +208,7 @@
     },
     disabled: true,
     buttonType: 'undo',
+    sortPosition: 50,
     prompt: OB.I18N.getLabel('OBUIAPP_CancelEdit'),
     updateState: function () {
       if (this.view.isShowingForm) {
@@ -231,6 +238,7 @@
     },
     disabled: false,
     buttonType: 'export',
+    sortPosition: 80,
     prompt: OB.I18N.getLabel('OBUIAPP_ExportGrid'),
     updateState: function () {
       this.setDisabled(this.view.isShowingForm || this.view.viewGrid.getTotalRows() === 0 || OB.PropertyStore.get("ExportToCsv", this.view.standardWindow.windowId) === 'N');
@@ -334,6 +342,7 @@
     },
     disabled: false,
     buttonType: 'attach',
+    sortPosition: 90,
     updateState: function () {
       var selectedRows = this.view.viewGrid.getSelectedRecords();
       var attachmentExists = this.view.attachmentExists;
@@ -419,6 +428,7 @@
     },
     disabled: false,
     buttonType: 'link',
+    sortPosition: 300,
     prompt: OB.I18N.getLabel('OBUIAPP_GetDirectLink'),
     updateState: function () {},
     keyboardShortcutId: 'ToolBar_Link'
@@ -462,6 +472,13 @@
         if (view.isShowingForm && form.isNew) {
           disabled = true;
         }
+        /*
+         * Fixes Issue 0023270. The Business partner print button provides statistics about the
+         * business partner transactions in a pop up and so handling multiple records are not allowed.
+         */
+        if (view.tabId === '220' && selectedRecords.length > 1) {
+          disabled = true;
+        }
         this.setDisabled(disabled);
       },
       keyboardShortcutId: 'ToolBar_Print'
@@ -490,22 +507,26 @@
 
   CLONE_BUTTON_PROPERTIES: {
     action: function () {
-      alert('this method must be overridden when registering the button');
+      alert('This method must be overridden when registering the button');
     },
     disabled: false,
     buttonType: 'clone',
+    sortPosition: 100,
     prompt: OB.I18N.getLabel('OBUIAPP_CloneData'),
     updateState: function () {
       var view = this.view,
           form = view.viewForm,
           grid = view.viewGrid,
           selectedRecords = grid.getSelectedRecords();
+
       if (selectedRecords && selectedRecords.length > 1) {
         this.setDisabled(true);
       } else if (view.isShowingForm && form.isNew) {
         this.setDisabled(true);
       } else if (view.isEditingGrid && grid.getEditForm().isNew) {
         this.setDisabled(true);
+      } else if (form.hasChanged || (view.isEditingGrid && grid.getEditForm().hasChanged)) {
+        this.setDisabled(true);
       } else {
         this.setDisabled(selectedRecords.length === 0);
       }
@@ -1667,17 +1688,88 @@
   view.setContextInfo(view.getContextInfo(true, true, true, true), openPopupTree, true);
 };
 
+
+// ** {{{ OB.ToolbarUtils.createCloneButton(/*String*/ actionHandler, /*Object*/ requestParams, /*Array[String]*/ tabIds, /*String*/ askMsg, /*Integer*/ sortOrder, /*Boolean*/ editRecordAfterClone, /*String*/ buttonId, /*Boolean*/ overwriteIfExists, /*Array[String]*/ tabIdsToAvoid}}} **
+// Automatically set up a clone button for the provided tabs
+// Parameters:
+// * {{{actionHandler}}}:  action handler which processes and returns the cloned record
+// * {{{requestParams}}}: (Optional) aditional parameters to send to the action handler
+// * {{{tabIds}}}: (Optional, all tabs will be included by default) array of tabIds where this button will be shown
+// * {{{askMsg}}}: (Optional, 'OBUIAPP_WantToCloneRecord' by default) Text that will be displayed when the button be pressed.
+// * {{{sortOrder}}}: (Optional, 'CLONE_BUTTON_PROPERTIES.sortPosition' by default) Position in the toolbar of the clone button.
+// * {{{editRecordAfterClone}}}: (Optional, true by default) If the form edit view (of the cloned record) should be opened after clone it.
+// * {{{buttonId}}}: (Optional, random by default) Don't set it unless you plan to do advanced coding with this button (as, for example, overwrite it later in another place).
+// * {{{overwriteIfExists}}}: (Optional, false by default) To be able to overwrite a particular existing clone button. The buttonId should match with the overwritten one.
+// * {{{tabIdsToAvoid}}}: (Optional, no tabs to avoid by default) array of tabIds where this button should not be shown
+OB.ToolbarUtils.createCloneButton = function (actionHandler, requestParams, tabIds, askMsg, sortOrder, editRecordAfterClone, buttonId, overwriteIfExists, tabIdsToAvoid) {
+  var cloneButtonProps = isc.addProperties({}, isc.OBToolbar.CLONE_BUTTON_PROPERTIES);
+
+  if (!askMsg) {
+    askMsg = OB.I18N.getLabel('OBUIAPP_WantToCloneRecord');
+  }
+  if (!sortOrder) {
+    sortOrder = isc.OBToolbar.CLONE_BUTTON_PROPERTIES.sortPosition;
+  }
+  if (editRecordAfterClone !== false) {
+    editRecordAfterClone = true;
+  }
+  if (!buttonId) {
+    buttonId = cloneButtonProps.buttonType + '_' + OB.Utilities.generateRandomString(8);
+  }
+  if (overwriteIfExists !== true) {
+    overwriteIfExists = false;
+  }
+
+  cloneButtonProps.action = function () {
+    var view = this.view,
+        callback;
+
+    callback = function (ok) {
+      if (!requestParams) {
+        requestParams = {};
+      }
+      requestParams.recordId = view.viewGrid.getSelectedRecord().id;
+      requestParams.tabId = view.tabId;
+      requestParams.windowId = view.windowId;
+
+      if (ok) {
+        OB.RemoteCallManager.call(actionHandler, {}, requestParams, function (rpcResponse, data, rpcRequest) {
+          var recordIndex = view.viewGrid.getRecordIndex(view.viewGrid.getSelectedRecord()) + 1,
+              recordsData = view.viewGrid.getDataSource().recordsFromObjects(data)[0];
+          view.viewGrid.addToCacheData(recordsData, recordIndex);
+          view.viewGrid.scrollToRow(recordIndex);
+          view.viewGrid.markForRedraw();
+          if (view.viewGrid.getEditRow()) {
+            view.viewGrid.endEditing();
+          }
+          view.viewGrid.doSelectSingleRecord(recordIndex);
+          if (editRecordAfterClone) {
+            view.editRecord(view.viewGrid.getRecord(recordIndex), false);
+          }
+        });
+      }
+    };
+    isc.ask(askMsg, callback);
+  };
+
+  OB.ToolbarRegistry.registerButton(buttonId, isc.OBToolbarIconButton, cloneButtonProps, sortOrder, tabIds, tabIdsToAvoid, overwriteIfExists);
+};
+
 OB.ToolbarRegistry = {
   buttonDefinitions: [],
 
   // note tabIds is an array of strings, but maybe null/undefined
-  registerButton: function (buttonId, clazz, properties, sortOrder, tabIds) {
+  registerButton: function (buttonId, clazz, properties, sortOrder, tabIds, tabIdsToAvoid, overwriteIfExists) {
     var length;
 
     if (tabIds && !isc.isA.Array(tabIds)) {
       tabIds = [tabIds];
     }
 
+    if (tabIdsToAvoid && !isc.isA.Array(tabIdsToAvoid)) {
+      tabIdsToAvoid = [tabIdsToAvoid];
+    }
+
     // declare the vars and the object which will be stored
     var i, index = 0,
         buttonDef;
@@ -1687,14 +1779,20 @@
       clazz: clazz,
       properties: properties,
       sortOrder: sortOrder,
-      tabIds: tabIds
+      tabIds: tabIds,
+      tabIdsToAvoid: tabIdsToAvoid
     };
 
-    // already registered, bail
+    // already registered button handling
     length = this.buttonDefinitions.length;
     for (i = 0; i < length; i++) {
       if (this.buttonDefinitions[i].buttonId === buttonId) {
-        return;
+        if (overwriteIfExists) {
+          this.buttonDefinitions.splice(i, 1);
+          break;
+        } else {
+          return;
+        }
       }
     }
 
@@ -1721,10 +1819,11 @@
     //  btnDefinitionClass.create(btnDefinitionProperties);
     var result = [],
         j, resultIndex = 0,
-        i, validTabId, tabIds, length = this.buttonDefinitions.length,
-        tabIdsLength;
+        i, validTabId, tabIds, tabIdsToAvoid, length = this.buttonDefinitions.length,
+        tabIdsLength, tabIdsToAvoidLength;
     for (i = 0; i < length; i++) {
       tabIds = this.buttonDefinitions[i].tabIds;
+      tabIdsToAvoid = this.buttonDefinitions[i].tabIdsToAvoid;
       validTabId = !tabIds;
       if (tabIds) {
         tabIdsLength = tabIds.length;
@@ -1736,6 +1835,15 @@
         }
       }
       if (validTabId) {
+        tabIdsToAvoidLength = (tabIdsToAvoid && isc.isA.Array(tabIdsToAvoid) && tabIdsToAvoid.length ? tabIdsToAvoid.length : 0);
+        for (j = 0; j < tabIdsToAvoidLength; j++) {
+          if (tabIdsToAvoid[j] === tabId) {
+            validTabId = false;
+            break;
+          }
+        }
+      }
+      if (validTabId) {
         result[resultIndex++] = this.buttonDefinitions[i].clazz.create(isc.clone(this.buttonDefinitions[i].properties));
       }
     }
@@ -1744,15 +1852,15 @@
 };
 
 //These are the icon toolbar buttons shown in all the tabs 
-OB.ToolbarRegistry.registerButton(isc.OBToolbar.NEW_DOC_BUTTON_PROPERTIES.buttonType, isc.OBToolbarIconButton, isc.OBToolbar.NEW_DOC_BUTTON_PROPERTIES, 10, null);
-OB.ToolbarRegistry.registerButton(isc.OBToolbar.NEW_ROW_BUTTON_PROPERTIES.buttonType, isc.OBToolbarIconButton, isc.OBToolbar.NEW_ROW_BUTTON_PROPERTIES, 20, null);
-OB.ToolbarRegistry.registerButton(isc.OBToolbar.SAVE_BUTTON_PROPERTIES.buttonType, isc.OBToolbarIconButton, isc.OBToolbar.SAVE_BUTTON_PROPERTIES, 30, null);
-OB.ToolbarRegistry.registerButton(isc.OBToolbar.SAVECLOSE_BUTTON_PROPERTIES.buttonType, isc.OBToolbarIconButton, isc.OBToolbar.SAVECLOSE_BUTTON_PROPERTIES, 40, null);
-OB.ToolbarRegistry.registerButton(isc.OBToolbar.UNDO_BUTTON_PROPERTIES.buttonType, isc.OBToolbarIconButton, isc.OBToolbar.UNDO_BUTTON_PROPERTIES, 50, null);
-OB.ToolbarRegistry.registerButton(isc.OBToolbar.DELETE_BUTTON_PROPERTIES.buttonType, isc.OBToolbarIconButton, isc.OBToolbar.DELETE_BUTTON_PROPERTIES, 60, null);
-OB.ToolbarRegistry.registerButton(isc.OBToolbar.REFRESH_BUTTON_PROPERTIES.buttonType, isc.OBToolbarIconButton, isc.OBToolbar.REFRESH_BUTTON_PROPERTIES, 70, null);
-OB.ToolbarRegistry.registerButton(isc.OBToolbar.EXPORT_BUTTON_PROPERTIES.buttonType, isc.OBToolbarIconButton, isc.OBToolbar.EXPORT_BUTTON_PROPERTIES, 80, null);
-OB.ToolbarRegistry.registerButton(isc.OBToolbar.ATTACHMENTS_BUTTON_PROPERTIES.buttonType, isc.OBToolbarIconButton, isc.OBToolbar.ATTACHMENTS_BUTTON_PROPERTIES, 90, null);
+OB.ToolbarRegistry.registerButton(isc.OBToolbar.NEW_DOC_BUTTON_PROPERTIES.buttonType, isc.OBToolbarIconButton, isc.OBToolbar.NEW_DOC_BUTTON_PROPERTIES, isc.OBToolbar.NEW_DOC_BUTTON_PROPERTIES.sortPosition, null, null, false);
+OB.ToolbarRegistry.registerButton(isc.OBToolbar.NEW_ROW_BUTTON_PROPERTIES.buttonType, isc.OBToolbarIconButton, isc.OBToolbar.NEW_ROW_BUTTON_PROPERTIES, isc.OBToolbar.NEW_ROW_BUTTON_PROPERTIES.sortPosition, null, null, false);
+OB.ToolbarRegistry.registerButton(isc.OBToolbar.SAVE_BUTTON_PROPERTIES.buttonType, isc.OBToolbarIconButton, isc.OBToolbar.SAVE_BUTTON_PROPERTIES, isc.OBToolbar.SAVE_BUTTON_PROPERTIES.sortPosition, null, null, false);
+OB.ToolbarRegistry.registerButton(isc.OBToolbar.SAVECLOSE_BUTTON_PROPERTIES.buttonType, isc.OBToolbarIconButton, isc.OBToolbar.SAVECLOSE_BUTTON_PROPERTIES, isc.OBToolbar.SAVECLOSE_BUTTON_PROPERTIES.sortPosition, null, null, false);
+OB.ToolbarRegistry.registerButton(isc.OBToolbar.UNDO_BUTTON_PROPERTIES.buttonType, isc.OBToolbarIconButton, isc.OBToolbar.UNDO_BUTTON_PROPERTIES, isc.OBToolbar.UNDO_BUTTON_PROPERTIES.sortPosition, null, null, false);
+OB.ToolbarRegistry.registerButton(isc.OBToolbar.DELETE_BUTTON_PROPERTIES.buttonType, isc.OBToolbarIconButton, isc.OBToolbar.DELETE_BUTTON_PROPERTIES, isc.OBToolbar.DELETE_BUTTON_PROPERTIES.sortPosition, null, null, false);
+OB.ToolbarRegistry.registerButton(isc.OBToolbar.REFRESH_BUTTON_PROPERTIES.buttonType, isc.OBToolbarIconButton, isc.OBToolbar.REFRESH_BUTTON_PROPERTIES, isc.OBToolbar.REFRESH_BUTTON_PROPERTIES.sortPosition, null, null, false);
+OB.ToolbarRegistry.registerButton(isc.OBToolbar.EXPORT_BUTTON_PROPERTIES.buttonType, isc.OBToolbarIconButton, isc.OBToolbar.EXPORT_BUTTON_PROPERTIES, isc.OBToolbar.EXPORT_BUTTON_PROPERTIES.sortPosition, null, null, false);
+OB.ToolbarRegistry.registerButton(isc.OBToolbar.ATTACHMENTS_BUTTON_PROPERTIES.buttonType, isc.OBToolbarIconButton, isc.OBToolbar.ATTACHMENTS_BUTTON_PROPERTIES, isc.OBToolbar.ATTACHMENTS_BUTTON_PROPERTIES.sortPosition, null, null, false);
 
 //and add the direct link at the end
-OB.ToolbarRegistry.registerButton(isc.OBToolbar.LINK_BUTTON_PROPERTIES.buttonType, isc.OBToolbarIconButton, isc.OBToolbar.LINK_BUTTON_PROPERTIES, 300, null);
\ No newline at end of file
+OB.ToolbarRegistry.registerButton(isc.OBToolbar.LINK_BUTTON_PROPERTIES.buttonType, isc.OBToolbarIconButton, isc.OBToolbar.LINK_BUTTON_PROPERTIES, isc.OBToolbar.LINK_BUTTON_PROPERTIES.sortPosition, null, null, false);
\ No newline at end of file
--- a/modules/org.openbravo.client.htmlwidget/src-db/database/sourcedata/AD_MODULE.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.htmlwidget/src-db/database/sourcedata/AD_MODULE.xml	Thu May 09 12:06:37 2013 +0200
@@ -6,7 +6,7 @@
 <!--D393BE6F22BB44B7B728259B34FC795A-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--D393BE6F22BB44B7B728259B34FC795A-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--D393BE6F22BB44B7B728259B34FC795A-->  <NAME><![CDATA[HTML Widget]]></NAME>
-<!--D393BE6F22BB44B7B728259B34FC795A-->  <VERSION><![CDATA[1.0.20056]]></VERSION>
+<!--D393BE6F22BB44B7B728259B34FC795A-->  <VERSION><![CDATA[1.0.20252]]></VERSION>
 <!--D393BE6F22BB44B7B728259B34FC795A-->  <DESCRIPTION><![CDATA[Provides the HTML Widget superclass that allows to create widget classes that embed the html code.]]></DESCRIPTION>
 <!--D393BE6F22BB44B7B728259B34FC795A-->  <HELP><![CDATA[With this module you can define your own widget classes just setting up your own html code or the html code provided by third parties.]]></HELP>
 <!--D393BE6F22BB44B7B728259B34FC795A-->  <URL><![CDATA[http://forge.openbravo.com/projects/htmlwidget]]></URL>
--- a/modules/org.openbravo.client.htmlwidget/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.htmlwidget/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Thu May 09 12:06:37 2013 +0200
@@ -7,7 +7,7 @@
 <!--DCE798FBC5B648F7A3C81A6941720A57-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--DCE798FBC5B648F7A3C81A6941720A57-->  <AD_MODULE_ID><![CDATA[D393BE6F22BB44B7B728259B34FC795A]]></AD_MODULE_ID>
 <!--DCE798FBC5B648F7A3C81A6941720A57-->  <AD_DEPENDENT_MODULE_ID><![CDATA[2758CD25B2704AF6BBAD10365FC82C06]]></AD_DEPENDENT_MODULE_ID>
-<!--DCE798FBC5B648F7A3C81A6941720A57-->  <STARTVERSION><![CDATA[2.1.20056]]></STARTVERSION>
+<!--DCE798FBC5B648F7A3C81A6941720A57-->  <STARTVERSION><![CDATA[2.1.20252]]></STARTVERSION>
 <!--DCE798FBC5B648F7A3C81A6941720A57-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--DCE798FBC5B648F7A3C81A6941720A57-->  <DEPENDANT_MODULE_NAME><![CDATA[My Openbravo Tab]]></DEPENDANT_MODULE_NAME>
 <!--DCE798FBC5B648F7A3C81A6941720A57-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
--- a/modules/org.openbravo.client.kernel/src-db/database/sourcedata/AD_MODULE.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.kernel/src-db/database/sourcedata/AD_MODULE.xml	Thu May 09 12:06:37 2013 +0200
@@ -6,7 +6,7 @@
 <!--4B828F4D03264080AA1D2057B13F613C-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--4B828F4D03264080AA1D2057B13F613C-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--4B828F4D03264080AA1D2057B13F613C-->  <NAME><![CDATA[User Interface Client Kernel]]></NAME>
-<!--4B828F4D03264080AA1D2057B13F613C-->  <VERSION><![CDATA[2.1.20056]]></VERSION>
+<!--4B828F4D03264080AA1D2057B13F613C-->  <VERSION><![CDATA[2.1.20252]]></VERSION>
 <!--4B828F4D03264080AA1D2057B13F613C-->  <DESCRIPTION><![CDATA[Provides framework functionality for the Openbravo User Interface]]></DESCRIPTION>
 <!--4B828F4D03264080AA1D2057B13F613C-->  <HELP><![CDATA[The user interface client kernel is a generation framework for generating client (browser) components used in Openbravo. Its components are mainly used by other modules to provide customizable and extendable user interfaces.]]></HELP>
 <!--4B828F4D03264080AA1D2057B13F613C-->  <URL><![CDATA[http://forge.openbravo.com/projects/openbravoclientkernel]]></URL>
--- a/modules/org.openbravo.client.kernel/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.kernel/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Thu May 09 12:06:37 2013 +0200
@@ -7,7 +7,7 @@
 <!--26B041893E844A53AFA58BC326C4F0D7-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--26B041893E844A53AFA58BC326C4F0D7-->  <AD_MODULE_ID><![CDATA[4B828F4D03264080AA1D2057B13F613C]]></AD_MODULE_ID>
 <!--26B041893E844A53AFA58BC326C4F0D7-->  <AD_DEPENDENT_MODULE_ID><![CDATA[0]]></AD_DEPENDENT_MODULE_ID>
-<!--26B041893E844A53AFA58BC326C4F0D7-->  <STARTVERSION><![CDATA[3.0.20056]]></STARTVERSION>
+<!--26B041893E844A53AFA58BC326C4F0D7-->  <STARTVERSION><![CDATA[3.0.20252]]></STARTVERSION>
 <!--26B041893E844A53AFA58BC326C4F0D7-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--26B041893E844A53AFA58BC326C4F0D7-->  <DEPENDANT_MODULE_NAME><![CDATA[core]]></DEPENDANT_MODULE_NAME>
 <!--26B041893E844A53AFA58BC326C4F0D7-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
@@ -21,7 +21,7 @@
 <!--3AB045DA35ED4CA58EF7EB5BF04CDE3F-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--3AB045DA35ED4CA58EF7EB5BF04CDE3F-->  <AD_MODULE_ID><![CDATA[4B828F4D03264080AA1D2057B13F613C]]></AD_MODULE_ID>
 <!--3AB045DA35ED4CA58EF7EB5BF04CDE3F-->  <AD_DEPENDENT_MODULE_ID><![CDATA[C70732EA90A14EC0916078B85CC33D2D]]></AD_DEPENDENT_MODULE_ID>
-<!--3AB045DA35ED4CA58EF7EB5BF04CDE3F-->  <STARTVERSION><![CDATA[1.1.20056]]></STARTVERSION>
+<!--3AB045DA35ED4CA58EF7EB5BF04CDE3F-->  <STARTVERSION><![CDATA[1.1.20252]]></STARTVERSION>
 <!--3AB045DA35ED4CA58EF7EB5BF04CDE3F-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--3AB045DA35ED4CA58EF7EB5BF04CDE3F-->  <DEPENDANT_MODULE_NAME><![CDATA[JBoss Weld]]></DEPENDANT_MODULE_NAME>
 <!--3AB045DA35ED4CA58EF7EB5BF04CDE3F-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
@@ -35,7 +35,7 @@
 <!--D7BA4BB0844942C58DC46B9E23CF8E67-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--D7BA4BB0844942C58DC46B9E23CF8E67-->  <AD_MODULE_ID><![CDATA[4B828F4D03264080AA1D2057B13F613C]]></AD_MODULE_ID>
 <!--D7BA4BB0844942C58DC46B9E23CF8E67-->  <AD_DEPENDENT_MODULE_ID><![CDATA[F8D1B3ECB3474E8DA5C216473C840DF1]]></AD_DEPENDENT_MODULE_ID>
-<!--D7BA4BB0844942C58DC46B9E23CF8E67-->  <STARTVERSION><![CDATA[2.0.20056]]></STARTVERSION>
+<!--D7BA4BB0844942C58DC46B9E23CF8E67-->  <STARTVERSION><![CDATA[2.0.20252]]></STARTVERSION>
 <!--D7BA4BB0844942C58DC46B9E23CF8E67-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--D7BA4BB0844942C58DC46B9E23CF8E67-->  <DEPENDANT_MODULE_NAME><![CDATA[JSON REST Webservice]]></DEPENDANT_MODULE_NAME>
 <!--D7BA4BB0844942C58DC46B9E23CF8E67-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelServlet.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelServlet.java	Thu May 09 12:06:37 2013 +0200
@@ -37,9 +37,11 @@
 import org.apache.log4j.Logger;
 import org.openbravo.base.ConfigParameters;
 import org.openbravo.base.HttpBaseUtils;
+import org.openbravo.base.exception.OBSecurityException;
 import org.openbravo.base.util.OBClassLoader;
 import org.openbravo.base.weld.WeldUtils;
 import org.openbravo.dal.core.OBContext;
+import org.openbravo.portal.PortalAccessible;
 import org.openbravo.service.web.WebServiceUtil;
 
 /**
@@ -256,6 +258,17 @@
       final Class<ActionHandler> actionHandlerClass = (Class<ActionHandler>) OBClassLoader
           .getInstance().loadClass(action);
       final ActionHandler actionHandler = weldUtils.getInstance(actionHandlerClass);
+
+      if (OBContext.getOBContext() != null && OBContext.getOBContext().isPortalRole()) {
+        if (!(actionHandler instanceof PortalAccessible)) {
+          log4j.error("Portal user " + OBContext.getOBContext().getUser() + " with role "
+              + OBContext.getOBContext().getRole()
+              + " is trying to access to non granted action handler " + request.getRequestURL()
+              + "?" + request.getQueryString());
+          throw new OBSecurityException("Portal role has no access to this handler");
+        }
+      }
+
       actionHandler.execute();
     } catch (Exception e) {
       log4j.error("Error executing action " + action + " error: " + e.getMessage(), e);
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/DateUIDefinition.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/DateUIDefinition.java	Thu May 09 12:06:37 2013 +0200
@@ -118,6 +118,9 @@
     if (value == null) {
       return "";
     }
+    if (value instanceof String) {
+      return (String) value;
+    }
     return getClassicFormat().format(value);
   }
 
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/FKComboUIDefinition.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/FKComboUIDefinition.java	Thu May 09 12:06:37 2013 +0200
@@ -68,6 +68,7 @@
               referencedTable.getDisplayedColumn());
           if (prop != null && referencedProp != null) {
             criteriaField = ", criteriaField: " + "'" + prop.getName() + DalUtil.FIELDSEPARATOR
+                + referencedProp.getName() + "', criteriaDisplayField: '"
                 + referencedProp.getName() + "'";
           }
         }
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/NumberUIDefinition.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/NumberUIDefinition.java	Thu May 09 12:06:37 2013 +0200
@@ -175,6 +175,11 @@
     if (value == null) {
       return "";
     }
+
+    if (value instanceof String) {
+      return (String) value;
+    }
+
     final String valueStr = value.toString();
     VariablesSecureApp variables = RequestContext.get().getVariablesSecureApp();
     // only replace the decimal symbol
--- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/TimeUIDefinition.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/TimeUIDefinition.java	Thu May 09 12:06:37 2013 +0200
@@ -58,6 +58,11 @@
     if (value == null || value == "") {
       return "";
     }
+
+    if (value instanceof String) {
+      return (String) value;
+    }
+
     String timestamp = value.toString();
     timestamp = timestamp.substring(timestamp.indexOf(" ") + 1);
     StringBuffer convertedValue = convertUtcToLocalTime(timestamp);
--- a/modules/org.openbravo.client.myob/src-db/database/sourcedata/AD_MODULE.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.myob/src-db/database/sourcedata/AD_MODULE.xml	Thu May 09 12:06:37 2013 +0200
@@ -6,7 +6,7 @@
 <!--2758CD25B2704AF6BBAD10365FC82C06-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--2758CD25B2704AF6BBAD10365FC82C06-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--2758CD25B2704AF6BBAD10365FC82C06-->  <NAME><![CDATA[Workspace & Widgets]]></NAME>
-<!--2758CD25B2704AF6BBAD10365FC82C06-->  <VERSION><![CDATA[2.1.20056]]></VERSION>
+<!--2758CD25B2704AF6BBAD10365FC82C06-->  <VERSION><![CDATA[2.1.20252]]></VERSION>
 <!--2758CD25B2704AF6BBAD10365FC82C06-->  <DESCRIPTION><![CDATA[Workspace & Widgets]]></DESCRIPTION>
 <!--2758CD25B2704AF6BBAD10365FC82C06-->  <HELP><![CDATA[Provides the infrastructure of workspace tab (formerly My Openbravo)]]></HELP>
 <!--2758CD25B2704AF6BBAD10365FC82C06-->  <URL><![CDATA[http://forge.openbravo.com/projects/myopenbravo]]></URL>
--- a/modules/org.openbravo.client.myob/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.myob/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Thu May 09 12:06:37 2013 +0200
@@ -7,7 +7,7 @@
 <!--15F51F03882F444CAB6593B4566DC929-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--15F51F03882F444CAB6593B4566DC929-->  <AD_MODULE_ID><![CDATA[2758CD25B2704AF6BBAD10365FC82C06]]></AD_MODULE_ID>
 <!--15F51F03882F444CAB6593B4566DC929-->  <AD_DEPENDENT_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_DEPENDENT_MODULE_ID>
-<!--15F51F03882F444CAB6593B4566DC929-->  <STARTVERSION><![CDATA[2.1.20056]]></STARTVERSION>
+<!--15F51F03882F444CAB6593B4566DC929-->  <STARTVERSION><![CDATA[2.1.20252]]></STARTVERSION>
 <!--15F51F03882F444CAB6593B4566DC929-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--15F51F03882F444CAB6593B4566DC929-->  <DEPENDANT_MODULE_NAME><![CDATA[User Interface Application]]></DEPENDANT_MODULE_NAME>
 <!--15F51F03882F444CAB6593B4566DC929-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
@@ -21,7 +21,7 @@
 <!--E71B28FC949D481D9F59C17D01E46EF9-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--E71B28FC949D481D9F59C17D01E46EF9-->  <AD_MODULE_ID><![CDATA[2758CD25B2704AF6BBAD10365FC82C06]]></AD_MODULE_ID>
 <!--E71B28FC949D481D9F59C17D01E46EF9-->  <AD_DEPENDENT_MODULE_ID><![CDATA[0]]></AD_DEPENDENT_MODULE_ID>
-<!--E71B28FC949D481D9F59C17D01E46EF9-->  <STARTVERSION><![CDATA[3.0.20056]]></STARTVERSION>
+<!--E71B28FC949D481D9F59C17D01E46EF9-->  <STARTVERSION><![CDATA[3.0.20252]]></STARTVERSION>
 <!--E71B28FC949D481D9F59C17D01E46EF9-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--E71B28FC949D481D9F59C17D01E46EF9-->  <DEPENDANT_MODULE_NAME><![CDATA[Core]]></DEPENDANT_MODULE_NAME>
 <!--E71B28FC949D481D9F59C17D01E46EF9-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
--- a/modules/org.openbravo.client.myob/src/org/openbravo/client/myob/MyOpenbravoActionHandler.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.myob/src/org/openbravo/client/myob/MyOpenbravoActionHandler.java	Thu May 09 12:06:37 2013 +0200
@@ -49,10 +49,11 @@
 import org.openbravo.model.ad.access.User;
 import org.openbravo.model.ad.system.Client;
 import org.openbravo.model.common.enterprise.Organization;
+import org.openbravo.portal.PortalAccessible;
 import org.openbravo.service.db.DalConnectionProvider;
 
 @ApplicationScoped
-public class MyOpenbravoActionHandler extends BaseActionHandler {
+public class MyOpenbravoActionHandler extends BaseActionHandler implements PortalAccessible {
   private static final Logger log = Logger.getLogger(MyOpenbravoActionHandler.class);
   private static final String WIDGET_MOVED = "WIDGET_MOVED";
   private static final String WIDGET_ADDED = "WIDGET_ADDED";
--- a/modules/org.openbravo.client.querylist/src-db/database/sourcedata/AD_MESSAGE.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.querylist/src-db/database/sourcedata/AD_MESSAGE.xml	Thu May 09 12:06:37 2013 +0200
@@ -12,6 +12,18 @@
 <!--18EE399F2AF54EA3BEB5086D4BF6D4B1-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--18EE399F2AF54EA3BEB5086D4BF6D4B1--></AD_MESSAGE>
 
+<!--4D8B309237B84F3DAC3F193F69CB81C5--><AD_MESSAGE>
+<!--4D8B309237B84F3DAC3F193F69CB81C5-->  <AD_MESSAGE_ID><![CDATA[4D8B309237B84F3DAC3F193F69CB81C5]]></AD_MESSAGE_ID>
+<!--4D8B309237B84F3DAC3F193F69CB81C5-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--4D8B309237B84F3DAC3F193F69CB81C5-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--4D8B309237B84F3DAC3F193F69CB81C5-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--4D8B309237B84F3DAC3F193F69CB81C5-->  <VALUE><![CDATA[OBCQL_NoAccessToWidget]]></VALUE>
+<!--4D8B309237B84F3DAC3F193F69CB81C5-->  <MSGTEXT><![CDATA[Current user/role does not have access to widget %0]]></MSGTEXT>
+<!--4D8B309237B84F3DAC3F193F69CB81C5-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--4D8B309237B84F3DAC3F193F69CB81C5-->  <AD_MODULE_ID><![CDATA[0A060B2AF1974E8EAA8DB61388E9AECC]]></AD_MODULE_ID>
+<!--4D8B309237B84F3DAC3F193F69CB81C5-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--4D8B309237B84F3DAC3F193F69CB81C5--></AD_MESSAGE>
+
 <!--51E3AB93D32F488E896F1E03654B89F3--><AD_MESSAGE>
 <!--51E3AB93D32F488E896F1E03654B89F3-->  <AD_MESSAGE_ID><![CDATA[51E3AB93D32F488E896F1E03654B89F3]]></AD_MESSAGE_ID>
 <!--51E3AB93D32F488E896F1E03654B89F3-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.client.querylist/src-db/database/sourcedata/AD_MODULE.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.querylist/src-db/database/sourcedata/AD_MODULE.xml	Thu May 09 12:06:37 2013 +0200
@@ -6,7 +6,7 @@
 <!--0A060B2AF1974E8EAA8DB61388E9AECC-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--0A060B2AF1974E8EAA8DB61388E9AECC-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--0A060B2AF1974E8EAA8DB61388E9AECC-->  <NAME><![CDATA[Query/List Widget]]></NAME>
-<!--0A060B2AF1974E8EAA8DB61388E9AECC-->  <VERSION><![CDATA[1.0.20056]]></VERSION>
+<!--0A060B2AF1974E8EAA8DB61388E9AECC-->  <VERSION><![CDATA[1.0.20252]]></VERSION>
 <!--0A060B2AF1974E8EAA8DB61388E9AECC-->  <DESCRIPTION><![CDATA[Provides the Query/List superclass widget that allows to create widget classes that prints a grid of data based on a query.]]></DESCRIPTION>
 <!--0A060B2AF1974E8EAA8DB61388E9AECC-->  <HELP><![CDATA[With this module you can define your own widget classes that just with simple Application Dictionary shows a grid of data based on a HQL Query.]]></HELP>
 <!--0A060B2AF1974E8EAA8DB61388E9AECC-->  <URL><![CDATA[http://forge.openbravo.com/projects/querylistwidget]]></URL>
--- a/modules/org.openbravo.client.querylist/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.querylist/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Thu May 09 12:06:37 2013 +0200
@@ -7,7 +7,7 @@
 <!--26558497C31140BFAB067BA4BC47D799-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--26558497C31140BFAB067BA4BC47D799-->  <AD_MODULE_ID><![CDATA[0A060B2AF1974E8EAA8DB61388E9AECC]]></AD_MODULE_ID>
 <!--26558497C31140BFAB067BA4BC47D799-->  <AD_DEPENDENT_MODULE_ID><![CDATA[2758CD25B2704AF6BBAD10365FC82C06]]></AD_DEPENDENT_MODULE_ID>
-<!--26558497C31140BFAB067BA4BC47D799-->  <STARTVERSION><![CDATA[2.1.20056]]></STARTVERSION>
+<!--26558497C31140BFAB067BA4BC47D799-->  <STARTVERSION><![CDATA[2.1.20252]]></STARTVERSION>
 <!--26558497C31140BFAB067BA4BC47D799-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--26558497C31140BFAB067BA4BC47D799-->  <DEPENDANT_MODULE_NAME><![CDATA[My Openbravo Tab]]></DEPENDANT_MODULE_NAME>
 <!--26558497C31140BFAB067BA4BC47D799-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
--- a/modules/org.openbravo.client.querylist/src/org/openbravo/client/querylist/QueryListDataSource.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.querylist/src/org/openbravo/client/querylist/QueryListDataSource.java	Thu May 09 12:06:37 2013 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2012 Openbravo SLU
+ * All portions are Copyright (C) 2010-2013 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -40,6 +40,7 @@
 import org.codehaus.jettison.json.JSONObject;
 import org.hibernate.Query;
 import org.openbravo.base.exception.OBException;
+import org.openbravo.base.exception.OBSecurityException;
 import org.openbravo.base.model.ModelProvider;
 import org.openbravo.base.model.domaintype.BigDecimalDomainType;
 import org.openbravo.base.model.domaintype.BooleanDomainType;
@@ -56,9 +57,12 @@
 import org.openbravo.client.kernel.reference.UIDefinitionController;
 import org.openbravo.client.kernel.reference.YesNoUIDefinition;
 import org.openbravo.client.myob.WidgetClass;
+import org.openbravo.client.myob.WidgetInstance;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBDal;
+import org.openbravo.erpCommon.utility.OBMessageUtils;
 import org.openbravo.model.ad.domain.Reference;
+import org.openbravo.portal.PortalAccessible;
 import org.openbravo.service.datasource.DataSourceProperty;
 import org.openbravo.service.datasource.ReadOnlyDataSourceService;
 import org.openbravo.service.json.JsonConstants;
@@ -69,7 +73,7 @@
  * 
  * @author gorkaion
  */
-public class QueryListDataSource extends ReadOnlyDataSourceService {
+public class QueryListDataSource extends ReadOnlyDataSourceService implements PortalAccessible {
   private static final String OPTIONAL_FILTERS = "@optional_filters@";
   private static final Logger log = Logger.getLogger(QueryListDataSource.class);
 
@@ -96,6 +100,32 @@
     try {
       WidgetClass widgetClass = OBDal.getInstance().get(WidgetClass.class,
           parameters.get("widgetId"));
+
+      // Check security: continue only if the widget instance is visible for current user/role
+      WidgetInstance wi = OBDal.getInstance().get(WidgetInstance.class,
+          parameters.get("widgetInstanceId"));
+      if (wi == null || wi.getWidgetClass().getId() != widgetClass.getId()) {
+        // weird stuff: widget class doesn't match widget instance's class, most probably URL is
+        // not generated by UI, but user is typing it
+        log.error("User " + OBContext.getOBContext().getUser() + " with role "
+            + OBContext.getOBContext().getRole() + " is trying to access widget '"
+            + widgetClass.getWidgetTitle() + "' but widget istance doesn't match with class");
+        throw new OBSecurityException(OBMessageUtils.getI18NMessage("OBCQL_NoAccessToWidget",
+            new String[] { widgetClass.getWidgetTitle() }));
+      }
+
+      if (OBContext.getOBContext() != null
+          && ((wi.getVisibleAtUser() != null && !wi.getVisibleAtUser().getId()
+              .equals(OBContext.getOBContext().getUser().getId())))
+          || (wi.getVisibleAtRole() != null && !wi.getVisibleAtRole().getId()
+              .equals(OBContext.getOBContext().getRole().getId()))) {
+        log.error("User " + OBContext.getOBContext().getUser() + " with role "
+            + OBContext.getOBContext().getRole() + " is trying to access widget '"
+            + widgetClass.getWidgetTitle() + "' which is not granted");
+        throw new OBSecurityException(OBMessageUtils.getI18NMessage("OBCQL_NoAccessToWidget",
+            new String[] { widgetClass.getWidgetTitle() }));
+      }
+
       boolean isExport = "true".equals(parameters.get("exportToFile"));
       boolean showAll = "true".equals(parameters.get("showAll"));
       String viewMode = parameters.get("viewMode");
--- a/modules/org.openbravo.client.widgets/src-db/database/sourcedata/AD_ELEMENT.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.widgets/src-db/database/sourcedata/AD_ELEMENT.xml	Thu May 09 12:06:37 2013 +0200
@@ -1,5 +1,17 @@
 <?xml version='1.0' encoding='UTF-8'?>
 <data>
+<!--32873C7A39ED464F9D781AB4BE08323B--><AD_ELEMENT>
+<!--32873C7A39ED464F9D781AB4BE08323B-->  <AD_ELEMENT_ID><![CDATA[32873C7A39ED464F9D781AB4BE08323B]]></AD_ELEMENT_ID>
+<!--32873C7A39ED464F9D781AB4BE08323B-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--32873C7A39ED464F9D781AB4BE08323B-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--32873C7A39ED464F9D781AB4BE08323B-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--32873C7A39ED464F9D781AB4BE08323B-->  <COLUMNNAME><![CDATA[organizationList]]></COLUMNNAME>
+<!--32873C7A39ED464F9D781AB4BE08323B-->  <NAME><![CDATA[Organization List]]></NAME>
+<!--32873C7A39ED464F9D781AB4BE08323B-->  <PRINTNAME><![CDATA[Organization List]]></PRINTNAME>
+<!--32873C7A39ED464F9D781AB4BE08323B-->  <AD_MODULE_ID><![CDATA[FF8080812D842086012D844F3CC0003E]]></AD_MODULE_ID>
+<!--32873C7A39ED464F9D781AB4BE08323B-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
+<!--32873C7A39ED464F9D781AB4BE08323B--></AD_ELEMENT>
+
 <!--9C7735D7BEB33C9EE040A8C0EB06271C--><AD_ELEMENT>
 <!--9C7735D7BEB33C9EE040A8C0EB06271C-->  <AD_ELEMENT_ID><![CDATA[9C7735D7BEB33C9EE040A8C0EB06271C]]></AD_ELEMENT_ID>
 <!--9C7735D7BEB33C9EE040A8C0EB06271C-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.client.widgets/src-db/database/sourcedata/AD_MODULE.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.widgets/src-db/database/sourcedata/AD_MODULE.xml	Thu May 09 12:06:37 2013 +0200
@@ -6,7 +6,7 @@
 <!--FF8080812D842086012D844F3CC0003E-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--FF8080812D842086012D844F3CC0003E-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--FF8080812D842086012D844F3CC0003E-->  <NAME><![CDATA[Widgets Collection]]></NAME>
-<!--FF8080812D842086012D844F3CC0003E-->  <VERSION><![CDATA[0.0.20056]]></VERSION>
+<!--FF8080812D842086012D844F3CC0003E-->  <VERSION><![CDATA[0.0.20252]]></VERSION>
 <!--FF8080812D842086012D844F3CC0003E-->  <DESCRIPTION><![CDATA[Collection of Workspace Widgets]]></DESCRIPTION>
 <!--FF8080812D842086012D844F3CC0003E-->  <HELP><![CDATA[Collection of Workspace Widgets]]></HELP>
 <!--FF8080812D842086012D844F3CC0003E-->  <URL><![CDATA[http://forge.openbravo.com/projects/widgetscollection]]></URL>
--- a/modules/org.openbravo.client.widgets/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.widgets/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Thu May 09 12:06:37 2013 +0200
@@ -7,7 +7,7 @@
 <!--FF8080812D842086012D845002070046-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--FF8080812D842086012D845002070046-->  <AD_MODULE_ID><![CDATA[FF8080812D842086012D844F3CC0003E]]></AD_MODULE_ID>
 <!--FF8080812D842086012D845002070046-->  <AD_DEPENDENT_MODULE_ID><![CDATA[2758CD25B2704AF6BBAD10365FC82C06]]></AD_DEPENDENT_MODULE_ID>
-<!--FF8080812D842086012D845002070046-->  <STARTVERSION><![CDATA[2.1.20056]]></STARTVERSION>
+<!--FF8080812D842086012D845002070046-->  <STARTVERSION><![CDATA[2.1.20252]]></STARTVERSION>
 <!--FF8080812D842086012D845002070046-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--FF8080812D842086012D845002070046-->  <DEPENDANT_MODULE_NAME><![CDATA[Workspace & Widgets]]></DEPENDANT_MODULE_NAME>
 <!--FF8080812D842086012D845002070046-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
--- a/modules/org.openbravo.client.widgets/src-db/database/sourcedata/OBCQL_QUERY_COLUMN.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.widgets/src-db/database/sourcedata/OBCQL_QUERY_COLUMN.xml	Thu May 09 12:06:37 2013 +0200
@@ -1,5 +1,24 @@
 <?xml version='1.0' encoding='UTF-8'?>
 <data>
+<!--00786482F5BC4FB2BB3E205C1DB6D9FE--><OBCQL_QUERY_COLUMN>
+<!--00786482F5BC4FB2BB3E205C1DB6D9FE-->  <OBCQL_QUERY_COLUMN_ID><![CDATA[00786482F5BC4FB2BB3E205C1DB6D9FE]]></OBCQL_QUERY_COLUMN_ID>
+<!--00786482F5BC4FB2BB3E205C1DB6D9FE-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--00786482F5BC4FB2BB3E205C1DB6D9FE-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--00786482F5BC4FB2BB3E205C1DB6D9FE-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--00786482F5BC4FB2BB3E205C1DB6D9FE-->  <OBCQL_WIDGET_QUERY_ID><![CDATA[53389C2060AD4DBEA1F9009A3C82B63F]]></OBCQL_WIDGET_QUERY_ID>
+<!--00786482F5BC4FB2BB3E205C1DB6D9FE-->  <DISPLAY_EXPRESSION><![CDATA[warehouse]]></DISPLAY_EXPRESSION>
+<!--00786482F5BC4FB2BB3E205C1DB6D9FE-->  <NAME><![CDATA[Warehouse]]></NAME>
+<!--00786482F5BC4FB2BB3E205C1DB6D9FE-->  <WIDTH><![CDATA[10]]></WIDTH>
+<!--00786482F5BC4FB2BB3E205C1DB6D9FE-->  <LINK_EXPRESSION><![CDATA[whid]]></LINK_EXPRESSION>
+<!--00786482F5BC4FB2BB3E205C1DB6D9FE-->  <SEQNO><![CDATA[20]]></SEQNO>
+<!--00786482F5BC4FB2BB3E205C1DB6D9FE-->  <AD_REFERENCE_ID><![CDATA[10]]></AD_REFERENCE_ID>
+<!--00786482F5BC4FB2BB3E205C1DB6D9FE-->  <INCLUDE_IN><![CDATA[M]]></INCLUDE_IN>
+<!--00786482F5BC4FB2BB3E205C1DB6D9FE-->  <HAS_LINK><![CDATA[Y]]></HAS_LINK>
+<!--00786482F5BC4FB2BB3E205C1DB6D9FE-->  <AD_TAB_ID><![CDATA[178]]></AD_TAB_ID>
+<!--00786482F5BC4FB2BB3E205C1DB6D9FE-->  <CAN_BE_FILTERED><![CDATA[Y]]></CAN_BE_FILTERED>
+<!--00786482F5BC4FB2BB3E205C1DB6D9FE-->  <WHERECLAUSE_LEFT_PART><![CDATA[Warehouse.name]]></WHERECLAUSE_LEFT_PART>
+<!--00786482F5BC4FB2BB3E205C1DB6D9FE--></OBCQL_QUERY_COLUMN>
+
 <!--28F920CD36E14AFBB2025802363E8B02--><OBCQL_QUERY_COLUMN>
 <!--28F920CD36E14AFBB2025802363E8B02-->  <OBCQL_QUERY_COLUMN_ID><![CDATA[28F920CD36E14AFBB2025802363E8B02]]></OBCQL_QUERY_COLUMN_ID>
 <!--28F920CD36E14AFBB2025802363E8B02-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -49,6 +68,41 @@
 <!--3A8324D4520B42B08DDED26BD05F98B5-->  <CAN_BE_FILTERED><![CDATA[N]]></CAN_BE_FILTERED>
 <!--3A8324D4520B42B08DDED26BD05F98B5--></OBCQL_QUERY_COLUMN>
 
+<!--7D6F8F4432754AB5872B925CF2BD1E37--><OBCQL_QUERY_COLUMN>
+<!--7D6F8F4432754AB5872B925CF2BD1E37-->  <OBCQL_QUERY_COLUMN_ID><![CDATA[7D6F8F4432754AB5872B925CF2BD1E37]]></OBCQL_QUERY_COLUMN_ID>
+<!--7D6F8F4432754AB5872B925CF2BD1E37-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--7D6F8F4432754AB5872B925CF2BD1E37-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--7D6F8F4432754AB5872B925CF2BD1E37-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--7D6F8F4432754AB5872B925CF2BD1E37-->  <OBCQL_WIDGET_QUERY_ID><![CDATA[53389C2060AD4DBEA1F9009A3C82B63F]]></OBCQL_WIDGET_QUERY_ID>
+<!--7D6F8F4432754AB5872B925CF2BD1E37-->  <DISPLAY_EXPRESSION><![CDATA[store]]></DISPLAY_EXPRESSION>
+<!--7D6F8F4432754AB5872B925CF2BD1E37-->  <NAME><![CDATA[Organization]]></NAME>
+<!--7D6F8F4432754AB5872B925CF2BD1E37-->  <WIDTH><![CDATA[10]]></WIDTH>
+<!--7D6F8F4432754AB5872B925CF2BD1E37-->  <LINK_EXPRESSION><![CDATA[orgid]]></LINK_EXPRESSION>
+<!--7D6F8F4432754AB5872B925CF2BD1E37-->  <SEQNO><![CDATA[10]]></SEQNO>
+<!--7D6F8F4432754AB5872B925CF2BD1E37-->  <AD_REFERENCE_ID><![CDATA[10]]></AD_REFERENCE_ID>
+<!--7D6F8F4432754AB5872B925CF2BD1E37-->  <INCLUDE_IN><![CDATA[W]]></INCLUDE_IN>
+<!--7D6F8F4432754AB5872B925CF2BD1E37-->  <HAS_LINK><![CDATA[Y]]></HAS_LINK>
+<!--7D6F8F4432754AB5872B925CF2BD1E37-->  <AD_TAB_ID><![CDATA[143]]></AD_TAB_ID>
+<!--7D6F8F4432754AB5872B925CF2BD1E37-->  <CAN_BE_FILTERED><![CDATA[Y]]></CAN_BE_FILTERED>
+<!--7D6F8F4432754AB5872B925CF2BD1E37-->  <WHERECLAUSE_LEFT_PART><![CDATA[Organization.name]]></WHERECLAUSE_LEFT_PART>
+<!--7D6F8F4432754AB5872B925CF2BD1E37--></OBCQL_QUERY_COLUMN>
+
+<!--8106A2118FF44331B98E04E3F6F022DE--><OBCQL_QUERY_COLUMN>
+<!--8106A2118FF44331B98E04E3F6F022DE-->  <OBCQL_QUERY_COLUMN_ID><![CDATA[8106A2118FF44331B98E04E3F6F022DE]]></OBCQL_QUERY_COLUMN_ID>
+<!--8106A2118FF44331B98E04E3F6F022DE-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--8106A2118FF44331B98E04E3F6F022DE-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--8106A2118FF44331B98E04E3F6F022DE-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--8106A2118FF44331B98E04E3F6F022DE-->  <OBCQL_WIDGET_QUERY_ID><![CDATA[53389C2060AD4DBEA1F9009A3C82B63F]]></OBCQL_WIDGET_QUERY_ID>
+<!--8106A2118FF44331B98E04E3F6F022DE-->  <DISPLAY_EXPRESSION><![CDATA[attr]]></DISPLAY_EXPRESSION>
+<!--8106A2118FF44331B98E04E3F6F022DE-->  <NAME><![CDATA[Product Attribute]]></NAME>
+<!--8106A2118FF44331B98E04E3F6F022DE-->  <WIDTH><![CDATA[10]]></WIDTH>
+<!--8106A2118FF44331B98E04E3F6F022DE-->  <SEQNO><![CDATA[50]]></SEQNO>
+<!--8106A2118FF44331B98E04E3F6F022DE-->  <AD_REFERENCE_ID><![CDATA[10]]></AD_REFERENCE_ID>
+<!--8106A2118FF44331B98E04E3F6F022DE-->  <INCLUDE_IN><![CDATA[M]]></INCLUDE_IN>
+<!--8106A2118FF44331B98E04E3F6F022DE-->  <HAS_LINK><![CDATA[N]]></HAS_LINK>
+<!--8106A2118FF44331B98E04E3F6F022DE-->  <CAN_BE_FILTERED><![CDATA[N]]></CAN_BE_FILTERED>
+<!--8106A2118FF44331B98E04E3F6F022DE--></OBCQL_QUERY_COLUMN>
+
 <!--824EC1769E0D45F8AB4C94DEAE2B5691--><OBCQL_QUERY_COLUMN>
 <!--824EC1769E0D45F8AB4C94DEAE2B5691-->  <OBCQL_QUERY_COLUMN_ID><![CDATA[824EC1769E0D45F8AB4C94DEAE2B5691]]></OBCQL_QUERY_COLUMN_ID>
 <!--824EC1769E0D45F8AB4C94DEAE2B5691-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -87,6 +141,23 @@
 <!--896F28AC4D454104A7B763ED8C279794-->  <CAN_BE_FILTERED><![CDATA[N]]></CAN_BE_FILTERED>
 <!--896F28AC4D454104A7B763ED8C279794--></OBCQL_QUERY_COLUMN>
 
+<!--97F2CA4B8CC64E64817EADAE7A837BF1--><OBCQL_QUERY_COLUMN>
+<!--97F2CA4B8CC64E64817EADAE7A837BF1-->  <OBCQL_QUERY_COLUMN_ID><![CDATA[97F2CA4B8CC64E64817EADAE7A837BF1]]></OBCQL_QUERY_COLUMN_ID>
+<!--97F2CA4B8CC64E64817EADAE7A837BF1-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--97F2CA4B8CC64E64817EADAE7A837BF1-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--97F2CA4B8CC64E64817EADAE7A837BF1-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--97F2CA4B8CC64E64817EADAE7A837BF1-->  <OBCQL_WIDGET_QUERY_ID><![CDATA[53389C2060AD4DBEA1F9009A3C82B63F]]></OBCQL_WIDGET_QUERY_ID>
+<!--97F2CA4B8CC64E64817EADAE7A837BF1-->  <DISPLAY_EXPRESSION><![CDATA[qtyonhand]]></DISPLAY_EXPRESSION>
+<!--97F2CA4B8CC64E64817EADAE7A837BF1-->  <NAME><![CDATA[Quantity On Hand]]></NAME>
+<!--97F2CA4B8CC64E64817EADAE7A837BF1-->  <SUMMARIZE_TYPE><![CDATA[sum]]></SUMMARIZE_TYPE>
+<!--97F2CA4B8CC64E64817EADAE7A837BF1-->  <WIDTH><![CDATA[10]]></WIDTH>
+<!--97F2CA4B8CC64E64817EADAE7A837BF1-->  <SEQNO><![CDATA[60]]></SEQNO>
+<!--97F2CA4B8CC64E64817EADAE7A837BF1-->  <AD_REFERENCE_ID><![CDATA[22]]></AD_REFERENCE_ID>
+<!--97F2CA4B8CC64E64817EADAE7A837BF1-->  <INCLUDE_IN><![CDATA[W]]></INCLUDE_IN>
+<!--97F2CA4B8CC64E64817EADAE7A837BF1-->  <HAS_LINK><![CDATA[N]]></HAS_LINK>
+<!--97F2CA4B8CC64E64817EADAE7A837BF1-->  <CAN_BE_FILTERED><![CDATA[N]]></CAN_BE_FILTERED>
+<!--97F2CA4B8CC64E64817EADAE7A837BF1--></OBCQL_QUERY_COLUMN>
+
 <!--A7F9DA78BB164108B69479709BEE41A3--><OBCQL_QUERY_COLUMN>
 <!--A7F9DA78BB164108B69479709BEE41A3-->  <OBCQL_QUERY_COLUMN_ID><![CDATA[A7F9DA78BB164108B69479709BEE41A3]]></OBCQL_QUERY_COLUMN_ID>
 <!--A7F9DA78BB164108B69479709BEE41A3-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -103,6 +174,25 @@
 <!--A7F9DA78BB164108B69479709BEE41A3-->  <CAN_BE_FILTERED><![CDATA[N]]></CAN_BE_FILTERED>
 <!--A7F9DA78BB164108B69479709BEE41A3--></OBCQL_QUERY_COLUMN>
 
+<!--ACAA48835B0E4A8D9AC6FCF73AD148C3--><OBCQL_QUERY_COLUMN>
+<!--ACAA48835B0E4A8D9AC6FCF73AD148C3-->  <OBCQL_QUERY_COLUMN_ID><![CDATA[ACAA48835B0E4A8D9AC6FCF73AD148C3]]></OBCQL_QUERY_COLUMN_ID>
+<!--ACAA48835B0E4A8D9AC6FCF73AD148C3-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--ACAA48835B0E4A8D9AC6FCF73AD148C3-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--ACAA48835B0E4A8D9AC6FCF73AD148C3-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--ACAA48835B0E4A8D9AC6FCF73AD148C3-->  <OBCQL_WIDGET_QUERY_ID><![CDATA[53389C2060AD4DBEA1F9009A3C82B63F]]></OBCQL_WIDGET_QUERY_ID>
+<!--ACAA48835B0E4A8D9AC6FCF73AD148C3-->  <DISPLAY_EXPRESSION><![CDATA[category]]></DISPLAY_EXPRESSION>
+<!--ACAA48835B0E4A8D9AC6FCF73AD148C3-->  <NAME><![CDATA[Product Category]]></NAME>
+<!--ACAA48835B0E4A8D9AC6FCF73AD148C3-->  <WIDTH><![CDATA[10]]></WIDTH>
+<!--ACAA48835B0E4A8D9AC6FCF73AD148C3-->  <LINK_EXPRESSION><![CDATA[pcid]]></LINK_EXPRESSION>
+<!--ACAA48835B0E4A8D9AC6FCF73AD148C3-->  <SEQNO><![CDATA[30]]></SEQNO>
+<!--ACAA48835B0E4A8D9AC6FCF73AD148C3-->  <AD_REFERENCE_ID><![CDATA[10]]></AD_REFERENCE_ID>
+<!--ACAA48835B0E4A8D9AC6FCF73AD148C3-->  <INCLUDE_IN><![CDATA[W]]></INCLUDE_IN>
+<!--ACAA48835B0E4A8D9AC6FCF73AD148C3-->  <HAS_LINK><![CDATA[Y]]></HAS_LINK>
+<!--ACAA48835B0E4A8D9AC6FCF73AD148C3-->  <AD_TAB_ID><![CDATA[189]]></AD_TAB_ID>
+<!--ACAA48835B0E4A8D9AC6FCF73AD148C3-->  <CAN_BE_FILTERED><![CDATA[Y]]></CAN_BE_FILTERED>
+<!--ACAA48835B0E4A8D9AC6FCF73AD148C3-->  <WHERECLAUSE_LEFT_PART><![CDATA[ProductCategory.name]]></WHERECLAUSE_LEFT_PART>
+<!--ACAA48835B0E4A8D9AC6FCF73AD148C3--></OBCQL_QUERY_COLUMN>
+
 <!--AD5A79DBC85846EBAA6F881DA264A0CD--><OBCQL_QUERY_COLUMN>
 <!--AD5A79DBC85846EBAA6F881DA264A0CD-->  <OBCQL_QUERY_COLUMN_ID><![CDATA[AD5A79DBC85846EBAA6F881DA264A0CD]]></OBCQL_QUERY_COLUMN_ID>
 <!--AD5A79DBC85846EBAA6F881DA264A0CD-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -171,6 +261,25 @@
 <!--E4755A4156FE4E87AFC771FDCE3F9A0B-->  <CAN_BE_FILTERED><![CDATA[N]]></CAN_BE_FILTERED>
 <!--E4755A4156FE4E87AFC771FDCE3F9A0B--></OBCQL_QUERY_COLUMN>
 
+<!--F4028CFC1E6C405FB02AF3F922A98CF4--><OBCQL_QUERY_COLUMN>
+<!--F4028CFC1E6C405FB02AF3F922A98CF4-->  <OBCQL_QUERY_COLUMN_ID><![CDATA[F4028CFC1E6C405FB02AF3F922A98CF4]]></OBCQL_QUERY_COLUMN_ID>
+<!--F4028CFC1E6C405FB02AF3F922A98CF4-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--F4028CFC1E6C405FB02AF3F922A98CF4-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--F4028CFC1E6C405FB02AF3F922A98CF4-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--F4028CFC1E6C405FB02AF3F922A98CF4-->  <OBCQL_WIDGET_QUERY_ID><![CDATA[53389C2060AD4DBEA1F9009A3C82B63F]]></OBCQL_WIDGET_QUERY_ID>
+<!--F4028CFC1E6C405FB02AF3F922A98CF4-->  <DISPLAY_EXPRESSION><![CDATA[product]]></DISPLAY_EXPRESSION>
+<!--F4028CFC1E6C405FB02AF3F922A98CF4-->  <NAME><![CDATA[Product]]></NAME>
+<!--F4028CFC1E6C405FB02AF3F922A98CF4-->  <WIDTH><![CDATA[10]]></WIDTH>
+<!--F4028CFC1E6C405FB02AF3F922A98CF4-->  <LINK_EXPRESSION><![CDATA[pid]]></LINK_EXPRESSION>
+<!--F4028CFC1E6C405FB02AF3F922A98CF4-->  <SEQNO><![CDATA[40]]></SEQNO>
+<!--F4028CFC1E6C405FB02AF3F922A98CF4-->  <AD_REFERENCE_ID><![CDATA[10]]></AD_REFERENCE_ID>
+<!--F4028CFC1E6C405FB02AF3F922A98CF4-->  <INCLUDE_IN><![CDATA[W]]></INCLUDE_IN>
+<!--F4028CFC1E6C405FB02AF3F922A98CF4-->  <HAS_LINK><![CDATA[Y]]></HAS_LINK>
+<!--F4028CFC1E6C405FB02AF3F922A98CF4-->  <AD_TAB_ID><![CDATA[180]]></AD_TAB_ID>
+<!--F4028CFC1E6C405FB02AF3F922A98CF4-->  <CAN_BE_FILTERED><![CDATA[Y]]></CAN_BE_FILTERED>
+<!--F4028CFC1E6C405FB02AF3F922A98CF4-->  <WHERECLAUSE_LEFT_PART><![CDATA[Product.name]]></WHERECLAUSE_LEFT_PART>
+<!--F4028CFC1E6C405FB02AF3F922A98CF4--></OBCQL_QUERY_COLUMN>
+
 <!--F80128948ADD4FDFBAC82BF7EBF0FEFD--><OBCQL_QUERY_COLUMN>
 <!--F80128948ADD4FDFBAC82BF7EBF0FEFD-->  <OBCQL_QUERY_COLUMN_ID><![CDATA[F80128948ADD4FDFBAC82BF7EBF0FEFD]]></OBCQL_QUERY_COLUMN_ID>
 <!--F80128948ADD4FDFBAC82BF7EBF0FEFD-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.client.widgets/src-db/database/sourcedata/OBCQL_WIDGET_QUERY.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.widgets/src-db/database/sourcedata/OBCQL_WIDGET_QUERY.xml	Thu May 09 12:06:37 2013 +0200
@@ -1,5 +1,28 @@
 <?xml version='1.0' encoding='UTF-8'?>
 <data>
+<!--53389C2060AD4DBEA1F9009A3C82B63F--><OBCQL_WIDGET_QUERY>
+<!--53389C2060AD4DBEA1F9009A3C82B63F-->  <OBCQL_WIDGET_QUERY_ID><![CDATA[53389C2060AD4DBEA1F9009A3C82B63F]]></OBCQL_WIDGET_QUERY_ID>
+<!--53389C2060AD4DBEA1F9009A3C82B63F-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--53389C2060AD4DBEA1F9009A3C82B63F-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--53389C2060AD4DBEA1F9009A3C82B63F-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--53389C2060AD4DBEA1F9009A3C82B63F-->  <OBKMO_WIDGET_CLASS_ID><![CDATA[5B41A19E11494C519BE33BBED6012DAE]]></OBKMO_WIDGET_CLASS_ID>
+<!--53389C2060AD4DBEA1F9009A3C82B63F-->  <HQL><![CDATA[select Organization.name as store, Warehouse.name as warehouse,Organization.id as orgid, Product.searchKey as identifier,Product.name as product,Product.id as pid, ProductCategory.name as category, ProductCategory.id as pcid,UOM.name as uom, sum(ps.quantityOnHand) as qtyonhand,AttributeSetInstance.description as attr,Warehouse.id as whid
+from ProductStockView ps left outer join ps.product as Product
+left outer join ps.storageBin as Locator
+left outer join Locator.warehouse as Warehouse
+left outer join Product.productCategory as ProductCategory
+left outer join Warehouse.organization as Organization
+left outer join ps.uOM as UOM
+left outer join ps.attributeSetValue as AttributeSetInstance
+where ps.client.id=:client
+and ps.organization.id IN (:organizationList)
+and Product.stocked='Y'
+and @optional_filters@
+group by Organization.name, Warehouse.name, Organization.id, Product.searchKey, Product.name, Product.id, ProductCategory.name, ProductCategory.id, UOM.name, AttributeSetInstance.description,Warehouse.id
+order by Warehouse.name, Product.name, sum(ps.quantityOnHand) desc]]></HQL>
+<!--53389C2060AD4DBEA1F9009A3C82B63F-->  <TYPE><![CDATA[HQL]]></TYPE>
+<!--53389C2060AD4DBEA1F9009A3C82B63F--></OBCQL_WIDGET_QUERY>
+
 <!--CFDF8EE593F04CFE9709F5AD19A3A573--><OBCQL_WIDGET_QUERY>
 <!--CFDF8EE593F04CFE9709F5AD19A3A573-->  <OBCQL_WIDGET_QUERY_ID><![CDATA[CFDF8EE593F04CFE9709F5AD19A3A573]]></OBCQL_WIDGET_QUERY_ID>
 <!--CFDF8EE593F04CFE9709F5AD19A3A573-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.client.widgets/src-db/database/sourcedata/OBKMO_WIDGET_CLASS.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.widgets/src-db/database/sourcedata/OBKMO_WIDGET_CLASS.xml	Thu May 09 12:06:37 2013 +0200
@@ -47,6 +47,22 @@
 <!--35002C82027448708D173B75FB27D037-->  <ACCESSLEVEL><![CDATA[3]]></ACCESSLEVEL>
 <!--35002C82027448708D173B75FB27D037--></OBKMO_WIDGET_CLASS>
 
+<!--5B41A19E11494C519BE33BBED6012DAE--><OBKMO_WIDGET_CLASS>
+<!--5B41A19E11494C519BE33BBED6012DAE-->  <OBKMO_WIDGET_CLASS_ID><![CDATA[5B41A19E11494C519BE33BBED6012DAE]]></OBKMO_WIDGET_CLASS_ID>
+<!--5B41A19E11494C519BE33BBED6012DAE-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--5B41A19E11494C519BE33BBED6012DAE-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--5B41A19E11494C519BE33BBED6012DAE-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--5B41A19E11494C519BE33BBED6012DAE-->  <AD_MODULE_ID><![CDATA[FF8080812D842086012D844F3CC0003E]]></AD_MODULE_ID>
+<!--5B41A19E11494C519BE33BBED6012DAE-->  <TITLE><![CDATA[Stock by Warehouse]]></TITLE>
+<!--5B41A19E11494C519BE33BBED6012DAE-->  <HEIGHT><![CDATA[300]]></HEIGHT>
+<!--5B41A19E11494C519BE33BBED6012DAE-->  <DESCRIPTION><![CDATA[Stock product by warehouse, attribute and unit of measure]]></DESCRIPTION>
+<!--5B41A19E11494C519BE33BBED6012DAE-->  <ALLOW_ANONYMOUS_ACCESS><![CDATA[Y]]></ALLOW_ANONYMOUS_ACCESS>
+<!--5B41A19E11494C519BE33BBED6012DAE-->  <ISSUPERCLASS><![CDATA[N]]></ISSUPERCLASS>
+<!--5B41A19E11494C519BE33BBED6012DAE-->  <WIDGET_SUPERCLASS_ID><![CDATA[2A32CF26F3F64FE39C7F94E9D82497D1]]></WIDGET_SUPERCLASS_ID>
+<!--5B41A19E11494C519BE33BBED6012DAE-->  <CAN_MAXIMIZE><![CDATA[N]]></CAN_MAXIMIZE>
+<!--5B41A19E11494C519BE33BBED6012DAE-->  <ACCESSLEVEL><![CDATA[3]]></ACCESSLEVEL>
+<!--5B41A19E11494C519BE33BBED6012DAE--></OBKMO_WIDGET_CLASS>
+
 <!--5EA740A9473048CFA6B6F1FB6F5576AC--><OBKMO_WIDGET_CLASS>
 <!--5EA740A9473048CFA6B6F1FB6F5576AC-->  <OBKMO_WIDGET_CLASS_ID><![CDATA[5EA740A9473048CFA6B6F1FB6F5576AC]]></OBKMO_WIDGET_CLASS_ID>
 <!--5EA740A9473048CFA6B6F1FB6F5576AC-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/modules/org.openbravo.client.widgets/src-db/database/sourcedata/OBUIAPP_PARAMETER.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.client.widgets/src-db/database/sourcedata/OBUIAPP_PARAMETER.xml	Thu May 09 12:06:37 2013 +0200
@@ -168,6 +168,26 @@
 <!--5479B44FEC814ACF825FA3B66D6DF25B-->  <EM_OBKMO_WIDGET_CLASS_ID><![CDATA[862EEC18D6FC4FA68E7867E3CF337CC7]]></EM_OBKMO_WIDGET_CLASS_ID>
 <!--5479B44FEC814ACF825FA3B66D6DF25B--></OBUIAPP_PARAMETER>
 
+<!--5DA6BE86940349C58FF5A3CC9A3F8FFF--><OBUIAPP_PARAMETER>
+<!--5DA6BE86940349C58FF5A3CC9A3F8FFF-->  <OBUIAPP_PARAMETER_ID><![CDATA[5DA6BE86940349C58FF5A3CC9A3F8FFF]]></OBUIAPP_PARAMETER_ID>
+<!--5DA6BE86940349C58FF5A3CC9A3F8FFF-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--5DA6BE86940349C58FF5A3CC9A3F8FFF-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--5DA6BE86940349C58FF5A3CC9A3F8FFF-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--5DA6BE86940349C58FF5A3CC9A3F8FFF-->  <AD_MODULE_ID><![CDATA[FF8080812D842086012D844F3CC0003E]]></AD_MODULE_ID>
+<!--5DA6BE86940349C58FF5A3CC9A3F8FFF-->  <NAME><![CDATA[Number of Rows]]></NAME>
+<!--5DA6BE86940349C58FF5A3CC9A3F8FFF-->  <SEQNO><![CDATA[0]]></SEQNO>
+<!--5DA6BE86940349C58FF5A3CC9A3F8FFF-->  <AD_REFERENCE_ID><![CDATA[11]]></AD_REFERENCE_ID>
+<!--5DA6BE86940349C58FF5A3CC9A3F8FFF-->  <COLUMNNAME><![CDATA[RowsNumber]]></COLUMNNAME>
+<!--5DA6BE86940349C58FF5A3CC9A3F8FFF-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--5DA6BE86940349C58FF5A3CC9A3F8FFF-->  <FIELDLENGTH><![CDATA[10]]></FIELDLENGTH>
+<!--5DA6BE86940349C58FF5A3CC9A3F8FFF-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--5DA6BE86940349C58FF5A3CC9A3F8FFF-->  <AD_ELEMENT_ID><![CDATA[9A0C92898CF17AC8E040007F01003160]]></AD_ELEMENT_ID>
+<!--5DA6BE86940349C58FF5A3CC9A3F8FFF-->  <ISFIXED><![CDATA[N]]></ISFIXED>
+<!--5DA6BE86940349C58FF5A3CC9A3F8FFF-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
+<!--5DA6BE86940349C58FF5A3CC9A3F8FFF-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
+<!--5DA6BE86940349C58FF5A3CC9A3F8FFF-->  <EM_OBKMO_WIDGET_CLASS_ID><![CDATA[5B41A19E11494C519BE33BBED6012DAE]]></EM_OBKMO_WIDGET_CLASS_ID>
+<!--5DA6BE86940349C58FF5A3CC9A3F8FFF--></OBUIAPP_PARAMETER>
+
 <!--61C0446937F449BC9FC32EC62857C504--><OBUIAPP_PARAMETER>
 <!--61C0446937F449BC9FC32EC62857C504-->  <OBUIAPP_PARAMETER_ID><![CDATA[61C0446937F449BC9FC32EC62857C504]]></OBUIAPP_PARAMETER_ID>
 <!--61C0446937F449BC9FC32EC62857C504-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -253,6 +273,27 @@
 <!--8DD513DA573E43FF8C1F89B758049767-->  <EM_OBKMO_WIDGET_CLASS_ID><![CDATA[CD1B06C4ED974B5F905A5A01B097DF4E]]></EM_OBKMO_WIDGET_CLASS_ID>
 <!--8DD513DA573E43FF8C1F89B758049767--></OBUIAPP_PARAMETER>
 
+<!--A4C8A10329CB458AA1467AB38CFD521A--><OBUIAPP_PARAMETER>
+<!--A4C8A10329CB458AA1467AB38CFD521A-->  <OBUIAPP_PARAMETER_ID><![CDATA[A4C8A10329CB458AA1467AB38CFD521A]]></OBUIAPP_PARAMETER_ID>
+<!--A4C8A10329CB458AA1467AB38CFD521A-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--A4C8A10329CB458AA1467AB38CFD521A-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--A4C8A10329CB458AA1467AB38CFD521A-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--A4C8A10329CB458AA1467AB38CFD521A-->  <AD_MODULE_ID><![CDATA[FF8080812D842086012D844F3CC0003E]]></AD_MODULE_ID>
+<!--A4C8A10329CB458AA1467AB38CFD521A-->  <NAME><![CDATA[Show all data]]></NAME>
+<!--A4C8A10329CB458AA1467AB38CFD521A-->  <SEQNO><![CDATA[10]]></SEQNO>
+<!--A4C8A10329CB458AA1467AB38CFD521A-->  <AD_REFERENCE_ID><![CDATA[20]]></AD_REFERENCE_ID>
+<!--A4C8A10329CB458AA1467AB38CFD521A-->  <COLUMNNAME><![CDATA[showAll]]></COLUMNNAME>
+<!--A4C8A10329CB458AA1467AB38CFD521A-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--A4C8A10329CB458AA1467AB38CFD521A-->  <FIELDLENGTH><![CDATA[10]]></FIELDLENGTH>
+<!--A4C8A10329CB458AA1467AB38CFD521A-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--A4C8A10329CB458AA1467AB38CFD521A-->  <DEFAULTVALUE><![CDATA[false]]></DEFAULTVALUE>
+<!--A4C8A10329CB458AA1467AB38CFD521A-->  <AD_ELEMENT_ID><![CDATA[9A0C92898CEE7AC8E040007F01003160]]></AD_ELEMENT_ID>
+<!--A4C8A10329CB458AA1467AB38CFD521A-->  <ISFIXED><![CDATA[N]]></ISFIXED>
+<!--A4C8A10329CB458AA1467AB38CFD521A-->  <EVALUATEFIXEDVALUE><![CDATA[N]]></EVALUATEFIXEDVALUE>
+<!--A4C8A10329CB458AA1467AB38CFD521A-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
+<!--A4C8A10329CB458AA1467AB38CFD521A-->  <EM_OBKMO_WIDGET_CLASS_ID><![CDATA[5B41A19E11494C519BE33BBED6012DAE]]></EM_OBKMO_WIDGET_CLASS_ID>
+<!--A4C8A10329CB458AA1467AB38CFD521A--></OBUIAPP_PARAMETER>
+
 <!--A5FAD3FDF3164692A0FA05DEFF5BBC0B--><OBUIAPP_PARAMETER>
 <!--A5FAD3FDF3164692A0FA05DEFF5BBC0B-->  <OBUIAPP_PARAMETER_ID><![CDATA[A5FAD3FDF3164692A0FA05DEFF5BBC0B]]></OBUIAPP_PARAMETER_ID>
 <!--A5FAD3FDF3164692A0FA05DEFF5BBC0B-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -274,6 +315,27 @@
 <!--A5FAD3FDF3164692A0FA05DEFF5BBC0B-->  <EM_OBKMO_WIDGET_CLASS_ID><![CDATA[862EEC18D6FC4FA68E7867E3CF337CC7]]></EM_OBKMO_WIDGET_CLASS_ID>
 <!--A5FAD3FDF3164692A0FA05DEFF5BBC0B--></OBUIAPP_PARAMETER>
 
+<!--A7EBA6BDA2C248378C86EF1B162423AE--><OBUIAPP_PARAMETER>
+<!--A7EBA6BDA2C248378C86EF1B162423AE-->  <OBUIAPP_PARAMETER_ID><![CDATA[A7EBA6BDA2C248378C86EF1B162423AE]]></OBUIAPP_PARAMETER_ID>
+<!--A7EBA6BDA2C248378C86EF1B162423AE-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--A7EBA6BDA2C248378C86EF1B162423AE-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--A7EBA6BDA2C248378C86EF1B162423AE-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--A7EBA6BDA2C248378C86EF1B162423AE-->  <AD_MODULE_ID><![CDATA[FF8080812D842086012D844F3CC0003E]]></AD_MODULE_ID>
+<!--A7EBA6BDA2C248378C86EF1B162423AE-->  <NAME><![CDATA[Client]]></NAME>
+<!--A7EBA6BDA2C248378C86EF1B162423AE-->  <SEQNO><![CDATA[60]]></SEQNO>
+<!--A7EBA6BDA2C248378C86EF1B162423AE-->  <AD_REFERENCE_ID><![CDATA[10]]></AD_REFERENCE_ID>
+<!--A7EBA6BDA2C248378C86EF1B162423AE-->  <COLUMNNAME><![CDATA[client]]></COLUMNNAME>
+<!--A7EBA6BDA2C248378C86EF1B162423AE-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--A7EBA6BDA2C248378C86EF1B162423AE-->  <FIELDLENGTH><![CDATA[10]]></FIELDLENGTH>
+<!--A7EBA6BDA2C248378C86EF1B162423AE-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--A7EBA6BDA2C248378C86EF1B162423AE-->  <AD_ELEMENT_ID><![CDATA[9C7735D7BEBF3C9EE040A8C0EB06271C]]></AD_ELEMENT_ID>
+<!--A7EBA6BDA2C248378C86EF1B162423AE-->  <ISFIXED><![CDATA[Y]]></ISFIXED>
+<!--A7EBA6BDA2C248378C86EF1B162423AE-->  <FIXEDVALUE><![CDATA[OB.getContext().getCurrentClient().id]]></FIXEDVALUE>
+<!--A7EBA6BDA2C248378C86EF1B162423AE-->  <EVALUATEFIXEDVALUE><![CDATA[Y]]></EVALUATEFIXEDVALUE>
+<!--A7EBA6BDA2C248378C86EF1B162423AE-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
+<!--A7EBA6BDA2C248378C86EF1B162423AE-->  <EM_OBKMO_WIDGET_CLASS_ID><![CDATA[5B41A19E11494C519BE33BBED6012DAE]]></EM_OBKMO_WIDGET_CLASS_ID>
+<!--A7EBA6BDA2C248378C86EF1B162423AE--></OBUIAPP_PARAMETER>
+
 <!--B181513A8B0141FB953295A0F1D02DDA--><OBUIAPP_PARAMETER>
 <!--B181513A8B0141FB953295A0F1D02DDA-->  <OBUIAPP_PARAMETER_ID><![CDATA[B181513A8B0141FB953295A0F1D02DDA]]></OBUIAPP_PARAMETER_ID>
 <!--B181513A8B0141FB953295A0F1D02DDA-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -408,4 +470,25 @@
 <!--DF2B5B0735884B4A951E72F10724D48A-->  <EM_OBKMO_WIDGET_CLASS_ID><![CDATA[8A6B99392E2B4192012E2B58F5790056]]></EM_OBKMO_WIDGET_CLASS_ID>
 <!--DF2B5B0735884B4A951E72F10724D48A--></OBUIAPP_PARAMETER>
 
+<!--E4CE808DC1B047158DB2AE1E20D5EE1D--><OBUIAPP_PARAMETER>
+<!--E4CE808DC1B047158DB2AE1E20D5EE1D-->  <OBUIAPP_PARAMETER_ID><![CDATA[E4CE808DC1B047158DB2AE1E20D5EE1D]]></OBUIAPP_PARAMETER_ID>
+<!--E4CE808DC1B047158DB2AE1E20D5EE1D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--E4CE808DC1B047158DB2AE1E20D5EE1D-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--E4CE808DC1B047158DB2AE1E20D5EE1D-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--E4CE808DC1B047158DB2AE1E20D5EE1D-->  <AD_MODULE_ID><![CDATA[FF8080812D842086012D844F3CC0003E]]></AD_MODULE_ID>
+<!--E4CE808DC1B047158DB2AE1E20D5EE1D-->  <NAME><![CDATA[Organization List]]></NAME>
+<!--E4CE808DC1B047158DB2AE1E20D5EE1D-->  <SEQNO><![CDATA[70]]></SEQNO>
+<!--E4CE808DC1B047158DB2AE1E20D5EE1D-->  <AD_REFERENCE_ID><![CDATA[10]]></AD_REFERENCE_ID>
+<!--E4CE808DC1B047158DB2AE1E20D5EE1D-->  <COLUMNNAME><![CDATA[organizationList]]></COLUMNNAME>
+<!--E4CE808DC1B047158DB2AE1E20D5EE1D-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--E4CE808DC1B047158DB2AE1E20D5EE1D-->  <FIELDLENGTH><![CDATA[10]]></FIELDLENGTH>
+<!--E4CE808DC1B047158DB2AE1E20D5EE1D-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--E4CE808DC1B047158DB2AE1E20D5EE1D-->  <AD_ELEMENT_ID><![CDATA[32873C7A39ED464F9D781AB4BE08323B]]></AD_ELEMENT_ID>
+<!--E4CE808DC1B047158DB2AE1E20D5EE1D-->  <ISFIXED><![CDATA[Y]]></ISFIXED>
+<!--E4CE808DC1B047158DB2AE1E20D5EE1D-->  <FIXEDVALUE><![CDATA[OB.getContext().getReadableOrganizations()]]></FIXEDVALUE>
+<!--E4CE808DC1B047158DB2AE1E20D5EE1D-->  <EVALUATEFIXEDVALUE><![CDATA[Y]]></EVALUATEFIXEDVALUE>
+<!--E4CE808DC1B047158DB2AE1E20D5EE1D-->  <STARTINNEWLINE><![CDATA[N]]></STARTINNEWLINE>
+<!--E4CE808DC1B047158DB2AE1E20D5EE1D-->  <EM_OBKMO_WIDGET_CLASS_ID><![CDATA[5B41A19E11494C519BE33BBED6012DAE]]></EM_OBKMO_WIDGET_CLASS_ID>
+<!--E4CE808DC1B047158DB2AE1E20D5EE1D--></OBUIAPP_PARAMETER>
+
 </data>
--- a/modules/org.openbravo.financial.paymentreport/src-db/database/sourcedata/AD_MODULE.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.financial.paymentreport/src-db/database/sourcedata/AD_MODULE.xml	Thu May 09 12:06:37 2013 +0200
@@ -6,7 +6,7 @@
 <!--2A5EE903D7974AC298C0504FBC4501A7-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--2A5EE903D7974AC298C0504FBC4501A7-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--2A5EE903D7974AC298C0504FBC4501A7-->  <NAME><![CDATA[Payment Report]]></NAME>
-<!--2A5EE903D7974AC298C0504FBC4501A7-->  <VERSION><![CDATA[3.0.20056]]></VERSION>
+<!--2A5EE903D7974AC298C0504FBC4501A7-->  <VERSION><![CDATA[3.0.20252]]></VERSION>
 <!--2A5EE903D7974AC298C0504FBC4501A7-->  <DESCRIPTION><![CDATA[Payment Report]]></DESCRIPTION>
 <!--2A5EE903D7974AC298C0504FBC4501A7-->  <URL><![CDATA[http://forge.openbravo.com/projects/paymentreport]]></URL>
 <!--2A5EE903D7974AC298C0504FBC4501A7-->  <TYPE><![CDATA[M]]></TYPE>
--- a/modules/org.openbravo.financial.paymentreport/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.financial.paymentreport/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Thu May 09 12:06:37 2013 +0200
@@ -7,7 +7,7 @@
 <!--A3B449C4D5FE4D688CC58236FE33B802-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--A3B449C4D5FE4D688CC58236FE33B802-->  <AD_MODULE_ID><![CDATA[2A5EE903D7974AC298C0504FBC4501A7]]></AD_MODULE_ID>
 <!--A3B449C4D5FE4D688CC58236FE33B802-->  <AD_DEPENDENT_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_DEPENDENT_MODULE_ID>
-<!--A3B449C4D5FE4D688CC58236FE33B802-->  <STARTVERSION><![CDATA[3.0.20056]]></STARTVERSION>
+<!--A3B449C4D5FE4D688CC58236FE33B802-->  <STARTVERSION><![CDATA[3.0.20252]]></STARTVERSION>
 <!--A3B449C4D5FE4D688CC58236FE33B802-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--A3B449C4D5FE4D688CC58236FE33B802-->  <DEPENDANT_MODULE_NAME><![CDATA[Advanced Payables and Receivables Mngmt]]></DEPENDANT_MODULE_NAME>
 <!--A3B449C4D5FE4D688CC58236FE33B802-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
--- a/modules/org.openbravo.reports.ordersawaitingdelivery/src-db/database/sourcedata/AD_MODULE.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.reports.ordersawaitingdelivery/src-db/database/sourcedata/AD_MODULE.xml	Thu May 09 12:06:37 2013 +0200
@@ -6,7 +6,7 @@
 <!--3A3A943684D64DEF9EC39F588A656848-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--3A3A943684D64DEF9EC39F588A656848-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--3A3A943684D64DEF9EC39F588A656848-->  <NAME><![CDATA[Orders Awaiting Delivery]]></NAME>
-<!--3A3A943684D64DEF9EC39F588A656848-->  <VERSION><![CDATA[1.1.20056]]></VERSION>
+<!--3A3A943684D64DEF9EC39F588A656848-->  <VERSION><![CDATA[1.1.20252]]></VERSION>
 <!--3A3A943684D64DEF9EC39F588A656848-->  <DESCRIPTION><![CDATA[Report displaying sales orders not shipped.]]></DESCRIPTION>
 <!--3A3A943684D64DEF9EC39F588A656848-->  <URL><![CDATA[http://forge.openbravo.com/projects/ordersawaitingdlivery]]></URL>
 <!--3A3A943684D64DEF9EC39F588A656848-->  <TYPE><![CDATA[M]]></TYPE>
--- a/modules/org.openbravo.reports.ordersawaitingdelivery/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.reports.ordersawaitingdelivery/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Thu May 09 12:06:37 2013 +0200
@@ -7,7 +7,7 @@
 <!--64060E9EE9EC408BBFFD0CC2DE25C86F-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--64060E9EE9EC408BBFFD0CC2DE25C86F-->  <AD_MODULE_ID><![CDATA[3A3A943684D64DEF9EC39F588A656848]]></AD_MODULE_ID>
 <!--64060E9EE9EC408BBFFD0CC2DE25C86F-->  <AD_DEPENDENT_MODULE_ID><![CDATA[0]]></AD_DEPENDENT_MODULE_ID>
-<!--64060E9EE9EC408BBFFD0CC2DE25C86F-->  <STARTVERSION><![CDATA[3.0.20056]]></STARTVERSION>
+<!--64060E9EE9EC408BBFFD0CC2DE25C86F-->  <STARTVERSION><![CDATA[3.0.20252]]></STARTVERSION>
 <!--64060E9EE9EC408BBFFD0CC2DE25C86F-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--64060E9EE9EC408BBFFD0CC2DE25C86F-->  <DEPENDANT_MODULE_NAME><![CDATA[core]]></DEPENDANT_MODULE_NAME>
 <!--64060E9EE9EC408BBFFD0CC2DE25C86F-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
--- a/modules/org.openbravo.service.datasource/src-db/database/sourcedata/AD_MODULE.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.service.datasource/src-db/database/sourcedata/AD_MODULE.xml	Thu May 09 12:06:37 2013 +0200
@@ -6,7 +6,7 @@
 <!--A44B9BA75C354D8FB2E3F7D6EB6BFDC4-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--A44B9BA75C354D8FB2E3F7D6EB6BFDC4-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--A44B9BA75C354D8FB2E3F7D6EB6BFDC4-->  <NAME><![CDATA[JSON Datasource]]></NAME>
-<!--A44B9BA75C354D8FB2E3F7D6EB6BFDC4-->  <VERSION><![CDATA[2.1.20056]]></VERSION>
+<!--A44B9BA75C354D8FB2E3F7D6EB6BFDC4-->  <VERSION><![CDATA[2.1.20252]]></VERSION>
 <!--A44B9BA75C354D8FB2E3F7D6EB6BFDC4-->  <DESCRIPTION><![CDATA[Provides data source CRUD functionality using JSON as the data format]]></DESCRIPTION>
 <!--A44B9BA75C354D8FB2E3F7D6EB6BFDC4-->  <HELP><![CDATA[This module implements the datasource concept. Datasources play a central role in Smartclient applications. The datasource module automatically creates a datasource for each Openbravo entity. In addition custom data source implementations can be defined.]]></HELP>
 <!--A44B9BA75C354D8FB2E3F7D6EB6BFDC4-->  <URL><![CDATA[http://forge.openbravo.com/projects/datasourceservice]]></URL>
--- a/modules/org.openbravo.service.datasource/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.service.datasource/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Thu May 09 12:06:37 2013 +0200
@@ -7,7 +7,7 @@
 <!--0BA071C783CC4984AC9C03BB7CAA87C7-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--0BA071C783CC4984AC9C03BB7CAA87C7-->  <AD_MODULE_ID><![CDATA[A44B9BA75C354D8FB2E3F7D6EB6BFDC4]]></AD_MODULE_ID>
 <!--0BA071C783CC4984AC9C03BB7CAA87C7-->  <AD_DEPENDENT_MODULE_ID><![CDATA[C70732EA90A14EC0916078B85CC33D2D]]></AD_DEPENDENT_MODULE_ID>
-<!--0BA071C783CC4984AC9C03BB7CAA87C7-->  <STARTVERSION><![CDATA[1.1.20056]]></STARTVERSION>
+<!--0BA071C783CC4984AC9C03BB7CAA87C7-->  <STARTVERSION><![CDATA[1.1.20252]]></STARTVERSION>
 <!--0BA071C783CC4984AC9C03BB7CAA87C7-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--0BA071C783CC4984AC9C03BB7CAA87C7-->  <DEPENDANT_MODULE_NAME><![CDATA[JBoss Weld]]></DEPENDANT_MODULE_NAME>
 <!--0BA071C783CC4984AC9C03BB7CAA87C7-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
@@ -21,7 +21,7 @@
 <!--3E531F0CD0A54130996F5AF3B6A2D01B-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--3E531F0CD0A54130996F5AF3B6A2D01B-->  <AD_MODULE_ID><![CDATA[A44B9BA75C354D8FB2E3F7D6EB6BFDC4]]></AD_MODULE_ID>
 <!--3E531F0CD0A54130996F5AF3B6A2D01B-->  <AD_DEPENDENT_MODULE_ID><![CDATA[F8D1B3ECB3474E8DA5C216473C840DF1]]></AD_DEPENDENT_MODULE_ID>
-<!--3E531F0CD0A54130996F5AF3B6A2D01B-->  <STARTVERSION><![CDATA[2.0.20056]]></STARTVERSION>
+<!--3E531F0CD0A54130996F5AF3B6A2D01B-->  <STARTVERSION><![CDATA[2.0.20252]]></STARTVERSION>
 <!--3E531F0CD0A54130996F5AF3B6A2D01B-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--3E531F0CD0A54130996F5AF3B6A2D01B-->  <DEPENDANT_MODULE_NAME><![CDATA[JSON REST Webservice]]></DEPENDANT_MODULE_NAME>
 <!--3E531F0CD0A54130996F5AF3B6A2D01B-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
@@ -35,7 +35,7 @@
 <!--4FCE95802A854F7E8623AFF7C33D13EE-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--4FCE95802A854F7E8623AFF7C33D13EE-->  <AD_MODULE_ID><![CDATA[A44B9BA75C354D8FB2E3F7D6EB6BFDC4]]></AD_MODULE_ID>
 <!--4FCE95802A854F7E8623AFF7C33D13EE-->  <AD_DEPENDENT_MODULE_ID><![CDATA[0]]></AD_DEPENDENT_MODULE_ID>
-<!--4FCE95802A854F7E8623AFF7C33D13EE-->  <STARTVERSION><![CDATA[3.0.20056]]></STARTVERSION>
+<!--4FCE95802A854F7E8623AFF7C33D13EE-->  <STARTVERSION><![CDATA[3.0.20252]]></STARTVERSION>
 <!--4FCE95802A854F7E8623AFF7C33D13EE-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--4FCE95802A854F7E8623AFF7C33D13EE-->  <DEPENDANT_MODULE_NAME><![CDATA[core]]></DEPENDANT_MODULE_NAME>
 <!--4FCE95802A854F7E8623AFF7C33D13EE-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
@@ -49,7 +49,7 @@
 <!--54AF8B39C55E4E7496902893ECD82786-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--54AF8B39C55E4E7496902893ECD82786-->  <AD_MODULE_ID><![CDATA[A44B9BA75C354D8FB2E3F7D6EB6BFDC4]]></AD_MODULE_ID>
 <!--54AF8B39C55E4E7496902893ECD82786-->  <AD_DEPENDENT_MODULE_ID><![CDATA[4B828F4D03264080AA1D2057B13F613C]]></AD_DEPENDENT_MODULE_ID>
-<!--54AF8B39C55E4E7496902893ECD82786-->  <STARTVERSION><![CDATA[2.1.20056]]></STARTVERSION>
+<!--54AF8B39C55E4E7496902893ECD82786-->  <STARTVERSION><![CDATA[2.1.20252]]></STARTVERSION>
 <!--54AF8B39C55E4E7496902893ECD82786-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--54AF8B39C55E4E7496902893ECD82786-->  <DEPENDANT_MODULE_NAME><![CDATA[User Interface Client Kernel]]></DEPENDANT_MODULE_NAME>
 <!--54AF8B39C55E4E7496902893ECD82786-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
@@ -63,7 +63,7 @@
 <!--D03C56D8A4E14F45A5466350E05C631F-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--D03C56D8A4E14F45A5466350E05C631F-->  <AD_MODULE_ID><![CDATA[A44B9BA75C354D8FB2E3F7D6EB6BFDC4]]></AD_MODULE_ID>
 <!--D03C56D8A4E14F45A5466350E05C631F-->  <AD_DEPENDENT_MODULE_ID><![CDATA[EC356CEE3D46416CA1EBEEB9AB82EDB9]]></AD_DEPENDENT_MODULE_ID>
-<!--D03C56D8A4E14F45A5466350E05C631F-->  <STARTVERSION><![CDATA[8.1.20056]]></STARTVERSION>
+<!--D03C56D8A4E14F45A5466350E05C631F-->  <STARTVERSION><![CDATA[8.1.20252]]></STARTVERSION>
 <!--D03C56D8A4E14F45A5466350E05C631F-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--D03C56D8A4E14F45A5466350E05C631F-->  <DEPENDANT_MODULE_NAME><![CDATA[Smartclient]]></DEPENDANT_MODULE_NAME>
 <!--D03C56D8A4E14F45A5466350E05C631F-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
--- a/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceProperty.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceProperty.java	Thu May 09 12:06:37 2013 +0200
@@ -140,7 +140,6 @@
    * 
    * @param reference
    *          List reference
-   * @return
    */
   public static Set<String> getAllowedValues(Reference reference) {
     Set<String> allowedValues = new HashSet<String>();
--- a/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceServlet.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceServlet.java	Thu May 09 12:06:37 2013 +0200
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2009-2012 Openbravo SLU 
+ * All portions are Copyright (C) 2009-2013 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -78,6 +78,7 @@
 import org.openbravo.model.ad.ui.FieldTrl;
 import org.openbravo.model.ad.ui.Tab;
 import org.openbravo.model.ad.ui.Window;
+import org.openbravo.portal.PortalAccessible;
 import org.openbravo.service.json.DefaultJsonDataService;
 import org.openbravo.service.json.JsonConstants;
 import org.openbravo.service.json.JsonUtils;
@@ -120,6 +121,15 @@
       throws ServletException, IOException {
 
     try {
+      if (OBContext.getOBContext() != null && OBContext.getOBContext().isPortalRole()) {
+        if (!(getDataSource(request) instanceof PortalAccessible)) {
+          log.error("Portal user " + OBContext.getOBContext().getUser() + " with role "
+              + OBContext.getOBContext().getRole()
+              + " is trying to access to non granted datasource " + request.getRequestURL());
+          throw new OBSecurityException();
+        }
+      }
+
       SessionInfo.setModuleId(request.getParameter("moduleId"));
       SessionInfo.setCommand(request.getParameter(DataSourceConstants.OPERATION_TYPE_PARAM));
       SessionInfo.setProcessId(request.getParameter("tabId"));
--- a/modules/org.openbravo.service.integration.google/src-db/database/sourcedata/AD_MODULE.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.service.integration.google/src-db/database/sourcedata/AD_MODULE.xml	Thu May 09 12:06:37 2013 +0200
@@ -6,7 +6,7 @@
 <!--FF8080813129ADA401312CA1222A0005-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--FF8080813129ADA401312CA1222A0005-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--FF8080813129ADA401312CA1222A0005-->  <NAME><![CDATA[Integration with Google APIs]]></NAME>
-<!--FF8080813129ADA401312CA1222A0005-->  <VERSION><![CDATA[0.1.20056]]></VERSION>
+<!--FF8080813129ADA401312CA1222A0005-->  <VERSION><![CDATA[0.1.20252]]></VERSION>
 <!--FF8080813129ADA401312CA1222A0005-->  <DESCRIPTION><![CDATA[Integration with Google APIs]]></DESCRIPTION>
 <!--FF8080813129ADA401312CA1222A0005-->  <TYPE><![CDATA[M]]></TYPE>
 <!--FF8080813129ADA401312CA1222A0005-->  <LICENSE><![CDATA[Licensed under the Openbravo Public License Version 1.1.
--- a/modules/org.openbravo.service.integration.google/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.service.integration.google/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Thu May 09 12:06:37 2013 +0200
@@ -7,7 +7,7 @@
 <!--FF8080813141B198013141BA0F7D0012-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--FF8080813141B198013141BA0F7D0012-->  <AD_MODULE_ID><![CDATA[FF8080813129ADA401312CA1222A0005]]></AD_MODULE_ID>
 <!--FF8080813141B198013141BA0F7D0012-->  <AD_DEPENDENT_MODULE_ID><![CDATA[FF8080813141B198013141B86DD70003]]></AD_DEPENDENT_MODULE_ID>
-<!--FF8080813141B198013141BA0F7D0012-->  <STARTVERSION><![CDATA[0.1.20056]]></STARTVERSION>
+<!--FF8080813141B198013141BA0F7D0012-->  <STARTVERSION><![CDATA[0.1.20252]]></STARTVERSION>
 <!--FF8080813141B198013141BA0F7D0012-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--FF8080813141B198013141BA0F7D0012-->  <DEPENDANT_MODULE_NAME><![CDATA[OpenID Service Integration]]></DEPENDANT_MODULE_NAME>
 <!--FF8080813141B198013141BA0F7D0012-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
@@ -21,7 +21,7 @@
 <!--FF8080813151AEE1013151C4ACE6001B-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--FF8080813151AEE1013151C4ACE6001B-->  <AD_MODULE_ID><![CDATA[FF8080813129ADA401312CA1222A0005]]></AD_MODULE_ID>
 <!--FF8080813151AEE1013151C4ACE6001B-->  <AD_DEPENDENT_MODULE_ID><![CDATA[7E48CDD73B7E493A8BED4F7253E7C989]]></AD_DEPENDENT_MODULE_ID>
-<!--FF8080813151AEE1013151C4ACE6001B-->  <STARTVERSION><![CDATA[2.1.20056]]></STARTVERSION>
+<!--FF8080813151AEE1013151C4ACE6001B-->  <STARTVERSION><![CDATA[2.1.20252]]></STARTVERSION>
 <!--FF8080813151AEE1013151C4ACE6001B-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--FF8080813151AEE1013151C4ACE6001B-->  <DEPENDANT_MODULE_NAME><![CDATA[Openbravo 3.0 Framework]]></DEPENDANT_MODULE_NAME>
 <!--FF8080813151AEE1013151C4ACE6001B-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
--- a/modules/org.openbravo.service.integration.openid/src-db/database/sourcedata/AD_MODULE.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.service.integration.openid/src-db/database/sourcedata/AD_MODULE.xml	Thu May 09 12:06:37 2013 +0200
@@ -6,7 +6,7 @@
 <!--FF8080813141B198013141B86DD70003-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--FF8080813141B198013141B86DD70003-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--FF8080813141B198013141B86DD70003-->  <NAME><![CDATA[OpenID Service Integration]]></NAME>
-<!--FF8080813141B198013141B86DD70003-->  <VERSION><![CDATA[0.1.20056]]></VERSION>
+<!--FF8080813141B198013141B86DD70003-->  <VERSION><![CDATA[0.1.20252]]></VERSION>
 <!--FF8080813141B198013141B86DD70003-->  <DESCRIPTION><![CDATA[OpenID Service Integration]]></DESCRIPTION>
 <!--FF8080813141B198013141B86DD70003-->  <TYPE><![CDATA[M]]></TYPE>
 <!--FF8080813141B198013141B86DD70003-->  <LICENSE><![CDATA[Licensed under the Openbravo Public License Version 1.1.
--- a/modules/org.openbravo.service.integration.openid/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.service.integration.openid/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Thu May 09 12:06:37 2013 +0200
@@ -7,7 +7,7 @@
 <!--FF8080813141B198013141B8B21B0006-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--FF8080813141B198013141B8B21B0006-->  <AD_MODULE_ID><![CDATA[FF8080813141B198013141B86DD70003]]></AD_MODULE_ID>
 <!--FF8080813141B198013141B8B21B0006-->  <AD_DEPENDENT_MODULE_ID><![CDATA[0]]></AD_DEPENDENT_MODULE_ID>
-<!--FF8080813141B198013141B8B21B0006-->  <STARTVERSION><![CDATA[3.0.20056]]></STARTVERSION>
+<!--FF8080813141B198013141B8B21B0006-->  <STARTVERSION><![CDATA[3.0.20252]]></STARTVERSION>
 <!--FF8080813141B198013141B8B21B0006-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--FF8080813141B198013141B8B21B0006-->  <DEPENDANT_MODULE_NAME><![CDATA[Core]]></DEPENDANT_MODULE_NAME>
 <!--FF8080813141B198013141B8B21B0006-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
--- a/modules/org.openbravo.service.json/src-db/database/sourcedata/AD_MODULE.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.service.json/src-db/database/sourcedata/AD_MODULE.xml	Thu May 09 12:06:37 2013 +0200
@@ -6,7 +6,7 @@
 <!--F8D1B3ECB3474E8DA5C216473C840DF1-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--F8D1B3ECB3474E8DA5C216473C840DF1-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--F8D1B3ECB3474E8DA5C216473C840DF1-->  <NAME><![CDATA[JSON REST Webservice]]></NAME>
-<!--F8D1B3ECB3474E8DA5C216473C840DF1-->  <VERSION><![CDATA[2.0.20056]]></VERSION>
+<!--F8D1B3ECB3474E8DA5C216473C840DF1-->  <VERSION><![CDATA[2.0.20252]]></VERSION>
 <!--F8D1B3ECB3474E8DA5C216473C840DF1-->  <DESCRIPTION><![CDATA[Provides a JSON REST webservice for CRUD service requests]]></DESCRIPTION>
 <!--F8D1B3ECB3474E8DA5C216473C840DF1-->  <HELP><![CDATA[Provides a JSON REST webservice for CRUD service requests. Both the servlet implementation (receiving HTTP REST requests in JSON) as the backend processing are provided.]]></HELP>
 <!--F8D1B3ECB3474E8DA5C216473C840DF1-->  <URL><![CDATA[http://forge.openbravo.com/projects/openbravojsonrest]]></URL>
--- a/modules/org.openbravo.service.json/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.service.json/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Thu May 09 12:06:37 2013 +0200
@@ -7,7 +7,7 @@
 <!--9E3E7B42DB16405FB794496D309D7044-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--9E3E7B42DB16405FB794496D309D7044-->  <AD_MODULE_ID><![CDATA[F8D1B3ECB3474E8DA5C216473C840DF1]]></AD_MODULE_ID>
 <!--9E3E7B42DB16405FB794496D309D7044-->  <AD_DEPENDENT_MODULE_ID><![CDATA[0]]></AD_DEPENDENT_MODULE_ID>
-<!--9E3E7B42DB16405FB794496D309D7044-->  <STARTVERSION><![CDATA[3.0.20056]]></STARTVERSION>
+<!--9E3E7B42DB16405FB794496D309D7044-->  <STARTVERSION><![CDATA[3.0.20252]]></STARTVERSION>
 <!--9E3E7B42DB16405FB794496D309D7044-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--9E3E7B42DB16405FB794496D309D7044-->  <DEPENDANT_MODULE_NAME><![CDATA[core]]></DEPENDANT_MODULE_NAME>
 <!--9E3E7B42DB16405FB794496D309D7044-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
--- a/modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java	Thu May 09 12:06:37 2013 +0200
@@ -28,6 +28,8 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.apache.commons.lang.StringUtils;
 import org.codehaus.jettison.json.JSONArray;
@@ -1127,7 +1129,26 @@
   }
 
   protected String getOrderByClausePart(String orderByParam) {
-    String localOrderBy = orderByParam;
+	// Support for one argument functions
+	String functionPattern = "(.*)\\((.*)\\) (desc|DESC)+";
+	Pattern p = Pattern.compile(functionPattern);
+	Matcher m = p.matcher(orderByParam);
+
+	String localOrderBy = null;
+	String functionName = null;
+	boolean descOrderedFunction = false;
+	if (m.find()) {
+		// If it is a function, retrieve the function name and the localOrderBy
+		functionName = m.group(1);
+		localOrderBy = m.group(2);
+		if (m.groupCount() == 3) {
+			// Check if the property is to be ordered in descending order
+			descOrderedFunction = true;
+		}
+	} else {
+		localOrderBy = orderByParam;
+	}
+
     final boolean asc = !localOrderBy.startsWith("-");
     String direction = "";
     if (!asc) {
@@ -1196,7 +1217,15 @@
       sb.append(resolvedPath);
       sb.append(direction);
     }
-    return sb.toString();
+
+    String orderByClausePart = sb.toString();
+    if (functionName != null) {
+    	orderByClausePart = functionName + "(" + orderByClausePart + ")";
+    	if (descOrderedFunction) {
+    		orderByClausePart = orderByClausePart + " desc";
+    	}
+    }
+    return orderByClausePart;
   }
 
   // Creates a Hibernate concatenation if there are multiple identifierproperties
--- a/modules/org.openbravo.service.json/src/org/openbravo/service/json/DataEntityQueryService.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.service.json/src/org/openbravo/service/json/DataEntityQueryService.java	Thu May 09 12:06:37 2013 +0200
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2009-2011 Openbravo SLU 
+ * All portions are Copyright (C) 2009-2013 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -32,11 +32,14 @@
 import org.openbravo.base.model.Entity;
 import org.openbravo.base.model.ModelProvider;
 import org.openbravo.base.model.Property;
+import org.openbravo.base.model.domaintype.TableDomainType;
 import org.openbravo.base.structure.BaseOBObject;
 import org.openbravo.base.util.Check;
+import org.openbravo.client.kernel.KernelUtils;
 import org.openbravo.dal.core.DalUtil;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.dal.service.OBQuery;
+import org.openbravo.model.ad.datamodel.Column;
 
 /**
  * Implements a service which can handle different types of query and paging options. This class
@@ -56,8 +59,6 @@
 
   public static final String PARAM_DELIMITER = "@";
 
-  private static final long serialVersionUID = 1L;
-
   private String entityName;
   private Integer firstResult = null;
   private Integer maxResults = null;
@@ -65,6 +66,9 @@
   private boolean filterOnActive = true;
   private AdvancedQueryBuilder queryBuilder = new AdvancedQueryBuilder();
 
+  private boolean filterOnReadableOrganizations = true;
+  private boolean filterOnReadableClients = true;
+
   private String distinct;
 
   private String summarySettings;
@@ -79,6 +83,8 @@
     Check.isNotNull(entityName, "entityName must be set");
     final OBQuery<BaseOBObject> obq = OBDal.getInstance().createQuery(entityName,
         queryBuilder.getJoinClause() + queryBuilder.getWhereClause());
+    obq.setFilterOnReadableClients(isFilterOnReadableClients());
+    obq.setFilterOnReadableOrganization(isFilterOnReadableOrganizations());
 
     if (queryBuilder.hasOrganizationParameter()) {
       obq.setFilterOnReadableOrganization(false);
@@ -121,16 +127,18 @@
     log.debug("Querying for " + entityName + " " + whereOrderBy);
 
     final OBQuery<BaseOBObject> obq = OBDal.getInstance().createQuery(entityName, whereOrderBy);
+    obq.setFilterOnReadableClients(isFilterOnReadableClients());
+    obq.setFilterOnReadableOrganization(isFilterOnReadableOrganizations());
+
     if (getSummarySettings() != null) {
       obq.setSelectClause(queryBuilder.getSelectClause());
     } else if (getDistinct() != null) {
       final String localDistinct = getDistinct();
       queryBuilder.addSelectClausePart(localDistinct + ".id");
 
-      final Property property = DalUtil.getPropertyFromPath(
-          ModelProvider.getInstance().getEntity(getEntityName()), localDistinct);
+      final List<Property> properties = getDistinctDisplayProperties();
 
-      for (Property identifierProp : property.getTargetEntity().getIdentifierProperties()) {
+      for (Property identifierProp : properties) {
         if (identifierProp.getTargetEntity() != null) {
           // go one level deeper
           final List<Property> nextIdentifierProps = JsonUtils.getIdentifierSet(identifierProp);
@@ -165,6 +173,33 @@
     return obq;
   }
 
+  // package private on purpose
+  List<Property> getDistinctDisplayProperties() {
+    final String localDistinct = getDistinct();
+    final List<Property> properties = new ArrayList<Property>();
+    final Property property = DalUtil.getPropertyFromPath(
+        ModelProvider.getInstance().getEntity(getEntityName()), localDistinct);
+
+    // now use the table reference definition or select on the identifier properties
+    if (property.getDomainType() instanceof TableDomainType
+        && ((TableDomainType) property.getDomainType()).getRefTable() != null) {
+      final TableDomainType domainType = (TableDomainType) property.getDomainType();
+      final Property displayProp = KernelUtils.getInstance().getPropertyFromColumn(
+          OBDal.getInstance()
+              .get(Column.class, domainType.getRefTable().getDisplayColumn().getId()));
+      if (displayProp != null) {
+        properties.add(displayProp);
+      }
+    }
+
+    if (properties.isEmpty()) {
+      for (Property identifierProp : property.getTargetEntity().getIdentifierProperties()) {
+        properties.add(identifierProp);
+      }
+    }
+    return properties;
+  }
+
   public int getRowNumber(String targetRecordId) {
     final String whereOrderBy = queryBuilder.getJoinClause() + queryBuilder.getWhereClause()
         + queryBuilder.getOrderByClause();
@@ -174,6 +209,8 @@
     // System.err.println("Querying for " + entityName + " " + whereOrderBy);
 
     final OBQuery<BaseOBObject> obq = OBDal.getInstance().createQuery(entityName, whereOrderBy);
+    obq.setFilterOnReadableClients(isFilterOnReadableClients());
+    obq.setFilterOnReadableOrganization(isFilterOnReadableOrganizations());
 
     if (queryBuilder.hasOrganizationParameter()) {
       obq.setFilterOnReadableOrganization(false);
@@ -312,4 +349,20 @@
     return summaryFields;
   }
 
+  public boolean isFilterOnReadableOrganizations() {
+    return filterOnReadableOrganizations;
+  }
+
+  public void setFilterOnReadableOrganizations(boolean filterOnReadableOrganizations) {
+    this.filterOnReadableOrganizations = filterOnReadableOrganizations;
+  }
+
+  public boolean isFilterOnReadableClients() {
+    return filterOnReadableClients;
+  }
+
+  public void setFilterOnReadableClients(boolean filterOnReadableClients) {
+    this.filterOnReadableClients = filterOnReadableClients;
+  }
+
 }
--- a/modules/org.openbravo.service.json/src/org/openbravo/service/json/DefaultJsonDataService.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.service.json/src/org/openbravo/service/json/DefaultJsonDataService.java	Thu May 09 12:06:37 2013 +0200
@@ -85,6 +85,8 @@
       Check.isNotNull(entityName, "The name of the service/entityname should not be null");
       Check.isNotNull(parameters, "The parameters should not be null");
 
+      String selectedProperties = parameters.get(JsonConstants.SELECTEDPROPERTIES_PARAMETER);
+
       final JSONObject jsonResult = new JSONObject();
       final JSONObject jsonResponse = new JSONObject();
       List<BaseOBObject> bobs;
@@ -167,6 +169,10 @@
           jsonResponse.put(JsonConstants.RESPONSE_TOTALROWS, 1);
           return jsonResult.toString();
         } else if (parameters.containsKey(JsonConstants.DISTINCT_PARAMETER)) {
+          // TODO: BaseOBObjects created by this query are not valid, see issue #23705, when this is
+          // fixed, IdentifierProvider should be revisited to remove code handling this
+          // incorrectness
+
           // when distinct an array of values is returned
           // the first value is the BaseObObject the other values
           // are part of the order by and such and can be ignored
@@ -174,9 +180,32 @@
           final Property distinctProperty = DalUtil.getPropertyFromPath(ModelProvider.getInstance()
               .getEntity(entityName), distinct);
           final Entity distinctEntity = distinctProperty.getTargetEntity();
+
           final List<Property> properties = new ArrayList<Property>();
           properties.addAll(distinctEntity.getIdProperties());
-          properties.addAll(distinctEntity.getIdentifierProperties());
+          properties.addAll(queryService.getDistinctDisplayProperties());
+
+          // filter the json serialization later on
+          final StringBuilder selectedSb = new StringBuilder();
+          for (Property prop : properties) {
+            if (selectedSb.length() > 0) {
+              selectedSb.append(",");
+            }
+            if (prop.getTargetEntity() != null) {
+              // go one level deeper
+              final List<Property> nextIdentifierProps = JsonUtils.getIdentifierSet(prop);
+              for (Property nextIdentifierProp : nextIdentifierProps) {
+                selectedSb.append(prop.getName() + "." + nextIdentifierProp);
+              }
+            } else {
+              selectedSb.append(prop.getName());
+            }
+          }
+          if (selectedProperties == null) {
+            selectedProperties = selectedSb.toString();
+          } else {
+            selectedProperties += "," + selectedSb.toString();
+          }
 
           bobs = new ArrayList<BaseOBObject>();
 
@@ -255,8 +284,7 @@
       final DataToJsonConverter toJsonConverter = OBProvider.getInstance().get(
           DataToJsonConverter.class);
       toJsonConverter.setAdditionalProperties(JsonUtils.getAdditionalProperties(parameters));
-      toJsonConverter.setSelectedProperties(parameters
-          .get(JsonConstants.SELECTEDPROPERTIES_PARAMETER));
+      toJsonConverter.setSelectedProperties(selectedProperties);
       final List<JSONObject> jsonObjects = toJsonConverter.toJsonObjects(bobs);
 
       addWritableAttribute(jsonObjects);
@@ -307,7 +335,7 @@
     log.debug("Fetch took " + (System.currentTimeMillis() - t) + " ms");
   }
 
-  private DataEntityQueryService createSetQueryService(Map<String, String> parameters,
+  protected DataEntityQueryService createSetQueryService(Map<String, String> parameters,
       boolean forCountOperation) {
     final String entityName = parameters.get(JsonConstants.ENTITYNAME);
     final String startRowStr = parameters.get(JsonConstants.STARTROW_PARAMETER);
@@ -381,8 +409,7 @@
         && parameters.get(JsonConstants.DISTINCT_PARAMETER).trim().length() > 0) {
       queryService.setDistinct(parameters.get(JsonConstants.DISTINCT_PARAMETER).trim());
       // sortby the distinct's identifier
-      orderBy = queryService.getDistinct() + DalUtil.DOT + JsonConstants.IDENTIFIER + ","
-          + queryService.getDistinct() + DalUtil.DOT + JsonConstants.ID;
+      orderBy = getOrderByForDistinct(entityName, queryService);
     } else {
       // Always append id to the orderby to make a predictable sorting
       orderBy += (orderBy.isEmpty() ? "" : ",") + "id";
@@ -418,6 +445,26 @@
     return queryService;
   }
 
+  private String getOrderByForDistinct(String entityName, DataEntityQueryService queryService) {
+    final String localDistinct = queryService.getDistinct();
+    final List<Property> properties = queryService.getDistinctDisplayProperties();
+    final StringBuilder sb = new StringBuilder();
+    for (Property identifierProp : properties) {
+      if (identifierProp.getTargetEntity() != null) {
+        // go one level deeper
+        final List<Property> nextIdentifierProps = JsonUtils.getIdentifierSet(identifierProp);
+        for (Property nextIdentifierProp : nextIdentifierProps) {
+          sb.append(localDistinct + DalUtil.DOT + identifierProp.getName() + "."
+              + nextIdentifierProp + ",");
+        }
+      } else {
+        sb.append(localDistinct + DalUtil.DOT + identifierProp.getName() + ",");
+      }
+    }
+    sb.append(localDistinct + DalUtil.DOT + JsonConstants.ID);
+    return sb.toString();
+  }
+
   private void addWritableAttribute(List<JSONObject> jsonObjects) throws JSONException {
     for (JSONObject jsonObject : jsonObjects) {
       if (!jsonObject.has("client") || !jsonObject.has("organization")) {
--- a/modules/org.openbravo.service.json/src/org/openbravo/service/json/JsonRestServlet.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.service.json/src/org/openbravo/service/json/JsonRestServlet.java	Thu May 09 12:06:37 2013 +0200
@@ -38,6 +38,7 @@
 import org.openbravo.base.model.ModelProvider;
 import org.openbravo.base.structure.BaseOBObject;
 import org.openbravo.base.util.CheckException;
+import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.core.SessionHandler;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.service.web.BaseWebServiceServlet;
@@ -74,6 +75,13 @@
   protected void doService(HttpServletRequest request, HttpServletResponse response)
       throws ServletException, IOException {
     try {
+      if (OBContext.getOBContext() != null && OBContext.getOBContext().isPortalRole()) {
+        // Portal users are not granted to direct web services
+        log.error("Portal user " + OBContext.getOBContext().getUser() + " with role "
+            + OBContext.getOBContext().getRole()
+            + " is trying to access to non granted web service " + request.getRequestURL());
+        throw new OBSecurityException();
+      }
       callServiceInSuper(request, response);
       response.setStatus(200);
     } catch (final InvalidRequestException e) {
--- a/modules/org.openbravo.userinterface.selector/src-db/database/sourcedata/AD_MODULE.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.userinterface.selector/src-db/database/sourcedata/AD_MODULE.xml	Thu May 09 12:06:37 2013 +0200
@@ -6,7 +6,7 @@
 <!--5EB4F15C80684ACA904756BDC12ADBE5-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--5EB4F15C80684ACA904756BDC12ADBE5-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--5EB4F15C80684ACA904756BDC12ADBE5-->  <NAME><![CDATA[User Interface Selector]]></NAME>
-<!--5EB4F15C80684ACA904756BDC12ADBE5-->  <VERSION><![CDATA[2.1.20056]]></VERSION>
+<!--5EB4F15C80684ACA904756BDC12ADBE5-->  <VERSION><![CDATA[2.1.20252]]></VERSION>
 <!--5EB4F15C80684ACA904756BDC12ADBE5-->  <DESCRIPTION><![CDATA[Provides a selector with a suggestion box and popup grid window]]></DESCRIPTION>
 <!--5EB4F15C80684ACA904756BDC12ADBE5-->  <HELP><![CDATA[The Openbravo selector provides new selector functionality which is used inside of existing Openbravo forms. The selector is mainly used for supporting foreign key references in the user interface. The selector combines both suggestion box behavior with a popup grid.]]></HELP>
 <!--5EB4F15C80684ACA904756BDC12ADBE5-->  <URL><![CDATA[http://forge.openbravo.com/projects/selector]]></URL>
--- a/modules/org.openbravo.userinterface.selector/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.userinterface.selector/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Thu May 09 12:06:37 2013 +0200
@@ -7,7 +7,7 @@
 <!--38825CAED43941D38CA0C78DB04FCFA0-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--38825CAED43941D38CA0C78DB04FCFA0-->  <AD_MODULE_ID><![CDATA[5EB4F15C80684ACA904756BDC12ADBE5]]></AD_MODULE_ID>
 <!--38825CAED43941D38CA0C78DB04FCFA0-->  <AD_DEPENDENT_MODULE_ID><![CDATA[EC356CEE3D46416CA1EBEEB9AB82EDB9]]></AD_DEPENDENT_MODULE_ID>
-<!--38825CAED43941D38CA0C78DB04FCFA0-->  <STARTVERSION><![CDATA[8.1.20056]]></STARTVERSION>
+<!--38825CAED43941D38CA0C78DB04FCFA0-->  <STARTVERSION><![CDATA[8.1.20252]]></STARTVERSION>
 <!--38825CAED43941D38CA0C78DB04FCFA0-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--38825CAED43941D38CA0C78DB04FCFA0-->  <DEPENDANT_MODULE_NAME><![CDATA[Smartclient]]></DEPENDANT_MODULE_NAME>
 <!--38825CAED43941D38CA0C78DB04FCFA0-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
@@ -21,7 +21,7 @@
 <!--6DDE7B1A70174242AF82B5022FB89279-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--6DDE7B1A70174242AF82B5022FB89279-->  <AD_MODULE_ID><![CDATA[5EB4F15C80684ACA904756BDC12ADBE5]]></AD_MODULE_ID>
 <!--6DDE7B1A70174242AF82B5022FB89279-->  <AD_DEPENDENT_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_DEPENDENT_MODULE_ID>
-<!--6DDE7B1A70174242AF82B5022FB89279-->  <STARTVERSION><![CDATA[2.1.20056]]></STARTVERSION>
+<!--6DDE7B1A70174242AF82B5022FB89279-->  <STARTVERSION><![CDATA[2.1.20252]]></STARTVERSION>
 <!--6DDE7B1A70174242AF82B5022FB89279-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--6DDE7B1A70174242AF82B5022FB89279-->  <DEPENDANT_MODULE_NAME><![CDATA[User Interface Application]]></DEPENDANT_MODULE_NAME>
 <!--6DDE7B1A70174242AF82B5022FB89279-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
@@ -35,7 +35,7 @@
 <!--94F9CD2CB5EF4467A67475C786C984A7-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--94F9CD2CB5EF4467A67475C786C984A7-->  <AD_MODULE_ID><![CDATA[5EB4F15C80684ACA904756BDC12ADBE5]]></AD_MODULE_ID>
 <!--94F9CD2CB5EF4467A67475C786C984A7-->  <AD_DEPENDENT_MODULE_ID><![CDATA[4B828F4D03264080AA1D2057B13F613C]]></AD_DEPENDENT_MODULE_ID>
-<!--94F9CD2CB5EF4467A67475C786C984A7-->  <STARTVERSION><![CDATA[2.1.20056]]></STARTVERSION>
+<!--94F9CD2CB5EF4467A67475C786C984A7-->  <STARTVERSION><![CDATA[2.1.20252]]></STARTVERSION>
 <!--94F9CD2CB5EF4467A67475C786C984A7-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--94F9CD2CB5EF4467A67475C786C984A7-->  <DEPENDANT_MODULE_NAME><![CDATA[User Interface Client Kernel]]></DEPENDANT_MODULE_NAME>
 <!--94F9CD2CB5EF4467A67475C786C984A7-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
@@ -49,7 +49,7 @@
 <!--BCCB5A08EC0446DE8BCE191C6BC607A4-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--BCCB5A08EC0446DE8BCE191C6BC607A4-->  <AD_MODULE_ID><![CDATA[5EB4F15C80684ACA904756BDC12ADBE5]]></AD_MODULE_ID>
 <!--BCCB5A08EC0446DE8BCE191C6BC607A4-->  <AD_DEPENDENT_MODULE_ID><![CDATA[C70732EA90A14EC0916078B85CC33D2D]]></AD_DEPENDENT_MODULE_ID>
-<!--BCCB5A08EC0446DE8BCE191C6BC607A4-->  <STARTVERSION><![CDATA[1.1.20056]]></STARTVERSION>
+<!--BCCB5A08EC0446DE8BCE191C6BC607A4-->  <STARTVERSION><![CDATA[1.1.20252]]></STARTVERSION>
 <!--BCCB5A08EC0446DE8BCE191C6BC607A4-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--BCCB5A08EC0446DE8BCE191C6BC607A4-->  <DEPENDANT_MODULE_NAME><![CDATA[JBoss Weld]]></DEPENDANT_MODULE_NAME>
 <!--BCCB5A08EC0446DE8BCE191C6BC607A4-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
@@ -63,7 +63,7 @@
 <!--C8DAC574B88649D08C9468521B343F12-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--C8DAC574B88649D08C9468521B343F12-->  <AD_MODULE_ID><![CDATA[5EB4F15C80684ACA904756BDC12ADBE5]]></AD_MODULE_ID>
 <!--C8DAC574B88649D08C9468521B343F12-->  <AD_DEPENDENT_MODULE_ID><![CDATA[0]]></AD_DEPENDENT_MODULE_ID>
-<!--C8DAC574B88649D08C9468521B343F12-->  <STARTVERSION><![CDATA[3.0.20056]]></STARTVERSION>
+<!--C8DAC574B88649D08C9468521B343F12-->  <STARTVERSION><![CDATA[3.0.20252]]></STARTVERSION>
 <!--C8DAC574B88649D08C9468521B343F12-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--C8DAC574B88649D08C9468521B343F12-->  <DEPENDANT_MODULE_NAME><![CDATA[core]]></DEPENDANT_MODULE_NAME>
 <!--C8DAC574B88649D08C9468521B343F12-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
@@ -77,7 +77,7 @@
 <!--F14EB17946BE4724A46F80CB1A47EC70-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--F14EB17946BE4724A46F80CB1A47EC70-->  <AD_MODULE_ID><![CDATA[5EB4F15C80684ACA904756BDC12ADBE5]]></AD_MODULE_ID>
 <!--F14EB17946BE4724A46F80CB1A47EC70-->  <AD_DEPENDENT_MODULE_ID><![CDATA[A44B9BA75C354D8FB2E3F7D6EB6BFDC4]]></AD_DEPENDENT_MODULE_ID>
-<!--F14EB17946BE4724A46F80CB1A47EC70-->  <STARTVERSION><![CDATA[2.1.20056]]></STARTVERSION>
+<!--F14EB17946BE4724A46F80CB1A47EC70-->  <STARTVERSION><![CDATA[2.1.20252]]></STARTVERSION>
 <!--F14EB17946BE4724A46F80CB1A47EC70-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--F14EB17946BE4724A46F80CB1A47EC70-->  <DEPENDANT_MODULE_NAME><![CDATA[JSON Datasource]]></DEPENDANT_MODULE_NAME>
 <!--F14EB17946BE4724A46F80CB1A47EC70-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
--- a/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/reference/SelectorUIReference.java	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/reference/SelectorUIReference.java	Thu May 09 12:06:37 2013 +0200
@@ -202,10 +202,13 @@
           String parentFieldName = fieldName;
           String name = ((fieldName != null && !fieldName.equals("")) ? fieldName : comboTableData
               .getObjectName());
-          if (name.startsWith("EM_")) {
-            // For external module fields use the column field in selector to avoid comparing
-            // fields with EM_fieldname which will not be present in the current table.
-            // Refer issue https://issues.openbravo.com/view.php?id=23267
+          /*
+           * if the column name is available in selector use that for comparison as it is the column
+           * that is going to be saved. Solves issues
+           * https://issues.openbravo.com/view.php?id=23267,
+           * https://issues.openbravo.com/view.php?id=23124
+           */
+          if (selector.getColumn() != null) {
             name = selector.getColumn().getDBColumnName();
           }
           String tableDirName;
--- a/modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js	Thu May 09 12:06:37 2013 +0200
@@ -493,6 +493,10 @@
       this.selectFirstPickListOption();
     }
 
+    if (this._clearingValue) {
+      this._editorEnterValue = null;
+    }
+
     this.Super('setValue', arguments);
   },
 
@@ -627,7 +631,7 @@
         this.valueMap = {};
       }
 
-      this.valueMap[record[this.valueField]] = record[this.displayField];
+      this.valueMap[record[this.valueField]] = record[this.displayField].replace(/[\n\r]/g, '');
       this.updateValueMap();
     }
 
@@ -963,7 +967,7 @@
       if (!this.valueMap) {
         this.valueMap = {};
       }
-      this.valueMap[record[this.gridValueField]] = record[this.gridDisplayField];
+      this.valueMap[record[this.gridValueField]] = record[this.gridDisplayField].replace(/[\n\r]/g, '');
       this.updateValueMap();
     }
     this.handleOutFields(record);
--- a/modules/org.openbravo.userinterface.skin.250to300Comp/src-db/database/sourcedata/AD_MODULE.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.userinterface.skin.250to300Comp/src-db/database/sourcedata/AD_MODULE.xml	Thu May 09 12:06:37 2013 +0200
@@ -6,7 +6,7 @@
 <!--96998CBC42744B3DBEE28AC8095C9335-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--96998CBC42744B3DBEE28AC8095C9335-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--96998CBC42744B3DBEE28AC8095C9335-->  <NAME><![CDATA[2.50 to 3.00 Compatibility Skin]]></NAME>
-<!--96998CBC42744B3DBEE28AC8095C9335-->  <VERSION><![CDATA[2.0.20056]]></VERSION>
+<!--96998CBC42744B3DBEE28AC8095C9335-->  <VERSION><![CDATA[2.0.20252]]></VERSION>
 <!--96998CBC42744B3DBEE28AC8095C9335-->  <DESCRIPTION><![CDATA[Skin module to proper visualization of classic windows inside the MDI interface]]></DESCRIPTION>
 <!--96998CBC42744B3DBEE28AC8095C9335-->  <HELP><![CDATA[With this skin module the classic windows styles will display in a way more coherent with the new 3.00 styles]]></HELP>
 <!--96998CBC42744B3DBEE28AC8095C9335-->  <URL><![CDATA[www.openbravo.com]]></URL>
--- a/modules/org.openbravo.userinterface.skin.250to300Comp/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.userinterface.skin.250to300Comp/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Thu May 09 12:06:37 2013 +0200
@@ -7,7 +7,7 @@
 <!--39BF75AD9AB3453698BF5DE29E727AA9-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--39BF75AD9AB3453698BF5DE29E727AA9-->  <AD_MODULE_ID><![CDATA[96998CBC42744B3DBEE28AC8095C9335]]></AD_MODULE_ID>
 <!--39BF75AD9AB3453698BF5DE29E727AA9-->  <AD_DEPENDENT_MODULE_ID><![CDATA[0]]></AD_DEPENDENT_MODULE_ID>
-<!--39BF75AD9AB3453698BF5DE29E727AA9-->  <STARTVERSION><![CDATA[3.0.20056]]></STARTVERSION>
+<!--39BF75AD9AB3453698BF5DE29E727AA9-->  <STARTVERSION><![CDATA[3.0.20252]]></STARTVERSION>
 <!--39BF75AD9AB3453698BF5DE29E727AA9-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--39BF75AD9AB3453698BF5DE29E727AA9-->  <DEPENDANT_MODULE_NAME><![CDATA[core]]></DEPENDANT_MODULE_NAME>
 <!--39BF75AD9AB3453698BF5DE29E727AA9-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
--- a/modules/org.openbravo.userinterface.smartclient/src-db/database/sourcedata/AD_MODULE.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.userinterface.smartclient/src-db/database/sourcedata/AD_MODULE.xml	Thu May 09 12:06:37 2013 +0200
@@ -6,7 +6,7 @@
 <!--EC356CEE3D46416CA1EBEEB9AB82EDB9-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--EC356CEE3D46416CA1EBEEB9AB82EDB9-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--EC356CEE3D46416CA1EBEEB9AB82EDB9-->  <NAME><![CDATA[Smartclient]]></NAME>
-<!--EC356CEE3D46416CA1EBEEB9AB82EDB9-->  <VERSION><![CDATA[8.1.20056]]></VERSION>
+<!--EC356CEE3D46416CA1EBEEB9AB82EDB9-->  <VERSION><![CDATA[8.1.20252]]></VERSION>
 <!--EC356CEE3D46416CA1EBEEB9AB82EDB9-->  <DESCRIPTION><![CDATA[SmartClient libraries for use within Openbravo]]></DESCRIPTION>
 <!--EC356CEE3D46416CA1EBEEB9AB82EDB9-->  <HELP><![CDATA[This module contains the SmartClient libraries for usage by other modules. It also contains some simple test pages to validate that SmartClient is working correctly. Also contains generic Openbravo SmartClient components]]></HELP>
 <!--EC356CEE3D46416CA1EBEEB9AB82EDB9-->  <URL><![CDATA[http://forge.openbravo.com/projects/obsmartclient]]></URL>
--- a/modules/org.openbravo.userinterface.smartclient/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.userinterface.smartclient/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Thu May 09 12:06:37 2013 +0200
@@ -7,7 +7,7 @@
 <!--086331E18477496B8AC74D2CFEBD1307-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--086331E18477496B8AC74D2CFEBD1307-->  <AD_MODULE_ID><![CDATA[EC356CEE3D46416CA1EBEEB9AB82EDB9]]></AD_MODULE_ID>
 <!--086331E18477496B8AC74D2CFEBD1307-->  <AD_DEPENDENT_MODULE_ID><![CDATA[0]]></AD_DEPENDENT_MODULE_ID>
-<!--086331E18477496B8AC74D2CFEBD1307-->  <STARTVERSION><![CDATA[3.0.20056]]></STARTVERSION>
+<!--086331E18477496B8AC74D2CFEBD1307-->  <STARTVERSION><![CDATA[3.0.20252]]></STARTVERSION>
 <!--086331E18477496B8AC74D2CFEBD1307-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--086331E18477496B8AC74D2CFEBD1307-->  <DEPENDANT_MODULE_NAME><![CDATA[core]]></DEPENDANT_MODULE_NAME>
 <!--086331E18477496B8AC74D2CFEBD1307-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
@@ -21,7 +21,7 @@
 <!--DC5D4EF450244482BD2B458DAA496333-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--DC5D4EF450244482BD2B458DAA496333-->  <AD_MODULE_ID><![CDATA[EC356CEE3D46416CA1EBEEB9AB82EDB9]]></AD_MODULE_ID>
 <!--DC5D4EF450244482BD2B458DAA496333-->  <AD_DEPENDENT_MODULE_ID><![CDATA[4B828F4D03264080AA1D2057B13F613C]]></AD_DEPENDENT_MODULE_ID>
-<!--DC5D4EF450244482BD2B458DAA496333-->  <STARTVERSION><![CDATA[2.1.20056]]></STARTVERSION>
+<!--DC5D4EF450244482BD2B458DAA496333-->  <STARTVERSION><![CDATA[2.1.20252]]></STARTVERSION>
 <!--DC5D4EF450244482BD2B458DAA496333-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--DC5D4EF450244482BD2B458DAA496333-->  <DEPENDANT_MODULE_NAME><![CDATA[User Interface Client Kernel]]></DEPENDANT_MODULE_NAME>
 <!--DC5D4EF450244482BD2B458DAA496333-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
@@ -35,7 +35,7 @@
 <!--F2AF15C0AF5540E393D96BE506E20648-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--F2AF15C0AF5540E393D96BE506E20648-->  <AD_MODULE_ID><![CDATA[EC356CEE3D46416CA1EBEEB9AB82EDB9]]></AD_MODULE_ID>
 <!--F2AF15C0AF5540E393D96BE506E20648-->  <AD_DEPENDENT_MODULE_ID><![CDATA[C70732EA90A14EC0916078B85CC33D2D]]></AD_DEPENDENT_MODULE_ID>
-<!--F2AF15C0AF5540E393D96BE506E20648-->  <STARTVERSION><![CDATA[1.1.20056]]></STARTVERSION>
+<!--F2AF15C0AF5540E393D96BE506E20648-->  <STARTVERSION><![CDATA[1.1.20252]]></STARTVERSION>
 <!--F2AF15C0AF5540E393D96BE506E20648-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--F2AF15C0AF5540E393D96BE506E20648-->  <DEPENDANT_MODULE_NAME><![CDATA[JBoss Weld]]></DEPENDANT_MODULE_NAME>
 <!--F2AF15C0AF5540E393D96BE506E20648-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
--- a/modules/org.openbravo.v3.datasets/src-db/database/sourcedata/AD_MODULE.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.v3.datasets/src-db/database/sourcedata/AD_MODULE.xml	Thu May 09 12:06:37 2013 +0200
@@ -6,7 +6,7 @@
 <!--883B5872CA0548F9AF2BBBE7D2DDFA61-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--883B5872CA0548F9AF2BBBE7D2DDFA61-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--883B5872CA0548F9AF2BBBE7D2DDFA61-->  <NAME><![CDATA[Standard Roles]]></NAME>
-<!--883B5872CA0548F9AF2BBBE7D2DDFA61-->  <VERSION><![CDATA[3.0.20056]]></VERSION>
+<!--883B5872CA0548F9AF2BBBE7D2DDFA61-->  <VERSION><![CDATA[3.0.20252]]></VERSION>
 <!--883B5872CA0548F9AF2BBBE7D2DDFA61-->  <DESCRIPTION><![CDATA[Pre-configured collection of standard ERP roles]]></DESCRIPTION>
 <!--883B5872CA0548F9AF2BBBE7D2DDFA61-->  <HELP><![CDATA[This dataset contains the following roles with their access to corresponding Openbravo entities - windows, reports, actions.
 * Employee - Any person of the enterprise
--- a/modules/org.openbravo.v3.datasets/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.v3.datasets/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml	Thu May 09 12:06:37 2013 +0200
@@ -7,7 +7,7 @@
 <!--148A000EE9A04A3CA653B1296A00B8E6-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--148A000EE9A04A3CA653B1296A00B8E6-->  <AD_MODULE_ID><![CDATA[883B5872CA0548F9AF2BBBE7D2DDFA61]]></AD_MODULE_ID>
 <!--148A000EE9A04A3CA653B1296A00B8E6-->  <AD_DEPENDENT_MODULE_ID><![CDATA[0]]></AD_DEPENDENT_MODULE_ID>
-<!--148A000EE9A04A3CA653B1296A00B8E6-->  <STARTVERSION><![CDATA[3.0.20056]]></STARTVERSION>
+<!--148A000EE9A04A3CA653B1296A00B8E6-->  <STARTVERSION><![CDATA[3.0.20252]]></STARTVERSION>
 <!--148A000EE9A04A3CA653B1296A00B8E6-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--148A000EE9A04A3CA653B1296A00B8E6-->  <DEPENDANT_MODULE_NAME><![CDATA[core]]></DEPENDANT_MODULE_NAME>
 <!--148A000EE9A04A3CA653B1296A00B8E6-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
@@ -21,7 +21,7 @@
 <!--30F966407A6F4E15965821BAEE34D25B-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--30F966407A6F4E15965821BAEE34D25B-->  <AD_MODULE_ID><![CDATA[883B5872CA0548F9AF2BBBE7D2DDFA61]]></AD_MODULE_ID>
 <!--30F966407A6F4E15965821BAEE34D25B-->  <AD_DEPENDENT_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_DEPENDENT_MODULE_ID>
-<!--30F966407A6F4E15965821BAEE34D25B-->  <STARTVERSION><![CDATA[3.0.20056]]></STARTVERSION>
+<!--30F966407A6F4E15965821BAEE34D25B-->  <STARTVERSION><![CDATA[3.0.20252]]></STARTVERSION>
 <!--30F966407A6F4E15965821BAEE34D25B-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--30F966407A6F4E15965821BAEE34D25B-->  <DEPENDANT_MODULE_NAME><![CDATA[Advanced Payables and Receivables Mngmt]]></DEPENDANT_MODULE_NAME>
 <!--30F966407A6F4E15965821BAEE34D25B-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
@@ -35,7 +35,7 @@
 <!--F93CE30003B24F8F8886510B0065EECC-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--F93CE30003B24F8F8886510B0065EECC-->  <AD_MODULE_ID><![CDATA[883B5872CA0548F9AF2BBBE7D2DDFA61]]></AD_MODULE_ID>
 <!--F93CE30003B24F8F8886510B0065EECC-->  <AD_DEPENDENT_MODULE_ID><![CDATA[3A3A943684D64DEF9EC39F588A656848]]></AD_DEPENDENT_MODULE_ID>
-<!--F93CE30003B24F8F8886510B0065EECC-->  <STARTVERSION><![CDATA[1.1.20056]]></STARTVERSION>
+<!--F93CE30003B24F8F8886510B0065EECC-->  <STARTVERSION><![CDATA[1.1.20252]]></STARTVERSION>
 <!--F93CE30003B24F8F8886510B0065EECC-->  <ISINCLUDED><![CDATA[N]]></ISINCLUDED>
 <!--F93CE30003B24F8F8886510B0065EECC-->  <DEPENDANT_MODULE_NAME><![CDATA[Orders Awaiting Delivery]]></DEPENDANT_MODULE_NAME>
 <!--F93CE30003B24F8F8886510B0065EECC-->  <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT>
--- a/modules/org.openbravo.v3.framework/src-db/database/sourcedata/AD_MODULE.xml	Wed May 08 16:26:46 2013 +0200
+++ b/modules/org.openbravo.v3.framework/src-db/database/sourcedata/AD_MODULE.xml	Thu May 09 12:06:37 2013 +0200
@@ -6,7 +6,7 @@
 <!--7E48CDD73B7E493A8BED4F7253E7C989-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--7E48CDD73B7E493A8BED4F7253E7C989-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--7E48CDD73B7E493A8BED4F7253E7C989-->  <NAME><![CDATA[Openbravo 3.0 Framework]]></NAME>
-<!--7E48CDD73B7E493A8BED4F7253E7C989-->  <VERSION><![CDATA[2.1.20056]]></VERSION>
+<!--7E48CDD73B7E493A8BED4F7253E7C989-->  <VERSION><![CDATA[2.1.20252]]></VERSION>
 <!--7E48CDD73B7E493A8BED4F7253E7C989-->  <DESCRIPTION><![CDATA[Openbravo 3.0 Framework]]></DESCRIPTION>
 <!--7E48CDD73B7E493A8BED4F7253E7C989-->  <HELP><![CDATA[Contains all the components required to run the Openbravo 3.0 framework]]></HELP>
 <!--7E48CDD73B7E493A8BED4F7253E7C989-->  <URL><![CDATA[http://forge.openbravo.com/projects/openbravov30framework]]></URL>