Skip to content

Commit

Permalink
Merge pull request #396 from efeone/aumms_064
Browse files Browse the repository at this point in the history
fix : Created Item From Jewellery Job card and Updated Corresponding M…
  • Loading branch information
MhmdSinanKT authored May 10, 2024
2 parents 83302ad + a37fa75 commit 5f8aeb3
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 159 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
"raw_material_item_section",
"item_details",
"weight",
"final_product",
"product_details_section",
"product_weight",
"column_break_8fhq",
"product",
"scrap_item_details_tab",
"scrap_item_details_column",
"table_gzos",
Expand Down Expand Up @@ -264,14 +267,7 @@
"fieldname": "expected_execution_time",
"fieldtype": "Float",
"label": "Expected Execution Time",
"precision": "2",
"label": "Expected Execution Time"
},
{
"fieldname": "final_product",
"fieldtype": "Link",
"label": "Final Product",
"options": "Item"
"precision": "1"
},
{
"default": "0",
Expand All @@ -286,11 +282,33 @@
"fieldtype": "Check",
"label": "Is Last Stage",
"read_only": 1
},
{
"fieldname": "product",
"fieldtype": "Link",
"label": "Product",
"options": "Item",
"read_only": 1
},
{
"fieldname": "column_break_8fhq",
"fieldtype": "Column Break"
},
{
"fieldname": "product_weight",
"fieldtype": "Float",
"label": "Product Weight",
"precision": "1"
},
{
"fieldname": "product_details_section",
"fieldtype": "Section Break",
"label": "Product Details"
}
],
"is_submittable": 1,
"links": [],
"modified": "2024-05-08 16:50:35.853099",
"modified": "2024-05-09 15:25:56.603760",
"modified_by": "Administrator",
"module": "AuMMS Manufacturing",
"name": "Jewellery Job Card",
Expand All @@ -313,4 +331,4 @@
"sort_field": "modified",
"sort_order": "DESC",
"states": []
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def update_item_table(self):
for item in raw_material_doc.items:
self.append('item_details', {
'item': item.item,
# 'raw_material_id' : item.raw_material_id,
'quantity': item.required_quantity,
'weight':item.required_weight
})
Expand All @@ -48,8 +47,9 @@ def update_product(self):
for stage in manufacturing_request.manufacturing_stages:
if stage.manufacturing_stage == self.stage:
for item in self.item_details:
frappe.db.set_value('Manufacturing Stage', stage.name, 'product', self.final_product)
frappe.db.set_value('Manufacturing Stage', stage.name, 'weight', self.weight)
frappe.db.set_value('Manufacturing Stage', self.manufacturing_request, 'product', item.item)
frappe.db.set_value('Manufacturing Stage', stage.name, 'weight', self.product_weight)
frappe.db.set_value('Manufacturing Request', self.manufacturing_request, 'weight', self.product_weight)
break

def create_metal_ledger(self) :
Expand Down Expand Up @@ -89,20 +89,18 @@ def create_stock_ledger(self):

def create_item(self):
warehouse = frappe.db.get_single_value('AuMMS Settings', 'item_group')
if not self.is_first_stage:
if self.is_first_stage:
new_item = frappe.new_doc('AuMMS Item')
new_item.item_name = f"{self.purity} {self.type} {self.category} {self.expected_weight} {self.stage}"
new_item.item_type = self.type
new_item.item_group = warehouse
new_item.stock_uom = self.uom
new_item.item_category = self.category
new_item.purity = self.purity
new_item.gold_weight = self.expected_weight
new_item.is_stock_item = True
new_item.item_code = f"{self.purity} {self.type} {self.category} {self.stage} {self.expected_weight}"
if self.is_last_stage:
new_item.is_raw_material = False
else:
new_item.is_raw_material = True
frappe.db.set_value('Jewellery Job Card', self.name, 'final_product', new_item.item_name)
frappe.db.set_value('Jewellery Job Card', self.name, 'product', new_item.item_name)
frappe.db.set_value('Manufacturing Request', self.manufacturing_request, 'product', new_item.item_code)
new_item.save(ignore_permissions=True)
frappe.msgprint("Item Created.", indicator="green", alert=1)
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
"raw_material_available",
"smith",
"smith_warehouse",
"is_first_stage",
"is_last_stage",
"custom_column_break_lwydq",
"workstation",
"create_job_card",
"job_card_created",
"completed",
"product",
"weight",
"previous_stage_product",
"previous_stage_weight",
Expand Down Expand Up @@ -149,19 +150,12 @@
"label": "Smith Warehouse",
"options": "Warehouse"
},
{
"depends_on": "eval:doc.completed == 1",
"fieldname": "product",
"fieldtype": "Link",
"label": "Product",
"options": "Item",
"read_only": 1
},
{
"depends_on": "eval:doc.completed == 1",
"fieldname": "weight",
"fieldtype": "Float",
"label": "Weight",
"precision": "1",
"read_only": 1
},
{
Expand All @@ -178,12 +172,24 @@
"fieldtype": "Float",
"label": "Previous Stage Weight",
"precision": "0"
},
{
"default": "0",
"fieldname": "is_first_stage",
"fieldtype": "Check",
"label": "Is First Stage"
},
{
"default": "0",
"fieldname": "is_last_stage",
"fieldtype": "Check",
"label": "Is Last Stage"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2024-05-08 17:27:56.569053",
"modified": "2024-05-10 13:01:39.150002",
"modified_by": "Administrator",
"module": "AuMMS Manufacturing",
"name": "Manufacturing Stage",
Expand All @@ -193,4 +199,4 @@
"sort_field": "modified",
"sort_order": "DESC",
"states": []
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ frappe.ui.form.on("Manufacturing Request", {
function marked_as_previous_stage_completed(frm) {
if (frm.doc.manufacturing_stages && frm.doc.manufacturing_stages.length > 0) {
frm.doc.manufacturing_stages[0].previous_stage_completed = 1;
// frm.doc.manufacturing_stages[0].is_first_stage = 1;
// const last_index = frm.doc.manufacturing_stages.length - 1;
// frm.doc.manufacturing_stages[last_index].is_last_stage = 1;
frm.doc.manufacturing_stages[0].is_first_stage = 1;
const last_index = frm.doc.manufacturing_stages.length - 1;
frm.doc.manufacturing_stages[last_index].is_last_stage = 1;
refresh_field('manufacturing_stages');
}
}
Expand All @@ -46,33 +46,17 @@ frappe.ui.form.on("Manufacturing Stage", {
})
},
create_job_card: function(frm, cdt, cdn) {
frm.call('create_jewellery_job_card', { 'stage_row_id':cdn }).then(r => {
frm.call('create_jewellery_job_card', { 'stage_row_id': cdn }).then(r => {
frm.refresh_fields();
});
},
weight: function(frm, cdt, cdn){
let row = locals[cdt][cdn];
calculate_weight(frm, cdt, cdn);
},
manufacturing_stages_remove: function (frm, cdt, cdn) {
let row = locals[cdt][cdn];
calculate_weight(frm)
},
previous_stage_completed: function(frm, cdt, cdn) {
let row = locals[cdt][cdn]
if (row.previous_stage_completed) {
frm.call('update_previous_stage', {idx:row.idx}).then(r=>{
row.previous_stage = r.message
frm.refresh_fields()
})
frm.call('update_previous_stage_product', {idx:row.idx}).then(r=>{
row.previous_stage_product = r.message
frm.refresh_fields()
})
frm.call('update_previous_stage_weight', {idx:row.idx}).then(r=>{
row.previous_stage_weight = r.message
frm.refresh_fields()
})
}
},
raw_material_available: function(frm, cdt, cdn) {
Expand All @@ -93,11 +77,3 @@ frappe.ui.form.on("Manufacturing Stage", {
}
},
});

function calculate_weight(frm , cdt, cdn) {
var net_weight = 0;
frm.doc.manufacturing_stages.forEach(function (row) {
net_weight += row.weight;
});
frm.set_value("weight", net_weight);
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,16 @@
"section_break_hpbr",
"type",
"quantity",
"posting_date",
"posting_time",
"column_break_ky2t",
"purity",
"column_break_ky2t",
"uom",
"party_link",
"column_break_1l2l",
"expected_weight",
"weight",
"keep_metal_ledger",
"column_break_izcc",
"column_break_1l2l",
"category",
"supervisor_warehouse",
"product",
"finished",
"section_break_1jdd",
"manufacturing_stages",
Expand Down Expand Up @@ -202,45 +199,27 @@
"depends_on": "eval:doc.request_from == \"Jewellery Order\"",
"fieldname": "weight",
"fieldtype": "Float",
"label": "Weight"
"label": "Weight",
"precision": "1"
},
{
"fieldname": "supervisor_warehouse",
"fieldtype": "Link",
"label": "Supervisor Warehouse",
"options": "Warehouse"
},
{
"fieldname": "column_break_izcc",
"fieldtype": "Column Break"
},
{
"default": "Today",
"fieldname": "posting_date",
"fieldtype": "Date",
"hidden": 1,
"label": "Posting Date"
},
{
"default": "Now",
"fieldname": "posting_time",
"fieldtype": "Time",
"hidden": 1,
"label": "Posting Time"
},
{
"fieldname": "party_link",
"fieldtype": "Link",
"hidden": 1,
"label": "Party Link",
"options": "Party Link"
},
{
"default": "0",
"depends_on": "eval:doc.request_from == \"Jewellery Order\"",
"fieldname": "keep_metal_ledger",
"fieldtype": "Check",
"label": "Keep Metal Ledger"
},
{
"fieldname": "product",
"fieldtype": "Link",
"label": "Product",
"options": "AuMMS Item"
}
],
"index_web_pages_for_search": 1,
Expand All @@ -255,7 +234,7 @@
"link_fieldname": "manufacturing_request"
}
],
"modified": "2024-05-07 17:34:55.175911",
"modified": "2024-05-10 13:07:45.670636",
"modified_by": "Administrator",
"module": "AuMMS Manufacturing",
"name": "Manufacturing Request",
Expand All @@ -280,4 +259,4 @@
"sort_order": "DESC",
"states": [],
"title_field": "title"
}
}
Loading

0 comments on commit 5f8aeb3

Please sign in to comment.