From df4b208de1a43ce6685b333045ae95acc71fae27 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 12 Oct 2020 11:10:49 +0200 Subject: [PATCH] fix: add missing edit field with pakaging option on --- .../class/fournisseur.commande.class.php | 2 +- .../fourn/class/fournisseur.product.class.php | 2 +- htdocs/langs/en_US/products.lang | 1 + htdocs/product/fournisseurs.php | 25 +++++++++++++++++-- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index f354b89186d..300a5032a2c 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1664,9 +1664,9 @@ class CommandeFournisseur extends CommonOrder { $coeff = intval($qty / $prod->packaging) + 1; $qty = $prod->packaging * $coeff; - setEventMessage($langs->trans('QtyRecalculatedWithPackaging'), 'mesgs'); } } + setEventMessage($langs->trans('QtyRecalculatedWithPackaging'), 'mesgs'); } } else { $product_type = $type; diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 8752d17a5d8..924734f69c5 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -272,7 +272,7 @@ class ProductFournisseur extends Product $charges = price2num($charges, 'MU'); $qty = price2num($qty, 'MS'); $unitBuyPrice = price2num($buyprice / $qty, 'MU'); - $packaging = ($this->packaging < $qty) ? $qty : $this->packaging; + $packaging = price2num((($this->packaging < $qty) ? $qty : $this->packaging), 'MS'); $error = 0; $now = dol_now(); diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 51f547dbdce..3077021aad6 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -339,6 +339,7 @@ UseProductFournDesc=Add a feature to define the descriptions of products defined ProductSupplierDescription=Vendor description for the product UseProductSupplierPackaging=Use packaging on supplier prices (recalculate quantities according to packaging set on supplier price when adding/updating line in supplier documents) PackagingForThisProduct=Packaging +PackagingForThisProductDesc=On supplier order, you will automaticly order this quantity (or a multiple of this quantity). Cannot be less than minimum buying quantity QtyRecalculatedWithPackaging=The quantity of the line were recalculated according to supplier packaging #Attributes diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index fb1be576ad5..f1b8dd5e455 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -230,10 +230,9 @@ if (empty($reshook)) } } + // TODO : may be remove, already done in class update_buyprice if (empty($packaging)) $packaging = 1; - if ($packaging < $quantity) $packaging = $quantity; - $object->packaging = $packaging; if (!$error) @@ -529,6 +528,28 @@ if ($id > 0 || $ref) } print ''; + if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { + // Packaging + print ''; + + print ''.$form->textwithpicto($langs->trans("PackagingForThisProduct"), $langs->trans("PackagingForThisProductDesc")).''; + print ''; + $packaging = GETPOSTISSET('packaging') ? price2num(GETPOST('packaging', 'nohtml'), 'MS') : "1"; + if ($rowid) + { + print ''; + print price2num($object->packaging, 'MS'); + } else { + print ''; + } + // Units + if ($conf->global->PRODUCT_USE_UNITS) { + $unit = $object->getLabelOfUnit(); + if ($unit !== '') { + print '  '.$langs->trans($unit); + } + } + } // Vat rate $default_vat = '';