Skip to content

Commit

Permalink
feat: Swith job card work order
Browse files Browse the repository at this point in the history
  • Loading branch information
fproldan committed Mar 7, 2024
1 parent db5a742 commit c843fca
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
6 changes: 6 additions & 0 deletions inventory_tools/inventory_tools/overrides/job_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,9 @@ def validate_job_card(self):
frappe.bold(self.for_quantity),
)
)


@frappe.whitelist()
def switch_job_card_work_order(job_card: str, work_order: str):
frappe.db.set_value("Job Card", job_card, "work_order", work_order)
frappe.db.commit()
49 changes: 49 additions & 0 deletions inventory_tools/public/js/job_card_custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ frappe.ui.form.on('Job Card', {
if (frm.doc.operation) {
set_workstation_query(frm)
}
if (frm.doc.docstatus == 1) {
add_swith_work_order_action(frm)
}
},
operation: frm => {
set_workstation_query(frm)
Expand All @@ -19,3 +22,49 @@ function set_workstation_query(frm) {
}
})
}

function add_swith_work_order_action(frm) {
frm.add_custom_button(
__('Switch Work Order'),
function () {
let dialog = new frappe.ui.Dialog({
title: __('Select a Work Order'),
fields: [
{
label: __('Work Order'),
fieldname: 'work_order',
fieldtype: 'Link',
options: 'Work Order',
reqd: 1,
get_query: function () {
return {
filters: [
['docstatus', '=', '1'],
['bom_no', '=', frm.doc.bom_no],
['company', '=', frm.doc.company],
['name', '!=', frm.doc.work_order],
],
}
},
},
],
primary_action: () => {
var args = dialog.get_values()
frappe
.xcall('inventory_tools.inventory_tools.overrides.job_card.switch_job_card_work_order', {
job_card: frm.doc.name,
work_order: args.work_order,
})
.then(r => {
frm.reload_doc()
frappe.msgprint(__('Work Order Switched.'))
dialog.hide()
})
},
primary_action_label: __('Switch Work Order'),
})
dialog.show()
},
__('Make')
)
}

0 comments on commit c843fca

Please sign in to comment.