diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 7062a87a78e..a90cf42b46f 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -6440,7 +6440,7 @@ class Form
}
if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) { // If option to have vat for end customer for services is on
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
- if (!isInEEC($societe_vendeuse) && (!is_object($societe_acheteuse) || (isInEEC($societe_acheteuse) && !$societe_acheteuse->isACompany()))) {
+ if (is_object($societe_vendeuse) && is_object($societe_acheteuse) && isInEEC($societe_vendeuse) && isInEEC($societe_acheteuse) && !$societe_acheteuse->isACompany()) {
// We also add the buyer country code
if (is_numeric($type)) {
if ($type == 1) { // We know product is a service