Openbravo Issue Tracking System - Modules
View Issue Details
0040157ModulesRemittancepublic2019-02-06 10:402019-02-18 13:36
ngarcia 
AtulOpenbravo 
immediatemajoralways
closedfixed 
5
 
 
2019-07-24
https://code.openbravo.com/erp/devel/pi/rev/95dcfa93d706654e1fbddfc3966bec7280081ac1 [^]
Sandrahuguet
0040157: Cannot reactivate a remittance: deleted object would be re-saved by cascade (remove deleted object from associations)
Cannot reactivate a remittance: deleted object would be re-saved by cascade (remove deleted object from associations): [REM_Instruction#...]

The problem is in the following piece of code of REM_RemittanceProcess class:

        // Remove instructions
        for (Instruction instr : remittance.getREMInstructionList()) {
          OBDal.getInstance().remove(instr);
        }
        remittance.setREMInstructionList(new ArrayList<Instruction>());
        OBDal.getInstance().save(remittance);
      }
      OBDal.getInstance().getSession().refresh(remittance);
      remittance.setProcessNow(false);
      OBDal.getInstance().save(remittance);
      OBDal.getInstance().flush();
As group admin role:
   Create a Sales Invoice, select Remittance payment method, add a line to it and complete it
   Create a Remittance header:
      Remittance Type: Printable Remittance
      Expected Date >= Sales Invoice - Payment Plan - Expected Date
      Select Orders or Invoices
      Select previously created invoice
   Process it
   Try to reactivate it and check the following error is shown:
      deleted object would be re-saved by cascade (remove deleted object from associations): [REM_Instruction#...]
No tags attached.
related to design defect 0029947 acknowledged Triage Platform Base Openbravo ERP Wrong query launched when OBDal.getInstance.getSession.refresh(Object) 
Issue History
2019-02-06 10:40ngarciaNew Issue
2019-02-06 10:40ngarciaAssigned To => Triage Finance
2019-02-06 10:40ngarciaResolution time => 1551222000
2019-02-06 10:40ngarciaIssue Monitored: networkb
2019-02-06 10:42SandrahuguetAssigned ToTriage Finance => AtulOpenbravo
2019-02-07 09:28AtulOpenbravoStatusnew => scheduled
2019-02-11 11:23caristuRelationship addedrelated to 0029947
2019-02-11 14:10AtulOpenbravoNote Added: 0109667
2019-02-11 17:34hgbotCheckin
2019-02-11 17:34hgbotNote Added: 0109679
2019-02-11 17:34hgbotStatusscheduled => resolved
2019-02-11 17:34hgbotResolutionopen => fixed
2019-02-11 17:34hgbotFixed in SCM revision => http://code.openbravo.com/erp/mods/org.openbravo.module.remittance/rev/e9fb2d8644efe729acb88e5c318fcd1bef7718dd [^]
2019-02-12 11:14AtulOpenbravoNote Added: 0109691
2019-02-12 11:15AtulOpenbravoNote Edited: 0109691bug_revision_view_page.php?bugnote_id=0109691#r18306
2019-02-12 11:17SandrahuguetReview Assigned To => Sandrahuguet
2019-02-12 11:17SandrahuguetNote Added: 0109692
2019-02-12 11:17SandrahuguetStatusresolved => closed
2019-02-12 12:21SandrahuguetRegression date => 2019-07-24
2019-02-12 12:21SandrahuguetRegression introduced by commit => https://code.openbravo.com/erp/devel/pi/rev/95dcfa93d706654e1fbddfc3966bec7280081ac1 [^]
2019-02-18 13:36caristuNote Added: 0109903
2019-02-18 13:37caristuNote Edited: 0109903bug_revision_view_page.php?bugnote_id=0109903#r18344
2019-02-18 13:38caristuNote Edited: 0109903bug_revision_view_page.php?bugnote_id=0109903#r18345

Notes
(0109667)
AtulOpenbravo   
2019-02-11 14:10   
Apply remittance module dataset and add Remittance payment method in Financial account's payment method tab.

- Login As group admin role:
- Create a Sales Invoice, select Remittance payment method, add a line to it and complete it.
- Create a Remittance header:
      Remittance Type: Printable Remittance
      Expected Date >= Sales Invoice - Payment Plan - Expected Date
      Select Orders or Invoices
      Select previously created invoice
- Process it.
- Try to reactivate it and check the process is successful.
(0109679)
hgbot   
2019-02-11 17:34   
Repository: erp/mods/org.openbravo.module.remittance
Changeset: e9fb2d8644efe729acb88e5c318fcd1bef7718dd
Author: Atul Gaware <atul.gaware <at> openbravo.com>
Date: Mon Feb 11 18:37:12 2019 +0530
URL: http://code.openbravo.com/erp/mods/org.openbravo.module.remittance/rev/e9fb2d8644efe729acb88e5c318fcd1bef7718dd [^]

Fixes Issue 40157:Cannot reactivate a remittance: deleted object would be
re-saved by cascade (remove deleted object from associations)

** Avoid refreshing remittance using getSession() of OBDal instance.
** Clear instruction list from remittance.
** Avoid saving remittance.

---
M src/org/openbravo/module/remittance/process/REM_RemittanceProcess.java
---
(0109691)
AtulOpenbravo   
2019-02-12 11:14   
(edited on: 2019-02-12 11:15)
This issue was not reproducible until version 3.0PR18Q3.3 but was reproducible since version 3.0PR18Q4 in pi. Probably reason behind is the hibernate upgrade that has changed the behaviour in this case.

(0109692)
Sandrahuguet   
2019-02-12 11:17   
code review + testing ok
(0109903)
caristu   
2019-02-18 13:36   
(edited on: 2019-02-18 13:38)
This issue can be reproduced after the Hibernate upgrade because the behavior is different after invoking the OBDal.getInstance().getSession().refresh(bob) method:

- Hibernate 3.6 -> refresh also retrieves the first collection (see 0029947) from the database but it is NOT marked as initialized. This caused the "deleted object would be re-saved by cascade" check being skipped.

- Hibernate 5.3 -> the first collection is also being loaded (this problem remains) but it is marked as initialized. Therefore the "deleted object would be re-saved by cascade" check is performed and the error is correctly thrown.

Note that after the upgrade the process detects that a deleted object has been reloaded into the session. Before the upgrade, this was not being detected and the previously deleted objects of the collection was being re-saved because of the refresh call. So they were not being eventually deleted.