Debug MRP
This commit is contained in:
parent
622dc7e8d7
commit
20c9035837
@ -537,7 +537,7 @@ CREATE TABLE llx_mrp_production(
|
|||||||
position integer NOT NULL DEFAULT 0,
|
position integer NOT NULL DEFAULT 0,
|
||||||
fk_product integer NOT NULL,
|
fk_product integer NOT NULL,
|
||||||
fk_warehouse integer,
|
fk_warehouse integer,
|
||||||
qty integer NOT NULL DEFAULT 1,
|
qty real NOT NULL DEFAULT 1,
|
||||||
qty_frozen smallint DEFAULT 0,
|
qty_frozen smallint DEFAULT 0,
|
||||||
disable_stock_change smallint DEFAULT 0,
|
disable_stock_change smallint DEFAULT 0,
|
||||||
batch varchar(30),
|
batch varchar(30),
|
||||||
@ -550,6 +550,7 @@ CREATE TABLE llx_mrp_production(
|
|||||||
fk_user_modif integer,
|
fk_user_modif integer,
|
||||||
import_key varchar(14)
|
import_key varchar(14)
|
||||||
) ENGINE=innodb;
|
) ENGINE=innodb;
|
||||||
|
ALTER TABLE llx_mrp_production MODIFY COLUMN qty real NOT NULL DEFAULT 1;
|
||||||
|
|
||||||
ALTER TABLE llx_mrp_production ADD COLUMN qty_frozen smallint DEFAULT 0;
|
ALTER TABLE llx_mrp_production ADD COLUMN qty_frozen smallint DEFAULT 0;
|
||||||
ALTER TABLE llx_mrp_production ADD COLUMN disable_stock_change smallint DEFAULT 0;
|
ALTER TABLE llx_mrp_production ADD COLUMN disable_stock_change smallint DEFAULT 0;
|
||||||
|
|||||||
@ -20,7 +20,7 @@ CREATE TABLE llx_mrp_production(
|
|||||||
position integer NOT NULL DEFAULT 0,
|
position integer NOT NULL DEFAULT 0,
|
||||||
fk_product integer NOT NULL,
|
fk_product integer NOT NULL,
|
||||||
fk_warehouse integer,
|
fk_warehouse integer,
|
||||||
qty integer NOT NULL DEFAULT 1,
|
qty real NOT NULL DEFAULT 1,
|
||||||
qty_frozen smallint DEFAULT 0,
|
qty_frozen smallint DEFAULT 0,
|
||||||
disable_stock_change smallint DEFAULT 0,
|
disable_stock_change smallint DEFAULT 0,
|
||||||
batch varchar(30),
|
batch varchar(30),
|
||||||
|
|||||||
@ -1331,7 +1331,7 @@ class MoLine extends CommonObjectLine
|
|||||||
'position' =>array('type'=>'integer', 'label'=>'Position', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>20),
|
'position' =>array('type'=>'integer', 'label'=>'Position', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>20),
|
||||||
'fk_product' =>array('type'=>'integer', 'label'=>'Fk product', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>25),
|
'fk_product' =>array('type'=>'integer', 'label'=>'Fk product', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>25),
|
||||||
'fk_warehouse' =>array('type'=>'integer', 'label'=>'Fk warehouse', 'enabled'=>1, 'visible'=>-1, 'position'=>30),
|
'fk_warehouse' =>array('type'=>'integer', 'label'=>'Fk warehouse', 'enabled'=>1, 'visible'=>-1, 'position'=>30),
|
||||||
'qty' =>array('type'=>'integer', 'label'=>'Qty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35),
|
'qty' =>array('type'=>'real', 'label'=>'Qty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35),
|
||||||
'qty_frozen' => array('type'=>'smallint', 'label'=>'QuantityFrozen', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>105, 'css'=>'maxwidth50imp', 'help'=>'QuantityConsumedInvariable'),
|
'qty_frozen' => array('type'=>'smallint', 'label'=>'QuantityFrozen', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>105, 'css'=>'maxwidth50imp', 'help'=>'QuantityConsumedInvariable'),
|
||||||
'disable_stock_change' => array('type'=>'smallint', 'label'=>'DisableStockChange', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>108, 'css'=>'maxwidth50imp', 'help'=>'DisableStockChangeHelp'),
|
'disable_stock_change' => array('type'=>'smallint', 'label'=>'DisableStockChange', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>108, 'css'=>'maxwidth50imp', 'help'=>'DisableStockChangeHelp'),
|
||||||
'batch' =>array('type'=>'varchar(30)', 'label'=>'Batch', 'enabled'=>1, 'visible'=>-1, 'position'=>140),
|
'batch' =>array('type'=>'varchar(30)', 'label'=>'Batch', 'enabled'=>1, 'visible'=>-1, 'position'=>140),
|
||||||
|
|||||||
@ -173,55 +173,59 @@ if (empty($reshook))
|
|||||||
|
|
||||||
$i=1;
|
$i=1;
|
||||||
while (GETPOSTISSET('qty-'.$line->id.'-'.$i)) {
|
while (GETPOSTISSET('qty-'.$line->id.'-'.$i)) {
|
||||||
// Check warehouse is set if we should have to
|
$qtytoprocess = price2num(GETPOST('qty-'.$line->id.'-'.$i));
|
||||||
if (GETPOSTISSET('idwarehouse-'.$line->id.'-'.$i)) { // If there is a warehouse to set
|
|
||||||
if (price2num(GETPOST('qty-'.$line->id.'-'.$i)) > 0 && ! (GETPOST('idwarehouse-'.$line->id.'-'.$i) > 0)) { // If there is a quantity to dispatch and warehouse not set.
|
|
||||||
$langs->load("errors");
|
|
||||||
setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Warehouse"), $tmpproduct->ref), null, 'errors');
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
if ($tmpproduct->status_batch && (! GETPOST('batch-'.$line->id.'-'.$i))) {
|
|
||||||
$langs->load("errors");
|
|
||||||
setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Batch"), $tmpproduct->ref), null, 'errors');
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$idstockmove = 0;
|
if ($qtytoprocess != 0) {
|
||||||
if (! $error && GETPOST('idwarehouse-'.$line->id.'-'.$i) > 0) {
|
// Check warehouse is set if we should have to
|
||||||
// Record stock movement
|
if (GETPOSTISSET('idwarehouse-'.$line->id.'-'.$i)) { // If there is a warehouse to set
|
||||||
$id_product_batch = 0;
|
if (! (GETPOST('idwarehouse-'.$line->id.'-'.$i) > 0)) { // If there is no warehouse set.
|
||||||
$stockmove->origin = $object;
|
$langs->load("errors");
|
||||||
$idstockmove = $stockmove->livraison($user, $line->fk_product, GETPOST('idwarehouse-'.$line->id.'-'.$i), price2num(GETPOST('qty-'.$line->id.'-'.$i)), 0, $labelmovement, dol_now(), '', '', GETPOST('batch-'.$line->id.'-'.$i), $id_product_batch, $codemovement);
|
setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Warehouse"), $tmpproduct->ref), null, 'errors');
|
||||||
if ($idstockmove < 0) {
|
$error++;
|
||||||
$error++;
|
}
|
||||||
setEventMessages($stockmove->error, $stockmove->errors, 'errors');
|
if ($tmpproduct->status_batch && (! GETPOST('batch-'.$line->id.'-'.$i))) {
|
||||||
}
|
$langs->load("errors");
|
||||||
}
|
setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Batch"), $tmpproduct->ref), null, 'errors');
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (! $error) {
|
$idstockmove = 0;
|
||||||
$pos = 0;
|
if (! $error && GETPOST('idwarehouse-'.$line->id.'-'.$i) > 0) {
|
||||||
// Record consumption
|
// Record stock movement
|
||||||
$moline = new MoLine($db);
|
$id_product_batch = 0;
|
||||||
$moline->fk_mo = $object->id;
|
$stockmove->origin = $object;
|
||||||
$moline->position = $pos;
|
$idstockmove = $stockmove->livraison($user, $line->fk_product, GETPOST('idwarehouse-'.$line->id.'-'.$i), $qtytoprocess, 0, $labelmovement, dol_now(), '', '', GETPOST('batch-'.$line->id.'-'.$i), $id_product_batch, $codemovement);
|
||||||
$moline->fk_product = $line->fk_product;
|
if ($idstockmove < 0) {
|
||||||
$moline->fk_warehouse = GETPOST('idwarehouse-'.$line->id.'-'.$i);
|
$error++;
|
||||||
$moline->qty = price2num(GETPOST('qty-'.$line->id.'-'.$i));
|
setEventMessages($stockmove->error, $stockmove->errors, 'errors');
|
||||||
$moline->batch = GETPOST('batch-'.$line->id.'-'.$i);
|
}
|
||||||
$moline->role = 'consumed';
|
}
|
||||||
$moline->fk_mrp_production = $line->id;
|
|
||||||
$moline->fk_stock_movement = $idstockmove;
|
|
||||||
$moline->fk_user_creat = $user->id;
|
|
||||||
|
|
||||||
$resultmoline = $moline->create($user);
|
if (! $error) {
|
||||||
if ($resultmoline <= 0) {
|
$pos = 0;
|
||||||
$error++;
|
// Record consumption
|
||||||
setEventMessages($moline->error, $moline->errors, 'errors');
|
$moline = new MoLine($db);
|
||||||
}
|
$moline->fk_mo = $object->id;
|
||||||
|
$moline->position = $pos;
|
||||||
|
$moline->fk_product = $line->fk_product;
|
||||||
|
$moline->fk_warehouse = GETPOST('idwarehouse-'.$line->id.'-'.$i);
|
||||||
|
$moline->qty = $qtytoprocess;
|
||||||
|
$moline->batch = GETPOST('batch-'.$line->id.'-'.$i);
|
||||||
|
$moline->role = 'consumed';
|
||||||
|
$moline->fk_mrp_production = $line->id;
|
||||||
|
$moline->fk_stock_movement = $idstockmove;
|
||||||
|
$moline->fk_user_creat = $user->id;
|
||||||
|
|
||||||
$pos++;
|
$resultmoline = $moline->create($user);
|
||||||
}
|
if ($resultmoline <= 0) {
|
||||||
|
$error++;
|
||||||
|
setEventMessages($moline->error, $moline->errors, 'errors');
|
||||||
|
}
|
||||||
|
|
||||||
|
$pos++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
@ -236,54 +240,58 @@ if (empty($reshook))
|
|||||||
|
|
||||||
$i=1;
|
$i=1;
|
||||||
while (GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i)) {
|
while (GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i)) {
|
||||||
// Check warehouse is set if we should have to
|
$qtytoprocess = price2num(GETPOST('qtytoproduce-'.$line->id.'-'.$i));
|
||||||
if (GETPOSTISSET('idwarehousetoproduce-'.$line->id.'-'.$i)) { // If there is a warehouse to set
|
|
||||||
if (price2num(GETPOST('qtytoproduce-'.$line->id.'-'.$i)) > 0 && ! (GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) > 0)) { // If there is a quantity to dispatch and warehouse not set.
|
|
||||||
$langs->load("errors");
|
|
||||||
setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Warehouse"), $tmpproduct->ref), null, 'errors');
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
if ($tmpproduct->status_batch && (! GETPOST('batchtoproduce-'.$line->id.'-'.$i))) {
|
|
||||||
$langs->load("errors");
|
|
||||||
setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Batch"), $tmpproduct->ref), null, 'errors');
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$idstockmove = 0;
|
if ($qtytoprocess != 0) {
|
||||||
if (! $error && GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) > 0) {
|
// Check warehouse is set if we should have to
|
||||||
// Record stock movement
|
if (GETPOSTISSET('idwarehousetoproduce-'.$line->id.'-'.$i)) { // If there is a warehouse to set
|
||||||
$id_product_batch = 0;
|
if (! (GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) > 0)) { // If there is no warehouse set.
|
||||||
$stockmove->origin = $object;
|
$langs->load("errors");
|
||||||
$idstockmove = $stockmove->reception($user, $line->fk_product, GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i), price2num(GETPOST('qtytoproduce-'.$line->id.'-'.$i)), 0, $labelmovement, dol_now(), '', '', GETPOST('batchtoproduce-'.$line->id.'-'.$i), $id_product_batch, $codemovement);
|
setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Warehouse"), $tmpproduct->ref), null, 'errors');
|
||||||
if ($idstockmove < 0) {
|
$error++;
|
||||||
$error++;
|
}
|
||||||
setEventMessages($stockmove->error, $stockmove->errors, 'errors');
|
if ($tmpproduct->status_batch && (! GETPOST('batchtoproduce-'.$line->id.'-'.$i))) {
|
||||||
}
|
$langs->load("errors");
|
||||||
}
|
setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Batch"), $tmpproduct->ref), null, 'errors');
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (! $error) {
|
$idstockmove = 0;
|
||||||
$pos = 0;
|
if (! $error && GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) > 0) {
|
||||||
// Record production
|
// Record stock movement
|
||||||
$moline = new MoLine($db);
|
$id_product_batch = 0;
|
||||||
$moline->fk_mo = $object->id;
|
$stockmove->origin = $object;
|
||||||
$moline->position = $pos;
|
$idstockmove = $stockmove->reception($user, $line->fk_product, GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i), $qtytoprocess, 0, $labelmovement, dol_now(), '', '', GETPOST('batchtoproduce-'.$line->id.'-'.$i), $id_product_batch, $codemovement);
|
||||||
$moline->fk_product = $line->fk_product;
|
if ($idstockmove < 0) {
|
||||||
$moline->fk_warehouse = GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i);
|
$error++;
|
||||||
$moline->qty = price2num(GETPOST('qtytoproduce-'.$line->id.'-'.$i));
|
setEventMessages($stockmove->error, $stockmove->errors, 'errors');
|
||||||
$moline->batch = GETPOST('batchtoproduce-'.$line->id.'-'.$i);
|
}
|
||||||
$moline->role = 'produced';
|
}
|
||||||
$moline->fk_mrp_production = $line->id;
|
|
||||||
$moline->fk_stock_movement = $idstockmove;
|
|
||||||
$moline->fk_user_creat = $user->id;
|
|
||||||
|
|
||||||
$resultmoline = $moline->create($user);
|
if (! $error) {
|
||||||
if ($resultmoline <= 0) {
|
$pos = 0;
|
||||||
$error++;
|
// Record production
|
||||||
setEventMessages($moline->error, $moline->errors, 'errors');
|
$moline = new MoLine($db);
|
||||||
}
|
$moline->fk_mo = $object->id;
|
||||||
|
$moline->position = $pos;
|
||||||
|
$moline->fk_product = $line->fk_product;
|
||||||
|
$moline->fk_warehouse = GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i);
|
||||||
|
$moline->qty = $qtytoprocess;
|
||||||
|
$moline->batch = GETPOST('batchtoproduce-'.$line->id.'-'.$i);
|
||||||
|
$moline->role = 'produced';
|
||||||
|
$moline->fk_mrp_production = $line->id;
|
||||||
|
$moline->fk_stock_movement = $idstockmove;
|
||||||
|
$moline->fk_user_creat = $user->id;
|
||||||
|
|
||||||
$pos++;
|
$resultmoline = $moline->create($user);
|
||||||
|
if ($resultmoline <= 0) {
|
||||||
|
$error++;
|
||||||
|
setEventMessages($moline->error, $moline->errors, 'errors');
|
||||||
|
}
|
||||||
|
|
||||||
|
$pos++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user