From a5def19cff1021a046eeb84ae8171af5e4a75aeb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 Apr 2020 12:56:52 +0200 Subject: [PATCH] Fix calculation from a BOM > 1 --- htdocs/langs/en_US/mrp.lang | 2 +- htdocs/mrp/class/mo.class.php | 7 ++++++- htdocs/mrp/mo_card.php | 1 + htdocs/mrp/mo_production.php | 2 +- htdocs/mrp/tpl/originproductline.tpl.php | 9 ++++++++- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 4e653e04409..d3591be3f1d 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -60,7 +60,7 @@ ConsumeOrProduce=Consume or Produce ConsumeAndProduceAll=Consume and Produce All Manufactured=Manufactured TheProductXIsAlreadyTheProductToProduce=The product to add is already the product to produce. -ForAQuantityOf1=For a quantity to produce of 1 +ForAQuantityOf=For a quantity to produce of %s ConfirmValidateMo=Are you sure you want to validate this Manufacturing Order? ConfirmProductionDesc=By clicking on '%s', you will validate the consumption and/or production for the quantities set. This will also update the stock and record stock movements. ProductionForRef=Production of %s diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 84bf44c84fe..1fd60907763 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1268,7 +1268,7 @@ class Mo extends CommonObject print ''; print ''.$langs->trans('Ref').''; - print ''.$langs->trans('Qty').' ('.$langs->trans("ForAQuantityOf1").')'; + print ''.$langs->trans('Qty').' ('.$langs->trans("ForAQuantityOf", $this->bom->qty).')'; print ''.$langs->trans('QtyFrozen').''; print ''.$langs->trans('DisableStockChange').''; //print ''.$langs->trans('Efficiency').''; @@ -1334,6 +1334,11 @@ class Mo extends CommonObject // TODO } + $this->tpl['qty_bom'] = 1; + if (is_object($this->bom) && $this->bom->qty > 1) { + $this->tpl['qty_bom'] = $this->bom->qty; + } + $this->tpl['qty'] = $line->qty; $this->tpl['qty_frozen'] = $line->qty_frozen; $this->tpl['disable_stock_change'] = $line->disable_stock_change; diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index 91f6f75b332..59dd5ed7a7c 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -293,6 +293,7 @@ if ($action == 'create') print ''; $object->lines = $objectbom->lines; + $object->bom = $objectbom; $object->printOriginLinesList('', array()); diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 70e248eaf3a..f1e847a6213 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -691,7 +691,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; print ''; if ($conf->productbatch->enabled) { print ''; diff --git a/htdocs/mrp/tpl/originproductline.tpl.php b/htdocs/mrp/tpl/originproductline.tpl.php index abe5dfdb427..6f3b63f6d4e 100644 --- a/htdocs/mrp/tpl/originproductline.tpl.php +++ b/htdocs/mrp/tpl/originproductline.tpl.php @@ -24,13 +24,20 @@ if (empty($conf) || !is_object($conf)) } if (!is_object($form)) $form = new Form($db); + +$qtytoconsumeforline = $this->tpl['qty'] / $this->tpl['efficiency']; +/*if ((empty($this->tpl['qty_frozen']) && $this->tpl['qty_bom'] > 1)) { + $qtytoconsumeforline = $qtytoconsumeforline / $this->tpl['qty_bom']; +}*/ +$qtytoconsumeforline = price2num($qtytoconsumeforline, 'MS'); + ?> tpl['strike']) ? '' : ' strikefordisabled').'">'; print ''; -print ''; +print ''; print ''; print ''; //print '';
'; - print ''; + print ''; print ' '.$this->tpl['label'].''.$this->tpl['qty'].(($this->tpl['efficiency'] > 0 && $this->tpl['efficiency'] < 1) ? ' / '.$form->textwithpicto($this->tpl['efficiency'], $langs->trans("ValueOfMeansLoss")).' = '.round($this->tpl['qty'] / $this->tpl['efficiency'], 2) : '').''.$this->tpl['qty'].(($this->tpl['efficiency'] > 0 && $this->tpl['efficiency'] < 1) ? ' / '.$form->textwithpicto($this->tpl['efficiency'], $langs->trans("ValueOfMeansLoss")).' = '.$qtytoconsumeforline : '').''.($this->tpl['qty_frozen'] ? yn($this->tpl['qty_frozen']) : '').''.($this->tpl['disable_stock_change'] ? yn($this->tpl['disable_stock_change']) : '').''.$this->tpl['efficiency'].'