Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:Hidding fields stone,stone weight,stone charge in the child table while Checking the check field has stone. #222

Merged
merged 1 commit into from
Feb 21, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,30 @@
"stone",
"stone_charge",
"making_charge",
"amount"
"amount",
"has_stone"
],
"fields": [
{
"fieldname": "item_details_column",
"fieldtype": "Column Break",
"label": "Item Details "
},
{
"fieldname": "item_code",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Item Code",
"read_only": 1
},
{
"fieldname": "uom",
"fieldtype": "Link",
"in_list_view": 1,
"label": "UOM",
"options": "UOM",
"reqd": 1
},
{
"fieldname": "gold_weight",
"fieldtype": "Float",
Expand All @@ -32,17 +48,17 @@
"reqd": 1
},
{
"fieldname": "net_weight",
"depends_on": "eval:doc.stone",
"fieldname": "stone_weight",
"fieldtype": "Float",
"in_list_view": 1,
"label": "Net Weight",
"read_only": 1
"label": "Stone Weight"
},
{
"fieldname": "amount",
"fieldname": "net_weight",
"fieldtype": "Float",
"in_list_view": 1,
"label": "Amount",
"label": "Net Weight",
"read_only": 1
},
{
Expand All @@ -56,13 +72,6 @@
"label": "Stone",
"read_only": 1
},
{
"depends_on": "eval:doc.stone",
"fieldname": "stone_weight",
"fieldtype": "Float",
"in_list_view": 1,
"label": "Stone Weight"
},
{
"depends_on": "eval:doc.stone",
"fieldname": "stone_charge",
Expand All @@ -71,32 +80,30 @@
"label": "Stone Charge"
},
{
"fieldname": "uom",
"fieldtype": "Link",
"fieldname": "making_charge",
"fieldtype": "Currency",
"in_list_view": 1,
"label": "UOM",
"options": "UOM",
"label": "Making Charge",
"reqd": 1
},
{
"fieldname": "item_code",
"fieldtype": "Data",
"fieldname": "amount",
"fieldtype": "Float",
"in_list_view": 1,
"label": "Item Code",
"label": "Amount",
"read_only": 1
},
{
"fieldname": "making_charge",
"fieldtype": "Currency",
"in_list_view": 1,
"label": "Making Charge",
"reqd": 1
"default": "0",
"fieldname": "has_stone",
"fieldtype": "Check",
"label": "has Stone"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2024-02-19 12:22:43.830822",
"modified": "2024-02-21 12:54:33.716315",
"modified_by": "Administrator",
"module": "AuMMS",
"name": "Jewellery Item Receipt",
Expand Down
42 changes: 32 additions & 10 deletions aumms/aumms/doctype/jewellery_receipt/jewellery_receipt.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,35 @@

frappe.ui.form.on("Jewellery Receipt", {
refresh:function(frm) {

// show only customers whose territory is set to India
frm.set_query('stone', () => {
return {
filters: {
is_stone_item: 1
}
return {
filters: {
is_stone_item: 1
}
}
})

},
has_stone: function (frm) {
if(!frm.doc.has_stone){
frm.set_value('stone', );
}
frm.fields_dict.item_details.grid.toggle_enable('has_stone', frm.doc.has_stone);
frm.refresh_fields();
frm.trigger('update_item_details');
},
stone: function(frm){
frm.trigger('update_item_details');
},
update_item_details: function(frm){
if(frm.doc.item_details){
frm.doc.item_details.forEach(function(item){
frappe.model.set_value(item.doctype, item.name, 'has_stone', frm.doc.has_stone);
frappe.model.set_value(item.doctype, item.name, 'stone', frm.doc.stone);
});
}
frm.refresh_fields();
}
});

frappe.ui.form.on("Jewellery Item Receipt", {
Expand All @@ -22,13 +40,20 @@ frappe.ui.form.on("Jewellery Item Receipt", {
if (frm.doc.stone) {
frappe.model.set_value(child.doctype, child.name, 'stone', frm.doc.stone);
}
if (frm.doc.has_stone) {
frappe.model.set_value(child.doctype, child.name, 'has_stone', frm.doc.has_stone);
frm.refresh_fields();
}
else{
frappe.model.set_value(child.doctype, child.name, 'has_stone', 0);
}
},
stone_weight: function(frm, cdt, cdn) {
let d = locals[cdt][cdn];
if (frm.doc.has_stone) {
let net_weight = d.gold_weight + d.stone_weight;
frappe.model.set_value(cdt, cdn, 'net_weight', net_weight);
}
}frm.fields_dict.item_details.grid.toggle_enable('has_stone', frm.doc.has_stone);frm.fields_dict.item_details.grid.toggle_enable('has_stone', frm.doc.has_stone);
},
gold_weight: function(frm, cdt, cdn) {
let d = locals[cdt][cdn];
Expand All @@ -49,6 +74,3 @@ frappe.ui.form.on("Jewellery Item Receipt", {
}
}
});
frappe.ui.form.on("Jewellery Item Receipt", {

});
1 change: 1 addition & 0 deletions aumms/aumms/doctype/jewellery_receipt/jewellery_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def create_item(self):
aumms_item.weight_per_unit = item_detail.net_weight
aumms_item.weight_uom = item_detail.uom
aumms_item.has_stone = self.has_stone
aumms_item.gold_weight = item_detail.gold_weight
# If has_stone is checked, fetch stone details from item_detail
if self.has_stone:
aumms_item.append('stone_details', {
Expand Down
106 changes: 0 additions & 106 deletions aumms/aumms/doctype/purchase_item_details/purchase_item_details.json

This file was deleted.

Loading