Merge branch '21.0' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
ldestailleur
2025-04-01 22:42:32 +02:00
4 changed files with 80 additions and 5 deletions

View File

@@ -1189,7 +1189,7 @@ class Contact extends CommonObject
}
}
return 1;
return $this->id;
} else {
$this->error = $langs->trans("RecordNotFound");
return 0;

View File

@@ -54,6 +54,7 @@ require_once $dolibarr_main_document_root.'/commande/class/commande.class.php';
require_once $dolibarr_main_document_root.'/fourn/class/fournisseur.commande.class.php';
require_once $dolibarr_main_document_root.'/core/lib/price.lib.php';
require_once $dolibarr_main_document_root.'/core/class/menubase.class.php';
require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
require_once $dolibarr_main_document_root.'/core/lib/files.lib.php';
global $langs;
@@ -517,10 +518,11 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
*/
// Scripts for 20.0
/*$afterversionarray = explode('.', '19.0.9');
$afterversionarray = explode('.', '19.0.9');
$beforeversionarray = explode('.', '20.0.9');
if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
}*/
migrate_invoice_export_models();
}
// Scripts for 21.0
$afterversionarray = explode('.', '20.0.9');
@@ -5141,6 +5143,78 @@ function migrate_contractdet_rank()
}
}
/**
* Invoice exports been shifted (facture_1 => facture_0, facture_2 => facture_1) in version 20, shift export models accordingly
*
* @return void
*/
function migrate_invoice_export_models()
{
global $db, $langs;
$lock = getDolGlobalInt('MIGRATION_FLAG_INVOICE_MODELS_V20');
$firstInstallVersion = getDolGlobalString('MAIN_VERSION_FIRST_INSTALL', DOL_VERSION);
$migrationNeeded = (versioncompare(explode('.', $firstInstallVersion, 3), array(20, 0, -5)) < 0 && !$lock);
print '<tr class="trforrunsql"><td colspan="4">';
print '<b>'.$langs->trans('InvoiceExportModelsMigration')."</b>: \n";
if (! $migrationNeeded) {
print $langs->trans("AlreadyDone");
print '</td></tr>';
dolibarr_set_const($db, 'MIGRATION_FLAG_INVOICE_MODELS_V20', 1, 'chaine', 0, 'To flag the upgrade of invoice template has been set', 0);
return;
}
$db->begin();
$sql1 = "UPDATE ".$db->prefix()."export_model SET type = 'facture_0' WHERE type = 'facture_1'";
$resql1 = $db->query($sql1);
if (! $resql1) {
dol_print_error($db);
$db->rollback();
print '</td></tr>';
return;
}
$modified1 = $db->affected_rows($resql1);
print str_repeat('.', $modified1);
$db->free($resql1);
$sql2 = "UPDATE ".$db->prefix()."export_model SET type = 'facture_1' WHERE type = 'facture_2'";
$resql2 = $db->query($sql2);
if (! $resql2) {
dol_print_error($db);
$db->rollback();
print '</td></tr>';
return;
}
$modified2 = $db->affected_rows($resql2);
print str_repeat('.', $modified2);
$db->free($resql2);
if (empty($modified1 + $modified2)) {
print $langs->trans('NothingToDo');
}
$db->commit();
dolibarr_set_const($db, 'MIGRATION_FLAG_INVOICE_MODELS_V20', 1, 'chaine', 0, 'To flag the upgrade of invoice template has been set', 0);
echo '</td></tr>';
}
/**
* Migrate Ref in bookkeeping lines
*

View File

@@ -220,3 +220,4 @@ NodoUpgradeAfterFiles=No action requested by external modules after upgrade of f
MigrationContractLineRank=Migrate Contract Line to use Rank (and enable Reorder)
MigrationProductLotPath=Migrate Product Batch files path
MigrationAccountancyBookkeeping=Migrate accountancy bookkeeping to use a ref
InvoiceExportModelsMigration=Migrate invoice export models

View File

@@ -390,7 +390,7 @@ class modMyModule extends DolibarrModules
// Exports profiles provided by this module
$r = 1;
$r = 0;
/* BEGIN MODULEBUILDER EXPORT MYOBJECT */
/*
$langs->load("mymodule@mymodule");
@@ -421,7 +421,7 @@ class modMyModule extends DolibarrModules
/* END MODULEBUILDER EXPORT MYOBJECT */
// Imports profiles provided by this module
$r = 1;
$r = 0;
/* BEGIN MODULEBUILDER IMPORT MYOBJECT */
/*
$langs->load("mymodule@mymodule");