Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0015834Openbravo ERPA. Platformpublic2011-02-01 16:382011-02-15 00:00
mirurita 
mirurita 
highmajoralways
closedfixed 
5
pi 
3.0RC4 
Core
No
0015834: @AD_Org_Id@ not working properly in a default value for a column
The FIN_Payment_Priority_ID column of C_Invoice and C_Order tables has the following default value:

@SQL=SELECT FIN_Payment_Priority_ID FROM FIN_Payment_Priority WHERE AD_ISORGINCLUDED(@AD_Org_ID@, AD_Org_ID, @#AD_Client_ID@) <> -1 AND Isdefault = 'Y' ORDER BY Priority

For example in SalesInvoice, looking at the WAD generated code in
org.openbravo.erpWindows.SalesInvoice.Header.java

it gets the default value for payment priority using this sql
SELECT FIN_Payment_Priority_ID FROM FIN_Payment_Priority WHERE AD_ISORGINCLUDED(?, AD_Org_ID, ?) <> -1 AND Isdefault = 'Y' ORDER BY Priority

and the first parameter is passes through

Line 864
data = HeaderData.set(HeaderData.selectDef0445FEDA79A747C48A7B3EF852D176DC(this, Utility.getContext(this, vars, "AD_Org_ID", "167"), ...)

When creating a new Sales Invoice the Utility.getContext(this, vars, "AD_Org_ID", "167") stores the organization id of the last visited (opened in edit view) sales invoice.

You will realize that if you first open in edit view a sales invoice of organization Main and then you create a new sales invoice the
Utility.getContext(this, vars, "AD_Org_ID", "167")
will return '1000000', which is the Main id. But the combo box of organization is selecting organization A.

If you open in edit view a sales invoice of organization A and then you create a new sales invoice the
Utility.getContext(this, vars, "AD_Org_ID", "167")
will return '1000002', which is the A id.
On this case the payment priority default value will be properly assigned.
1) In 2.50 environment clone and install Payment Priorities module
https://code.openbravo.com/erp/pmods/org.openbravo.financial.paymentpriorities/ [^]
1.1) Download from central repository last Selector for 2.50 module.
1.2) Clone APRM for 2.50
https://code.openbravo.com/erp/pmods/org.openbravo.advpaymentmngt/ [^]

2) Go to Financial Management || Receivables & Payables || Setup || Payment Priority || Payment Priority window and create the following priorities:
Org: A
Name: High
Priority: 1
Default: No

Org: A
Name: Standard
Priority: 2
Default: Yes

At this point, if we create a new Sales/Purchase Invoice/Order for organization A it should select by default 'Standard' payment priority.

3) Important: open in edit view a existing Sales Invoice for organization Main.

4) Click on new button and notice that the payment priority is empty.
No tags attached.
depends on backport 00159472.50MP27 closed mirurita @AD_Org_Id@ not working properly in a default value for a column 
Issue History
2011-02-01 16:38miruritaNew Issue
2011-02-01 16:38miruritaAssigned To => alostale
2011-02-01 16:38miruritaModules => Core
2011-02-01 16:40miruritaFile Added: aprm.diff
2011-02-01 16:40miruritaFile Added: core.diff
2011-02-01 16:40miruritaSummaryDefault value @AD_Org_Id@ value not working properly => @AD_Org_Id@ not working properly in a default value for a column
2011-02-01 16:41miruritaTarget Version => 2.50MP27
2011-02-01 19:12miruritaSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=1472#r1472
2011-02-01 19:12miruritaFile Deleted: aprm.diff
2011-02-01 19:13miruritaFile Deleted: core.diff
2011-02-07 08:31alostaleStatusnew => scheduled
2011-02-10 19:53miruritaAssigned Toalostale => mirurita
2011-02-10 19:57hgbotCheckin
2011-02-10 19:57hgbotNote Added: 0034140
2011-02-10 19:57hgbotStatusscheduled => resolved
2011-02-10 19:57hgbotResolutionopen => fixed
2011-02-10 19:57hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/fc82f636ea78dee874cf36439b23226b84790fef [^]
2011-02-10 19:58miruritaStatusresolved => new
2011-02-10 19:58miruritaResolutionfixed => open
2011-02-10 19:59miruritaStatusnew => scheduled
2011-02-10 19:59miruritafix_in_branch => pi
2011-02-10 19:59miruritaversion2.50MP25EU2 => pi
2011-02-10 19:59miruritaTarget Version2.50MP27 => 3.0RC4
2011-02-10 19:59miruritafix_in_branchpi =>
2011-02-10 20:00miruritaStatusscheduled => resolved
2011-02-10 20:00miruritaResolutionopen => fixed
2011-02-14 16:59psanjuanNote Added: 0034182
2011-02-14 16:59psanjuanStatusresolved => closed
2011-02-15 00:00anonymoussf_bug_id0 => 3181409

Notes
(0034140)
hgbot   
2011-02-10 19:57   
Repository: erp/devel/pi
Changeset: fc82f636ea78dee874cf36439b23226b84790fef
Author: Mikel Irurita <mikel.irurita <at> openbravo.com>
Date: Thu Feb 10 19:56:03 2011 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/fc82f636ea78dee874cf36439b23226b84790fef [^]

Fixes issue 15834: @AD_Org_Id@ not working properly

---
M src-db/database/sourcedata/AD_COLUMN.xml
---
(0034182)
psanjuan   
2011-02-14 16:59   
fixed and working