Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@



## v14.6.0 (2024-05-13)

### Chore

* chore: update quotation demand docs (#77) ([`f168079`](https://github.com/agritheory/inventory_tools/commit/f168079e29d99056d4c5eb2321d84957cff84f3b))

### Feature

* feat: add inventory tools settings to boot (#81) ([`7ac2e15`](https://github.com/agritheory/inventory_tools/commit/7ac2e15aa74676ba5741887231814cdf9e675755))


## v14.5.0 (2024-04-29)

### Feature
Expand Down
2 changes: 1 addition & 1 deletion inventory_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "14.5.0"
__version__ = "14.6.0"


"""
Expand Down
Binary file modified inventory_tools/docs/assets/qd_report_view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified inventory_tools/docs/assets/qd_selection.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions inventory_tools/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@

# include js in doctype views
doctype_js = {
"Work Order": "public/js/work_order_custom.js",
"Purchase Order": "public/js/purchase_order_custom.js",
"Purchase Invoice": "public/js/purchase_invoice_custom.js",
"Stock Entry": "public/js/stock_entry_custom.js",
"Job Card": "public/js/job_card_custom.js",
"Purchase Invoice": "public/js/purchase_invoice_custom.js",
"Purchase Order": "public/js/purchase_order_custom.js",
"Operation": "public/js/operation_custom.js",
"Stock Entry": "public/js/stock_entry_custom.js",
"Work Order": "public/js/work_order_custom.js",
}
# doctype_list_js = {"doctype" : "public/js/doctype_list.js"}
# doctype_tree_js = {"doctype" : "public/js/doctype_tree.js"}
Expand Down Expand Up @@ -83,7 +83,7 @@

# Boot
# ------------
# extend_bootinfo = "inventory_tools.inventory_tools.boot.boot_session"
extend_bootinfo = "inventory_tools.inventory_tools.boot.boot_session"


# Desk Notifications
Expand Down
8 changes: 8 additions & 0 deletions inventory_tools/inventory_tools/boot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import frappe


def boot_session(bootinfo):
bootinfo.inventory_tools_settings = {}
for company in frappe.get_all("Inventory Tools Settings", pluck="company"):
settings = frappe.get_doc("Inventory Tools Settings", company)
bootinfo.inventory_tools_settings[company] = settings
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
"update_warehouse_path",
"section_break_gzcbr",
"uoms_section",
"enforce_uoms"
"enforce_uoms",
"job_card_section",
"allow_switch_work_order"
],
"fields": [
{
Expand Down Expand Up @@ -124,6 +126,17 @@
"fieldtype": "Percent",
"label": "Overproduction Percentage For Work Order"
},
{
"fieldname": "job_card_section",
"fieldtype": "Section Break",
"label": "Job Card"
},
{
"default": "0",
"fieldname": "allow_switch_work_order",
"fieldtype": "Check",
"label": "Allow Switch Work Order"
},
{
"fieldname": "quotation_demand_section",
"fieldtype": "Section Break",
Expand All @@ -146,11 +159,22 @@
"fieldtype": "Link",
"label": "Aggregated Sales Warehouse",
"options": "Warehouse"
},
{
"fieldname": "job_card_section",
"fieldtype": "Section Break",
"label": "Job Card"
},
{
"default": "0",
"fieldname": "allow_switch_work_order",
"fieldtype": "Check",
"label": "Allow Switch Work Order"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2024-04-12 10:02:32.688310",
"modified": "2024-04-18 10:20:36.647244",
"modified_by": "Administrator",
"module": "Inventory Tools",
"name": "Inventory Tools Settings",
Expand Down
8 changes: 8 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,11 @@ def validate_job_card(self):
frappe.bold(self.for_quantity),
)
)


@frappe.whitelist()
def switch_job_card_work_order(job_card: str, work_order: str):
doc = frappe.get_doc("Job Card", job_card)
frappe.db.set_value("Job Card", job_card, "work_order", work_order)
doc.update_work_order()
frappe.db.commit()
69 changes: 69 additions & 0 deletions inventory_tools/public/js/job_card_custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ frappe.ui.form.on('Job Card', {
refresh: frm => {
if (frm.doc.operation) {
set_workstation_query(frm)
set_work_order_query(frm)
}
add_switch_work_order_action(frm)
},
operation: frm => {
set_workstation_query(frm)
Expand All @@ -19,3 +21,70 @@ function set_workstation_query(frm) {
}
})
}

function set_work_order_query(frm) {
if (frm.is_new()) {
return
}
frm.set_query('work_order', doc => {
return {
filters: {
production_item: doc.production_item,
},
}
})
}

function add_switch_work_order_action(frm) {
if (frm.doc.docstatus != 1) {
return
}
frappe.db.get_value('Inventory Tools Settings', { company: frm.doc.company }, 'allow_switch_work_order').then(r => {
if (r && r.message && r.message.allow_switch_work_order) {
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'],
['status', '!=', 'Closed'],
['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')
)
}
})
}
6 changes: 6 additions & 0 deletions inventory_tools/tests/test_switch_work_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import frappe
import pytest


def test_switch_work_order_on_job_card():
pass