Difference in Exception handling py code in Odoo 11 - odoo

What are differences in exception from the coding point of view in Odoo 11 as compared in Odoo 10? Can't find other differences except
except Exception, e: to except Exception as e:
My code shows error somehow from exception while converting a module from Odoo 10 to Odoo 11.

In Python 2.5 and earlier versions, 'as' isn't supported, so you use except Exception, e:
In Python 2.6+ versions, both can be used.
But from Python 3.x, except Exception as e is required to assign an exception to a variable.

Related

I need help upgrading OroCommerce to 4.1.1

I just upgraded from 3.1.17 to 4.1.1 and I'm finding a problem with my shopping lists.
When I get to /customer/shoppinglist/5064 I see this:
Looking at my log files from production I see:
[2020-06-23 17:42:56] request.CRITICAL: Uncaught PHP Exception Symfony\Component\ErrorHandler\Error\UndefinedMethodError: "Attempted to call an undefined method named "getDigitalAsset" of class "Proxies\__CG__\Oro\Bundle\AttachmentBundle\Entity\File"." at /usr/share/nginx/html/oroapp/vendor/oro/platform/src/Oro/Bundle/DigitalAssetBundle/Provider/FileTitleProvider.php line 47 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Attempted to call an undefined method named \"getDigitalAsset\" of class \"Proxies\\__CG__\\Oro\\Bundle\\AttachmentBundle\\Entity\\File\". at /usr/share/nginx/html/oroapp/vendor/oro/platform/src/Oro/Bundle/DigitalAssetBundle/Provider/FileTitleProvider.php:47)"} []
I went to look at the code and I see that in fact there is no method getDigitalAsset in oro/platform/src/Oro/Bundle/DigitalAssetBundle/Provider/FileTitleProvider.php, nor in the proxy... how can this be?
I checked this on my VM (where the problem is not happening) and I see that there's this definition in the proxy class:
/**
* {#inheritDoc}
*/
public function getDigitalAsset()
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getDigitalAsset', []);
return parent::getDigitalAsset();
}
But again, I don't see a method called getDigitalAsset in the parent class.
I had some issues when doing the upgrade (I realized my nodejs wasn't upgraded as I thought it was), could that have anything to do with the issue?
Thanks
Edit:
I went through my platform upgrade again and found that there were some problems that prevented it from finishing completely.
This is what I found:
> loading Oro\Bundle\CMSBundle\Migrations\Data\ORM\LoadImageSlider
In LoadImageSlider.php line 117:
Attempted to call an undefined method named "setMainImage" of class "Oro\Bundle\CMSBundle\Entity\ImageSlide".
I commented out the loop inside the load method and re-run the upgrade. Then I got:
> loading Oro\Bundle\CMSBundle\Migrations\Data\ORM\LoadImageSlider
In QueryException.php line 65:
[Semantical Error] line 0, col 117 near 'digitalAsset': Error: Class Oro\Bundle\AttachmentBundle\Entity\File has no association named digitalAsset
In QueryException.php line 43:
SELECT file, digitalAsset, sourceFile FROM Oro\Bundle\AttachmentBundle\Entity\File file INNER JOIN file.digitalAsset digitalAsset INNER JOIN digitalAsset.sourceFile sourceFile WHERE file.parentEntityClass = :parentEntityClass
AND file.parentEntityId = :parentEntityId AND file.parentEntityFieldName =
:parentEntityFieldName
Finally I was able to complete the upgrade by commenting out the whole body of the load method
I had some issues when doing the upgrade (I realized my nodejs wasn't upgraded as I thought it was), could that have anything to do with the issue?
It looks like you have multiple versions of nodejs installed. To make an application use the right one, you can provide the absolute path to the executable with the AssetBundle configuration, like:
# config/config.yml
oro_asset:
nodejs_path: /usr/local/node
npm_path: /usr/local/npm

Update php version 7 on server its hows fatal error on symonfy2`

request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalErrorException: "Compile Error: Cannot use Symfony\Component\Validator\Constraints\Null as Null because 'Null' is a special class name" at /vol/vhost/utterprints.com/src/Design/AppBundle/Controller/OrdersController.php line 30 {"exception":"[object] (Symfony\Component\Debug\Exception\FatalErrorException(code: 0): Compile Error: Cannot use Symfony\Component\Validator\Constraints\Null as Null because 'Null' is a special class name at /vol/vhost/utterprints.com/src/Design/AppBundle/Controller/OrdersController.php:30)"} []
IN ordersController on line 30 this validator component is use.
use Symfony\Component\Validator\Constraints\Null;
Starting with PHP 7.0 the "null" keyword becomes a reserved word in a sense that it cannot be used as a name of class, trait, interface nor a part of namespace.
I see that Symfony has support for PHP7 since August 2015, so you may need to update your Symfony installation.

Changing java heapsizes for a websphere server using websphere and wsadminlib.py

Im trying to call a command from wsadminlib.py to change the initialHeapSize and the maximumHeapSize in a script. But unfortunately my jython (and general scripting knowledge) is still total newbie.
Im using the call
#Change Java Heap Size
setJvmProperty(nodeName,serverName,maximumHeapsize -2048 ,initialHeapSize -2048)
Which should relate to the command in the wsadminlib.py library
def setJvmProperty(nodename,servername,propertyname,value):
"""Set a particular JVM property for the named server
Some useful examples:
'maximumHeapSize': 512 ,
'initialHeapSize':512,
'verboseModeGarbageCollection':"true",
'genericJvmArguments':"-Xgcpolicy:gencon -Xdump:heap:events=user -Xgc:noAdaptiveTenure,tenureAge=8,stdGlobalCompactToSatisfyAllocate -Xconcurrentlevel1 -Xtgc:parallel",
"""
jvm = getServerJvm(nodename,servername)
AdminConfig.modify(jvm, [[propertyname, value]])
But I'm met with this issue when i run the script
WASX7017E: Exception received while running file "/etc/was-scripts/administrateservertest.py"; exception information: com.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
File "", line 14, in ?
NameError: maximumHeapsize
Any suggestions would be appreciated as I'm tearing my hair out trying to work this out
this was answered by a friend on face book
I think you might need to make two calls, one for each property you
want to set. e.g.
setJvmProperty(nodeName,serverName,'maximumHeapsize',2048)
For others looking for a more specific answer, try this:
AdminConfig.modify(jvmId,[['genericJvmArguments',arguments],["maximumHeapSize", str(1536)]])

Some PHP errors/notices not displaying call stack information within Slim Framework

I'm using the Slim Framework.
Most PHP errors in my application output normal PHP error messages
Example code with an error that outputs the Call Stack:
echo 'missing semicolon at eol'
Error Output:
Parse error: syntax error, unexpected T_IF, expecting ',' or ';' in /data/www/app/routes/companies_routes.php on line 737
Call Stack:
0.0002 637144 1. {main}() /data/www/html/index.php:0
But other errors ( maybe just notices ) output a limited message that doesn't have a line number, file name, or call stack. This makes debugging these errors extremely time consuming.
Code with an error that outputs a limited error message
echo $an_undefined_variable;
Limited Message
Undefined variable: an_undefined_variable
I can't figure out what's going on. I've never had this problem before. I suspect it has something to do with the way Slim handles PHP errors. I've tried wrapping these errors in Try/Catch blocks, but that doesn't solve the problem.
The problem is that Slim is handling exceptions itself ( some sort of default behavior I've yet to track down ).
I've got my code wrapped in Try/Catch blocks, so when Slim catches a PHP error, it's throwing it's own Exception that I'm then outputting in my Catch block. If I remove my Catch block, Slim them outputs it's own complete error message that contains the stack as usual.
This surely means I'm not using Slim quite right, but that's a different question.

Aspose.Cells .NET: upgrading 6.0.1 to 7.3.1, WorkBookDesigner.SetDataSource() fails

Scenario: add two DataSets by invoking WorkBookDesigner.SetDataSource(DataSet) twice, each of the DataSets has a DataTable of customers, the DataTables have different names.
6.0.1: worked fine
7.3.1: Exception
Test method Nirvana.Reporting.Engines.Aspose.Tests.Cells.AsposeCellsEngineTests.Execute_Report_NoTemplate_TemplateTypeDesigner_FormatXLS_ReturnsEmptySpreadSheet threw exception:
Nirvana.Reporting.Core.ReportExecutionException: An error occured executing report 'CustomerList' ---> System.ArgumentException: Item has already been added. Key in dictionary: 'PHONENUMBERS' Key being added: 'PHONENUMBERS'
System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
System.Collections.Hashtable.Add(Object key, Object value)
Aspose.Cells.WorkbookDesigner.SetDataSource(DataTable dataTable)
Nirvana.Reporting.Engines.Aspose.Cells.AsposeCellsEngine.AssignDataSourcesToWorkbookDesigner(IReport report, WorkbookDesigner designer) in C:\Workspaces\ja38524\KBC.ServiceOrganisation\Framework\Trunk\Source\Nirvana.Solution\Nirvana.Reporting.Engines.Aspose\Cells\AsposeCellsEngine.cs: line 344
Nirvana.Reporting.Engines.Aspose.Cells.AsposeCellsEngine.ExecuteDesignerReport(IReport report) in C:\Workspaces\ja38524\KBC.ServiceOrganisation\Framework\Trunk\Source\Nirvana.Solution\Nirvana.Reporting.Engines.Aspose\Cells\AsposeCellsEngine.cs: line 298
Nirvana.Reporting.Engines.Aspose.Cells.AsposeCellsEngine.Execute(Guid reportInstanceId, IReport report) in C:\Workspaces\ja38524\KBC.ServiceOrganisation\Framework\Trunk\Source\Nirvana.Solution\Nirvana.Reporting.Engines.Aspose\Cells\AsposeCellsEngine.cs: line 103
Nirvana.Reporting.Engines.Aspose.Cells.AsposeCellsEngine.Execute(Guid reportInstanceId, IReport report) in C:\Workspaces\ja38524\KBC.ServiceOrganisation\Framework\Trunk\Source\Nirvana.Solution\Nirvana.Reporting.Engines.Aspose\Cells\AsposeCellsEngine.cs: line 120
Nirvana.Reporting.Engines.Aspose.Tests.Cells.AsposeCellsEngineTests.Execute_Report_NoTemplate_TemplateTypeDesigner_FormatXLS_ReturnsEmptySpreadSheet() in C:\Workspaces\ja38524\KBC.ServiceOrganisation\Framework\Trunk\Source\Nirvana.Solution\Nirvana.Reporting.Engines.Aspose.Tests\Cells\AsposeCellsEngineTest.cs: line 188
How can I solve?
This issue looks like a regression but it might be solved in latest versions. So, you should give a try to latest version: Aspose.Cells for .NET 8.4.2 and see if it makes any difference.
Note: I am working as Developer Evangelist at Aspose