FIX broken feature, check if module is enabled

This commit is contained in:
Regis Houssin 2024-12-19 12:22:10 +01:00
parent b8f094f121
commit e070a3eda4
2 changed files with 12 additions and 3 deletions

View File

@ -4847,6 +4847,15 @@ abstract class CommonObject
$haschild = 0;
foreach ($arraytoscan as $table => $element) {
//print $id.'-'.$table.'-'.$elementname.'<br>';
// Check if module is enabled (to avoid error if tables of module not created)
if (isset($element['enabled']) && !empty($element['enabled'])) {
$enabled = (int) dol_eval($element['enabled'], 1);
if (empty($enabled)) {
continue;
}
}
// Check if element can be deleted
$sql = "SELECT COUNT(*) as nb";
$sql .= " FROM ".$this->db->prefix().$table." as c";

View File

@ -87,9 +87,9 @@ class Product extends CommonObject
'contratdet' => array('name' => 'Contract', 'parent' => 'contrat', 'parentkey' => 'fk_contrat'),
'facture_fourn_det' => array('name' => 'SupplierInvoice', 'parent' => 'facture_fourn', 'parentkey' => 'fk_facture_fourn'),
'commande_fournisseurdet' => array('name' => 'SupplierOrder', 'parent' => 'commande_fournisseur', 'parentkey' => 'fk_commande'),
'mrp_production' => array('name' => 'Mo', 'parent' => 'mrp_mo', 'parentkey' => 'fk_mo' ),
'bom_bom' => array('name' => 'BOM'),
'bom_bomline' => array('name' => 'BOMLine', 'parent' => 'bom_bom', 'parentkey' => 'fk_bom'),
'mrp_production' => array('name' => 'Mo', 'parent' => 'mrp_mo', 'parentkey' => 'fk_mo', 'enabled' => 'isModEnabled("mrp")'),
'bom_bom' => array('name' => 'BOM', 'enabled' => 'isModEnabled("bom")'),
'bom_bomline' => array('name' => 'BOMLine', 'parent' => 'bom_bom', 'parentkey' => 'fk_bom', 'enabled' => 'isModEnabled("bom")'),
);
/**