Skip to content

Commit

Permalink
fix(ux): SCR consumed-qty read-only property
Browse files Browse the repository at this point in the history
(cherry picked from commit adf2474)
  • Loading branch information
s-aga-r authored and mergify[bot] committed May 17, 2023
1 parent fa9fa97 commit aa7fede
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,26 +76,14 @@ frappe.ui.form.on('Subcontracting Receipt', {
}
});

let batch_no_field = frm.get_docfield("items", "batch_no");
let batch_no_field = frm.get_docfield('items', 'batch_no');
if (batch_no_field) {
batch_no_field.get_route_options_for_new_doc = function(row) {
return {
"item": row.doc.item_code
'item': row.doc.item_code
}
};
}

frappe.db.get_single_value('Buying Settings', 'backflush_raw_materials_of_subcontract_based_on').then(val => {
if (val == 'Material Transferred for Subcontract') {
frm.fields_dict['supplied_items'].grid.grid_rows.forEach((grid_row) => {
grid_row.docfields.forEach((df) => {
if (df.fieldname == 'consumed_qty') {
df.read_only = 0;
}
});
});
}
});
},

refresh: (frm) => {
Expand Down Expand Up @@ -157,6 +145,8 @@ frappe.ui.form.on('Subcontracting Receipt', {
}
});
}, __('Get Items From'));

frm.fields_dict.supplied_items.grid.update_docfield_property('consumed_qty', 'read_only', frm.doc.__onload && frm.doc.__onload.backflush_based_on === 'BOM');
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ def __init__(self, *args, **kwargs):
},
]

def onload(self):
self.set_onload(
"backflush_based_on",
frappe.db.get_single_value(
"Buying Settings", "backflush_raw_materials_of_subcontract_based_on"
),
)

def update_status_updater_args(self):
if cint(self.is_return):
self.status_updater.extend(
Expand Down

0 comments on commit aa7fede

Please sign in to comment.