Merge branch 'develop' into general-ui-fixes

This commit is contained in:
Suraj Shetty 2018-12-25 14:36:43 +05:30 committed by GitHub
commit 8775204d63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1106,6 +1106,8 @@ def set_purchase_order_defaults(parent_doctype, parent_doctype_name, child_docna
def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name, child_docname="items"): def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name, child_docname="items"):
data = json.loads(trans_items) data = json.loads(trans_items)
parent = frappe.get_doc(parent_doctype, parent_doctype_name)
for d in data: for d in data:
new_child_flag = False new_child_flag = False
if not d.get("docname"): if not d.get("docname"):
@ -1125,43 +1127,44 @@ def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name, chil
child_item.rate = flt(d.get("rate")) child_item.rate = flt(d.get("rate"))
child_item.flags.ignore_validate_update_after_submit = True child_item.flags.ignore_validate_update_after_submit = True
if new_child_flag: if new_child_flag:
child_item.idx = len(parent.items) + 1
child_item.insert() child_item.insert()
else: else:
child_item.save() child_item.save()
p_doctype = frappe.get_doc(parent_doctype, parent_doctype_name) parent.reload()
p_doctype.flags.ignore_validate_update_after_submit = True parent.flags.ignore_validate_update_after_submit = True
p_doctype.set_qty_as_per_stock_uom() parent.set_qty_as_per_stock_uom()
p_doctype.calculate_taxes_and_totals() parent.calculate_taxes_and_totals()
frappe.get_doc('Authorization Control').validate_approving_authority(p_doctype.doctype, frappe.get_doc('Authorization Control').validate_approving_authority(parent.doctype,
p_doctype.company, p_doctype.base_grand_total) parent.company, parent.base_grand_total)
p_doctype.set_payment_schedule() parent.set_payment_schedule()
if parent_doctype == 'Purchase Order': if parent_doctype == 'Purchase Order':
p_doctype.validate_minimum_order_qty() parent.validate_minimum_order_qty()
p_doctype.validate_budget() parent.validate_budget()
if p_doctype.is_against_so(): if parent.is_against_so():
p_doctype.update_status_updater() parent.update_status_updater()
else: else:
p_doctype.check_credit_limit() parent.check_credit_limit()
p_doctype.save() parent.save()
if parent_doctype == 'Purchase Order': if parent_doctype == 'Purchase Order':
update_last_purchase_rate(p_doctype, is_submit = 1) update_last_purchase_rate(parent, is_submit = 1)
p_doctype.update_prevdoc_status() parent.update_prevdoc_status()
p_doctype.update_requested_qty() parent.update_requested_qty()
p_doctype.update_ordered_qty() parent.update_ordered_qty()
p_doctype.update_ordered_and_reserved_qty() parent.update_ordered_and_reserved_qty()
p_doctype.update_receiving_percentage() parent.update_receiving_percentage()
if p_doctype.is_subcontracted == "Yes": if parent.is_subcontracted == "Yes":
p_doctype.update_reserved_qty_for_subcontract() parent.update_reserved_qty_for_subcontract()
else: else:
p_doctype.update_reserved_qty() parent.update_reserved_qty()
p_doctype.update_project() parent.update_project()
p_doctype.update_prevdoc_status('submit') parent.update_prevdoc_status('submit')
p_doctype.update_delivery_status() parent.update_delivery_status()
p_doctype.update_blanket_order() parent.update_blanket_order()
p_doctype.update_billing_percentage() parent.update_billing_percentage()
p_doctype.set_status() parent.set_status()