Looking for advice for two-way updates of two views

Hello everyone,
I created a new doctype “public IP”, represents an ip associated with a customer [Link] and a resource (Serial No) [Link].
I would like to add a table of “public IP” in a section on the customer and made it changeble, now the question is: how can I report all changes made to the customer directly on the IP and in the other way?

For the moment i have try a create an intermediate view “public IP view” and made a table of it in customer. This doctype have a link to an IP and other fields equal with the fields of IP, with a custom script “on select” of link it populate other fields during inserting new row and with other custom script (client and server) “on validate” upload “public IP” or “public IP view” based on current doctype that i change.
I think that this way is too tricky, due to this i ask of you if there are a simplest way.

We have two type of users: one that must manage customer with all the fields in one page and the techinical one the manage informatical part of ip.
I state that we have other two custom doctype with a similar requirements.


Hi @alberto_solaro,

I hope I understand this correctly… You have a custom doctype with IP and link to customer and want to display this from the customer.

Why not add a HTML field to the customer record and then add a custom script to this that looks something like this:

frappe.ui.form.on('Customer', {
	refresh: function(frm) {
		if (!frm.doc.__islocal) {
function display_ips(frm) {
	// render ips
        method: 'myapp.myapp.doctype.ip.ip.get_ips',
        args: {
	        customer: frm.doc.name
		callback: function(r) {
			if (r.message) {			
				var html = "";
				r.message.ips.forEach(function (ip) {
					// code generator
					html += '<p>' + ip.address + "</p>";
				if (frm.fields_dict['ips_html']) {


You will need a function get_ips like this something like this in a custom app (propose to have this to contain your doctype as well):

def get_ips(customer):
	sql_query = ("""SELECT *  
		FROM `tabIP` 
			WHERE `customer` = '{0}'""".format(customer))
		ips = frappe.db.sql(sql_query, as_dict=True)
return { 'ips': ips}

Hope this helps.

After some tests we decide to proceed with your solution, if i want to use an html to visualize the table like address and contact, how can i do?
I try to read the code related to this but i miss something, any advice?
Thanks for your time

The code above creates a very simple html structure that only uses paragraphs with the IPs.

html += '<p>' + ip.address + "</p>";

You can extend this to any sort of html, and also use other fields as returned by your SQL query… You can also use the frappe.render_template. Refer to e.g. https://github.com/frappe/frappe/blob/develop/frappe/public/js/frappe/misc/address_and_contact.js