Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0044871Openbravo ERPA. Platformpublic2020-08-24 09:062020-08-24 20:07
joniturralde93 
platform 
urgentmajoralways
closedout of date 
5
 
 
Core
No
0044871: Callout SE_Invoice_BPartner doesn't work when there is too much data
When selecting a business partner when creating a sales invoice, the callout won't work for too much data, specifically number of vendors (users marked as vendors and related to a business partner). The business partner gets selected, but the related fields are not automatically selected (payment method and payment terms).

This is the error shown in openbravo.log:
2020-08-22 05:49:07,863 [http-194] ERROR org.openbravo.client.application.window.FormInitializationComponent - Couldn't parse callout response. The parsed response was: var calloutName='SE_Invoice_BPartner';
(...)
org.mozilla.javascript.EvaluatorException: Encountered code generation error while compiling script: generated bytecode for method exceeds 64K limit. (<cmd>#1)
    at org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:109)
    at org.mozilla.javascript.Context.reportRuntimeError(Context.java:938)
    at org.mozilla.javascript.optimizer.Codegen.reportClassFileFormatException(Codegen.java:196)
    at org.mozilla.javascript.optimizer.Codegen.generateCode(Codegen.java:329)
    at org.mozilla.javascript.optimizer.Codegen.compileToClassFile(Codegen.java:182)
    at org.mozilla.javascript.optimizer.Codegen.compile(Codegen.java:91)
    at org.mozilla.javascript.Context.compileImpl(Context.java:2391)
    at org.mozilla.javascript.Context.compileString(Context.java:1359)
    at org.mozilla.javascript.Context.compileString(Context.java:1348)
    at org.mozilla.javascript.Context.evaluateString(Context.java:1101)
    at org.openbravo.client.application.window.FormInitializationComponent.parseCalloutResponse(FormInitializationComponent.java:1744)
    at org.openbravo.client.application.window.FormInitializationComponent.runCallouts(FormInitializationComponent.java:1540)
    at org.openbravo.client.application.window.FormInitializationComponent.executeCallouts(FormInitializationComponent.java:1444)
    at org.openbravo.client.application.window.FormInitializationComponent.execute(FormInitializationComponent.java:276)

This error means that the javascript generated by FormInitializationComponent is too large (Rhino javascript engine doesn't support that).


In our case, there were 1772 results when executing this query:
select count(1) from ad_user
inner join c_bpartner on ad_user.c_bpartner_id=c_bpartner.c_bpartner_id
where issalesrep='Y' and ad_user.isactive='Y';

After we set as inactive the ones created in the last days (440 records), the callout started working again.
- Configure a lot of vendors (active users with a business partner assigned which has "sales representative" checked), in our case there were 1772
- Create a sales invoice
- Select a business partner
- The callout doesn't work, the related fields are not automatically selected and there is an error in openbravo.log
In this case, in my opinion the first thing would be to review the callout, because the code that is generating a very large amount of data (the ComboTableData call to read the sales representatives) maybe is not needed, as the new selectors should already compute this information in a lazy way if I'm not mistaken
No tags attached.
related to design defect 0020455 scheduled marvintm When you have one combotabledata with a big quantity of data inside a callout the callout breaks 
Issue History
2020-08-24 09:06joniturralde93New Issue
2020-08-24 09:06joniturralde93Assigned To => platform
2020-08-24 09:06joniturralde93Modules => Core
2020-08-24 09:06joniturralde93Resolution time => 1600034400
2020-08-24 09:06joniturralde93Triggers an Emergency Pack => No
2020-08-24 09:09marvintmProposed Solution updated
2020-08-24 09:42joniturralde93Relationship addedrelated to 0020455
2020-08-24 13:45AugustoMauchNote Added: 0122304
2020-08-24 13:45AugustoMauchStatusnew => closed
2020-08-24 13:45AugustoMauchResolutionopen => out of date
2020-08-24 20:06AugustoMauchNote Added: 0122317
2020-08-24 20:07AugustoMauchNote Added: 0122318

Notes
(0122304)
AugustoMauch   
2020-08-24 13:45   
The client where this issue was reproduced has a very old Openbravo version (18Q3). We no longer use Rhino to evaluate the response of the callouts [1], and also the callout in question was reimplemented as a SimpleCallout, like many others [2]


[1] https://issues.openbravo.com/view.php?id=40535 [^]
[2] https://issues.openbravo.com/view.php?id=36067 [^]
(0122317)
AugustoMauch   
2020-08-24 20:06   
Hello,

My previous assessment was not correct. Those callouts I mentioned are already reimplemented in the 18Q3 version, the problem here is that there are some custom callouts (FE_Invoice_BPartner) that overwrites SE_Invoice_BPartner but that is still using the old callout technology. The next step should be to reimplemente that callout like SE_Invoice_BPartner was reimplemented
(0122318)
AugustoMauch   
2020-08-24 20:07   
To look for other callouts that use the deprecated technology, the following command can be executed on the modules/ folder:

grep -Ir --exclude="*productImages/*" 'var respuesta' . | less