NEW Add estimated duration on the BOM module
This commit is contained in:
parent
323f31d832
commit
7973b03201
@ -94,6 +94,7 @@ class BOM extends CommonObject
|
||||
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'help'=>'ProductBOMHelp'),
|
||||
'qty' => array('type'=>'real', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>55, 'notnull'=>1, 'isameasure'=>'1', 'css'=>'maxwidth75imp'),
|
||||
'efficiency' => array('type'=>'real', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>-1, 'default'=>1, 'position'=>100, 'notnull'=>0, 'css'=>'maxwidth50imp', 'help'=>'ValueOfMeansLoss'),
|
||||
'duration' => array('type'=>'real', 'label'=>'EstimatedDuration', 'enabled'=>1, 'visible'=>-1, 'position'=>101, 'notnull'=>-1, 'css'=>'maxwidth50imp', 'help'=>'EstimatedDurationDesc'),
|
||||
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>-1, 'position'=>161, 'notnull'=>-1,),
|
||||
'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>-1, 'position'=>162, 'notnull'=>-1,),
|
||||
'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>300, 'notnull'=>1,),
|
||||
@ -202,7 +203,7 @@ class BOM extends CommonObject
|
||||
*/
|
||||
public function create(User $user, $notrigger = false)
|
||||
{
|
||||
if ($this->efficiency < 0 || $this->efficiency > 1) $this->efficiency = 1;
|
||||
if ($this->efficiency <= 0 || $this->efficiency > 1) $this->efficiency = 1;
|
||||
|
||||
return $this->createCommon($user, $notrigger);
|
||||
}
|
||||
@ -412,7 +413,7 @@ class BOM extends CommonObject
|
||||
*/
|
||||
public function update(User $user, $notrigger = false)
|
||||
{
|
||||
if ($this->efficiency < 0 || $this->efficiency > 1) $this->efficiency = 1;
|
||||
if ($this->efficiency <= 0 || $this->efficiency > 1) $this->efficiency = 1;
|
||||
|
||||
return $this->updateCommon($user, $notrigger);
|
||||
}
|
||||
|
||||
@ -2572,8 +2572,7 @@ abstract class CommonObject
|
||||
public function updateRangOfLine($rowid, $rang)
|
||||
{
|
||||
$fieldposition = 'rang'; // @TODO Rename 'rang' into 'position'
|
||||
if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position';
|
||||
if (in_array($this->table_element_line, array('bom_bomline'))) $fieldposition = 'position';
|
||||
if (in_array($this->table_element_line, array('bom_bomline', 'ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position';
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang;
|
||||
$sql.= ' WHERE rowid = '.$rowid;
|
||||
@ -2879,11 +2878,11 @@ abstract class CommonObject
|
||||
$MODULE = "MODULE_DISALLOW_UPDATE_PRICE_PROPOSAL";
|
||||
elseif ($this->element == 'commande' || $this->element == 'order')
|
||||
$MODULE = "MODULE_DISALLOW_UPDATE_PRICE_ORDER";
|
||||
elseif ($this->element == 'facture')
|
||||
elseif ($this->element == 'facture' || $this->element == 'invoice')
|
||||
$MODULE = "MODULE_DISALLOW_UPDATE_PRICE_INVOICE";
|
||||
elseif ($this->element == 'facture_fourn')
|
||||
elseif ($this->element == 'facture_fourn' || $this->element == 'supplier_invoice')
|
||||
$MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_INVOICE";
|
||||
elseif ($this->element == 'order_supplier')
|
||||
elseif ($this->element == 'order_supplier' || $this->element == 'supplier_order')
|
||||
$MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_ORDER";
|
||||
elseif ($this->element == 'supplier_proposal')
|
||||
$MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_PROPOSAL";
|
||||
@ -6271,18 +6270,12 @@ abstract class CommonObject
|
||||
$value='';
|
||||
}
|
||||
}
|
||||
elseif ($type == 'double')
|
||||
elseif ($type == 'double' || $type == 'real')
|
||||
{
|
||||
if (!empty($value)) {
|
||||
$value=price($value);
|
||||
}
|
||||
}
|
||||
elseif ($type == 'real')
|
||||
{
|
||||
if (!empty($value)) {
|
||||
$value=price($value);
|
||||
}
|
||||
}
|
||||
elseif ($type == 'boolean')
|
||||
{
|
||||
$checked='';
|
||||
@ -7115,7 +7108,7 @@ abstract class CommonObject
|
||||
* Function test if type is array
|
||||
*
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
* @return bool true if array
|
||||
*/
|
||||
protected function isArray($info)
|
||||
{
|
||||
@ -7124,42 +7117,26 @@ abstract class CommonObject
|
||||
if(isset($info['type']) && $info['type']=='array') return true;
|
||||
else return false;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function test if type is null
|
||||
*
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
*/
|
||||
protected function isNull($info)
|
||||
{
|
||||
if(is_array($info))
|
||||
{
|
||||
if(isset($info['type']) && $info['type']=='null') return true;
|
||||
else return false;
|
||||
}
|
||||
else return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function test if type is date
|
||||
*
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
* @return bool true if date
|
||||
*/
|
||||
public function isDate($info)
|
||||
{
|
||||
if(isset($info['type']) && ($info['type']=='date' || $info['type']=='datetime' || $info['type']=='timestamp')) return true;
|
||||
else return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function test if type is integer
|
||||
*
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
* @return bool true if integer
|
||||
*/
|
||||
public function isInt($info)
|
||||
{
|
||||
@ -7175,7 +7152,7 @@ abstract class CommonObject
|
||||
* Function test if type is float
|
||||
*
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
* @return bool true if float
|
||||
*/
|
||||
public function isFloat($info)
|
||||
{
|
||||
@ -7184,14 +7161,14 @@ abstract class CommonObject
|
||||
if (isset($info['type']) && (preg_match('/^(double|real|price)/i', $info['type']))) return true;
|
||||
else return false;
|
||||
}
|
||||
else return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function test if type is text
|
||||
*
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
* @return bool true if type text
|
||||
*/
|
||||
public function isText($info)
|
||||
{
|
||||
@ -7200,7 +7177,39 @@ abstract class CommonObject
|
||||
if(isset($info['type']) && $info['type']=='text') return true;
|
||||
else return false;
|
||||
}
|
||||
else return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function test if field can be null
|
||||
*
|
||||
* @param array $info content informations of field
|
||||
* @return bool true if it can be null
|
||||
*/
|
||||
protected function canBeNull($info)
|
||||
{
|
||||
if(is_array($info))
|
||||
{
|
||||
if(isset($info['notnull']) && $info['notnull']!='1') return true;
|
||||
else return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function test if field is forced to null if zero or empty
|
||||
*
|
||||
* @param array $info content informations of field
|
||||
* @return bool true if forced to null
|
||||
*/
|
||||
protected function isForcedToNullIfZero($info)
|
||||
{
|
||||
if(is_array($info))
|
||||
{
|
||||
if(isset($info['notnull']) && $info['notnull']=='-1') return true;
|
||||
else return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -7216,7 +7225,7 @@ abstract class CommonObject
|
||||
if(isset($info['index']) && $info['index']==true) return true;
|
||||
else return false;
|
||||
}
|
||||
else return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -7309,17 +7318,30 @@ abstract class CommonObject
|
||||
elseif($this->isInt($info))
|
||||
{
|
||||
if ($field == 'rowid') $this->id = (int) $obj->{$field};
|
||||
else $this->{$field} = (int) $obj->{$field};
|
||||
else
|
||||
{
|
||||
if ($this->isForcedToNullIfZero($info))
|
||||
{
|
||||
if (empty($obj->{$field})) $this->{$field} = null;
|
||||
else $this->{$field} = (double) $obj->{$field};
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->{$field} = (int) $obj->{$field};
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif($this->isFloat($info))
|
||||
{
|
||||
$this->{$field} = (double) $obj->{$field};
|
||||
}
|
||||
elseif($this->isNull($info))
|
||||
{
|
||||
$val = $obj->{$field};
|
||||
// zero is not null
|
||||
$this->{$field} = (is_null($val) || (empty($val) && $val!==0 && $val!=='0') ? null : $val);
|
||||
if ($this->isForcedToNullIfZero($info))
|
||||
{
|
||||
if (empty($obj->{$field})) $this->{$field} = null;
|
||||
else $this->{$field} = (double) $obj->{$field};
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->{$field} = (double) $obj->{$field};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -7376,7 +7398,8 @@ abstract class CommonObject
|
||||
if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) $fieldvalues['date_creation']=$this->db->idate($now);
|
||||
if (array_key_exists('fk_user_creat', $fieldvalues) && ! ($fieldvalues['fk_user_creat'] > 0)) $fieldvalues['fk_user_creat']=$user->id;
|
||||
unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into insert.
|
||||
|
||||
if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref']=dol_string_nospecial($fieldvalues['ref']); // If field is a ref,we sanitize data
|
||||
|
||||
$keys=array();
|
||||
$values = array();
|
||||
foreach ($fieldvalues as $k => $v) {
|
||||
|
||||
@ -49,6 +49,8 @@ UPDATE llx_c_units SET label = 'SurfaceUnitm2' WHERE code IN ('M2');
|
||||
|
||||
-- For v11
|
||||
|
||||
ALTER TABLE llx_bom_bom ADD COLUMN duration double(8,4) DEFAULT NULL;
|
||||
|
||||
create table llx_categorie_warehouse
|
||||
(
|
||||
fk_categorie integer NOT NULL,
|
||||
|
||||
@ -26,6 +26,7 @@ CREATE TABLE llx_bom_bom(
|
||||
fk_product integer,
|
||||
qty double(24,8),
|
||||
efficiency double(8,4) DEFAULT 1,
|
||||
duration double(8,4) DEFAULT NULL,
|
||||
date_creation datetime NOT NULL,
|
||||
date_valid datetime,
|
||||
tms timestamp,
|
||||
|
||||
@ -21,4 +21,6 @@ NewMO=New Manufacturing Order
|
||||
QtyToProduce=Qty to produce
|
||||
DateStartPlannedMo=Date start planned
|
||||
DateEndPlannedMo=Date end planned
|
||||
KeepEmptyForAsap=Empty means 'As Soon As Possible'
|
||||
KeepEmptyForAsap=Empty means 'As Soon As Possible'
|
||||
EstimatedDuration=Estimated duration
|
||||
EstimatedDurationDesc=Estimated duration to manufacture this product using this BOM
|
||||
Loading…
Reference in New Issue
Block a user