diff --git a/aumms/aumms/doctype/design_analysis/design_analysis.js b/aumms/aumms/doctype/design_analysis/design_analysis.js index 844fc58f..10dc1a1b 100644 --- a/aumms/aumms/doctype/design_analysis/design_analysis.js +++ b/aumms/aumms/doctype/design_analysis/design_analysis.js @@ -124,13 +124,15 @@ frappe.ui.form.on('Design Analysis', { const item_code = frm.doc.item_code; const item_group = frm.doc.item_group; const purity = frm.doc.purity; + const customer_expected_weight = frm.doc.customer_expected_weight; frappe.call({ method: 'aumms.aumms.doctype.design_analysis.design_analysis.create_aumms_item_from_design_analysis', args: { item: item_code, item_group: item_group, - purity: purity + purity: purity, + customer_expected_weight: customer_expected_weight, }, callback: (r) => { if (r.message) { diff --git a/aumms/aumms/doctype/design_analysis/design_analysis.py b/aumms/aumms/doctype/design_analysis/design_analysis.py index 044299c3..6682093c 100644 --- a/aumms/aumms/doctype/design_analysis/design_analysis.py +++ b/aumms/aumms/doctype/design_analysis/design_analysis.py @@ -27,13 +27,17 @@ def create_bom_function(design_analysis): return False @frappe.whitelist() -def create_aumms_item_from_design_analysis(item, item_group, purity): - +def create_aumms_item_from_design_analysis(customer_expected_weight, item, item_group, purity): + #Calculate Item Code to set as docname + weight = float(customer_expected_weight) + weight = int(weight*1000) + weight_with_zero = str(weight).zfill(6) + doc_name = item + '-' + weight_with_zero # Create a new Aumms Item document aumms_item = frappe.get_doc({ "doctype": "AuMMS Item", "item_name": item, - "item_code": item, + "item_code": doc_name, "item_group": item_group, "purity": purity })