diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index bc7e0c14462..ddc70d21c85 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -763,6 +763,11 @@ class Adherent extends CommonObject 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; $error = 0; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index d3d0c3c2ddf..45a30fdef82 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -760,6 +760,11 @@ class Account extends CommonObject $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 require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; @@ -900,6 +905,11 @@ class Account extends CommonObject { 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; $this->db->begin(); diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index e2961594ea4..e785fc0a520 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -607,6 +607,11 @@ class Contact extends CommonObject { 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; $this->id = $id; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index fa3cc2b2d4e..7c72797d446 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1423,6 +1423,10 @@ class Product extends CommonObject if (empty($this->country_id)) { $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)) { $this->state_id = 0; diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 3ca48bbd39d..76ddc84ecfb 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -255,6 +255,10 @@ class Entrepot extends CommonObject $this->error = "ErrorFieldRequired"; 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(); @@ -325,6 +329,11 @@ class Entrepot extends CommonObject */ 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; if (empty($id)) { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 18f07046905..8ced8b891c4 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1012,11 +1012,6 @@ class Societe extends CommonObject $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); $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'); } + 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; dol_syslog(get_class($this)."::Update id=".$id." call_trigger=".$call_trigger." allowmodcodeclient=".$allowmodcodeclient." allowmodcodefournisseur=".$allowmodcodefournisseur); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 1ea16d01c17..549bbb4454d 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2096,6 +2096,11 @@ class User extends CommonObject { 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; $error = 0;