[doclist] new pattern / [item] pricelist must be unique / [formatter] show null floats as empty string
This commit is contained in:
parent
3aeed95e0a
commit
c711598940
@ -47,13 +47,13 @@ class BuyingController(StockController):
|
||||
self.set_total_in_words()
|
||||
|
||||
def validate_warehouse_belongs_to_company(self):
|
||||
for d in self.doclist.get({"warehouse": True}):
|
||||
warehouse_company = webnotes.conn.get_value("Warehouse", d.warehouse, "company")
|
||||
if warehouse_company and warehouse_company != self.doc.company:
|
||||
for warehouse, company in webnotes.conn.get_values("Warehouse",
|
||||
self.doclist.get_distinct_values("warehouse"), "company").items():
|
||||
if company and company != self.doc.company:
|
||||
webnotes.msgprint(_("Warehouse must belong to company") + \
|
||||
(": %s (%s, %s)" % (d.warehouse, warehouse_company, self.doc.company)),
|
||||
(": %s (%s, %s)" % (warehouse, company, self.doc.company)),
|
||||
raise_exception=WrongWarehouseCompany)
|
||||
|
||||
|
||||
def validate_stock_or_nonstock_items(self):
|
||||
items = [d.item_code for d in self.doclist.get({"parentfield": self.fname})]
|
||||
if self.stock_items:
|
||||
|
@ -23,6 +23,7 @@ from webnotes.model.bean import getlist
|
||||
from webnotes import msgprint, _
|
||||
|
||||
from webnotes.model.controller import DocListController
|
||||
|
||||
class DocType(DocListController):
|
||||
def validate(self):
|
||||
if not self.doc.stock_uom:
|
||||
@ -124,13 +125,12 @@ class DocType(DocListController):
|
||||
def check_ref_rate_detail(self):
|
||||
check_list=[]
|
||||
for d in getlist(self.doclist,'ref_rate_details'):
|
||||
if [cstr(d.price_list_name), cstr(d.ref_currency),
|
||||
cint(d.selling), cint(d.buying)] in check_list:
|
||||
msgprint("Ref Rate is entered twice for Price List : '%s' and Currency : '%s'." %
|
||||
(d.price_list_name,d.ref_currency), raise_exception=1)
|
||||
if d.price_list_name in check_list:
|
||||
msgprint(_("Cannot have two prices for same Price List") + ": " + d.price_list_name,
|
||||
raise_exception= webnotes.DuplicateEntryError)
|
||||
else:
|
||||
check_list.append([cstr(d.price_list_name),cstr(d.ref_currency)])
|
||||
|
||||
check_list.append(d.price_list_name)
|
||||
|
||||
def fill_customer_code(self):
|
||||
""" Append all the customer codes and insert into "customer_code" field of item table """
|
||||
cust_code=[]
|
||||
|
@ -20,6 +20,14 @@ import webnotes
|
||||
|
||||
test_ignore = ["BOM"]
|
||||
|
||||
class TestItem(unittest.TestCase):
|
||||
def test_duplicate_price_list(self):
|
||||
item = webnotes.bean(copy=test_records[0])
|
||||
item.doc.item_code = "_Test Item 10"
|
||||
item_price = item.doclist.get({"doctype": "Item Price"})[0]
|
||||
item.doclist.append(webnotes.doc(item_price.fields.copy()))
|
||||
self.assertRaises(webnotes.DuplicateEntryError, item.insert)
|
||||
|
||||
test_records = [
|
||||
[{
|
||||
"doctype": "Item",
|
||||
@ -45,7 +53,14 @@ test_records = [
|
||||
"warehouse": "_Test Warehouse",
|
||||
"warehouse_reorder_level": 20,
|
||||
"warehouse_reorder_qty": 20
|
||||
}],
|
||||
}, {
|
||||
"doctype": "Item Price",
|
||||
"parentfield": "ref_rate_details",
|
||||
"price_list_name": "_Test Price List",
|
||||
"ref_rate": 100,
|
||||
"ref_currency": "INR"
|
||||
}
|
||||
],
|
||||
[{
|
||||
"doctype": "Item",
|
||||
"item_code": "_Test Item Home Desktop 100",
|
||||
|
Loading…
x
Reference in New Issue
Block a user