Anand Doshi | 885e074 | 2015-03-03 14:55:30 +0530 | [diff] [blame] | 1 | // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors |
Rushabh Mehta | e67d1fb | 2013-08-05 14:59:54 +0530 | [diff] [blame] | 2 | // License: GNU General Public License v3. See license.txt |
Rushabh Mehta | 793ba6b | 2014-02-14 15:47:51 +0530 | [diff] [blame] | 3 | frappe.provide("erpnext"); |
Nabin Hait | b072c74 | 2014-12-16 12:49:13 +0530 | [diff] [blame] | 4 | frappe.provide("erpnext.utils"); |
Anand Doshi | e65e621 | 2012-11-19 15:43:18 +0530 | [diff] [blame] | 5 | |
Anand Doshi | bdee6e0 | 2013-07-09 13:03:39 +0530 | [diff] [blame] | 6 | $.extend(erpnext, { |
| 7 | get_currency: function(company) { |
| 8 | if(!company && cur_frm) |
| 9 | company = cur_frm.doc.company; |
| 10 | if(company) |
Rushabh Mehta | 66d52b5 | 2014-03-27 14:17:33 +0530 | [diff] [blame] | 11 | return frappe.get_doc(":Company", company).default_currency || frappe.boot.sysdefaults.currency; |
Anand Doshi | bdee6e0 | 2013-07-09 13:03:39 +0530 | [diff] [blame] | 12 | else |
Rushabh Mehta | 793ba6b | 2014-02-14 15:47:51 +0530 | [diff] [blame] | 13 | return frappe.boot.sysdefaults.currency; |
Anand Doshi | bdee6e0 | 2013-07-09 13:03:39 +0530 | [diff] [blame] | 14 | }, |
Rushabh Mehta | c38fc71 | 2014-04-16 17:21:25 +0530 | [diff] [blame] | 15 | |
tundebabzy | c897825 | 2018-02-12 10:34:50 +0100 | [diff] [blame] | 16 | get_presentation_currency_list: () => { |
| 17 | const docs = frappe.boot.docs; |
Zarrar | e25dcd2 | 2018-06-21 10:53:12 +0530 | [diff] [blame] | 18 | let currency_list = docs.filter(d => d.doctype === ":Currency").map(d => d.name); |
| 19 | currency_list.unshift(""); |
tundebabzy | c897825 | 2018-02-12 10:34:50 +0100 | [diff] [blame] | 20 | return currency_list; |
| 21 | }, |
| 22 | |
Anand Doshi | 8bde7f9 | 2014-04-24 18:11:49 +0530 | [diff] [blame] | 23 | toggle_naming_series: function() { |
Rushabh Mehta | c38fc71 | 2014-04-16 17:21:25 +0530 | [diff] [blame] | 24 | if(cur_frm.fields_dict.naming_series) { |
Anand Doshi | bdee6e0 | 2013-07-09 13:03:39 +0530 | [diff] [blame] | 25 | cur_frm.toggle_display("naming_series", cur_frm.doc.__islocal?true:false); |
| 26 | } |
| 27 | }, |
Rushabh Mehta | c38fc71 | 2014-04-16 17:21:25 +0530 | [diff] [blame] | 28 | |
Anand Doshi | bdee6e0 | 2013-07-09 13:03:39 +0530 | [diff] [blame] | 29 | hide_company: function() { |
| 30 | if(cur_frm.fields_dict.company) { |
Rushabh Mehta | 8941841 | 2013-10-07 18:22:29 +0530 | [diff] [blame] | 31 | var companies = Object.keys(locals[":Company"] || {}); |
Anand Doshi | bdee6e0 | 2013-07-09 13:03:39 +0530 | [diff] [blame] | 32 | 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 Mehta | 45ca8a4 | 2015-04-28 16:02:09 +0530 | [diff] [blame] | 35 | } else if(erpnext.last_selected_company) { |
| 36 | if(!cur_frm.doc.company) cur_frm.set_value("company", erpnext.last_selected_company); |
Anand Doshi | bdee6e0 | 2013-07-09 13:03:39 +0530 | [diff] [blame] | 37 | } |
| 38 | } |
Anand Doshi | 1ffc5b5 | 2013-07-15 18:09:43 +0530 | [diff] [blame] | 39 | }, |
Rushabh Mehta | c38fc71 | 2014-04-16 17:21:25 +0530 | [diff] [blame] | 40 | |
Rohit Waghchaure | e9ff191 | 2017-06-19 12:54:59 +0530 | [diff] [blame] | 41 | is_perpetual_inventory_enabled: function(company) { |
| 42 | if(company) { |
| 43 | return frappe.get_doc(":Company", company).enable_perpetual_inventory |
| 44 | } |
| 45 | }, |
| 46 | |
Makarand Bauskar | e6712c1 | 2017-10-25 12:17:40 +0530 | [diff] [blame] | 47 | stale_rate_allowed: () => { |
rohitwaghchaure | 7677ff0 | 2017-11-02 18:12:14 +0530 | [diff] [blame] | 48 | return cint(frappe.boot.sysdefaults.allow_stale); |
Makarand Bauskar | e6712c1 | 2017-10-25 12:17:40 +0530 | [diff] [blame] | 49 | }, |
| 50 | |
Rushabh Mehta | 2a21bc9 | 2015-02-25 15:08:42 +0530 | [diff] [blame] | 51 | setup_serial_no: function() { |
| 52 | var grid_row = cur_frm.open_grid_row(); |
akshay | 14384c2 | 2016-07-28 13:53:17 +0530 | [diff] [blame] | 53 | 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 Mehta | c38fc71 | 2014-04-16 17:21:25 +0530 | [diff] [blame] | 55 | |
Pratik Vyas | b52618c | 2014-04-14 16:25:30 +0530 | [diff] [blame] | 56 | var $btn = $('<button class="btn btn-sm btn-default">'+__("Add Serial No")+'</button>') |
Rushabh Mehta | 62030e0 | 2013-08-14 18:37:28 +0530 | [diff] [blame] | 57 | .appendTo($("<div>") |
Rushabh Mehta | 2a21bc9 | 2015-02-25 15:08:42 +0530 | [diff] [blame] | 58 | .css({"margin-bottom": "10px", "margin-top": "10px"}) |
akshay | 14384c2 | 2016-07-28 13:53:17 +0530 | [diff] [blame] | 59 | .appendTo(grid_row.grid_form.fields_dict.serial_no.$wrapper)); |
Rushabh Mehta | c38fc71 | 2014-04-16 17:21:25 +0530 | [diff] [blame] | 60 | |
scmmishra | ed4b052 | 2019-04-16 17:03:25 +0530 | [diff] [blame] | 61 | var me = this; |
Rushabh Mehta | 62030e0 | 2013-08-14 18:37:28 +0530 | [diff] [blame] | 62 | $btn.on("click", function() { |
Rohit Waghchaure | dadd049 | 2019-08-02 19:11:31 +0530 | [diff] [blame] | 63 | let callback = ''; |
| 64 | let on_close = ''; |
| 65 | |
Marica | 29a2e16 | 2019-11-12 14:43:41 +0530 | [diff] [blame] | 66 | frappe.model.get_value('Item', {'name':grid_row.doc.item_code}, 'has_serial_no', |
| 67 | (data) => { |
| 68 | if(data) { |
| 69 | grid_row.doc.has_serial_no = data.has_serial_no; |
| 70 | me.show_serial_batch_selector(grid_row.frm, grid_row.doc, |
| 71 | callback, on_close, true); |
| 72 | } |
| 73 | } |
| 74 | ); |
Rushabh Mehta | 62030e0 | 2013-08-14 18:37:28 +0530 | [diff] [blame] | 75 | }); |
deepeshgarg007 | e64c357 | 2019-05-14 08:50:45 +0530 | [diff] [blame] | 76 | }, |
Nabin Hait | 1ed1c4e | 2019-11-25 12:33:40 +0530 | [diff] [blame] | 77 | |
| 78 | route_to_adjustment_jv: (args) => { |
| 79 | frappe.model.with_doctype('Journal Entry', () => { |
| 80 | // route to adjustment Journal Entry to handle Account Balance and Stock Value mismatch |
| 81 | let journal_entry = frappe.model.get_new_doc('Journal Entry'); |
| 82 | |
| 83 | args.accounts.forEach((je_account) => { |
| 84 | let child_row = frappe.model.add_child(journal_entry, "accounts"); |
| 85 | child_row.account = je_account.account; |
| 86 | child_row.debit_in_account_currency = je_account.debit_in_account_currency; |
| 87 | child_row.credit_in_account_currency = je_account.credit_in_account_currency; |
| 88 | child_row.party_type = "" ; |
| 89 | }); |
| 90 | frappe.set_route('Form','Journal Entry', journal_entry.name); |
| 91 | }); |
| 92 | } |
Rushabh Mehta | c38fc71 | 2014-04-16 17:21:25 +0530 | [diff] [blame] | 93 | }); |
Rushabh Mehta | 7d36875 | 2014-11-24 14:16:47 +0530 | [diff] [blame] | 94 | |
Nabin Hait | b072c74 | 2014-12-16 12:49:13 +0530 | [diff] [blame] | 95 | |
| 96 | $.extend(erpnext.utils, { |
Rushabh Mehta | 559aa3a | 2016-09-19 16:04:58 +0530 | [diff] [blame] | 97 | set_party_dashboard_indicators: function(frm) { |
| 98 | if(frm.doc.__onload && frm.doc.__onload.dashboard_info) { |
deepeshgarg007 | 920dc14 | 2018-11-23 10:17:28 +0530 | [diff] [blame] | 99 | var company_wise_info = frm.doc.__onload.dashboard_info; |
deepeshgarg007 | f31caff | 2018-11-27 15:04:12 +0530 | [diff] [blame] | 100 | if(company_wise_info.length > 1) { |
deepeshgarg007 | a1cffc3 | 2018-11-23 16:51:35 +0530 | [diff] [blame] | 101 | company_wise_info.forEach(function(info) { |
deepeshgarg007 | 12f5cef | 2018-12-25 16:06:19 +0530 | [diff] [blame] | 102 | erpnext.utils.add_indicator_for_multicompany(frm, info); |
deepeshgarg007 | a1cffc3 | 2018-11-23 16:51:35 +0530 | [diff] [blame] | 103 | }); |
deepeshgarg007 | 12f5cef | 2018-12-25 16:06:19 +0530 | [diff] [blame] | 104 | } else if (company_wise_info.length === 1) { |
deepeshgarg007 | 64238ee | 2018-12-25 16:28:39 +0530 | [diff] [blame] | 105 | frm.dashboard.add_indicator(__('Annual Billing: {0}', |
| 106 | [format_currency(company_wise_info[0].billing_this_year, company_wise_info[0].currency)]), 'blue'); |
| 107 | frm.dashboard.add_indicator(__('Total Unpaid: {0}', |
| 108 | [format_currency(company_wise_info[0].total_unpaid, company_wise_info[0].currency)]), |
deepeshgarg007 | 8300f5e | 2019-01-01 20:28:49 +0530 | [diff] [blame] | 109 | company_wise_info[0].total_unpaid ? 'orange' : 'green'); |
deepeshgarg007 | 12f5cef | 2018-12-25 16:06:19 +0530 | [diff] [blame] | 110 | |
deepeshgarg007 | 64238ee | 2018-12-25 16:28:39 +0530 | [diff] [blame] | 111 | if(company_wise_info[0].loyalty_points) { |
| 112 | frm.dashboard.add_indicator(__('Loyalty Points: {0}', |
| 113 | [company_wise_info[0].loyalty_points]), 'blue'); |
| 114 | } |
deepeshgarg007 | f31caff | 2018-11-27 15:04:12 +0530 | [diff] [blame] | 115 | } |
Rushabh Mehta | 559aa3a | 2016-09-19 16:04:58 +0530 | [diff] [blame] | 116 | } |
| 117 | }, |
| 118 | |
deepeshgarg007 | 12f5cef | 2018-12-25 16:06:19 +0530 | [diff] [blame] | 119 | add_indicator_for_multicompany: function(frm, info) { |
| 120 | frm.dashboard.stats_area.removeClass('hidden'); |
| 121 | frm.dashboard.stats_area_row.addClass('flex'); |
| 122 | frm.dashboard.stats_area_row.css('flex-wrap', 'wrap'); |
| 123 | |
| 124 | var color = info.total_unpaid ? 'orange' : 'green'; |
| 125 | |
| 126 | var indicator = $('<div class="flex-column col-xs-6">'+ |
| 127 | '<div style="margin-top:10px"><h6>'+info.company+'</h6></div>'+ |
| 128 | |
| 129 | '<div class="badge-link small" style="margin-bottom:10px"><span class="indicator blue">'+ |
| 130 | 'Annual Billing: '+format_currency(info.billing_this_year, info.currency)+'</span></div>'+ |
| 131 | |
| 132 | '<div class="badge-link small" style="margin-bottom:10px">'+ |
| 133 | '<span class="indicator '+color+'">Total Unpaid: ' |
| 134 | +format_currency(info.total_unpaid, info.currency)+'</span></div>'+ |
| 135 | |
| 136 | |
| 137 | '</div>').appendTo(frm.dashboard.stats_area_row); |
| 138 | |
| 139 | if(info.loyalty_points){ |
| 140 | $('<div class="badge-link small" style="margin-bottom:10px"><span class="indicator blue">'+ |
| 141 | 'Loyalty Points: '+info.loyalty_points+'</span></div>').appendTo(indicator); |
| 142 | } |
| 143 | |
| 144 | return indicator; |
| 145 | }, |
| 146 | |
Shreya Shah | 149f7ee | 2018-03-27 11:29:25 +0530 | [diff] [blame] | 147 | get_party_name: function(party_type) { |
| 148 | var dict = {'Customer': 'customer_name', 'Supplier': 'supplier_name', 'Employee': 'employee_name', |
| 149 | 'Member': 'member_name'}; |
| 150 | return dict[party_type]; |
| 151 | }, |
| 152 | |
Rushabh Mehta | 49f9747 | 2018-08-30 18:50:48 +0530 | [diff] [blame] | 153 | copy_value_in_all_rows: function(doc, dt, dn, table_fieldname, fieldname) { |
Neil Trini Lasrado | fe2ffae | 2015-07-08 18:16:51 +0530 | [diff] [blame] | 154 | var d = locals[dt][dn]; |
| 155 | if(d[fieldname]){ |
| 156 | var cl = doc[table_fieldname] || []; |
| 157 | for(var i = 0; i < cl.length; i++) { |
| 158 | if(!cl[i][fieldname]) cl[i][fieldname] = d[fieldname]; |
| 159 | } |
| 160 | } |
| 161 | refresh_field(table_fieldname); |
Makarand Bauskar | 157c334 | 2017-05-26 21:32:33 +0530 | [diff] [blame] | 162 | }, |
| 163 | |
| 164 | get_terms: function(tc_name, doc, callback) { |
| 165 | if(tc_name) { |
| 166 | return frappe.call({ |
| 167 | method: 'erpnext.setup.doctype.terms_and_conditions.terms_and_conditions.get_terms_and_conditions', |
| 168 | args: { |
| 169 | template_name: tc_name, |
| 170 | doc: doc |
| 171 | }, |
| 172 | callback: function(r) { |
| 173 | callback(r) |
| 174 | } |
| 175 | }); |
| 176 | } |
tundebabzy | 1a947db | 2017-08-29 13:48:27 +0100 | [diff] [blame] | 177 | }, |
| 178 | |
rohitwaghchaure | 713cfc7 | 2018-09-11 17:40:37 +0530 | [diff] [blame] | 179 | make_bank_account: function(doctype, docname) { |
| 180 | frappe.call({ |
| 181 | method: "erpnext.accounts.doctype.bank_account.bank_account.make_bank_account", |
| 182 | args: { |
| 183 | doctype: doctype, |
| 184 | docname: docname |
| 185 | }, |
| 186 | freeze: true, |
| 187 | callback: function(r) { |
| 188 | var doclist = frappe.model.sync(r.message); |
| 189 | frappe.set_route("Form", doclist[0].doctype, doclist[0].name); |
| 190 | } |
| 191 | }) |
| 192 | }, |
| 193 | |
Deepesh Garg | 11ea0b1 | 2020-05-26 19:23:45 +0530 | [diff] [blame] | 194 | add_dimensions: function(report_name, index) { |
| 195 | let filters = frappe.query_reports[report_name].filters; |
| 196 | |
| 197 | erpnext.dimension_filters.forEach((dimension) => { |
| 198 | let found = filters.some(el => el.fieldname === dimension['fieldname']); |
| 199 | |
| 200 | if (!found) { |
| 201 | filters.splice(index, 0 ,{ |
| 202 | "fieldname": dimension["fieldname"], |
| 203 | "label": __(dimension["label"]), |
| 204 | "fieldtype": "Link", |
| 205 | "options": dimension["document_type"] |
| 206 | }); |
| 207 | } |
| 208 | }); |
| 209 | }, |
| 210 | |
rohitwaghchaure | 166b78f | 2017-09-07 16:14:22 +0530 | [diff] [blame] | 211 | make_subscription: function(doctype, docname) { |
| 212 | frappe.call({ |
Rucha Mahabal | 65a627c | 2019-07-17 13:50:32 +0530 | [diff] [blame] | 213 | method: "frappe.automation.doctype.auto_repeat.auto_repeat.make_auto_repeat", |
rohitwaghchaure | 166b78f | 2017-09-07 16:14:22 +0530 | [diff] [blame] | 214 | args: { |
| 215 | doctype: doctype, |
| 216 | docname: docname |
| 217 | }, |
| 218 | callback: function(r) { |
| 219 | var doclist = frappe.model.sync(r.message); |
| 220 | frappe.set_route("Form", doclist[0].doctype, doclist[0].name); |
| 221 | } |
| 222 | }) |
| 223 | }, |
| 224 | |
Saif | 90cf2dd | 2018-09-30 21:46:31 +0500 | [diff] [blame] | 225 | make_pricing_rule: function(doctype, docname) { |
| 226 | frappe.call({ |
| 227 | method: "erpnext.accounts.doctype.pricing_rule.pricing_rule.make_pricing_rule", |
| 228 | args: { |
| 229 | doctype: doctype, |
| 230 | docname: docname |
| 231 | }, |
| 232 | callback: function(r) { |
| 233 | var doclist = frappe.model.sync(r.message); |
| 234 | frappe.set_route("Form", doclist[0].doctype, doclist[0].name); |
| 235 | } |
| 236 | }) |
| 237 | }, |
| 238 | |
tundebabzy | 1a947db | 2017-08-29 13:48:27 +0100 | [diff] [blame] | 239 | /** |
| 240 | * Checks if the first row of a given child table is empty |
| 241 | * @param child_table - Child table Doctype |
| 242 | * @return {Boolean} |
| 243 | **/ |
| 244 | first_row_is_empty: function(child_table){ |
| 245 | if($.isArray(child_table) && child_table.length > 0) { |
| 246 | return !child_table[0].item_code; |
| 247 | } |
| 248 | return false; |
| 249 | }, |
| 250 | |
| 251 | /** |
| 252 | * Removes the first row of a child table if it is empty |
| 253 | * @param {_Frm} frm - The current form |
| 254 | * @param {String} child_table_name - The child table field name |
| 255 | * @return {Boolean} |
| 256 | **/ |
| 257 | remove_empty_first_row: function(frm, child_table_name){ |
| 258 | const rows = frm['doc'][child_table_name]; |
| 259 | if (this.first_row_is_empty(rows)){ |
| 260 | frm['doc'][child_table_name] = rows.splice(1); |
| 261 | } |
| 262 | return rows; |
| 263 | }, |
Zarrar | 6ffdf94 | 2018-06-14 12:24:16 +0530 | [diff] [blame] | 264 | get_tree_options: function(option) { |
| 265 | // get valid options for tree based on user permission & locals dict |
| 266 | let unscrub_option = frappe.model.unscrub(option); |
| 267 | let user_permission = frappe.defaults.get_user_permissions(); |
deepeshgarg007 | 0d64d62 | 2019-02-20 17:55:14 +0530 | [diff] [blame] | 268 | let options; |
| 269 | |
Zarrar | 6ffdf94 | 2018-06-14 12:24:16 +0530 | [diff] [blame] | 270 | if(user_permission && user_permission[unscrub_option]) { |
deepeshgarg007 | 0d64d62 | 2019-02-20 17:55:14 +0530 | [diff] [blame] | 271 | options = user_permission[unscrub_option].map(perm => perm.doc); |
Zarrar | 6ffdf94 | 2018-06-14 12:24:16 +0530 | [diff] [blame] | 272 | } else { |
deepeshgarg007 | 0d64d62 | 2019-02-20 17:55:14 +0530 | [diff] [blame] | 273 | options = $.map(locals[`:${unscrub_option}`], function(c) { return c.name; }).sort(); |
Zarrar | 6ffdf94 | 2018-06-14 12:24:16 +0530 | [diff] [blame] | 274 | } |
deepeshgarg007 | 0d64d62 | 2019-02-20 17:55:14 +0530 | [diff] [blame] | 275 | |
| 276 | // filter unique values, as there may be multiple user permissions for any value |
| 277 | return options.filter((value, index, self) => self.indexOf(value) === index); |
Zarrar | 6ffdf94 | 2018-06-14 12:24:16 +0530 | [diff] [blame] | 278 | }, |
| 279 | get_tree_default: function(option) { |
| 280 | // set default for a field based on user permission |
| 281 | let options = this.get_tree_options(option); |
| 282 | if(options.includes(frappe.defaults.get_default(option))) { |
| 283 | return frappe.defaults.get_default(option); |
| 284 | } else { |
| 285 | return options[0]; |
| 286 | } |
Sanjay Kumar | 1b49f3a | 2018-09-06 13:09:35 +0400 | [diff] [blame] | 287 | }, |
| 288 | copy_parent_value_in_all_row: function(doc, dt, dn, table_fieldname, fieldname, parent_fieldname) { |
| 289 | var d = locals[dt][dn]; |
| 290 | if(d[fieldname]){ |
| 291 | var cl = doc[table_fieldname] || []; |
| 292 | for(var i = 0; i < cl.length; i++) { |
| 293 | cl[i][fieldname] = doc[parent_fieldname]; |
| 294 | } |
| 295 | } |
| 296 | refresh_field(table_fieldname); |
| 297 | }, |
| 298 | |
Nabin Hait | 34c551d | 2019-07-03 10:34:31 +0530 | [diff] [blame] | 299 | create_new_doc: function (doctype, update_fields) { |
| 300 | frappe.model.with_doctype(doctype, function() { |
| 301 | var new_doc = frappe.model.get_new_doc(doctype); |
| 302 | for (let [key, value] of Object.entries(update_fields)) { |
| 303 | new_doc[key] = value; |
| 304 | } |
| 305 | frappe.ui.form.make_quick_entry(doctype, null, null, new_doc); |
| 306 | }); |
| 307 | } |
| 308 | |
Rushabh Mehta | 95b995b | 2015-05-28 12:10:55 +0530 | [diff] [blame] | 309 | }); |
| 310 | |
rohitwaghchaure | a3c3dec | 2018-03-28 11:51:44 +0530 | [diff] [blame] | 311 | erpnext.utils.select_alternate_items = function(opts) { |
| 312 | const frm = opts.frm; |
| 313 | const warehouse_field = opts.warehouse_field || 'warehouse'; |
| 314 | const item_field = opts.item_field || 'item_code'; |
| 315 | |
| 316 | this.data = []; |
| 317 | const dialog = new frappe.ui.Dialog({ |
| 318 | title: __("Select Alternate Item"), |
| 319 | fields: [ |
| 320 | {fieldtype:'Section Break', label: __('Items')}, |
| 321 | { |
| 322 | fieldname: "alternative_items", fieldtype: "Table", cannot_add_rows: true, |
| 323 | in_place_edit: true, data: this.data, |
| 324 | get_data: () => { |
| 325 | return this.data; |
| 326 | }, |
| 327 | fields: [{ |
| 328 | fieldtype:'Data', |
| 329 | fieldname:"docname", |
| 330 | hidden: 1 |
| 331 | }, { |
| 332 | fieldtype:'Link', |
| 333 | fieldname:"item_code", |
| 334 | options: 'Item', |
| 335 | in_list_view: 1, |
| 336 | read_only: 1, |
| 337 | label: __('Item Code') |
| 338 | }, { |
| 339 | fieldtype:'Link', |
| 340 | fieldname:"alternate_item", |
| 341 | options: 'Item', |
| 342 | default: "", |
| 343 | in_list_view: 1, |
| 344 | label: __('Alternate Item'), |
| 345 | onchange: function() { |
| 346 | const item_code = this.get_value(); |
| 347 | const warehouse = this.grid_row.on_grid_fields_dict.warehouse.get_value(); |
| 348 | if (item_code && warehouse) { |
| 349 | frappe.call({ |
| 350 | method: "erpnext.stock.utils.get_latest_stock_qty", |
| 351 | args: { |
| 352 | item_code: item_code, |
| 353 | warehouse: warehouse |
| 354 | }, |
| 355 | callback: (r) => { |
| 356 | this.grid_row.on_grid_fields_dict |
| 357 | .actual_qty.set_value(r.message || 0); |
| 358 | } |
| 359 | }) |
| 360 | } |
| 361 | }, |
| 362 | get_query: (e) => { |
| 363 | return { |
| 364 | query: "erpnext.stock.doctype.item_alternative.item_alternative.get_alternative_items", |
| 365 | filters: { |
| 366 | item_code: e.item_code |
| 367 | } |
| 368 | }; |
| 369 | } |
| 370 | }, { |
| 371 | fieldtype:'Link', |
| 372 | fieldname:"warehouse", |
| 373 | options: 'Warehouse', |
| 374 | default: "", |
| 375 | in_list_view: 1, |
| 376 | label: __('Warehouse'), |
| 377 | onchange: function() { |
| 378 | const warehouse = this.get_value(); |
| 379 | const item_code = this.grid_row.on_grid_fields_dict.item_code.get_value(); |
| 380 | if (item_code && warehouse) { |
| 381 | frappe.call({ |
| 382 | method: "erpnext.stock.utils.get_latest_stock_qty", |
| 383 | args: { |
| 384 | item_code: item_code, |
| 385 | warehouse: warehouse |
| 386 | }, |
| 387 | callback: (r) => { |
| 388 | this.grid_row.on_grid_fields_dict |
| 389 | .actual_qty.set_value(r.message || 0); |
| 390 | } |
| 391 | }) |
| 392 | } |
| 393 | }, |
| 394 | }, { |
| 395 | fieldtype:'Float', |
| 396 | fieldname:"actual_qty", |
| 397 | default: 0, |
| 398 | read_only: 1, |
| 399 | in_list_view: 1, |
| 400 | label: __('Available Qty') |
| 401 | }] |
| 402 | }, |
| 403 | ], |
| 404 | primary_action: function() { |
| 405 | const args = this.get_values()["alternative_items"]; |
| 406 | const alternative_items = args.filter(d => { |
| 407 | if (d.alternate_item && d.item_code != d.alternate_item) { |
| 408 | return true; |
| 409 | } |
| 410 | }); |
| 411 | |
| 412 | alternative_items.forEach(d => { |
| 413 | let row = frappe.get_doc(opts.child_doctype, d.docname); |
Doridel Cahanap | e42192b | 2018-05-16 13:28:39 +0800 | [diff] [blame] | 414 | let qty = null; |
| 415 | if (row.doctype === 'Work Order Item') { |
| 416 | qty = row.required_qty; |
| 417 | } else { |
| 418 | qty = row.qty; |
| 419 | } |
rohitwaghchaure | a3c3dec | 2018-03-28 11:51:44 +0530 | [diff] [blame] | 420 | row[item_field] = d.alternate_item; |
rohitwaghchaure | a3c3dec | 2018-03-28 11:51:44 +0530 | [diff] [blame] | 421 | frm.script_manager.trigger(item_field, row.doctype, row.name) |
| 422 | .then(() => { |
| 423 | frappe.model.set_value(row.doctype, row.name, 'qty', qty); |
| 424 | frappe.model.set_value(row.doctype, row.name, |
| 425 | opts.original_item_field, d.item_code); |
| 426 | }); |
| 427 | }); |
| 428 | |
| 429 | refresh_field(opts.child_docname); |
| 430 | this.hide(); |
| 431 | }, |
| 432 | primary_action_label: __('Update') |
| 433 | }); |
| 434 | |
| 435 | frm.doc[opts.child_docname].forEach(d => { |
| 436 | if (!opts.condition || opts.condition(d)) { |
| 437 | dialog.fields_dict.alternative_items.df.data.push({ |
| 438 | "docname": d.name, |
| 439 | "item_code": d[item_field], |
| 440 | "warehouse": d[warehouse_field], |
| 441 | "actual_qty": d.actual_qty |
| 442 | }); |
| 443 | } |
| 444 | }) |
| 445 | |
| 446 | this.data = dialog.fields_dict.alternative_items.df.data; |
| 447 | dialog.fields_dict.alternative_items.grid.refresh(); |
| 448 | dialog.show(); |
| 449 | } |
| 450 | |
Doridel Cahanap | 6f06cc2 | 2018-05-17 16:28:58 +0800 | [diff] [blame] | 451 | erpnext.utils.update_child_items = function(opts) { |
| 452 | const frm = opts.frm; |
Stavros Anastasiadis | 3d82b74 | 2018-12-10 13:00:55 +0100 | [diff] [blame] | 453 | const cannot_add_row = (typeof opts.cannot_add_row === 'undefined') ? true : opts.cannot_add_row; |
| 454 | const child_docname = (typeof opts.cannot_add_row === 'undefined') ? "items" : opts.child_docname; |
Saqib | 56fea7d | 2020-10-09 21:19:25 +0530 | [diff] [blame] | 455 | const child_meta = frappe.get_meta(`${frm.doc.doctype} Item`); |
| 456 | const get_precision = (fieldname) => child_meta.fields.find(f => f.fieldname == fieldname).precision; |
| 457 | |
Doridel Cahanap | 6f06cc2 | 2018-05-17 16:28:58 +0800 | [diff] [blame] | 458 | this.data = []; |
Saqib Ansari | f53299e | 2020-04-15 22:08:12 +0530 | [diff] [blame] | 459 | const fields = [{ |
| 460 | fieldtype:'Data', |
| 461 | fieldname:"docname", |
| 462 | read_only: 1, |
| 463 | hidden: 1, |
| 464 | }, { |
| 465 | fieldtype:'Link', |
| 466 | fieldname:"item_code", |
| 467 | options: 'Item', |
| 468 | in_list_view: 1, |
| 469 | read_only: 0, |
| 470 | disabled: 0, |
| 471 | label: __('Item Code') |
| 472 | }, { |
Saqib | 6131424 | 2020-09-15 11:14:31 +0530 | [diff] [blame] | 473 | fieldtype:'Link', |
| 474 | fieldname:'uom', |
| 475 | options: 'UOM', |
| 476 | read_only: 0, |
| 477 | label: __('UOM'), |
| 478 | reqd: 1, |
| 479 | onchange: function () { |
| 480 | frappe.call({ |
| 481 | method: "erpnext.stock.get_item_details.get_conversion_factor", |
| 482 | args: { item_code: this.doc.item_code, uom: this.value }, |
| 483 | callback: r => { |
| 484 | if(!r.exc) { |
| 485 | if (this.doc.conversion_factor == r.message.conversion_factor) return; |
marination | 4f395cc | 2020-09-24 12:43:41 +0530 | [diff] [blame] | 486 | |
Saqib | 6131424 | 2020-09-15 11:14:31 +0530 | [diff] [blame] | 487 | const docname = this.doc.docname; |
| 488 | dialog.fields_dict.trans_items.df.data.some(doc => { |
| 489 | if (doc.docname == docname) { |
| 490 | doc.conversion_factor = r.message.conversion_factor; |
| 491 | dialog.fields_dict.trans_items.grid.refresh(); |
| 492 | return true; |
| 493 | } |
| 494 | }) |
| 495 | } |
| 496 | } |
| 497 | }); |
| 498 | } |
| 499 | }, { |
Saqib Ansari | f53299e | 2020-04-15 22:08:12 +0530 | [diff] [blame] | 500 | fieldtype:'Float', |
| 501 | fieldname:"qty", |
| 502 | default: 0, |
| 503 | read_only: 0, |
| 504 | in_list_view: 1, |
Saqib | 56fea7d | 2020-10-09 21:19:25 +0530 | [diff] [blame] | 505 | label: __('Qty'), |
| 506 | precision: get_precision("qty") |
Saqib Ansari | f53299e | 2020-04-15 22:08:12 +0530 | [diff] [blame] | 507 | }, { |
| 508 | fieldtype:'Currency', |
| 509 | fieldname:"rate", |
| 510 | default: 0, |
| 511 | read_only: 0, |
| 512 | in_list_view: 1, |
Saqib | 56fea7d | 2020-10-09 21:19:25 +0530 | [diff] [blame] | 513 | label: __('Rate'), |
| 514 | precision: get_precision("rate") |
Saqib Ansari | f53299e | 2020-04-15 22:08:12 +0530 | [diff] [blame] | 515 | }]; |
| 516 | |
| 517 | if (frm.doc.doctype == 'Sales Order' || frm.doc.doctype == 'Purchase Order' ) { |
| 518 | fields.splice(2, 0, { |
| 519 | fieldtype: 'Date', |
| 520 | fieldname: frm.doc.doctype == 'Sales Order' ? "delivery_date" : "schedule_date", |
| 521 | in_list_view: 1, |
Saqib Ansari | c579b08 | 2020-05-29 22:21:50 +0530 | [diff] [blame] | 522 | label: frm.doc.doctype == 'Sales Order' ? __("Delivery Date") : __("Reqd by date"), |
| 523 | reqd: 1 |
Saqib Ansari | f53299e | 2020-04-15 22:08:12 +0530 | [diff] [blame] | 524 | }) |
Saqib Ansari | 2c3c8aa | 2020-05-29 21:55:38 +0530 | [diff] [blame] | 525 | fields.splice(3, 0, { |
| 526 | fieldtype: 'Float', |
| 527 | fieldname: "conversion_factor", |
| 528 | in_list_view: 1, |
Saqib | 56fea7d | 2020-10-09 21:19:25 +0530 | [diff] [blame] | 529 | label: __("Conversion Factor"), |
| 530 | precision: get_precision('conversion_factor') |
Saqib Ansari | 2c3c8aa | 2020-05-29 21:55:38 +0530 | [diff] [blame] | 531 | }) |
Saqib Ansari | f53299e | 2020-04-15 22:08:12 +0530 | [diff] [blame] | 532 | } |
| 533 | |
Doridel Cahanap | 6f06cc2 | 2018-05-17 16:28:58 +0800 | [diff] [blame] | 534 | const dialog = new frappe.ui.Dialog({ |
| 535 | title: __("Update Items"), |
| 536 | fields: [ |
Doridel Cahanap | 6f06cc2 | 2018-05-17 16:28:58 +0800 | [diff] [blame] | 537 | { |
Stavros Anastasiadis | 3d82b74 | 2018-12-10 13:00:55 +0100 | [diff] [blame] | 538 | fieldname: "trans_items", |
| 539 | fieldtype: "Table", |
Marica | fc96c1a | 2020-03-06 10:57:59 +0530 | [diff] [blame] | 540 | label: "Items", |
Stavros Anastasiadis | 3d82b74 | 2018-12-10 13:00:55 +0100 | [diff] [blame] | 541 | cannot_add_rows: cannot_add_row, |
Saqib | bc919e2 | 2020-11-05 17:38:35 +0530 | [diff] [blame] | 542 | in_place_edit: false, |
Marica | fc96c1a | 2020-03-06 10:57:59 +0530 | [diff] [blame] | 543 | reqd: 1, |
Stavros Anastasiadis | 3d82b74 | 2018-12-10 13:00:55 +0100 | [diff] [blame] | 544 | data: this.data, |
Doridel Cahanap | 6f06cc2 | 2018-05-17 16:28:58 +0800 | [diff] [blame] | 545 | get_data: () => { |
| 546 | return this.data; |
| 547 | }, |
Saqib Ansari | f53299e | 2020-04-15 22:08:12 +0530 | [diff] [blame] | 548 | fields: fields |
Doridel Cahanap | 6f06cc2 | 2018-05-17 16:28:58 +0800 | [diff] [blame] | 549 | }, |
| 550 | ], |
| 551 | primary_action: function() { |
| 552 | const trans_items = this.get_values()["trans_items"]; |
| 553 | frappe.call({ |
| 554 | method: 'erpnext.controllers.accounts_controller.update_child_qty_rate', |
Stavros Anastasiadis | 3d82b74 | 2018-12-10 13:00:55 +0100 | [diff] [blame] | 555 | freeze: true, |
Doridel Cahanap | 6f06cc2 | 2018-05-17 16:28:58 +0800 | [diff] [blame] | 556 | args: { |
| 557 | 'parent_doctype': frm.doc.doctype, |
| 558 | 'trans_items': trans_items, |
Stavros Anastasiadis | 3d82b74 | 2018-12-10 13:00:55 +0100 | [diff] [blame] | 559 | 'parent_doctype_name': frm.doc.name, |
| 560 | 'child_docname': child_docname |
Doridel Cahanap | 6f06cc2 | 2018-05-17 16:28:58 +0800 | [diff] [blame] | 561 | }, |
| 562 | callback: function() { |
| 563 | frm.reload_doc(); |
| 564 | } |
| 565 | }); |
| 566 | this.hide(); |
| 567 | refresh_field("items"); |
| 568 | }, |
| 569 | primary_action_label: __('Update') |
| 570 | }); |
| 571 | |
| 572 | frm.doc[opts.child_docname].forEach(d => { |
| 573 | dialog.fields_dict.trans_items.df.data.push({ |
| 574 | "docname": d.name, |
Prssanna Desai | 4f72c0b | 2019-12-23 18:27:12 +0530 | [diff] [blame] | 575 | "name": d.name, |
Doridel Cahanap | 6f06cc2 | 2018-05-17 16:28:58 +0800 | [diff] [blame] | 576 | "item_code": d.item_code, |
Saqib Ansari | f53299e | 2020-04-15 22:08:12 +0530 | [diff] [blame] | 577 | "delivery_date": d.delivery_date, |
| 578 | "schedule_date": d.schedule_date, |
Saqib Ansari | 2c3c8aa | 2020-05-29 21:55:38 +0530 | [diff] [blame] | 579 | "conversion_factor": d.conversion_factor, |
Doridel Cahanap | 6f06cc2 | 2018-05-17 16:28:58 +0800 | [diff] [blame] | 580 | "qty": d.qty, |
| 581 | "rate": d.rate, |
Saqib | 6131424 | 2020-09-15 11:14:31 +0530 | [diff] [blame] | 582 | "uom": d.uom |
Doridel Cahanap | 6f06cc2 | 2018-05-17 16:28:58 +0800 | [diff] [blame] | 583 | }); |
| 584 | this.data = dialog.fields_dict.trans_items.df.data; |
| 585 | dialog.fields_dict.trans_items.grid.refresh(); |
| 586 | }) |
| 587 | dialog.show(); |
| 588 | } |
| 589 | |
Rushabh Mehta | 176b63b | 2016-07-14 17:43:48 +0530 | [diff] [blame] | 590 | erpnext.utils.map_current_doc = function(opts) { |
Marica | db00270 | 2020-02-17 15:58:08 +0530 | [diff] [blame] | 591 | let query_args = {}; |
| 592 | if (opts.get_query_filters) { |
| 593 | query_args.filters = opts.get_query_filters; |
| 594 | } |
| 595 | |
| 596 | if (opts.get_query_method) { |
| 597 | query_args.query = opts.get_query_method; |
| 598 | } |
| 599 | |
| 600 | if (query_args.filters || query_args.query) { |
| 601 | opts.get_query = () => { |
| 602 | return query_args; |
Rushabh Mehta | 176b63b | 2016-07-14 17:43:48 +0530 | [diff] [blame] | 603 | } |
| 604 | } |
| 605 | var _map = function() { |
Rushabh Mehta | 55ea7b1 | 2016-07-15 16:43:25 +0530 | [diff] [blame] | 606 | if($.isArray(cur_frm.doc.items) && cur_frm.doc.items.length > 0) { |
Prateeksha Singh | edeb4dc | 2017-05-15 11:32:06 +0530 | [diff] [blame] | 607 | // remove first item row if empty |
Rushabh Mehta | 176b63b | 2016-07-14 17:43:48 +0530 | [diff] [blame] | 608 | if(!cur_frm.doc.items[0].item_code) { |
| 609 | cur_frm.doc.items = cur_frm.doc.items.splice(1); |
| 610 | } |
bhupen | 3c7e70f | 2016-11-30 14:32:11 +0530 | [diff] [blame] | 611 | |
| 612 | // find the doctype of the items table |
| 613 | var items_doctype = frappe.meta.get_docfield(cur_frm.doctype, 'items').options; |
Prateeksha Singh | edeb4dc | 2017-05-15 11:32:06 +0530 | [diff] [blame] | 614 | |
bhupen | 3c7e70f | 2016-11-30 14:32:11 +0530 | [diff] [blame] | 615 | // find the link fieldname from items table for the given |
| 616 | // source_doctype |
| 617 | var link_fieldname = null; |
Prateeksha Singh | edeb4dc | 2017-05-15 11:32:06 +0530 | [diff] [blame] | 618 | frappe.get_meta(items_doctype).fields.forEach(function(d) { |
bhupen | 3c7e70f | 2016-11-30 14:32:11 +0530 | [diff] [blame] | 619 | if(d.options===opts.source_doctype) link_fieldname = d.fieldname; }); |
| 620 | |
Nabin Hait | 802b435 | 2017-01-09 15:32:20 +0530 | [diff] [blame] | 621 | // search in existing items if the source_name is already set and full qty fetched |
bhupen | 3c7e70f | 2016-11-30 14:32:11 +0530 | [diff] [blame] | 622 | var already_set = false; |
Nabin Hait | 802b435 | 2017-01-09 15:32:20 +0530 | [diff] [blame] | 623 | var item_qty_map = {}; |
bhupen | 3c7e70f | 2016-11-30 14:32:11 +0530 | [diff] [blame] | 624 | |
Prateeksha Singh | edeb4dc | 2017-05-15 11:32:06 +0530 | [diff] [blame] | 625 | $.each(cur_frm.doc.items, function(i, d) { |
| 626 | opts.source_name.forEach(function(src) { |
| 627 | if(d[link_fieldname]==src) { |
| 628 | already_set = true; |
| 629 | if (item_qty_map[d.item_code]) |
| 630 | item_qty_map[d.item_code] += flt(d.qty); |
| 631 | else |
| 632 | item_qty_map[d.item_code] = flt(d.qty); |
| 633 | } |
| 634 | }); |
| 635 | }); |
| 636 | |
| 637 | if(already_set) { |
| 638 | opts.source_name.forEach(function(src) { |
| 639 | frappe.model.with_doc(opts.source_doctype, src, function(r) { |
| 640 | var source_doc = frappe.model.get_doc(opts.source_doctype, src); |
| 641 | $.each(source_doc.items || [], function(i, row) { |
| 642 | if(row.qty > flt(item_qty_map[row.item_code])) { |
| 643 | already_set = false; |
| 644 | return false; |
| 645 | } |
| 646 | }) |
| 647 | }) |
| 648 | |
| 649 | if(already_set) { |
| 650 | frappe.msgprint(__("You have already selected items from {0} {1}", |
| 651 | [opts.source_doctype, src])); |
| 652 | return; |
| 653 | } |
| 654 | |
| 655 | }) |
Nabin Hait | 802b435 | 2017-01-09 15:32:20 +0530 | [diff] [blame] | 656 | } |
Rushabh Mehta | 176b63b | 2016-07-14 17:43:48 +0530 | [diff] [blame] | 657 | } |
| 658 | |
| 659 | return frappe.call({ |
| 660 | // Sometimes we hit the limit for URL length of a GET request |
| 661 | // as we send the full target_doc. Hence this is a POST request. |
| 662 | type: "POST", |
Prateeksha Singh | edeb4dc | 2017-05-15 11:32:06 +0530 | [diff] [blame] | 663 | method: 'frappe.model.mapper.map_docs', |
Rushabh Mehta | 176b63b | 2016-07-14 17:43:48 +0530 | [diff] [blame] | 664 | args: { |
Prateeksha Singh | edeb4dc | 2017-05-15 11:32:06 +0530 | [diff] [blame] | 665 | "method": opts.method, |
| 666 | "source_names": opts.source_name, |
| 667 | "target_doc": cur_frm.doc, |
Marica | db00270 | 2020-02-17 15:58:08 +0530 | [diff] [blame] | 668 | "args": opts.args |
Rushabh Mehta | 176b63b | 2016-07-14 17:43:48 +0530 | [diff] [blame] | 669 | }, |
| 670 | callback: function(r) { |
| 671 | if(!r.exc) { |
| 672 | var doc = frappe.model.sync(r.message); |
Vishal Dhayagude | f06c281 | 2017-12-26 16:22:40 +0530 | [diff] [blame] | 673 | cur_frm.dirty(); |
Rushabh Mehta | 176b63b | 2016-07-14 17:43:48 +0530 | [diff] [blame] | 674 | cur_frm.refresh(); |
| 675 | } |
| 676 | } |
| 677 | }); |
| 678 | } |
| 679 | if(opts.source_doctype) { |
Prateeksha Singh | edeb4dc | 2017-05-15 11:32:06 +0530 | [diff] [blame] | 680 | var d = new frappe.ui.form.MultiSelectDialog({ |
| 681 | doctype: opts.source_doctype, |
| 682 | target: opts.target, |
| 683 | date_field: opts.date_field || undefined, |
| 684 | setters: opts.setters, |
| 685 | get_query: opts.get_query, |
marination | 4f395cc | 2020-09-24 12:43:41 +0530 | [diff] [blame] | 686 | add_filters_group: 1, |
Prateeksha Singh | edeb4dc | 2017-05-15 11:32:06 +0530 | [diff] [blame] | 687 | action: function(selections, args) { |
| 688 | let values = selections; |
| 689 | if(values.length === 0){ |
Nabin Hait | a11dcb6 | 2017-12-04 13:36:50 +0530 | [diff] [blame] | 690 | frappe.msgprint(__("Please select {0}", [opts.source_doctype])) |
Prateeksha Singh | edeb4dc | 2017-05-15 11:32:06 +0530 | [diff] [blame] | 691 | return; |
| 692 | } |
| 693 | opts.source_name = values; |
| 694 | opts.setters = args; |
| 695 | d.dialog.hide(); |
| 696 | _map(); |
| 697 | }, |
Rushabh Mehta | 176b63b | 2016-07-14 17:43:48 +0530 | [diff] [blame] | 698 | }); |
Rushabh Mehta | 176b63b | 2016-07-14 17:43:48 +0530 | [diff] [blame] | 699 | } else if(opts.source_name) { |
Prateeksha Singh | edeb4dc | 2017-05-15 11:32:06 +0530 | [diff] [blame] | 700 | opts.source_name = [opts.source_name]; |
Rushabh Mehta | 176b63b | 2016-07-14 17:43:48 +0530 | [diff] [blame] | 701 | _map(); |
| 702 | } |
| 703 | } |
| 704 | |
Rushabh Mehta | 180e435 | 2016-07-26 17:57:42 +0530 | [diff] [blame] | 705 | frappe.form.link_formatters['Item'] = function(value, doc) { |
marination | 824f48f | 2020-10-12 20:08:03 +0530 | [diff] [blame] | 706 | if (doc && value && doc.item_name && doc.item_name !== value) { |
| 707 | return value + ': ' + doc.item_name; |
| 708 | } else if (!value && doc.doctype && doc.item_name) { |
| 709 | // format blank value in child table |
| 710 | return doc.item_name; |
Rushabh Mehta | 180e435 | 2016-07-26 17:57:42 +0530 | [diff] [blame] | 711 | } else { |
marination | 824f48f | 2020-10-12 20:08:03 +0530 | [diff] [blame] | 712 | // if value is blank in report view or item code and name are the same, return as is |
Rushabh Mehta | 180e435 | 2016-07-26 17:57:42 +0530 | [diff] [blame] | 713 | return value; |
| 714 | } |
| 715 | } |
| 716 | |
| 717 | frappe.form.link_formatters['Employee'] = function(value, doc) { |
Nabin Hait | 981f6ea | 2016-07-31 11:44:43 +0530 | [diff] [blame] | 718 | if(doc && doc.employee_name && doc.employee_name !== value) { |
mbauskar | be81442 | 2016-10-27 09:49:22 +0530 | [diff] [blame] | 719 | return value? value + ': ' + doc.employee_name: doc.employee_name; |
Rushabh Mehta | 180e435 | 2016-07-26 17:57:42 +0530 | [diff] [blame] | 720 | } else { |
| 721 | return value; |
| 722 | } |
| 723 | } |
| 724 | |
Rushabh Mehta | 95b995b | 2015-05-28 12:10:55 +0530 | [diff] [blame] | 725 | // add description on posting time |
| 726 | $(document).on('app_ready', function() { |
| 727 | if(!frappe.datetime.is_timezone_same()) { |
| 728 | $.each(["Stock Reconciliation", "Stock Entry", "Stock Ledger Entry", |
| 729 | "Delivery Note", "Purchase Receipt", "Sales Invoice"], function(i, d) { |
| 730 | frappe.ui.form.on(d, "onload", function(frm) { |
| 731 | cur_frm.set_df_property("posting_time", "description", |
Faris Ansari | ab74ca7 | 2017-05-30 12:54:42 +0530 | [diff] [blame] | 732 | frappe.sys_defaults.time_zone); |
Rushabh Mehta | 95b995b | 2015-05-28 12:10:55 +0530 | [diff] [blame] | 733 | }); |
| 734 | }); |
| 735 | } |
akshay | 14384c2 | 2016-07-28 13:53:17 +0530 | [diff] [blame] | 736 | }); |