[fix] Mapping allowed for negative quantity

This commit is contained in:
Nabin Hait 2015-12-01 17:26:35 +05:30
parent 84f44ad5eb
commit d793fc9446
4 changed files with 6 additions and 7 deletions

View File

@ -8,7 +8,6 @@ from frappe.utils import cstr, flt
from frappe import msgprint, _, throw from frappe import msgprint, _, throw
from frappe.model.mapper import get_mapped_doc from frappe.model.mapper import get_mapped_doc
from erpnext.controllers.buying_controller import BuyingController 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 erpnext.stock.stock_balance import update_bin_qty, get_ordered_qty
from frappe.desk.notifications import clear_doctype_notifications from frappe.desk.notifications import clear_doctype_notifications
@ -282,7 +281,7 @@ def make_purchase_receipt(source_name, target_doc=None):
"parenttype": "prevdoc_doctype", "parenttype": "prevdoc_doctype",
}, },
"postprocess": update_item, "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": { "Purchase Taxes and Charges": {
"doctype": "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", "parent": "purchase_order",
}, },
"postprocess": update_item, "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": { "Purchase Taxes and Charges": {
"doctype": "Purchase Taxes and Charges", "doctype": "Purchase Taxes and Charges",

View File

@ -384,7 +384,7 @@ def make_delivery_note(source_name, target_doc=None):
"parent": "against_sales_order", "parent": "against_sales_order",
}, },
"postprocess": update_item, "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": { "Sales Taxes and Charges": {
"doctype": "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", "parent": "sales_order",
}, },
"postprocess": update_item, "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": { "Sales Taxes and Charges": {
"doctype": "Sales Taxes and Charges", "doctype": "Sales Taxes and Charges",

View File

@ -332,7 +332,7 @@ def make_sales_invoice(source_name, target_doc=None):
"serial_no": "serial_no" "serial_no": "serial_no"
}, },
"postprocess": update_item, "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": { "Sales Taxes and Charges": {
"doctype": "Sales Taxes and Charges", "doctype": "Sales Taxes and Charges",

View File

@ -469,7 +469,7 @@ def make_purchase_invoice(source_name, target_doc=None):
"prevdoc_docname": "purchase_order", "prevdoc_docname": "purchase_order",
}, },
"postprocess": update_item, "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": { "Purchase Taxes and Charges": {
"doctype": "Purchase Taxes and Charges", "doctype": "Purchase Taxes and Charges",