Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0022011Openbravo ERPA. Platformpublic2012-10-19 12:492012-10-31 13:30
Xpand-IT 
mtaal 
highmajoralways
closedfixed 
107
3.0MP15 
3.0MP17 
dbaz
Google Chrome
Core
No
0022011: Can't change Invoice Lines in a Business Handler when the Invoice is changed
I need to change all the lines when a field on the Invoice is changed.

In the business handler I can change the lines but they are not saved into the database.
If I add a line, it is saved but if I change an existing line it is not updated in the database.
I attached my handler.

Changes made on the for in onUpdate (line 123) are not committed.
No tags attached.
related to design defect 0024287 closed platform Event Handler runs 2 times when the change is made by another Event Handler 
? XphrPurchaseInvoiceHandler.java (11,236) 2012-10-19 12:49
https://issues.openbravo.com/file_download.php?file_id=5665&type=bug
Issue History
2012-10-19 12:49Xpand-ITNew Issue
2012-10-19 12:49Xpand-ITAssigned To => marvintm
2012-10-19 12:49Xpand-ITFile Added: XphrPurchaseInvoiceHandler.java
2012-10-19 12:49Xpand-ITWeb browser => Google Chrome
2012-10-19 12:49Xpand-ITModules => Core
2012-10-19 15:14shuehnerWeb browserGoogle Chrome => Google Chrome
2012-10-19 15:14shuehnerAssigned Tomarvintm => mtaal
2012-10-19 15:14shuehnerCategoryY. DBSourceManager => A. Platform
2012-10-25 09:41mtaalReview Assigned To => AugustoMauch
2012-10-25 09:41mtaalWeb browserGoogle Chrome => Google Chrome
2012-10-25 09:44hgbotCheckin
2012-10-25 09:44hgbotNote Added: 0053674
2012-10-25 09:44hgbotStatusnew => resolved
2012-10-25 09:44hgbotResolutionopen => fixed
2012-10-25 09:44hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/4ac6cc415fd40f861a96377627669f3f4985cd31 [^]
2012-10-25 10:51hgbotCheckin
2012-10-25 10:51hgbotNote Added: 0053679
2012-10-30 09:10alostaleReview Assigned ToAugustoMauch => dbaz
2012-10-30 13:43mtaalNote Added: 0053823
2012-10-30 15:55dbazNote Added: 0053834
2012-10-30 15:55dbazStatusresolved => closed
2012-10-30 15:55dbazFixed in Version => 3.0MP17
2012-10-30 16:18mtaalNote Added: 0053836
2012-10-30 16:18mtaalNote Added: 0053837
2012-10-31 13:30hudsonbotCheckin
2012-10-31 13:30hudsonbotNote Added: 0053918
2012-10-31 13:30hudsonbotCheckin
2012-10-31 13:30hudsonbotNote Added: 0053920
2015-01-27 10:25alostaleRelationship addedrelated to 0024287

Notes
(0053674)
hgbot   
2012-10-25 09:44   
Repository: erp/devel/pi
Changeset: 4ac6cc415fd40f861a96377627669f3f4985cd31
Author: Martin Taal <martin.taal <at> openbravo.com>
Date: Thu Oct 25 09:42:50 2012 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/4ac6cc415fd40f861a96377627669f3f4985cd31 [^]

Fixes issue 22011: Can't change Invoice Lines in a Business Handler when the Invoice is changed
Repeat flush until there are no changes anymore in the data, also improve error logging
when a batch update exception occurs

---
M modules/org.openbravo.service.json/src/org/openbravo/service/json/DefaultJsonDataService.java
---
(0053679)
hgbot   
2012-10-25 10:51   
Repository: erp/devel/pi
Changeset: a39ab20852a59118bf01221db38392997ad808a0
Author: Martin Taal <martin.taal <at> openbravo.com>
Date: Thu Oct 25 10:50:59 2012 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/a39ab20852a59118bf01221db38392997ad808a0 [^]

Related to issue 22011: Can't change Invoice Lines in a Business Handler when the Invoice is changed
Also do the extra flushes in normal commits.

---
M src/org/openbravo/dal/core/SessionHandler.java
---
(0053823)
mtaal   
2012-10-30 13:43   
To reproduce this issue:

- go to the org.openbravo.client.application.event.SetDocumentNoHandler and add some code which changes the line of a sales order, for example increase the quantity.
- in the event handler you can get the sales order with event.getTargetInstance(), this is a sales order (or purchase order)
- from there you can get to the lines
- make sure that you don't get an error if the sales order header has no lines

compile and restart, create a new sales order header and a line, then go back and change the header, the line should be changed by the event handler and the change should be visible in the ui.
(0053834)
dbaz   
2012-10-30 15:55   
Reviewed
(0053836)
mtaal   
2012-10-30 16:18   
Here a diff to reproduce the issue:

diff --git a/modules/org.openbravo.client.application/src/org/openbravo/client/application/event/SetDocumentNoHandler.java b/modules/org.openbravo.client.application/src/org/openbravo/client/application/event/SetDocumentNoHandler.java
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/event/SetDocumentNoHandler.java
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/event/SetDocumentNoHandler.java
@@ -19,6 +19,7 @@

 package org.openbravo.client.application.event;

+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;

@@ -79,6 +80,14 @@
     Property docTypeTargetProperty = documentTypeTargetProperties[index];
     Property processedProperty = processedProperties[index];

+ // test to set an arbitrary value for the order quantity
+ if (event.getTargetInstance() instanceof Order) {
+ final Order order = (Order) event.getTargetInstance();
+ if (order.getOrderLineList().size() > 0) {
+ order.getOrderLineList().get(0).setOrderedQuantity(new BigDecimal(83));
+ }
+ }
+
     String documentNo = (String) event.getCurrentState(documentNoProperty);
     boolean processed = false;
     Object oProcessed = (processedProperty == null ? false : event
(0053837)
mtaal   
2012-10-30 16:18   
The above diff should change the order quantity of the first sales order line to 83 when the sales order header is saved.

This should be visible in the ui.
(0053918)
hudsonbot   
2012-10-31 13:30   
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/9e773cbcb723 [^]

Maturity status: Test
(0053920)
hudsonbot   
2012-10-31 13:30   
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/9e773cbcb723 [^]

Maturity status: Test