Skip to content

Commit

Permalink
fix: Changed autoname method for AuMMS Item
Browse files Browse the repository at this point in the history
  • Loading branch information
nidh-eesh committed Oct 31, 2023
1 parent c59ba4e commit b3b0b47
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion aumms/aumms/doctype/design_analysis/design_analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 7 additions & 3 deletions aumms/aumms/doctype/design_analysis/design_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down

0 comments on commit b3b0b47

Please sign in to comment.