Display the physical and virtual stock of the products when creating OF from a BOM

This commit is contained in:
kevin 2022-01-20 16:55:57 +01:00
parent dfa2cab408
commit 553dc5a1ef
2 changed files with 27 additions and 0 deletions

View File

@ -1300,6 +1300,17 @@ class Mo extends CommonObject
{
global $langs, $hookmanager, $conf, $form;
$langs->load('stocks');
$text_stock_options = $langs->trans("RealStockDesc").'<br>';
$text_stock_options .= $langs->trans("RealStockWillAutomaticallyWhen").'<br>';
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE) ? '- '.$langs->trans("DeStockOnShipment").'<br>' : '');
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) ? '- '.$langs->trans("DeStockOnValidateOrder").'<br>' : '');
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_BILL) ? '- '.$langs->trans("DeStockOnBill").'<br>' : '');
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) ? '- '.$langs->trans("ReStockOnBill").'<br>' : '');
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) ? '- '.$langs->trans("ReStockOnValidateOrder").'<br>' : '');
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) ? '- '.$langs->trans("ReStockOnDispatchOrder").'<br>' : '');
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE) ? '- '.$langs->trans("StockOnReception").'<br>' : '');
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Ref').'</td>';
print '<td class="right">'.$langs->trans('Qty');
@ -1309,6 +1320,8 @@ class Mo extends CommonObject
print ' <span class="opacitymedium">('.$langs->trans("ForAQuantityToConsumeOf", $this->bom->qty).')</span>';
}
print '</td>';
print '<td class="center">'.$form->textwithpicto($langs->trans("PhysicalStock"), $text_stock_options, 1).'</td>';
print '<td class="center">'.$form->textwithpicto($langs->trans("VirtualStock"), $langs->trans("VirtualStockDesc")).'</td>';
print '<td class="center">'.$langs->trans('QtyFrozen').'</td>';
print '<td class="center">'.$langs->trans('DisableStockChange').'</td>';
//print '<td class="right">'.$langs->trans('Efficiency').'</td>';
@ -1358,6 +1371,7 @@ class Mo extends CommonObject
if (!empty($line->fk_product)) {
$productstatic = new Product($this->db);
$productstatic->fetch($line->fk_product);
$productstatic->load_virtual_stock();
$this->tpl['label'] .= $productstatic->getNomUrl(1);
//$this->tpl['label'].= ' - '.$productstatic->label;
} else {
@ -1370,6 +1384,9 @@ class Mo extends CommonObject
$this->tpl['qty_bom'] = $this->bom->qty;
}
$this->tpl['stock'] = $productstatic->stock_reel;
$this->tpl['seuil_stock_alerte'] = $productstatic->seuil_stock_alerte;
$this->tpl['virtual_stock'] = $productstatic->stock_theorique;
$this->tpl['qty'] = $line->qty;
$this->tpl['qty_frozen'] = $line->qty_frozen;
$this->tpl['disable_stock_change'] = $line->disable_stock_change;

View File

@ -39,6 +39,16 @@ $qtytoconsumeforline = price2num($qtytoconsumeforline, 'MS');
print '<tr class="oddeven'.(empty($this->tpl['strike']) ? '' : ' strikefordisabled').'">';
print '<td>'.$this->tpl['label'].'</td>';
print '<td class="right">'.$this->tpl['qty'].(($this->tpl['efficiency'] > 0 && $this->tpl['efficiency'] < 1) ? ' / '.$form->textwithpicto($this->tpl['efficiency'], $langs->trans("ValueOfMeansLoss")).' = '.$qtytoconsumeforline : '').'</td>';
print '<td class="center">'.(empty($this->tpl['stock']) ? 0 : price2num($this->tpl['stock'], 'MS'));
if ($this->tpl['seuil_stock_alerte'] != '' && ($this->tpl['stock'] < $this->tpl['seuil_stock_alerte'])) {
print ' '.img_warning($langs->trans("StockLowerThanLimit", $this->tpl['seuil_stock_alerte']));
}
print '</td>';
print '<td class="center">'.((empty($this->tpl['virtual_stock']) ? 0 : price2num($this->tpl['virtual_stock'], 'MS')));
if ($this->tpl['seuil_stock_alerte'] != '' && ($this->tpl['virtual_stock'] < $this->tpl['seuil_stock_alerte'])) {
print ' '.img_warning($langs->trans("StockLowerThanLimit", $this->tpl['seuil_stock_alerte']));
}
print '</td>';
print '<td class="center">'.($this->tpl['qty_frozen'] ? yn($this->tpl['qty_frozen']) : '').'</td>';
print '<td class="center">'.($this->tpl['disable_stock_change'] ? yn($this->tpl['disable_stock_change']) : '').'</td>';
//print '<td class="right">'.$this->tpl['efficiency'].'</td>';