Skip to content

Commit

Permalink
refactor: clean up product bundle client side code (backport #31455) (#…
Browse files Browse the repository at this point in the history
…31456)

refactor: clean up product bundle client side code (#31455)

refactor: clean up product bundle cient side code

- Remove deprecated CUR_FRM scripts
- Remove client side fetches and move it to doctype schema

(cherry picked from commit 20dac08)

Co-authored-by: Ankush Menat <ankush@frappe.io>
  • Loading branch information
mergify[bot] and ankush authored Jun 27, 2022
1 parent 873d1ec commit 5e7cad4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
28 changes: 11 additions & 17 deletions erpnext/selling/doctype/product_bundle/product_bundle.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt

cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.toggle_enable('new_item_code', doc.__islocal);
}

cur_frm.fields_dict.new_item_code.get_query = function() {
return{
query: "erpnext.selling.doctype.product_bundle.product_bundle.get_new_item_code"
}
}
cur_frm.fields_dict.new_item_code.query_description = __('Please select Item where "Is Stock Item" is "No" and "Is Sales Item" is "Yes" and there is no other Product Bundle');

cur_frm.cscript.onload = function() {
// set add fetch for item_code's item_name and description
cur_frm.add_fetch('item_code', 'stock_uom', 'uom');
cur_frm.add_fetch('item_code', 'description', 'description');
}
frappe.ui.form.on("Product Bundle", {
refresh: function (frm) {
frm.toggle_enable("new_item_code", frm.is_new());
frm.set_query("new_item_code", () => {
return {
query: "erpnext.selling.doctype.product_bundle.product_bundle.get_new_item_code",
};
});
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
"reqd": 1
},
{
"fetch_from": "item_code.description",
"fetch_if_empty": 1,
"fieldname": "description",
"fieldtype": "Text Editor",
"in_list_view": 1,
Expand All @@ -51,6 +53,8 @@
"print_hide": 1
},
{
"fetch_from": "item_code.stock_uom",
"fetch_if_empty": 1,
"fieldname": "uom",
"fieldtype": "Link",
"in_list_view": 1,
Expand All @@ -64,13 +68,14 @@
"idx": 1,
"istable": 1,
"links": [],
"modified": "2020-02-28 14:06:05.725655",
"modified": "2022-06-27 05:30:18.475150",
"modified_by": "Administrator",
"module": "Selling",
"name": "Product Bundle Item",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"track_changes": 1
}

0 comments on commit 5e7cad4

Please sign in to comment.