Topic: Clone Manufactured Item -> Clone BOM?

When I clone an item that is manufactured, the BOM is not considered if I understand correctly? Am I missing an option that would allow the BOM to also be cloned with costs (and a bonus to bring up the BOM for the new item during cloning for small modifications)? Or could this be considered for a future release?

Re: Clone Manufactured Item -> Clone BOM?

Cloning does not copy the BOM.

My fork has code to copy the BOM under Manufacturing->Bills Of Materials

diff --git a/core/manufacturing/manage/bom_edit.php b/core/manufacturing/manage/bom_edit.php
index 35230dd..9d6fbfd 100644
--- a/core/manufacturing/manage/bom_edit.php
+++ b/core/manufacturing/manage/bom_edit.php
@@ -45,9 +45,10 @@ function display_bom_items($selected_parent)
        table_header($th);
 
        $k = 0;
+    $found = false;
        while ($myrow = db_fetch($result))
        {
-
+        $found = true;
                alt_table_row_color($k);
 
                label_cell($myrow["component"]);
@@ -62,9 +63,30 @@ function display_bom_items($selected_parent)
 
        } //END WHILE LIST LOOP
        end_table();
+
+    if ($found) {
+        start_table(TABLESTYLE, "width='60%'");
+        stock_manufactured_items_list_row(_("Copy BOM to another manufacturable item"), 'new_stock_id', $selected_parent, false, true);
+        end_table();
+    }
+
        div_end();
 }
 
+function copy_bom_items($stock_id, $new_stock_id)
+{
+       $result = get_bom($stock_id);
+       while ($myrow = db_fetch($result))
+       {
+               $_POST['component'] = $myrow["component"];
+        $_POST['loc_code'] = $myrow["loc_code"];
+        $_POST['workcentre_added'] = $myrow["workcentre_added"];
+        $_POST['quantity'] = $myrow["quantity"];
+        on_submit($new_stock_id, -1);
+    }
+}
+
+
 
 
 //--------------------------------------------------------------------------------------------------
 
+if (list_updated('new_stock_id')) {
+    copy_bom_items($_POST['stock_id'], $_POST['new_stock_id']);
+    $item = get_item($_POST['new_stock_id']);
+    $_POST['stock_id'] = $_POST['new_stock_id'];
+    $Ajax->activate('_page_body');
+    display_notification("BOM copied to " . $item['description']);
+}
+

 start_form();
 
 start_form(false, true);

Re: Clone Manufactured Item -> Clone BOM?

Thank you Braath,

  I now have your changes applied to my system. At first I attempted to apply your patch to my local file (from Sourceforge v.2.4.7,  Build 26.07.2019) and got a "patch does not apply" message, so I manually added your lines as the patch indicates. I'm not smart, so I am sure I didn't do something correctly when trying to apply the patch via git apply.

  Then I didn't see how to apply the copied items at first, but then tabbing through the copy section simply finished your copy command.

  Thank you very much!

  Will your changes be added to the main program download for future installations?

Re: Clone Manufactured Item -> Clone BOM?

@joe: want to add this?

Re: Clone Manufactured Item -> Clone BOM?

Yes, this is ok, I guess.

/Joe

Re: Clone Manufactured Item -> Clone BOM?

This has been committed to repo 2.4.7.

/Joe

Re: Clone Manufactured Item -> Clone BOM?

Great - Thank you all!

  So, what is the best way to stay "current" to include all that has been and to be committed? It would seem difficult to answer the many questions (from me!) without knowing what version the person is using.

Re: Clone Manufactured Item -> Clone BOM?

1. Search the forums and the wiki.
2. Study the DB changes for each transaction / form entry and see if it makes sense.
3. Keep track of the FA version and the DB version in version.php
4. Study the commits in the Repos - Core and Extensions (official and others you follow).
5. Make sure the config.php and sys_prefs table entries match the changes committed in each version.
6. Plug and Pray that nothing breaks.
7. Wish @joe & @itronics a long life to fix anything that goes wrong and gets found wink