Skip to content

Commit

Permalink
fix: make weight required if weight UOM is present and vice versa (#108)
Browse files Browse the repository at this point in the history
* fix: make weight required if weight UOM is present and vice versa

* fix: update commit hashes for overriden methods
  • Loading branch information
MyuddinKhatri authored Jul 30, 2024
1 parent 7e89b54 commit fdf6a44
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions inventory_tools/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

# include js in doctype views
doctype_js = {
"Item": "public/js/item.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",
Expand Down
55 changes: 55 additions & 0 deletions inventory_tools/inventory_tools/custom/item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"custom_fields": [],
"custom_perms": [],
"doctype": "Item",
"links": [],
"property_setters": [
{
"_assign": null,
"_comments": null,
"_liked_by": null,
"_user_tags": null,
"creation": "2024-07-28 04:36:24.732734",
"default_value": null,
"doc_type": "Item",
"docstatus": 0,
"doctype_or_field": "DocField",
"field_name": "weight_uom",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-07-28 04:36:24.732734",
"modified_by": "Administrator",
"module": null,
"name": "Item-weight_uom-mandatory_depends_on",
"owner": "Administrator",
"property": "mandatory_depends_on",
"property_type": "Data",
"row_name": null,
"value": "eval:doc.weight_per_unit"
},
{
"_assign": null,
"_comments": null,
"_liked_by": null,
"_user_tags": null,
"creation": "2024-07-28 04:36:24.552718",
"default_value": null,
"doc_type": "Item",
"docstatus": 0,
"doctype_or_field": "DocField",
"field_name": "weight_per_unit",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-07-28 04:36:24.552718",
"modified_by": "Administrator",
"module": null,
"name": "Item-weight_per_unit-mandatory_depends_on",
"owner": "Administrator",
"property": "mandatory_depends_on",
"property_type": "Data",
"row_name": null,
"value": "eval:doc.weight_uom"
}
],
"sync_on_migrate": 1
}
7 changes: 7 additions & 0 deletions inventory_tools/public/js/item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
frappe.ui.form.on('Item', {
validate: frm => {
if (frm.doc.weight_uom && frm.doc.weight_per_unit == 0) {
frappe.throw(__("Please mention 'Weight Per Unit' along with Weight UOM."))
}
},
})

0 comments on commit fdf6a44

Please sign in to comment.