SOLVED: SQL-Error on correct stock / 8.0.3

Hi,

if I want to correct the stock I get the following SQL-error. How I can fix it?

dolibarr.log.zip (7.77 KB)

Logfile:
2018-11-20 11:48:40 ERR x.x.x.x DoliDBMysqli::query SQL Error query: SELECT ps.rowid, ps.reel, ps.fk_entrepot FROM llx_product_stock as ps, llx_entrepot as w WHERE w.entity IN (1) AND w.rowid = ps.fk_entrepot AND ps.fk_product =
2018-11-20 11:48:40 ERR x.x.x.x DoliDBMysqli::query SQL Error message: DB_ERROR_SYNTAX You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’ at line 1
2018-11-20 11:48:40 ERR x.x.x.x DoliDBMysqli::query SQL Error query: UPDATE llx_product as p SET pmp = , stock=(SELECT SUM(ps.reel) FROM llx_product_stock as ps WHERE ps.fk_product = p.rowid) WHERE rowid = 91
2018-11-20 11:48:40 ERR x.x.x.x DoliDBMysqli::query SQL Error message: DB_ERROR_SYNTAX You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ’ stock=(SELECT SUM(ps.reel) FROM llx_product_stock as ps WHERE ps.fk_product = ’ at line 1
2018-11-20 11:48:40 ERR x.x.x.x MouvementStock::_create error code=-4
2018-11-20 11:48:40 ERR x.x.x.x MouvementStock::_create error code=-6


DOLIBARR ENVIRONMENT
- Version: [8.0.3]
- Operating System: [Linux 2.6.32-openvz-042stab127.2-amd64]
- Web Server: [nginx/1.14.0]
- PHP: [PHP 5.6.8]
- Database: [MySQL or MariaDB 5.6.28-1]
- URL(s): [/product/stock/product.php?id=676]


and here is the Debug-Log

dolibarr.log_2018-11-22.zip (7.77 KB)

Hi,

the error was due to a reference to a subproduct (virtual product) in the llx_product_association table that no longer existed in the llx_product table. How this came about in an earlier version of Dolibarr can no longer be determined.

Today when deleting a product, which is also linked as subproduct, all references are deleted without warning - how rude!

In /product/stock/class/mouvementstock.class.php, when determining pmp, it is not checked whether a subproduct actually exists and therefore leads to SQL error.