Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0027775Openbravo ERPI. Performancepublic2014-10-06 17:012014-12-30 23:22
vmromanos 
vmromanos 
normalminoralways
closedfixed 
5
 
3.0PR15Q1 
fsoto82
Core
No
0027775: Improve performance in TruncInvoiceDate and Issue26826_Org_AllowPeriodControl module scripts
The TruncInvoiceDate and Issue26826_Org_AllowPeriodControl module scripts runs a full table scan each time they are run, regardless any record is updated or not.

For this kind of heavy queries, it is better to set a preference the first time the module script is executed and avoid the following executions if the preference is set.
1. As group admin, go to Purchase Invoice.
2. Create a new header and save it
3. Go to the database and run the following update for the created header:
update c_invoice
set dateinvoiced=now()
where docstatus = 'DR' and c_invoice_id = <THE ID>
4. Run ant smartbuild -Dlocal=no
5. Verify the TruncInvoiceDate module script has fixed it. You can either take a look at the log or query the database
6. Repeat steps 3 and 4. The TruncInvoiceDate module script has fixed it. You can either take a look at the log or query the database. This is wrong, because we only want the module script to be executed just one time
No tags attached.
related to defect 00268263.0PR15Q1 closed vmromanos Should not be possible to save Organization header with "Organization type"=Organization and check "Allow period control"= Yes 
related to defect 00270893.0PR15Q1 closed fsoto82 Invoice Date and Accounting Date should be truncated when invoice is created using "Generate Invoice from Receipt" process 
Issue History
2014-10-06 17:01vmromanosNew Issue
2014-10-06 17:01vmromanosAssigned To => vmromanos
2014-10-06 17:01vmromanosModules => Core
2014-10-06 17:01vmromanosTriggers an Emergency Pack => No
2014-10-06 17:02vmromanosRelationship addedrelated to 0026826
2014-10-06 17:02vmromanosRelationship addedrelated to 0027089
2014-10-06 17:02vmromanosStatusnew => scheduled
2014-10-06 17:02vmromanosfix_in_branch => pi
2014-10-06 17:11vmromanosNote Added: 0070746
2014-10-06 17:15vmromanosReview Assigned To => shuehner
2014-10-06 17:15vmromanosfix_in_branchpi =>
2014-10-06 17:22vmromanosNote Edited: 0070746bug_revision_view_page.php?bugnote_id=0070746#r6740
2014-10-06 17:29vmromanosNote Edited: 0070746bug_revision_view_page.php?bugnote_id=0070746#r6741
2014-10-06 17:54vmromanosReview Assigned Toshuehner => vmromanos
2014-10-06 17:55hgbotCheckin
2014-10-06 17:55hgbotNote Added: 0070748
2014-10-06 17:55hgbotStatusscheduled => resolved
2014-10-06 17:55hgbotResolutionopen => fixed
2014-10-06 17:55hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/bda678370986e6eb7f81c83ed8cbe4167359ebc6 [^]
2014-10-07 09:59vmromanosReview Assigned Tovmromanos => fsoto82
2014-10-07 09:59vmromanosStatusresolved => closed
2014-12-30 23:22hudsonbotCheckin
2014-12-30 23:22hudsonbotNote Added: 0072905

Notes
(0070746)
vmromanos   
2014-10-06 17:11   
(edited on: 2014-10-06 17:29)
Test plan for TruncInvoiceDate:
1. As group admin, go to Purchase Invoice.
2. Create a new header and save it
3. Go to the database and run the following update for the created header:
update c_invoice
set dateinvoiced=now()
where docstatus = 'DR' and c_invoice_id = <THE ID>
4. Run ant smartbuild -Dlocal=no
5. Verify the TruncInvoiceDate module script has fixed it. You can either take a look at the log or query the database
6. Repeat steps 3 and 4. Verify the module script doesn't fix it, which means the process hasn't been executed


Test plan for Issue26826_Org_AllowPeriodControl:
1. Before applying the fix, run the following query in the database:
update ad_org set ISPERIODCONTROLALLOWED = 'Y' where ad_org_id = '0'
This will set the Period Control Allowed flag to Y for the 0 organization, which is a wrong configuration
2. Apply the fix to the environment
3. Run ant smartbuild -Dlocal=no
4. Review the module script log and verify the following info message is shown just after the execution of the Issue26826_Org_AllowPeriodControl module script
Fixed 1 organizations.
5. Run again step 1. You will need to comment the line: "RAISE EXCEPTION '%','@OrgTypeDoesNotAllowPeriodControl@'; --OBTG:-20000--" into the ad_org_trg before running the query
6. Run again ant smartbuild -Dlocal=no -Dforce=true
7. Verify no organization has been updated

(0070748)
hgbot   
2014-10-06 17:55   
Repository: erp/devel/pi
Changeset: bda678370986e6eb7f81c83ed8cbe4167359ebc6
Author: Víctor Martínez Romanos <victor.martinez <at> openbravo.com>
Date: Mon Oct 06 17:39:14 2014 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/bda678370986e6eb7f81c83ed8cbe4167359ebc6 [^]

Fixed bug 27775: Performance improvement in 2 module scripts

The TruncInvoiceDate and Issue26826_Org_AllowPeriodControl module scripts had the same performance problem: they ran a full table scan each time the module script was executed regardless it updated any record or not.

To fix it, the module script now verifies whether a preference exists or not. If it doesn't exist, the update is executed and the preference is set, so the update process won't be executed in the future.

---
M src-util/modulescript/build/classes/org/openbravo/modulescript/Issue26826OrgAllowPeriodControlData.class
M src-util/modulescript/build/classes/org/openbravo/modulescript/Issue26826_Org_AllowPeriodControl.class
M src-util/modulescript/build/classes/org/openbravo/modulescript/TruncInvoiceDate.class
M src-util/modulescript/build/classes/org/openbravo/modulescript/TruncInvoiceDateData.class
M src-util/modulescript/src/org/openbravo/modulescript/Issue26826_Org_AllowPeriodControl.java
M src-util/modulescript/src/org/openbravo/modulescript/Issue26826_Org_AllowPeriodControl_data.xsql
M src-util/modulescript/src/org/openbravo/modulescript/TruncInvoiceDate.java
M src-util/modulescript/src/org/openbravo/modulescript/TruncInvoiceDate_data.xsql
---
(0072905)
hudsonbot   
2014-12-30 23:22   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/6525fe229e06 [^]
Maturity status: Test