[Fix] Throw error if item is added multiple time

This commit is contained in:
Kanchan Chauhan 2017-02-21 12:35:40 +05:30
parent d5442b5544
commit f2803ac427
5 changed files with 11 additions and 7 deletions

View File

@ -19,6 +19,7 @@ test_ignore = ["Serial No"]
class TestPurchaseInvoice(unittest.TestCase):
def setUp(self):
unlink_payment_on_cancel_of_invoice()
frappe.db.set_value("Buying Settings", None, "allow_multiple_items", 1)
def tearDown(self):
unlink_payment_on_cancel_of_invoice(0)

View File

@ -72,8 +72,7 @@ class PurchaseCommon(BuyingController):
if items and len(items) != len(set(items)) and \
not cint(frappe.db.get_single_value("Buying Settings", "allow_multiple_items") or 0):
frappe.msgprint(_("Warning: Same item has been entered multiple times."), alert=True)
frappe.throw(_("Same item cannot be entered multiple times."))
def check_for_closed_status(self, doctype, docname):
status = frappe.db.get_value(doctype, docname, "status")

View File

@ -112,6 +112,7 @@ class TestPurchaseOrder(unittest.TestCase):
self.assertEquals(get_ordered_qty(item_code="_Test Item", warehouse="_Test Warehouse - _TC"), existing_ordered_qty)
def test_group_same_items(self):
frappe.db.set_value("Buying Settings", None, "allow_multiple_items", 1)
frappe.get_doc({
"doctype": "Purchase Order",
"company": "_Test Company",
@ -121,7 +122,7 @@ class TestPurchaseOrder(unittest.TestCase):
"conversion_factor" : 1,
"items" : get_same_items(),
"group_same_items": 1
}).insert()
}).insert(ignore_permissions=True)
def get_same_items():

View File

@ -11,6 +11,9 @@ from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchas
from erpnext import set_perpetual_inventory
class TestPurchaseReceipt(unittest.TestCase):
def setUp(self):
frappe.db.set_value("Buying Settings", None, "allow_multiple_items", 1)
def test_make_purchase_invoice(self):
pr = make_purchase_receipt(do_not_save=True)
self.assertRaises(frappe.ValidationError, make_purchase_invoice, pr.name)

View File

@ -50,10 +50,10 @@
{
"base_amount": 250.0,
"conversion_factor": 1.0,
"description": "_Test Item",
"description": "_Test FG Item",
"doctype": "Purchase Receipt Item",
"item_code": "_Test Item",
"item_name": "_Test Item",
"item_code": "_Test FG Item",
"item_name": "_Test FG Item",
"parentfield": "items",
"qty": 5.0,
"rate": 50.0,