From 13bf82d9cd1f4a1670a69e1554cc70c5763ae8f6 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Tue, 3 Dec 2024 11:31:04 +0100 Subject: [PATCH 1/2] NEW : auto-detect country from code in creation --- htdocs/societe/class/societe.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index e1e66ac6edf..a61716ea08a 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1010,6 +1010,11 @@ 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(); From c6e3ac592b91ec92b293569e2e6895ec23beb28f Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Wed, 4 Dec 2024 15:12:38 +0100 Subject: [PATCH 2/2] Fix phpstan error --- htdocs/societe/class/societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index a61716ea08a..d33409b2e11 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1011,7 +1011,7 @@ class Societe extends CommonObject } if (empty($this->country_id) && !empty($this->country_code)) { - $country_id = getCountry($this->country_code, 3); + $country_id = getCountry($this->country_code, '3'); $this->country_id = is_int($country_id) ? $country_id : 0; }