8.3: Fatal error: Uncaught DivisionByZeroError when creating quote/sales order/invoice from opportunity
When creating a quote, sales order or invoice from the opportunity detail view I receive the following error:
Fatal error: Uncaught DivisionByZeroError: Division by zero in /var/www/html/test/templates_c/v7/52e1425cc91a58e321ae96fb753858a9a8b3a49f_0.file.LineItemsContent.tpl.php:165 Stack trace: #0 /var/www/html/vendor/smarty/smarty/libs/sysplugins/smarty_template_resource_base.php(123): content_670d12c3006116_89247107() #1 /var/www/html/vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php(114): Smarty_Template_Resource_Base->getRenderedTemplateCode() #2 /var/www/html/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php(217): Smarty_Template_Compiled->render() #3 /var/www/html/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php(386): Smarty_Internal_Template->render() #4 /var/www/html/test/templates_c/v7/a1ab9b57c0b0cdf1750f16db1f843964375dd754_0.file.LineItemsEdit.tpl.php(180): Smarty_Internal_Template->_subTemplateRender() #5 /var/www/html/vendor/smarty/smarty/libs/sysplugins/smarty_template_resource_base.php(123): content_670d12c2ec36f1_43587155() #6 /var/www/html/vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php(114): Smarty_Template_Resource_Base->getRenderedTemplateCode() #7 /var/www/html/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php(217): Smarty_Template_Compiled->render() #8 /var/www/html/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php(386): Smarty_Internal_Template->render() #9 /var/www/html/test/templates_c/v7/abef94a1b598ee5000fcec758c68815074fe084e_0.file.EditViewContents.tpl.php(97): Smarty_Internal_Template->_subTemplateRender() #10 /var/www/html/vendor/smarty/smarty/libs/sysplugins/smarty_template_resource_base.php(123): content_670d12c2d2efe3_53416119() #11 /var/www/html/vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php(114): Smarty_Template_Resource_Base->getRenderedTemplateCode() #12 /var/www/html/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php(217): Smarty_Template_Compiled->render() #13 /var/www/html/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php(386): Smarty_Internal_Template->render() #14 /var/www/html/test/templates_c/v7/e28b872f572c15acf19fdb7b42e6ed57a39ecb13_0.file.EditView.tpl.php(123): Smarty_Internal_Template->_subTemplateRender() #15 /var/www/html/vendor/smarty/smarty/libs/sysplugins/smarty_template_resource_base.php(123): content_670d12c2cfdc96_54429960() #16 /var/www/html/vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php(114): Smarty_Template_Resource_Base->getRenderedTemplateCode() #17 /var/www/html/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php(217): Smarty_Template_Compiled->render() #18 /var/www/html/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(238): Smarty_Internal_Template->render() #19 /var/www/html/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(134): Smarty_Internal_TemplateBase->_execute() #20 /var/www/html/includes/runtime/Viewer.php(226): Smarty_Internal_TemplateBase->display() #21 /var/www/html/modules/Inventory/views/Edit.php(203): Vtiger_Viewer->view() #22 /var/www/html/modules/Quotes/views/Edit.php(14): Inventory_Edit_View->process() #23 /var/www/html/includes/main/WebUI.php(215): Quotes_Edit_View->process() #24 /var/www/html/index.php(26): Vtiger_WebUI->process() #25 {main} thrown in /var/www/html/test/templates_c/v7/52e1425cc91a58e321ae96fb753858a9a8b3a49f_0.file.LineItemsContent.tpl.php on line 165
If creating quote, sales order or invoice directly from the modules themselves it works. What's probably throwing this error is the automatic addition of one line item when creating an entity from the opportunity directly. For some reason this is only done, when the query has sourceModule=Potentials
. If this is not present, it does not automatically add a single line item. This could be an entirely different bug. So apparently the quantity of the empty item is set to 0 somehow and that throws an error. I can't find in the code what triggers that line item and what parameters it has.