Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0015947Openbravo ERPA. Platformpublic2011-02-01 16:382011-05-24 10:56
mirurita 
mirurita 
highmajoralways
closedfixed 
5
2.50MP25EU2 
2.50MP27 
Core
No
0015947: @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.
closingMay2011
blocks defect 00158343.0RC4 closed mirurita @AD_Org_Id@ not working properly in a default value for a column 
Issue History
2011-02-10 19:59miruritaTypedefect => backport
2011-02-10 19:59miruritafix_in_branch => 2.50
2011-02-10 20:02hgbotCheckin
2011-02-10 20:02hgbotNote Added: 0034142
2011-02-10 20:02hgbotStatusscheduled => resolved
2011-02-10 20:02hgbotResolutionopen => fixed
2011-02-10 20:02hgbotFixed in SCM revisionhttp://code.openbravo.com/erp/devel/pi/rev/fc82f636ea78dee874cf36439b23226b84790fef [^] => http://code.openbravo.com/erp/stable/2.50/rev/6c7a48f224145ef8501334d51cdd851ffdded904 [^]
2011-05-24 10:08dalsasuaTag Attached: closingMay2011
2011-05-24 10:56dalsasuaStatusresolved => closed

Notes
(0034142)
hgbot   
2011-02-10 20:02   
Repository: erp/stable/2.50
Changeset: 6c7a48f224145ef8501334d51cdd851ffdded904
Author: Mikel Irurita <mikel.irurita <at> openbravo.com>
Date: Thu Feb 10 20:01:58 2011 +0100
URL: http://code.openbravo.com/erp/stable/2.50/rev/6c7a48f224145ef8501334d51cdd851ffdded904 [^]

Fixes issue 15947: @AD_Org_Id@ not working properly

---
M src-db/database/sourcedata/AD_COLUMN.xml
---