Merge pull request #16093 from rohitwaghchaure/manufacturing_settings_permissions_issue

[Fix] No permission for Manufacturing Settings
This commit is contained in:
Nabin Hait 2018-11-27 13:07:44 +05:30 committed by GitHub
commit 5f7b37ee11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View File

@ -13,3 +13,11 @@ class ManufacturingSettings(Document):
def get_mins_between_operations():
return relativedelta(minutes=cint(frappe.db.get_single_value("Manufacturing Settings",
"mins_between_operations")) or 10)
@frappe.whitelist()
def is_material_consumption_enabled():
if not hasattr(frappe.local, 'material_consumption'):
frappe.local.material_consumption = cint(frappe.db.get_single_value('Manufacturing Settings',
'material_consumption'))
return frappe.local.material_consumption

View File

@ -199,12 +199,15 @@ frappe.ui.form.on('Stock Entry', {
},
validate_purpose_consumption: function(frm) {
frappe.model.get_value('Manufacturing Settings', {'name': 'Manufacturing Settings'}, 'material_consumption', function(d) {
if (d.material_consumption==0 && frm.doc.purpose=="Material Consumption for Manufacture") {
frappe.call({
method: "erpnext.manufacturing.doctype.manufacturing_settings.manufacturing_settings.is_material_consumption_enabled",
}).then(r => {
if (cint(r.message) == 0
&& frm.doc.purpose=="Material Consumption for Manufacture") {
frm.set_value("purpose", 'Manufacture');
frappe.throw(__('Material Consumption is not set in Manufacturing Settings.'));
}
})
});
},
company: function(frm) {