Skip to content

Commit

Permalink
feat:renaming of item created from jewellery job card
Browse files Browse the repository at this point in the history
  • Loading branch information
G-eethu committed May 10, 2024
1 parent 5f8aeb3 commit bf5f888
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,14 @@ def create_item(self):
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}"
frappe.db.set_value('Jewellery Job Card', self.name, 'product', new_item.item_name)
new_item.item_code = f"{self.purity} {self.type} {self.category} {self.expected_weight} {self.stage}"
frappe.db.set_value('Manufacturing Request', self.manufacturing_request, 'product', new_item.item_code)
if self.is_last_stage:
new_item.is_raw_material = False
new_item.item_name = self.product
new_item.item_code = self.product
else:
new_item.is_raw_material = True
frappe.db.set_value('Jewellery Job Card', self.name, 'product', new_item.item_name)
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 @@ -53,10 +53,14 @@ frappe.ui.form.on("Manufacturing Stage", {
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', { idx: row.idx }).then(r => {
row.previous_stage = r.message;
frm.refresh_field('manufacturing_stages');
});
frm.call('update_previous_stage_weight', { idx: row.idx }).then(r => {
row.previous_stage_weight = r.message;
frm.refresh_field('manufacturing_stages');
});
}
},
raw_material_available: function(frm, cdt, cdn) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ def update_previous_stage(self, idx):
if row.idx == prev_row:
return row.manufacturing_stage

@frappe.whitelist()
def update_previous_stage_weight(self, idx):
for stage in self.manufacturing_stages:
if stage.idx == idx:
if stage.previous_stage_completed:
prev_row = stage.idx - 1
for row in self.manufacturing_stages:
if row.idx == prev_row:
return row.weight

@frappe.whitelist()
def create_jewellery_job_card(self, stage_row_id):
first_stage, last_stage = False, False
Expand Down

0 comments on commit bf5f888

Please sign in to comment.