Merge pull request #14136 from rohitwaghchaure/multiple_fixes_for_v11

Fixes in material request, asset maintenance
This commit is contained in:
rohitwaghchaure 2018-05-18 16:39:48 +05:30 committed by GitHub
commit d08ac1fe79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 86 additions and 18 deletions

View File

@ -24,7 +24,28 @@ frappe.ui.form.on('Asset Maintenance', {
return indicator;
}
);
frm.set_query('select_serial_no', function(doc){
return {
asset: frm.doc.asset_name
}
})
},
select_serial_no: (frm) => {
let serial_nos = frm.doc.serial_no || frm.doc.select_serial_no;
if (serial_nos) {
serial_nos = serial_nos.split('\n');
serial_nos.push(frm.doc.select_serial_no);
const unique_sn = serial_nos.filter(function(elem, index, self) {
return index === self.indexOf(elem);
});
frm.set_value("serial_no", unique_sn.join('\n'));
}
},
refresh: (frm) => {
if(!frm.is_new()) {
frm.trigger('make_dashboard');

View File

@ -203,6 +203,38 @@
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "select_serial_no",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Select Serial No",
"length": 0,
"no_copy": 0,
"options": "Serial No",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
@ -221,12 +253,12 @@
"label": "Serial No",
"length": 0,
"no_copy": 0,
"options": "asset_name.serial_no",
"options": "",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
@ -465,7 +497,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-04-20 08:39:27.072622",
"modified": "2018-05-18 16:16:56.181695",
"modified_by": "Administrator",
"module": "Assets",
"name": "Asset Maintenance",

View File

@ -11,9 +11,6 @@ from frappe.utils import add_days, add_months, add_years, getdate, nowdate
class AssetMaintenance(Document):
def validate(self):
if not self.serial_no:
self.serial_no = frappe.db.get_value("Asset", self.asset_name, 'serial_no')
for task in self.get('asset_maintenance_tasks'):
if task.end_date and (getdate(task.start_date) >= getdate(task.end_date)):
throw(_("Start date should be less than end date for task {0}").format(task.maintenance_task))

View File

@ -216,27 +216,39 @@ var set_customer_group = function(frm, cdt, cdn) {
$.extend(erpnext.item, {
setup_queries: function(frm) {
frm.fields_dict["item_defaults"].grid.get_field("expense_account").get_query = function(doc) {
frm.fields_dict["item_defaults"].grid.get_field("expense_account").get_query = function(doc, cdt, cdn) {
const row = locals[cdt][cdn];
return {
query: "erpnext.controllers.queries.get_expense_account",
filters: { company: row.company }
}
}
frm.fields_dict["item_defaults"].grid.get_field("income_account").get_query = function(doc) {
frm.fields_dict["item_defaults"].grid.get_field("income_account").get_query = function(doc, cdt, cdn) {
const row = locals[cdt][cdn];
return {
query: "erpnext.controllers.queries.get_income_account"
query: "erpnext.controllers.queries.get_income_account",
filters: { company: row.company }
}
}
frm.fields_dict["item_defaults"].grid.get_field("buying_cost_center").get_query = function(doc) {
frm.fields_dict["item_defaults"].grid.get_field("buying_cost_center").get_query = function(doc, cdt, cdn) {
const row = locals[cdt][cdn];
return {
filters: { "is_group": 0 }
filters: {
"is_group": 0,
"company": row.company
}
}
}
frm.fields_dict["item_defaults"].grid.get_field("selling_cost_center").get_query = function(doc) {
frm.fields_dict["item_defaults"].grid.get_field("selling_cost_center").get_query = function(doc, cdt, cdn) {
const row = locals[cdt][cdn];
return {
filters: { "is_group": 0 }
filters: {
"is_group": 0,
"company": row.company
}
}
}
@ -267,9 +279,13 @@ $.extend(erpnext.item, {
return { query: "erpnext.controllers.queries.supplier_query" }
}
frm.fields_dict["item_defaults"].grid.get_field("default_warehouse").get_query = function(doc) {
frm.fields_dict["item_defaults"].grid.get_field("default_warehouse").get_query = function(doc, cdt, cdn) {
const row = locals[cdt][cdn];
return {
filters: { "is_group": 0 }
filters: {
"is_group": 0,
"company": row.company
}
}
}

View File

@ -45,6 +45,8 @@ frappe.ui.form.on('Material Request', {
stock_qty: item.stock_qty,
company: frm.doc.company,
conversion_rate: 1,
name: frm.doc.name,
material_request_type: frm.doc.material_request_type,
plc_conversion_rate: 1,
rate: item.rate,
conversion_factor: item.conversion_factor

View File

@ -210,8 +210,8 @@ def get_basic_details(args, item):
warehouse = user_default_warehouse or item_defaults.get("default_warehouse") or args.warehouse
material_request_type = ''
if args.get('doctype') == "Material Request":
material_request_type = frappe.db.get_value('Material Request',
if args.get('doctype') == "Material Request" and not args.get('material_request_type'):
args['material_request_type'] = frappe.db.get_value('Material Request',
args.get('name'), 'material_request_type')
#Set the UOM to the Default Sales UOM or Default Purchase UOM if configured in the Item Master
@ -219,7 +219,7 @@ def get_basic_details(args, item):
if args.get('doctype') in ['Quotation', 'Sales Order', 'Delivery Note', 'Sales Invoice']:
args.uom = item.sales_uom if item.sales_uom else item.stock_uom
elif (args.get('doctype') in ['Purchase Order', 'Purchase Receipt', 'Purchase Invoice']) or \
(args.get('doctype') == 'Material Request' and material_request_type == 'Purchase'):
(args.get('doctype') == 'Material Request' and args.get('material_request_type') == 'Purchase'):
args.uom = item.purchase_uom if item.purchase_uom else item.stock_uom
else:
args.uom = item.stock_uom