Where can I find "Username" to include in a Print Format?

I use a print format to print my Sales Invoice receipts just the way I want them to look. This format was created for me by a contractor that is no longer around and I would like to alter one of the fields in the format.

Currently, the receipt prints with a row of important information that we need that includes 3 fields. The first is a customer ID field that we get from the sales invoice, the second field is the Sales Rep responsible for creating the invoice, and last is the Customer PO number.

To give you some idea of what that looks like, here is the section of code in the print format that gathers and places these data for these fields:

	<div class="row">
		<div class="col-xs-4" >
			<p><b style="font-size:14px;">Customer ID:&nbsp;</b>{{ frappe.get_doc("Customer", doc.customer).jmi_customer_id }} </p>
		</div>
		<div class="col-xs-4">
			<p><b style="font-size:14px;">Sales Rep:&nbsp;</b>{{ frappe.get_doc("User",frappe.session.user).full_name }}</p>
		</div>
		<div class="col-xs-4">
			<p><b style="font-size:14px;">PO No.:&nbsp;</b>{{ doc.po_no or None}}</p>
		</div>
	</div> 

The problem I have now is the “Sales Rep” field information is taken from the person currently logged in and printing the invoice.

This means that when the Sales Invoice is first made, the information in this field is correct because the person logged in and making the sale is the originator of the Sales Invoice.

However, when it comes time to revisit this Sales Invoice for collecting the amount due at the end of the month, the accounting worker reprints the sales invoice to send to the client for collecting payment.

When the accounting worker prints the sales invoice, it prints with the accounting workers name instead of the original Sales Rep. So, to fix it I want to change the following line to something that will actually get the name of the owner of the document instead of the person trying to print it at the moment.

This line needs to change:

		<div class="col-xs-4">
			<p><b style="font-size:14px;">Sales Rep:&nbsp;</b>{{ frappe.get_doc("User",frappe.session.user).full_name }}</p>
		</div>  

My problem is that I do not know what to use instead of [“User”,frappe.session.user] in this format to get the owner information instead.

Can anyone offer some guidance?

Thank you in advance.

BKM :nerd_face:

This should do the trick, printing the Full Name of the 'owner' of the Sales Invoice.

<div class="col-xs-4">
  <p>
    <b style="font-size:14px;">Sales Rep:&nbsp;</b>
    {{ frappe.get_doc("User", doc.owner).full_name }}
  </p>
</div>  
2 Likes

@brian_pond Thank you!

Of course it figures that it was something simple like “doc.owner” while I was searching down the wrong path of “user.something”

It is no wonder that I couldn’t find what I was looking for since I was off in the wrong direction.

Thanks again.

BKM