Save type (manufacture/disassemble) on MO.
This commit is contained in:
parent
b04ea59a51
commit
cd313d7506
@ -63,6 +63,7 @@ INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUE
|
||||
|
||||
ALTER TABLE llx_product ADD COLUMN fk_default_bom integer DEFAULT NULL;
|
||||
|
||||
ALTER TABLE llx_mrp_mo ADD COLUMN mrptype integer DEFAULT 0;
|
||||
|
||||
DELETE FROM llx_menu WHERE type = 'top' AND module = 'cashdesk' AND mainmenu = 'cashdesk';
|
||||
|
||||
|
||||
@ -17,8 +17,9 @@
|
||||
CREATE TABLE llx_mrp_mo(
|
||||
-- BEGIN MODULEBUILDER FIELDS
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
|
||||
ref varchar(128) DEFAULT '(PROV)' NOT NULL,
|
||||
entity integer DEFAULT 1 NOT NULL,
|
||||
ref varchar(128) DEFAULT '(PROV)' NOT NULL,
|
||||
mrptype integer DEFAULT 0, -- 0 for a manufacture MO, 1 for a dismantle MO
|
||||
label varchar(255),
|
||||
qty real NOT NULL,
|
||||
fk_warehouse integer,
|
||||
|
||||
@ -55,6 +55,7 @@ WarehouseForProduction=Warehouse for production
|
||||
CreateMO=Create MO
|
||||
ToConsume=To consume
|
||||
ToProduce=To produce
|
||||
ToObtain=To obtain
|
||||
QtyAlreadyConsumed=Qty already consumed
|
||||
QtyAlreadyProduced=Qty already produced
|
||||
QtyRequiredIfNoLoss=Qty required if there is no loss (Manufacturing efficiency is 100%%)
|
||||
|
||||
@ -101,6 +101,7 @@ class Mo extends CommonObject
|
||||
'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'position'=>5, 'notnull'=>1, 'default'=>'1', 'index'=>1),
|
||||
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>4, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'showoncombobox'=>'1', 'noteditable'=>1),
|
||||
'fk_bom' => array('type'=>'integer:Bom:bom/class/bom.class.php:0:t.status=1', 'filter'=>'active=1', 'label'=>'BOM', 'enabled'=>1, 'visible'=>1, 'position'=>33, 'notnull'=>-1, 'index'=>1, 'comment'=>"Original BOM", 'css'=>'minwidth100 maxwidth300', 'csslist'=>'nowraponall'),
|
||||
'mrptype' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>1, 'visible'=>1, 'position'=>34, 'notnull'=>1, 'default'=>'0', 'arrayofkeyval'=>array(0=>'Manufacturing', 1=>'Disassemble'), 'css'=>'minwidth150', 'csslist'=>'minwidth150 center'),
|
||||
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:0', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'comment'=>"Product to produce", 'css'=>'maxwidth300', 'csslist'=>'tdoverflowmax100', 'picto'=>'product'),
|
||||
'qty' => array('type'=>'real', 'label'=>'QtyToProduce', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>1, 'comment'=>"Qty to produce", 'css'=>'width75', 'default'=>1, 'isameasure'=>1),
|
||||
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>42, 'notnull'=>-1, 'searchall'=>1, 'showoncombobox'=>'2', 'css'=>'maxwidth300', 'csslist'=>'tdoverflowmax200'),
|
||||
@ -121,8 +122,9 @@ class Mo extends CommonObject
|
||||
'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>2, 'position'=>1000, 'default'=>0, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '2'=>'InProgress', '3'=>'StatusMOProduced', '9'=>'Canceled')),
|
||||
);
|
||||
public $rowid;
|
||||
public $ref;
|
||||
public $entity;
|
||||
public $ref;
|
||||
public $mrptype;
|
||||
public $label;
|
||||
public $qty;
|
||||
public $fk_warehouse;
|
||||
@ -253,7 +255,7 @@ class Mo extends CommonObject
|
||||
$this->db->begin();
|
||||
|
||||
// Check that product is not a kit/virtual product
|
||||
if (empty($conf->global->ALLOW_USE_KITS_INTO_BOM_AND_MO) and $this->fk_product > 0) {
|
||||
if (empty($conf->global->ALLOW_USE_KITS_INTO_BOM_AND_MO) && $this->fk_product > 0) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
$tmpproduct = new Product($this->db);
|
||||
$tmpproduct->fetch($this->fk_product);
|
||||
@ -265,6 +267,14 @@ class Mo extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->fk_bom > 0) {
|
||||
// If there is a nown BOM, we force the type of MO to the type of BOM
|
||||
$tmpbom = new BOM($this->db);
|
||||
$tmpbom->fetch($this->fk_bom);
|
||||
|
||||
$this->mrptype = $tmpbom->bomtype;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$idcreated = $this->createCommon($user, $notrigger);
|
||||
if ($idcreated <= 0) {
|
||||
@ -273,7 +283,7 @@ class Mo extends CommonObject
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$result = $this->updateProduction($user, $notrigger);
|
||||
$result = $this->updateProduction($user, $notrigger); // Insert lines from BOM
|
||||
if ($result <= 0) {
|
||||
$error++;
|
||||
}
|
||||
@ -638,7 +648,7 @@ class Mo extends CommonObject
|
||||
$moline->fk_product = $this->fk_product;
|
||||
$moline->position = 1;
|
||||
|
||||
if ($this->fk_bom > 0) { // If a BOM is defined, we know what to consume.
|
||||
if ($this->fk_bom > 0) { // If a BOM is defined, we know what to produce.
|
||||
include_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
|
||||
$bom = new Bom($this->db);
|
||||
$bom->fetch($this->fk_bom);
|
||||
|
||||
@ -49,6 +49,7 @@ $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
|
||||
// Initialize technical objects
|
||||
$object = new Mo($db);
|
||||
$objectbom = new BOM($db);
|
||||
|
||||
$extrafields = new ExtraFields($db);
|
||||
$diroutputmassaction = $conf->mrp->dir_output.'/temp/massgeneration/'.$user->id;
|
||||
$hookmanager->initHooks(array('mocard', 'globalcard')); // Note that conf->hooks_modules contains array
|
||||
@ -74,13 +75,14 @@ if (empty($action) && empty($id) && empty($ref)) {
|
||||
// Load object
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
|
||||
|
||||
if (GETPOST('fk_bom', 'int')) {
|
||||
if (GETPOST('fk_bom', 'int') > 0) {
|
||||
$objectbom->fetch(GETPOST('fk_bom', 'int'));
|
||||
|
||||
if ($action != 'add') {
|
||||
// We force calling parameters if we are not in the submit of creation of MO
|
||||
$_POST['fk_product'] = $objectbom->fk_product;
|
||||
$_POST['qty'] = $objectbom->qty;
|
||||
$_POST['mrptype'] = $objectbom->bomtype;
|
||||
$_POST['fk_warehouse'] = $objectbom->fk_warehouse;
|
||||
$_POST['note_private'] = $objectbom->note_private;
|
||||
}
|
||||
@ -205,6 +207,13 @@ llxHeader('', $title, '');
|
||||
|
||||
// Part to create
|
||||
if ($action == 'create') {
|
||||
if (GETPOST('fk_bom', 'int') > 0) {
|
||||
$titlelist = $langs->trans("ToConsume");
|
||||
if ($objectbom->bomtype == 1) {
|
||||
$titlelist = $langs->trans("ToObtain");
|
||||
}
|
||||
}
|
||||
|
||||
print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Mo")), '', 'mrp');
|
||||
|
||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
@ -245,7 +254,10 @@ if ($action == 'create') {
|
||||
console.log(data);
|
||||
if (typeof data.rowid != "undefined") {
|
||||
console.log("New BOM loaded, we set values in form");
|
||||
console.log(data);
|
||||
$('#qty').val(data.qty);
|
||||
$("#mrptype").val(data.bomtype); // We set bomtype into mrptype
|
||||
$('#mrptype').trigger('change'); // Notify any JS components that the value changed
|
||||
$("#fk_product").val(data.fk_product);
|
||||
$('#fk_product').trigger('change'); // Notify any JS components that the value changed
|
||||
$('#note_private').val(data.description);
|
||||
@ -268,7 +280,7 @@ if ($action == 'create') {
|
||||
else if (jQuery('#fk_bom').val() < 0) {
|
||||
// Redirect to page with all fields defined except fk_bom set
|
||||
console.log(jQuery('#fk_product').val());
|
||||
window.location.href = '<?php echo $_SERVER["PHP_SELF"] ?>?action=create&qty='+jQuery('#qty').val()+'&fk_product='+jQuery('#fk_product').val()+'&label='+jQuery('#label').val()+'&fk_project='+jQuery('#fk_project').val()+'&fk_warehouse='+jQuery('#fk_warehouse').val();
|
||||
window.location.href = '<?php echo $_SERVER["PHP_SELF"] ?>?action=create&qty='+jQuery('#qty').val()+'&mrptype='+jQuery('#mrptype').val()+'&fk_product='+jQuery('#fk_product').val()+'&label='+jQuery('#label').val()+'&fk_project='+jQuery('#fk_project').val()+'&fk_warehouse='+jQuery('#fk_warehouse').val();
|
||||
/*
|
||||
$('#qty').val('');
|
||||
$("#fk_product").val('');
|
||||
@ -288,13 +300,14 @@ if ($action == 'create') {
|
||||
|
||||
print $form->buttonsSaveCancel("Create");
|
||||
|
||||
if (GETPOST('fk_bom', 'int') > 0) {
|
||||
print load_fiche_titre($langs->trans("ToConsume"));
|
||||
if ($objectbom->id > 0) {
|
||||
print load_fiche_titre($titlelist);
|
||||
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder centpercent">';
|
||||
|
||||
$object->lines = $objectbom->lines;
|
||||
$object->mrptype = $objectbom->bomtype;
|
||||
$object->bom = $objectbom;
|
||||
|
||||
$object->printOriginLinesList('', array());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user