Skip to content

Commit

Permalink
Fixes the Sales Team pulling from the customer
Browse files Browse the repository at this point in the history
- Earlier it was pulling the id from customer as well which was causing the new SO to have duplicate primary key.
  • Loading branch information
adityaduggal committed Jun 4, 2020
1 parent 1c5b652 commit 7ef0815
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion rigpl_erpnext/rigpl_erpnext/validations/sales_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,15 @@ def check_price_list(doc):

def update_fields(doc):
cust_doc = frappe.get_doc("Customer", doc.customer)
doc.sales_team = cust_doc.sales_team
# Adding the Sales Team data from Customer to the Sales Team of Sales Order.
# This is how you add data in Child table.
doc.sales_team = []
steam_dict = {}
for d in cust_doc.sales_team:
steam_dict["sales_person"] = d.sales_person
steam_dict["allocated_percentage"] = d.allocated_percentage

doc.append('sales_team', steam_dict)
doc.shipping_address_title = frappe.get_value("Address",
doc.shipping_address_name, "address_title")
doc.transaction_date = nowdate()
Expand Down

0 comments on commit 7ef0815

Please sign in to comment.