diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py index af144003ce..feb144d0dd 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/purchase_order.py @@ -8,7 +8,6 @@ from frappe.utils import cstr, flt from frappe import msgprint, _, throw from frappe.model.mapper import get_mapped_doc from erpnext.controllers.buying_controller import BuyingController -from erpnext.stock.doctype.item.item import get_last_purchase_details from erpnext.stock.stock_balance import update_bin_qty, get_ordered_qty from frappe.desk.notifications import clear_doctype_notifications @@ -282,7 +281,7 @@ def make_purchase_receipt(source_name, target_doc=None): "parenttype": "prevdoc_doctype", }, "postprocess": update_item, - "condition": lambda doc: doc.received_qty < doc.qty and doc.delivered_by_supplier!=1 + "condition": lambda doc: abs(doc.received_qty) < abs(doc.qty) and doc.delivered_by_supplier!=1 }, "Purchase Taxes and Charges": { "doctype": "Purchase Taxes and Charges", @@ -318,7 +317,7 @@ def make_purchase_invoice(source_name, target_doc=None): "parent": "purchase_order", }, "postprocess": update_item, - "condition": lambda doc: (doc.base_amount==0 or doc.billed_amt < doc.amount) + "condition": lambda doc: (doc.base_amount==0 or abs(doc.billed_amt) < abs(doc.amount)) }, "Purchase Taxes and Charges": { "doctype": "Purchase Taxes and Charges", diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index d2b165398d..66ca31e916 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -384,7 +384,7 @@ def make_delivery_note(source_name, target_doc=None): "parent": "against_sales_order", }, "postprocess": update_item, - "condition": lambda doc: doc.delivered_qty < doc.qty and doc.delivered_by_supplier!=1 + "condition": lambda doc: abs(doc.delivered_qty) < abs(doc.qty) and doc.delivered_by_supplier!=1 }, "Sales Taxes and Charges": { "doctype": "Sales Taxes and Charges", @@ -430,7 +430,7 @@ def make_sales_invoice(source_name, target_doc=None): "parent": "sales_order", }, "postprocess": update_item, - "condition": lambda doc: doc.qty and (doc.base_amount==0 or doc.billed_amt < doc.amount) + "condition": lambda doc: doc.qty and (doc.base_amount==0 or abs(doc.billed_amt) < abs(doc.amount)) }, "Sales Taxes and Charges": { "doctype": "Sales Taxes and Charges", diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index fd3742e1f1..c5fd34f80a 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -332,7 +332,7 @@ def make_sales_invoice(source_name, target_doc=None): "serial_no": "serial_no" }, "postprocess": update_item, - "filter": lambda d: d.qty - invoiced_qty_map.get(d.name, 0)<=0 + "filter": lambda d: abs(d.qty) - abs(invoiced_qty_map.get(d.name, 0))<=0 }, "Sales Taxes and Charges": { "doctype": "Sales Taxes and Charges", diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py index a640e6e88b..b20617e95f 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py @@ -469,7 +469,7 @@ def make_purchase_invoice(source_name, target_doc=None): "prevdoc_docname": "purchase_order", }, "postprocess": update_item, - "filter": lambda d: d.qty - invoiced_qty_map.get(d.name, 0)<=0 + "filter": lambda d: abs(d.qty) - abs(invoiced_qty_map.get(d.name, 0))<=0 }, "Purchase Taxes and Charges": { "doctype": "Purchase Taxes and Charges",