2
0
forked from Wavyzz/dolibarr

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

This commit is contained in:
Laurent Destailleur (aka Eldy)
2025-01-21 13:00:34 +01:00
11 changed files with 48 additions and 10 deletions

View File

@@ -150,7 +150,7 @@ while ($i < GEN_NUMBER_FACTURE && $result >= 0) {
$fuser = new User($db); $fuser = new User($db);
$fuser->fetch(mt_rand(1, 2)); $fuser->fetch(mt_rand(1, 2));
$fuser->getRights(); $fuser->loadRights();
$result=$object->create($fuser); $result=$object->create($fuser);
if ($result >= 0) { if ($result >= 0) {

View File

@@ -180,7 +180,7 @@ for ($s = 0; $s < GEN_NUMBER_COMMANDE; $s++) {
$fuser = new User($db); $fuser = new User($db);
$fuser->fetch($listofuserid[mt_rand(0, 2)]); $fuser->fetch($listofuserid[mt_rand(0, 2)]);
$fuser->getRights(); $fuser->loadRights();
$db->begin(); $db->begin();

View File

@@ -171,7 +171,7 @@ while ($i < GEN_NUMBER_PROPAL && $result >= 0) {
$fuser = new User($db); $fuser = new User($db);
$fuser->fetch(mt_rand(1, 2)); $fuser->fetch(mt_rand(1, 2));
$fuser->getRights(); $fuser->loadRights();
$object->contactid = $contids[$socids[$socid]][0]; $object->contactid = $contids[$socids[$socid]][0];
$object->socid = $socids[$socid]; $object->socid = $socids[$socid];

View File

@@ -763,6 +763,11 @@ class Adherent extends CommonObject
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
if (empty($this->country_id) && !empty($this->country_code)) {
$country_id = getCountry($this->country_code, '3');
$this->country_id = is_int($country_id) ? $country_id : 0;
}
$nbrowsaffected = 0; $nbrowsaffected = 0;
$error = 0; $error = 0;

View File

@@ -760,6 +760,11 @@ class Account extends CommonObject
$this->status = $this->clos; $this->status = $this->clos;
} }
if (empty($this->country_id) && !empty($this->country_code)) {
$country_id = getCountry($this->country_code, '3');
$this->country_id = is_int($country_id) ? $country_id : 0;
}
// Load the library to validate/check a BAN account // Load the library to validate/check a BAN account
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
@@ -900,6 +905,11 @@ class Account extends CommonObject
{ {
global $langs, $conf; global $langs, $conf;
if (empty($this->country_id) && !empty($this->country_code)) {
$country_id = getCountry($this->country_code, '3');
$this->country_id = is_int($country_id) ? $country_id : 0;
}
$error = 0; $error = 0;
$this->db->begin(); $this->db->begin();

View File

@@ -607,6 +607,11 @@ class Contact extends CommonObject
{ {
global $conf; global $conf;
if (empty($this->country_id) && !empty($this->country_code)) {
$country_id = getCountry($this->country_code, '3');
$this->country_id = is_int($country_id) ? $country_id : 0;
}
$error = 0; $error = 0;
$this->id = $id; $this->id = $id;

View File

@@ -1423,6 +1423,10 @@ class Product extends CommonObject
if (empty($this->country_id)) { if (empty($this->country_id)) {
$this->country_id = 0; $this->country_id = 0;
} }
if (empty($this->country_id) && !empty($this->country_code)) {
$country_id = getCountry($this->country_code, '3');
$this->country_id = is_int($country_id) ? $country_id : 0;
}
if (empty($this->state_id)) { if (empty($this->state_id)) {
$this->state_id = 0; $this->state_id = 0;

View File

@@ -255,6 +255,10 @@ class Entrepot extends CommonObject
$this->error = "ErrorFieldRequired"; $this->error = "ErrorFieldRequired";
return 0; return 0;
} }
if (empty($this->country_id) && !empty($this->country_code)) {
$country_id = getCountry($this->country_code, '3');
$this->country_id = is_int($country_id) ? $country_id : 0;
}
$now = dol_now(); $now = dol_now();
@@ -325,6 +329,11 @@ class Entrepot extends CommonObject
*/ */
public function update($id, $user, $notrigger = 0) public function update($id, $user, $notrigger = 0)
{ {
if (empty($this->country_id) && !empty($this->country_code)) {
$country_id = getCountry($this->country_code, '3');
$this->country_id = is_int($country_id) ? $country_id : 0;
}
$error = 0; $error = 0;
if (empty($id)) { if (empty($id)) {

View File

@@ -1012,11 +1012,6 @@ class Societe extends CommonObject
$this->fk_multicurrency = 0; $this->fk_multicurrency = 0;
} }
if (empty($this->country_id) && !empty($this->country_code)) {
$country_id = getCountry($this->country_code, '3');
$this->country_id = is_int($country_id) ? $country_id : 0;
}
dol_syslog(get_class($this)."::create ".$this->name); dol_syslog(get_class($this)."::create ".$this->name);
$now = dol_now(); $now = dol_now();
@@ -1446,6 +1441,11 @@ class Societe extends CommonObject
$this->country_id = dol_getIdFromCode($this->db, $this->country_code, 'c_country', 'code', 'rowid'); $this->country_id = dol_getIdFromCode($this->db, $this->country_code, 'c_country', 'code', 'rowid');
} }
if (empty($this->country_id) && !empty($this->country_code)) {
$country_id = getCountry($this->country_code, '3');
$this->country_id = is_int($country_id) ? $country_id : 0;
}
$error = 0; $error = 0;
dol_syslog(get_class($this)."::Update id=".$id." call_trigger=".$call_trigger." allowmodcodeclient=".$allowmodcodeclient." allowmodcodefournisseur=".$allowmodcodefournisseur); dol_syslog(get_class($this)."::Update id=".$id." call_trigger=".$call_trigger." allowmodcodeclient=".$allowmodcodeclient." allowmodcodefournisseur=".$allowmodcodefournisseur);

View File

@@ -2096,6 +2096,11 @@ class User extends CommonObject
{ {
global $conf, $langs; global $conf, $langs;
if (empty($this->country_id) && !empty($this->country_code)) {
$country_id = getCountry($this->country_code, '3');
$this->country_id = is_int($country_id) ? $country_id : 0;
}
$nbrowsaffected = 0; $nbrowsaffected = 0;
$error = 0; $error = 0;

View File

@@ -88,7 +88,7 @@ class SupplierProposalTest extends CommonClassTest
// Set permission not set by default sql sample // Set permission not set by default sql sample
$user->addrights(0, 'supplier_proposal'); $user->addrights(0, 'supplier_proposal');
$user->getrights('supplier_proposal', 1); $user->loadRights('supplier_proposal', 1);
} }
/** /**
@@ -183,7 +183,7 @@ class SupplierProposalTest extends CommonClassTest
$result = $user->addrights(0, 'supplier_proposal'); $result = $user->addrights(0, 'supplier_proposal');
$this->assertLessThan($result, 0); $this->assertLessThan($result, 0);
$result = $user->getrights('supplier_proposal', 1); $result = $user->loadRights('supplier_proposal', 1);
//$this->assertLessThan($result, 0); //$this->assertLessThan($result, 0);
$result = $localobject->valid($user); $result = $localobject->valid($user);