Hi,
We have two new custom fields in Item. They are Gross Weight and Measurement.
Now, when making Packing Slip from Delivery Note, we would like to pull the details from the Item into the Packing Slip Item :
Understand there is this following code in packing_slip.py that does the pulling of net_weight and weight_uom. Do I overwrite this function to pull in Gross Weight and Measurement as well? What is the best way to do pull these additional fields from Items into Packing Slip Item?
def update_item_details(self):
"""
Fill empty columns in Packing Slip Item
"""
if not self.from_case_no:
self.from_case_no = self.get_recommended_case_no()
for d in self.get("items"):
res = frappe.db.get_value("Item", d.item_code,
["net_weight", "weight_uom"], as_dict=True)
if res and len(res)>0:
d.net_weight = res["net_weight"]
d.weight_uom = res["weight_uom"]
Hi,
In your .py file, you need do changes
as
for d in self.get(âitemsâ):
res = frappe.db.get_value(âItemâ, d.item_code,
[ânet_weightâ, âweight_uomâ,âgross_weightâ,âmeasurmentâ], as_dict=True)
if res and len(res)>0:
d.net_weight = res["net_weight"]
d.weight_uom = res["weight_uom"]
d.weight_uom = res["gross_weight"]
d.weight_uom = res["measurment"]
Hi Shraddha,
Thank you for the help.
We do not do customisation on the ERPNext App itself and have a custom app for these client specific customisation.
So how would you advice I perform the changes you have mentioned not on the ERPNext but from our custom app side?
Thanks once again!
Hi,
Okay.
Just create your custom .py file in your app and write method same as update_item_details given in packing_slip.py
import that method in packing_slip.py
from file_path import method_name
Write method as given in packing_slip.py
write following script in your file.(i.e custom py file)
import frappe
def update_details(self):
for d in self.get("items"):
res = frappe.db.get_value("Item", d.item_code,
["gross_weight","measurment"], as_dict=True)
if res and len(res)>0:
d.gross_weight = res["gross_weight"]
d.measurment = res["measurment"]
1 Like
@shraddha Thank you for the guidance.
However, this would mean that I make changes to standard ERPNextâs packing_slip.py by adding the line on import, right?
Wouldânt this cause conflict when I do the next bench update?
Hi,
NoâŚyou create own custom.py file and write code.
@asneha1 i dont understand why you need to modify files for this ? why you dont add it via Customize form?
@ramielian, I could customize at Customize Form if Item is selected at Packing Slip.
But in this case, this is when I click âMake Packing Slipâ from Delivery Note, so it runs the above mentioned server-side function to pull the details.
Hi,
For this case write a function for packing slip in onload event of your custom appâs hooks.py file
Thanks, Rohit