Skip to content

Commit

Permalink
Merge pull request #28745 from noahjacob/maint_batch_map
Browse files Browse the repository at this point in the history
refactor: map serial from schedule if only one
  • Loading branch information
ankush authored Dec 6, 2021
2 parents 3928a40 + eb522a3 commit ef53eb7
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,14 @@ def update_status_and_detail(source, target, parent):
target.maintenance_schedule = source.name
target.maintenance_schedule_detail = s_id

def update_sales(source, target, parent):
def update_sales_and_serial(source, target, parent):
sales_person = frappe.db.get_value('Maintenance Schedule Detail', s_id, 'sales_person')
target.service_person = sales_person
target.serial_no = ''
serial_nos = get_serial_nos(target.serial_no)
if len(serial_nos) == 1:
target.serial_no = serial_nos[0]
else:
target.serial_no = ''

doclist = get_mapped_doc("Maintenance Schedule", source_name, {
"Maintenance Schedule": {
Expand All @@ -342,7 +346,7 @@ def update_sales(source, target, parent):
"Maintenance Schedule Item": {
"doctype": "Maintenance Visit Purpose",
"condition": lambda doc: doc.item_name == item_name,
"postprocess": update_sales
"postprocess": update_sales_and_serial
}
}, target_doc)

Expand Down

0 comments on commit ef53eb7

Please sign in to comment.