Clean code. Replace property with local variable.

This commit is contained in:
ldestailleur
2025-09-21 14:21:38 +02:00
parent 35e720354e
commit e45352bd11
8 changed files with 7 additions and 32 deletions

View File

@@ -395,10 +395,6 @@ class pdf_standard_movementstock extends ModelePDFMovement
$file = $dir."/".$objectref.".pdf"; $file = $dir."/".$objectref.".pdf";
} }
$stockFournisseur = new ProductFournisseur($this->db);
$supplierprices = $stockFournisseur->list_product_fournisseur_price($object->id);
$object->supplierprices = $supplierprices;
$productstatic = new Product($this->db); $productstatic = new Product($this->db);
if (!file_exists($dir)) { if (!file_exists($dir)) {

View File

@@ -245,7 +245,6 @@ class doc_generic_product_odt extends ModelePDFProduct
} }
$productFournisseur = new ProductFournisseur($this->db); $productFournisseur = new ProductFournisseur($this->db);
$supplierprices = $productFournisseur->list_product_fournisseur_price($object->id); $supplierprices = $productFournisseur->list_product_fournisseur_price($object->id);
$object->supplierprices = $supplierprices;
$dir = $conf->product->dir_output; $dir = $conf->product->dir_output;
$objectref = dol_sanitizeFileName($object->ref); $objectref = dol_sanitizeFileName($object->ref);
@@ -415,8 +414,8 @@ class doc_generic_product_odt extends ModelePDFProduct
// Replace tags of lines // Replace tags of lines
try { try {
$listlines = $odfHandler->setSegment('supplierprices'); $listlines = $odfHandler->setSegment('supplierprices');
if (!empty($object->supplierprices)) { if (!empty($supplierprices)) {
foreach ($object->supplierprices as $supplierprice) { foreach ($supplierprices as $supplierprice) {
$array_lines = $this->get_substitutionarray_each_var_object($supplierprice, $outputlangs); $array_lines = $this->get_substitutionarray_each_var_object($supplierprice, $outputlangs);
complete_substitutions_array($array_lines, $outputlangs, $object, $supplierprice, "completesubstitutionarray_lines"); complete_substitutions_array($array_lines, $outputlangs, $object, $supplierprice, "completesubstitutionarray_lines");
// Call the ODTSubstitutionLine hook // Call the ODTSubstitutionLine hook

View File

@@ -159,10 +159,6 @@ class pdf_standard extends ModelePDFProduct
$file = $dir."/".$objectref.".pdf"; $file = $dir."/".$objectref.".pdf";
} }
$productFournisseur = new ProductFournisseur($this->db);
$supplierprices = $productFournisseur->list_product_fournisseur_price($object->id);
$object->supplierprices = $supplierprices;
if (!file_exists($dir)) { if (!file_exists($dir)) {
if (dol_mkdir($dir) < 0) { if (dol_mkdir($dir) < 0) {
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);

View File

@@ -248,7 +248,6 @@ class doc_generic_stock_odt extends ModelePDFStock
$stockFournisseur = new ProductFournisseur($this->db); $stockFournisseur = new ProductFournisseur($this->db);
$supplierprices = $stockFournisseur->list_stock_fournisseur_price($object->id); $supplierprices = $stockFournisseur->list_stock_fournisseur_price($object->id);
$object->supplierprices = $supplierprices;
$dir = $conf->product->dir_output; $dir = $conf->product->dir_output;
$objectref = dol_sanitizeFileName($object->ref); $objectref = dol_sanitizeFileName($object->ref);
@@ -419,8 +418,8 @@ class doc_generic_stock_odt extends ModelePDFStock
$foundtagforlines = 0; $foundtagforlines = 0;
dol_syslog($e->getMessage(), LOG_INFO); dol_syslog($e->getMessage(), LOG_INFO);
} }
if ($foundtagforlines && !empty($object->supplierprices)) { if ($foundtagforlines && !empty($supplierprices)) {
foreach ($object->supplierprices as $supplierprice) { foreach ($supplierprices as $supplierprice) {
$array_lines = $this->get_substitutionarray_each_var_object($supplierprice, $outputlangs); $array_lines = $this->get_substitutionarray_each_var_object($supplierprice, $outputlangs);
complete_substitutions_array($array_lines, $outputlangs, $object, $supplierprice, "completesubstitutionarray_lines"); complete_substitutions_array($array_lines, $outputlangs, $object, $supplierprice, "completesubstitutionarray_lines");
// Call the ODTSubstitutionLine hook // Call the ODTSubstitutionLine hook

View File

@@ -195,10 +195,6 @@ class pdf_standard_stock extends ModelePDFStock
$file = $dir."/".$objectref.".pdf"; $file = $dir."/".$objectref.".pdf";
} }
$stockFournisseur = new ProductFournisseur($this->db);
$supplierprices = $stockFournisseur->list_product_fournisseur_price($object->id);
$object->supplierprices = $supplierprices;
$productstatic = new Product($this->db); $productstatic = new Product($this->db);
if (!file_exists($dir)) { if (!file_exists($dir)) {

View File

@@ -2231,8 +2231,6 @@ class Products extends DolibarrApi
unset($object->fk_bank); unset($object->fk_bank);
unset($object->fk_account); unset($object->fk_account);
unset($object->supplierprices); // Must use another API to get them
if (!DolibarrApiAccess::$user->hasRight('stock', 'lire')) { if (!DolibarrApiAccess::$user->hasRight('stock', 'lire')) {
unset($object->stock_reel); unset($object->stock_reel);
unset($object->stock_theorique); unset($object->stock_theorique);

View File

@@ -777,13 +777,6 @@ class Product extends CommonObject
*/ */
public $price_autogen = 0; public $price_autogen = 0;
/**
* Array with list of supplier prices of product
*
* @var ProductFournisseur[]
*/
public $supplierprices;
/** /**
* Array with list of sub-products for Kits * Array with list of sub-products for Kits
* *

View File

@@ -47,7 +47,7 @@ class Workstations extends DolibarrApi
*/ */
public function __construct() public function __construct()
{ {
global $db, $conf; global $db;
$this->db = $db; $this->db = $db;
$this->workstation = new Workstation($this->db); $this->workstation = new Workstation($this->db);
@@ -185,8 +185,8 @@ class Workstations extends DolibarrApi
/** /**
* Clean sensible object datas * Clean sensible object datas
* *
* @param Object $object Object to clean * @param Object $object Object to clean
* @return Object Object with cleaned properties * @return Object Object with cleaned properties
*/ */
protected function _cleanObjectDatas($object) protected function _cleanObjectDatas($object)
{ {
@@ -284,8 +284,6 @@ class Workstations extends DolibarrApi
unset($object->fk_bank); unset($object->fk_bank);
unset($object->fk_account); unset($object->fk_account);
unset($object->supplierprices);
unset($object->stock_reel); unset($object->stock_reel);
unset($object->stock_theorique); unset($object->stock_theorique);
unset($object->stock_warehouse); unset($object->stock_warehouse);