blob: e4c1d5314c2527266dd8102fe4665c3a8fc1b2c3 [file] [log] [blame]
Anand Doshi885e0742015-03-03 14:55:30 +05301// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
Rushabh Mehtae67d1fb2013-08-05 14:59:54 +05302// License: GNU General Public License v3. See license.txt
Rushabh Mehta793ba6b2014-02-14 15:47:51 +05303frappe.provide("erpnext");
Nabin Haitb072c742014-12-16 12:49:13 +05304frappe.provide("erpnext.utils");
Anand Doshie65e6212012-11-19 15:43:18 +05305
Anand Doshibdee6e02013-07-09 13:03:39 +05306$.extend(erpnext, {
7 get_currency: function(company) {
8 if(!company && cur_frm)
9 company = cur_frm.doc.company;
10 if(company)
Rushabh Mehta66d52b52014-03-27 14:17:33 +053011 return frappe.get_doc(":Company", company).default_currency || frappe.boot.sysdefaults.currency;
Anand Doshibdee6e02013-07-09 13:03:39 +053012 else
Rushabh Mehta793ba6b2014-02-14 15:47:51 +053013 return frappe.boot.sysdefaults.currency;
Anand Doshibdee6e02013-07-09 13:03:39 +053014 },
Rushabh Mehtac38fc712014-04-16 17:21:25 +053015
tundebabzyc8978252018-02-12 10:34:50 +010016 get_presentation_currency_list: () => {
17 const docs = frappe.boot.docs;
Zarrare25dcd22018-06-21 10:53:12 +053018 let currency_list = docs.filter(d => d.doctype === ":Currency").map(d => d.name);
19 currency_list.unshift("");
tundebabzyc8978252018-02-12 10:34:50 +010020 return currency_list;
21 },
22
Anand Doshi8bde7f92014-04-24 18:11:49 +053023 toggle_naming_series: function() {
Rushabh Mehtac38fc712014-04-16 17:21:25 +053024 if(cur_frm.fields_dict.naming_series) {
Anand Doshibdee6e02013-07-09 13:03:39 +053025 cur_frm.toggle_display("naming_series", cur_frm.doc.__islocal?true:false);
26 }
27 },
Rushabh Mehtac38fc712014-04-16 17:21:25 +053028
Anand Doshibdee6e02013-07-09 13:03:39 +053029 hide_company: function() {
30 if(cur_frm.fields_dict.company) {
Rushabh Mehta89418412013-10-07 18:22:29 +053031 var companies = Object.keys(locals[":Company"] || {});
Anand Doshibdee6e02013-07-09 13:03:39 +053032 if(companies.length === 1) {
33 if(!cur_frm.doc.company) cur_frm.set_value("company", companies[0]);
34 cur_frm.toggle_display("company", false);
Rushabh Mehta45ca8a42015-04-28 16:02:09 +053035 } else if(erpnext.last_selected_company) {
36 if(!cur_frm.doc.company) cur_frm.set_value("company", erpnext.last_selected_company);
Anand Doshibdee6e02013-07-09 13:03:39 +053037 }
38 }
Anand Doshi1ffc5b52013-07-15 18:09:43 +053039 },
Rushabh Mehtac38fc712014-04-16 17:21:25 +053040
Rohit Waghchauree9ff1912017-06-19 12:54:59 +053041 is_perpetual_inventory_enabled: function(company) {
42 if(company) {
43 return frappe.get_doc(":Company", company).enable_perpetual_inventory
44 }
45 },
46
Makarand Bauskare6712c12017-10-25 12:17:40 +053047 stale_rate_allowed: () => {
rohitwaghchaure7677ff02017-11-02 18:12:14 +053048 return cint(frappe.boot.sysdefaults.allow_stale);
Makarand Bauskare6712c12017-10-25 12:17:40 +053049 },
50
Rushabh Mehta2a21bc92015-02-25 15:08:42 +053051 setup_serial_no: function() {
52 var grid_row = cur_frm.open_grid_row();
akshay14384c22016-07-28 13:53:17 +053053 if(!grid_row || !grid_row.grid_form.fields_dict.serial_no ||
54 grid_row.grid_form.fields_dict.serial_no.get_status()!=="Write") return;
Rushabh Mehtac38fc712014-04-16 17:21:25 +053055
Pratik Vyasb52618c2014-04-14 16:25:30 +053056 var $btn = $('<button class="btn btn-sm btn-default">'+__("Add Serial No")+'</button>')
Rushabh Mehta62030e02013-08-14 18:37:28 +053057 .appendTo($("<div>")
Rushabh Mehta2a21bc92015-02-25 15:08:42 +053058 .css({"margin-bottom": "10px", "margin-top": "10px"})
akshay14384c22016-07-28 13:53:17 +053059 .appendTo(grid_row.grid_form.fields_dict.serial_no.$wrapper));
Rushabh Mehtac38fc712014-04-16 17:21:25 +053060
Rushabh Mehta62030e02013-08-14 18:37:28 +053061 $btn.on("click", function() {
Rushabh Mehta793ba6b2014-02-14 15:47:51 +053062 var d = new frappe.ui.Dialog({
Pratik Vyasb52618c2014-04-14 16:25:30 +053063 title: __("Add Serial No"),
Rushabh Mehta62030e02013-08-14 18:37:28 +053064 fields: [
65 {
66 "fieldtype": "Link",
Rohit Waghchaure2087e572017-02-27 13:43:04 +053067 "fieldname": "serial_no",
Rushabh Mehta62030e02013-08-14 18:37:28 +053068 "options": "Serial No",
Pratik Vyasb52618c2014-04-14 16:25:30 +053069 "label": __("Serial No"),
Neil Trini Lasrado3d61bbb2015-03-12 12:51:50 +053070 "get_query": function () {
Rushabh Mehta45ca8a42015-04-28 16:02:09 +053071 return {
72 filters: {
Shreya14bd43d2018-04-27 16:24:05 +053073 item_code:grid_row.doc.item_code,
Nabin Haitb7c0c552015-08-04 12:18:12 +053074 warehouse:cur_frm.doc.is_return ? null : grid_row.doc.warehouse
Neil Trini Lasrado3d61bbb2015-03-12 12:51:50 +053075 }
76 }
Rushabh Mehta62030e02013-08-14 18:37:28 +053077 }
78 },
79 {
80 "fieldtype": "Button",
Kanchan Chauhan69818702017-02-27 12:53:05 +053081 "fieldname": "add",
Pratik Vyasb52618c2014-04-14 16:25:30 +053082 "label": __("Add")
Rushabh Mehta62030e02013-08-14 18:37:28 +053083 }
84 ]
85 });
Rushabh Mehtac38fc712014-04-16 17:21:25 +053086
Rushabh Mehta62030e02013-08-14 18:37:28 +053087 d.get_input("add").on("click", function() {
88 var serial_no = d.get_value("serial_no");
89 if(serial_no) {
90 var val = (grid_row.doc.serial_no || "").split("\n").concat([serial_no]).join("\n");
akshay14384c22016-07-28 13:53:17 +053091 grid_row.grid_form.fields_dict.serial_no.set_model_value(val.trim());
Rushabh Mehta62030e02013-08-14 18:37:28 +053092 }
93 d.hide();
94 return false;
95 });
Rushabh Mehtac38fc712014-04-16 17:21:25 +053096
Rushabh Mehta62030e02013-08-14 18:37:28 +053097 d.show();
98 });
Rushabh Mehta5495bc52015-05-19 12:00:34 +053099 }
Rushabh Mehtac38fc712014-04-16 17:21:25 +0530100});
Rushabh Mehta7d368752014-11-24 14:16:47 +0530101
Nabin Haitb072c742014-12-16 12:49:13 +0530102
103$.extend(erpnext.utils, {
Rushabh Mehta559aa3a2016-09-19 16:04:58 +0530104 set_party_dashboard_indicators: function(frm) {
105 if(frm.doc.__onload && frm.doc.__onload.dashboard_info) {
106 var info = frm.doc.__onload.dashboard_info;
107 frm.dashboard.add_indicator(__('Annual Billing: {0}',
Rohit Waghchaurec857f372016-12-05 17:09:30 +0530108 [format_currency(info.billing_this_year, info.currency)]), 'blue');
Rushabh Mehta559aa3a2016-09-19 16:04:58 +0530109 frm.dashboard.add_indicator(__('Total Unpaid: {0}',
Rohit Waghchaurec857f372016-12-05 17:09:30 +0530110 [format_currency(info.total_unpaid, info.currency)]),
Rushabh Mehta559aa3a2016-09-19 16:04:58 +0530111 info.total_unpaid ? 'orange' : 'green');
112 }
113 },
114
Shreya Shah149f7ee2018-03-27 11:29:25 +0530115 get_party_name: function(party_type) {
116 var dict = {'Customer': 'customer_name', 'Supplier': 'supplier_name', 'Employee': 'employee_name',
117 'Member': 'member_name'};
118 return dict[party_type];
119 },
120
Neil Trini Lasradofe2ffae2015-07-08 18:16:51 +0530121 copy_value_in_all_row: function(doc, dt, dn, table_fieldname, fieldname) {
122 var d = locals[dt][dn];
123 if(d[fieldname]){
124 var cl = doc[table_fieldname] || [];
125 for(var i = 0; i < cl.length; i++) {
126 if(!cl[i][fieldname]) cl[i][fieldname] = d[fieldname];
127 }
128 }
129 refresh_field(table_fieldname);
Makarand Bauskar157c3342017-05-26 21:32:33 +0530130 },
131
132 get_terms: function(tc_name, doc, callback) {
133 if(tc_name) {
134 return frappe.call({
135 method: 'erpnext.setup.doctype.terms_and_conditions.terms_and_conditions.get_terms_and_conditions',
136 args: {
137 template_name: tc_name,
138 doc: doc
139 },
140 callback: function(r) {
141 callback(r)
142 }
143 });
144 }
tundebabzy1a947db2017-08-29 13:48:27 +0100145 },
146
rohitwaghchaure166b78f2017-09-07 16:14:22 +0530147 make_subscription: function(doctype, docname) {
148 frappe.call({
rohitwaghchaure79e5b072018-06-21 12:58:14 +0530149 method: "frappe.desk.doctype.auto_repeat.auto_repeat.make_auto_repeat",
rohitwaghchaure166b78f2017-09-07 16:14:22 +0530150 args: {
151 doctype: doctype,
152 docname: docname
153 },
154 callback: function(r) {
155 var doclist = frappe.model.sync(r.message);
156 frappe.set_route("Form", doclist[0].doctype, doclist[0].name);
157 }
158 })
159 },
160
tundebabzy1a947db2017-08-29 13:48:27 +0100161 /**
162 * Checks if the first row of a given child table is empty
163 * @param child_table - Child table Doctype
164 * @return {Boolean}
165 **/
166 first_row_is_empty: function(child_table){
167 if($.isArray(child_table) && child_table.length > 0) {
168 return !child_table[0].item_code;
169 }
170 return false;
171 },
172
173 /**
174 * Removes the first row of a child table if it is empty
175 * @param {_Frm} frm - The current form
176 * @param {String} child_table_name - The child table field name
177 * @return {Boolean}
178 **/
179 remove_empty_first_row: function(frm, child_table_name){
180 const rows = frm['doc'][child_table_name];
181 if (this.first_row_is_empty(rows)){
182 frm['doc'][child_table_name] = rows.splice(1);
183 }
184 return rows;
185 },
Zarrar6ffdf942018-06-14 12:24:16 +0530186 get_tree_options: function(option) {
187 // get valid options for tree based on user permission & locals dict
188 let unscrub_option = frappe.model.unscrub(option);
189 let user_permission = frappe.defaults.get_user_permissions();
190 if(user_permission && user_permission[unscrub_option]) {
191 return user_permission[unscrub_option]["docs"];
192 } else {
193 return $.map(locals[`:${unscrub_option}`], function(c) { return c.name; }).sort();
194 }
195 },
196 get_tree_default: function(option) {
197 // set default for a field based on user permission
198 let options = this.get_tree_options(option);
199 if(options.includes(frappe.defaults.get_default(option))) {
200 return frappe.defaults.get_default(option);
201 } else {
202 return options[0];
203 }
204 }
Rushabh Mehta95b995b2015-05-28 12:10:55 +0530205});
206
rohitwaghchaurea3c3dec2018-03-28 11:51:44 +0530207erpnext.utils.select_alternate_items = function(opts) {
208 const frm = opts.frm;
209 const warehouse_field = opts.warehouse_field || 'warehouse';
210 const item_field = opts.item_field || 'item_code';
211
212 this.data = [];
213 const dialog = new frappe.ui.Dialog({
214 title: __("Select Alternate Item"),
215 fields: [
216 {fieldtype:'Section Break', label: __('Items')},
217 {
218 fieldname: "alternative_items", fieldtype: "Table", cannot_add_rows: true,
219 in_place_edit: true, data: this.data,
220 get_data: () => {
221 return this.data;
222 },
223 fields: [{
224 fieldtype:'Data',
225 fieldname:"docname",
226 hidden: 1
227 }, {
228 fieldtype:'Link',
229 fieldname:"item_code",
230 options: 'Item',
231 in_list_view: 1,
232 read_only: 1,
233 label: __('Item Code')
234 }, {
235 fieldtype:'Link',
236 fieldname:"alternate_item",
237 options: 'Item',
238 default: "",
239 in_list_view: 1,
240 label: __('Alternate Item'),
241 onchange: function() {
242 const item_code = this.get_value();
243 const warehouse = this.grid_row.on_grid_fields_dict.warehouse.get_value();
244 if (item_code && warehouse) {
245 frappe.call({
246 method: "erpnext.stock.utils.get_latest_stock_qty",
247 args: {
248 item_code: item_code,
249 warehouse: warehouse
250 },
251 callback: (r) => {
252 this.grid_row.on_grid_fields_dict
253 .actual_qty.set_value(r.message || 0);
254 }
255 })
256 }
257 },
258 get_query: (e) => {
259 return {
260 query: "erpnext.stock.doctype.item_alternative.item_alternative.get_alternative_items",
261 filters: {
262 item_code: e.item_code
263 }
264 };
265 }
266 }, {
267 fieldtype:'Link',
268 fieldname:"warehouse",
269 options: 'Warehouse',
270 default: "",
271 in_list_view: 1,
272 label: __('Warehouse'),
273 onchange: function() {
274 const warehouse = this.get_value();
275 const item_code = this.grid_row.on_grid_fields_dict.item_code.get_value();
276 if (item_code && warehouse) {
277 frappe.call({
278 method: "erpnext.stock.utils.get_latest_stock_qty",
279 args: {
280 item_code: item_code,
281 warehouse: warehouse
282 },
283 callback: (r) => {
284 this.grid_row.on_grid_fields_dict
285 .actual_qty.set_value(r.message || 0);
286 }
287 })
288 }
289 },
290 }, {
291 fieldtype:'Float',
292 fieldname:"actual_qty",
293 default: 0,
294 read_only: 1,
295 in_list_view: 1,
296 label: __('Available Qty')
297 }]
298 },
299 ],
300 primary_action: function() {
301 const args = this.get_values()["alternative_items"];
302 const alternative_items = args.filter(d => {
303 if (d.alternate_item && d.item_code != d.alternate_item) {
304 return true;
305 }
306 });
307
308 alternative_items.forEach(d => {
309 let row = frappe.get_doc(opts.child_doctype, d.docname);
Doridel Cahanape42192b2018-05-16 13:28:39 +0800310 let qty = null;
311 if (row.doctype === 'Work Order Item') {
312 qty = row.required_qty;
313 } else {
314 qty = row.qty;
315 }
rohitwaghchaurea3c3dec2018-03-28 11:51:44 +0530316 row[item_field] = d.alternate_item;
rohitwaghchaurea3c3dec2018-03-28 11:51:44 +0530317 frm.script_manager.trigger(item_field, row.doctype, row.name)
318 .then(() => {
319 frappe.model.set_value(row.doctype, row.name, 'qty', qty);
320 frappe.model.set_value(row.doctype, row.name,
321 opts.original_item_field, d.item_code);
322 });
323 });
324
325 refresh_field(opts.child_docname);
326 this.hide();
327 },
328 primary_action_label: __('Update')
329 });
330
331 frm.doc[opts.child_docname].forEach(d => {
332 if (!opts.condition || opts.condition(d)) {
333 dialog.fields_dict.alternative_items.df.data.push({
334 "docname": d.name,
335 "item_code": d[item_field],
336 "warehouse": d[warehouse_field],
337 "actual_qty": d.actual_qty
338 });
339 }
340 })
341
342 this.data = dialog.fields_dict.alternative_items.df.data;
343 dialog.fields_dict.alternative_items.grid.refresh();
344 dialog.show();
345}
346
Doridel Cahanap6f06cc22018-05-17 16:28:58 +0800347erpnext.utils.update_child_items = function(opts) {
348 const frm = opts.frm;
349
350 this.data = [];
351 const dialog = new frappe.ui.Dialog({
352 title: __("Update Items"),
353 fields: [
354 {fieldtype:'Section Break', label: __('Items')},
355 {
356 fieldname: "trans_items", fieldtype: "Table", cannot_add_rows: true,
357 in_place_edit: true, data: this.data,
358 get_data: () => {
359 return this.data;
360 },
361 fields: [{
362 fieldtype:'Data',
363 fieldname:"docname",
364 hidden: 0,
365 }, {
366 fieldtype:'Link',
367 fieldname:"item_code",
368 options: 'Item',
369 in_list_view: 1,
370 read_only: 1,
371 label: __('Item Code')
372 }, {
373 fieldtype:'Float',
374 fieldname:"qty",
375 default: 0,
376 read_only: 0,
377 in_list_view: 1,
378 label: __('Qty')
379 }, {
380 fieldtype:'Currency',
381 fieldname:"rate",
382 default: 0,
383 read_only: 0,
384 in_list_view: 1,
385 label: __('Rate')
386 }]
387 },
388 ],
389 primary_action: function() {
390 const trans_items = this.get_values()["trans_items"];
391 frappe.call({
392 method: 'erpnext.controllers.accounts_controller.update_child_qty_rate',
393 args: {
394 'parent_doctype': frm.doc.doctype,
395 'trans_items': trans_items,
396 'parent_doctype_name': frm.doc.name
397 },
398 callback: function() {
399 frm.reload_doc();
400 }
401 });
402 this.hide();
403 refresh_field("items");
404 },
405 primary_action_label: __('Update')
406 });
407
408 frm.doc[opts.child_docname].forEach(d => {
409 dialog.fields_dict.trans_items.df.data.push({
410 "docname": d.name,
411 "item_code": d.item_code,
412 "qty": d.qty,
413 "rate": d.rate,
414 });
415 this.data = dialog.fields_dict.trans_items.df.data;
416 dialog.fields_dict.trans_items.grid.refresh();
417 })
418 dialog.show();
419}
420
Rushabh Mehta176b63b2016-07-14 17:43:48 +0530421erpnext.utils.map_current_doc = function(opts) {
422 if(opts.get_query_filters) {
423 opts.get_query = function() {
424 return {filters: opts.get_query_filters};
425 }
426 }
427 var _map = function() {
Rushabh Mehta55ea7b12016-07-15 16:43:25 +0530428 if($.isArray(cur_frm.doc.items) && cur_frm.doc.items.length > 0) {
Prateeksha Singhedeb4dc2017-05-15 11:32:06 +0530429 // remove first item row if empty
Rushabh Mehta176b63b2016-07-14 17:43:48 +0530430 if(!cur_frm.doc.items[0].item_code) {
431 cur_frm.doc.items = cur_frm.doc.items.splice(1);
432 }
bhupen3c7e70f2016-11-30 14:32:11 +0530433
434 // find the doctype of the items table
435 var items_doctype = frappe.meta.get_docfield(cur_frm.doctype, 'items').options;
Prateeksha Singhedeb4dc2017-05-15 11:32:06 +0530436
bhupen3c7e70f2016-11-30 14:32:11 +0530437 // find the link fieldname from items table for the given
438 // source_doctype
439 var link_fieldname = null;
Prateeksha Singhedeb4dc2017-05-15 11:32:06 +0530440 frappe.get_meta(items_doctype).fields.forEach(function(d) {
bhupen3c7e70f2016-11-30 14:32:11 +0530441 if(d.options===opts.source_doctype) link_fieldname = d.fieldname; });
442
Nabin Hait802b4352017-01-09 15:32:20 +0530443 // search in existing items if the source_name is already set and full qty fetched
bhupen3c7e70f2016-11-30 14:32:11 +0530444 var already_set = false;
Nabin Hait802b4352017-01-09 15:32:20 +0530445 var item_qty_map = {};
bhupen3c7e70f2016-11-30 14:32:11 +0530446
Prateeksha Singhedeb4dc2017-05-15 11:32:06 +0530447 $.each(cur_frm.doc.items, function(i, d) {
448 opts.source_name.forEach(function(src) {
449 if(d[link_fieldname]==src) {
450 already_set = true;
451 if (item_qty_map[d.item_code])
452 item_qty_map[d.item_code] += flt(d.qty);
453 else
454 item_qty_map[d.item_code] = flt(d.qty);
455 }
456 });
457 });
458
459 if(already_set) {
460 opts.source_name.forEach(function(src) {
461 frappe.model.with_doc(opts.source_doctype, src, function(r) {
462 var source_doc = frappe.model.get_doc(opts.source_doctype, src);
463 $.each(source_doc.items || [], function(i, row) {
464 if(row.qty > flt(item_qty_map[row.item_code])) {
465 already_set = false;
466 return false;
467 }
468 })
469 })
470
471 if(already_set) {
472 frappe.msgprint(__("You have already selected items from {0} {1}",
473 [opts.source_doctype, src]));
474 return;
475 }
476
477 })
Nabin Hait802b4352017-01-09 15:32:20 +0530478 }
Rushabh Mehta176b63b2016-07-14 17:43:48 +0530479 }
480
481 return frappe.call({
482 // Sometimes we hit the limit for URL length of a GET request
483 // as we send the full target_doc. Hence this is a POST request.
484 type: "POST",
Prateeksha Singhedeb4dc2017-05-15 11:32:06 +0530485 method: 'frappe.model.mapper.map_docs',
Rushabh Mehta176b63b2016-07-14 17:43:48 +0530486 args: {
Prateeksha Singhedeb4dc2017-05-15 11:32:06 +0530487 "method": opts.method,
488 "source_names": opts.source_name,
489 "target_doc": cur_frm.doc,
Rushabh Mehta176b63b2016-07-14 17:43:48 +0530490 },
491 callback: function(r) {
492 if(!r.exc) {
493 var doc = frappe.model.sync(r.message);
Vishal Dhayagudef06c2812017-12-26 16:22:40 +0530494 cur_frm.dirty();
Rushabh Mehta176b63b2016-07-14 17:43:48 +0530495 cur_frm.refresh();
496 }
497 }
498 });
499 }
500 if(opts.source_doctype) {
Prateeksha Singhedeb4dc2017-05-15 11:32:06 +0530501 var d = new frappe.ui.form.MultiSelectDialog({
502 doctype: opts.source_doctype,
503 target: opts.target,
504 date_field: opts.date_field || undefined,
505 setters: opts.setters,
506 get_query: opts.get_query,
507 action: function(selections, args) {
508 let values = selections;
509 if(values.length === 0){
Nabin Haita11dcb62017-12-04 13:36:50 +0530510 frappe.msgprint(__("Please select {0}", [opts.source_doctype]))
Prateeksha Singhedeb4dc2017-05-15 11:32:06 +0530511 return;
512 }
513 opts.source_name = values;
514 opts.setters = args;
515 d.dialog.hide();
516 _map();
517 },
Rushabh Mehta176b63b2016-07-14 17:43:48 +0530518 });
Rushabh Mehta176b63b2016-07-14 17:43:48 +0530519 } else if(opts.source_name) {
Prateeksha Singhedeb4dc2017-05-15 11:32:06 +0530520 opts.source_name = [opts.source_name];
Rushabh Mehta176b63b2016-07-14 17:43:48 +0530521 _map();
522 }
523}
524
Rushabh Mehta180e4352016-07-26 17:57:42 +0530525frappe.form.link_formatters['Item'] = function(value, doc) {
Nabin Hait981f6ea2016-07-31 11:44:43 +0530526 if(doc && doc.item_name && doc.item_name !== value) {
mbauskarbe814422016-10-27 09:49:22 +0530527 return value? value + ': ' + doc.item_name: doc.item_name;
Rushabh Mehta180e4352016-07-26 17:57:42 +0530528 } else {
529 return value;
530 }
531}
532
533frappe.form.link_formatters['Employee'] = function(value, doc) {
Nabin Hait981f6ea2016-07-31 11:44:43 +0530534 if(doc && doc.employee_name && doc.employee_name !== value) {
mbauskarbe814422016-10-27 09:49:22 +0530535 return value? value + ': ' + doc.employee_name: doc.employee_name;
Rushabh Mehta180e4352016-07-26 17:57:42 +0530536 } else {
537 return value;
538 }
539}
540
Rushabh Mehta95b995b2015-05-28 12:10:55 +0530541// add description on posting time
542$(document).on('app_ready', function() {
543 if(!frappe.datetime.is_timezone_same()) {
544 $.each(["Stock Reconciliation", "Stock Entry", "Stock Ledger Entry",
545 "Delivery Note", "Purchase Receipt", "Sales Invoice"], function(i, d) {
546 frappe.ui.form.on(d, "onload", function(frm) {
547 cur_frm.set_df_property("posting_time", "description",
Faris Ansariab74ca72017-05-30 12:54:42 +0530548 frappe.sys_defaults.time_zone);
Rushabh Mehta95b995b2015-05-28 12:10:55 +0530549 });
550 });
551 }
akshay14384c22016-07-28 13:53:17 +0530552});