Best approach for field mapping

30 views
Skip to first unread message

Jev Björsell

unread,
Feb 21, 2014, 7:31:34 PM2/21/14
to erpnext-u...@googlegroups.com
I need some guidance with mapping data between the Sales Order DocType and the Delivery Note Item doctype during the composing of a new Delivery Note using the 'From Sales Order' action.

My use case:

I have a custom field called po_number on the `Delivery Note Item` object. When building a Delivery Note from one or more Sales Orders, I want the `tabDelivery Note Item`.po_number to be populated with the value from the corresponding `tabSales Order`.po_no value.

For example. I have two Sales Orders, each with their own lines.

SO1 with po_no == abc
|--> SO1Line1
`--> SO1Line2

SO2 with po_no == 123
|--> SO2Line1
`--> SO2Line2


I create a new Delivery Note, and using the 'From Sales Order' action, I load both SO1 and SO2 onto this new delivery note.

The result I want is:

DeliveryNote1
|--> SO1Line1     po_number == abc
|--> SO1Line2     po_number == abc
|--> SO2Line1     po_number == 123
`--> SO2Line2     po_number == 123

What's the best approach for this? A Custom Script? Can someone please provide an example?

Thank you,
-Jev

Nabin Hait

unread,
Feb 23, 2014, 11:10:52 PM2/23/14
to erpnext-u...@googlegroups.com
You can look into make_delivery_note() function in selling/doctype/sales_order/sales_order.py file.

That function maps doclist from sales order to delivery note. There is a sub-function called update_item(), you can easily add following line in that function to fulfil your requirements.

target.po_number = source_parent.po_number


--
You received this message because you are subscribed to the Google Groups "ERPNext User's Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-user-fo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-user-forum/68a5a6e8-2d97-4b37-8c1d-3a74b375f9e1%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Jev Björsell

unread,
Feb 24, 2014, 9:49:35 AM2/24/14
to erpnext-u...@googlegroups.com
Great. I put that mapping in place, restarted gunicorn, and everything is working well.

Thank you.
-Jev
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-user-forum+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages