This commit is contained in:
Laurent Destailleur 2022-01-31 21:46:35 +01:00
parent 902246e50b
commit 3b8ece6c0b
2 changed files with 5 additions and 4 deletions

View File

@ -874,9 +874,10 @@ class Product extends CommonObject
$arrayofnonnegativevalue = array('weight'=>'Weight', 'width'=>'Width', 'height'=>'Height', 'length'=>'Length', 'surface'=>'Surface', 'volume'=>'Volume'); $arrayofnonnegativevalue = array('weight'=>'Weight', 'width'=>'Width', 'height'=>'Height', 'length'=>'Length', 'surface'=>'Surface', 'volume'=>'Volume');
foreach ($arrayofnonnegativevalue as $key => $value) { foreach ($arrayofnonnegativevalue as $key => $value) {
if (property_exists($this, $key) && $this->$key < 0) { if (property_exists($this, $key) && !empty($this->$key) && ($this->$key < 0)) {
$langs->load("other"); $langs->loadLangs(array("main", "other"));
$this->errors[] = $langs->trans("FieldCannotBeNegative", $langs->transnoentitiesnoconv($value)); $this->error = $langs->trans("FieldCannotBeNegative", $langs->transnoentitiesnoconv($value));
$this->errors[] = $this->error;
$result = -4; $result = -4;
} }
} }

View File

@ -199,7 +199,7 @@ class ProductTest extends PHPUnit\Framework\TestCase
$localobject->note_private = 'New private note after update'; $localobject->note_private = 'New private note after update';
$result=$localobject->update($localobject->id, $user); $result=$localobject->update($localobject->id, $user);
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0); $this->assertLessThan($result, 0, 'Error '.$localobject->error);
return $localobject; return $localobject;
} }