Abhishek Balam | 346ca56 | 2020-10-14 18:11:04 +0530 | [diff] [blame] | 1 | // Copyright (c) 2016, Frappe Technologies and contributors |
| 2 | // For license information, please see license.txt |
| 3 | |
| 4 | frappe.ui.form.on("Address", { |
| 5 | is_your_company_address: function(frm) { |
Abhishek Balam | 349fcfd | 2020-10-15 12:21:43 +0530 | [diff] [blame] | 6 | frm.clear_table('links'); |
| 7 | if(frm.doc.is_your_company_address) { |
Abhishek Balam | 346ca56 | 2020-10-14 18:11:04 +0530 | [diff] [blame] | 8 | frm.add_child('links', { |
| 9 | link_doctype: 'Company', |
| 10 | link_name: frappe.defaults.get_user_default('Company') |
| 11 | }); |
Abhishek Balam | 349fcfd | 2020-10-15 12:21:43 +0530 | [diff] [blame] | 12 | frm.set_query('link_doctype', 'links', () => { |
Abhishek Balam | 346ca56 | 2020-10-14 18:11:04 +0530 | [diff] [blame] | 13 | return { |
| 14 | filters: { |
| 15 | name: 'Company' |
| 16 | } |
Abhishek Balam | 38b26c8 | 2020-10-14 18:24:51 +0530 | [diff] [blame] | 17 | }; |
Abhishek Balam | 349fcfd | 2020-10-15 12:21:43 +0530 | [diff] [blame] | 18 | }); |
Abhishek Balam | 346ca56 | 2020-10-14 18:11:04 +0530 | [diff] [blame] | 19 | frm.refresh_field('links'); |
| 20 | } |
Abhishek Balam | 349fcfd | 2020-10-15 12:21:43 +0530 | [diff] [blame] | 21 | else { |
| 22 | frm.trigger('refresh'); |
Abhishek Balam | 346ca56 | 2020-10-14 18:11:04 +0530 | [diff] [blame] | 23 | } |
Abhishek Balam | 346ca56 | 2020-10-14 18:11:04 +0530 | [diff] [blame] | 24 | } |
| 25 | }); |