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", { |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 5 | is_your_company_address: function (frm) { |
| 6 | frm.clear_table("links"); |
| 7 | if (frm.doc.is_your_company_address) { |
| 8 | frm.add_child("links", { |
| 9 | link_doctype: "Company", |
| 10 | link_name: frappe.defaults.get_user_default("Company"), |
Abhishek Balam | 346ca56 | 2020-10-14 18:11:04 +0530 | [diff] [blame] | 11 | }); |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +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: { |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 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 | }); |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 19 | frm.refresh_field("links"); |
| 20 | } else { |
| 21 | frm.trigger("refresh"); |
Abhishek Balam | 346ca56 | 2020-10-14 18:11:04 +0530 | [diff] [blame] | 22 | } |
Ankush Menat | ec74a5e | 2024-03-10 19:45:40 +0530 | [diff] [blame] | 23 | }, |
Abhishek Balam | 346ca56 | 2020-10-14 18:11:04 +0530 | [diff] [blame] | 24 | }); |