[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,11 +47,11 @@ class BuyingController(StockController):
|
|||||||
self.set_total_in_words()
|
self.set_total_in_words()
|
||||||
|
|
||||||
def validate_warehouse_belongs_to_company(self):
|
def validate_warehouse_belongs_to_company(self):
|
||||||
for d in self.doclist.get({"warehouse": True}):
|
for warehouse, company in webnotes.conn.get_values("Warehouse",
|
||||||
warehouse_company = webnotes.conn.get_value("Warehouse", d.warehouse, "company")
|
self.doclist.get_distinct_values("warehouse"), "company").items():
|
||||||
if warehouse_company and warehouse_company != self.doc.company:
|
if company and company != self.doc.company:
|
||||||
webnotes.msgprint(_("Warehouse must belong to 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)
|
raise_exception=WrongWarehouseCompany)
|
||||||
|
|
||||||
def validate_stock_or_nonstock_items(self):
|
def validate_stock_or_nonstock_items(self):
|
||||||
|
@ -23,6 +23,7 @@ from webnotes.model.bean import getlist
|
|||||||
from webnotes import msgprint, _
|
from webnotes import msgprint, _
|
||||||
|
|
||||||
from webnotes.model.controller import DocListController
|
from webnotes.model.controller import DocListController
|
||||||
|
|
||||||
class DocType(DocListController):
|
class DocType(DocListController):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
if not self.doc.stock_uom:
|
if not self.doc.stock_uom:
|
||||||
@ -124,12 +125,11 @@ class DocType(DocListController):
|
|||||||
def check_ref_rate_detail(self):
|
def check_ref_rate_detail(self):
|
||||||
check_list=[]
|
check_list=[]
|
||||||
for d in getlist(self.doclist,'ref_rate_details'):
|
for d in getlist(self.doclist,'ref_rate_details'):
|
||||||
if [cstr(d.price_list_name), cstr(d.ref_currency),
|
if d.price_list_name in check_list:
|
||||||
cint(d.selling), cint(d.buying)] in check_list:
|
msgprint(_("Cannot have two prices for same Price List") + ": " + d.price_list_name,
|
||||||
msgprint("Ref Rate is entered twice for Price List : '%s' and Currency : '%s'." %
|
raise_exception= webnotes.DuplicateEntryError)
|
||||||
(d.price_list_name,d.ref_currency), raise_exception=1)
|
|
||||||
else:
|
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):
|
def fill_customer_code(self):
|
||||||
""" Append all the customer codes and insert into "customer_code" field of item table """
|
""" Append all the customer codes and insert into "customer_code" field of item table """
|
||||||
|
@ -20,6 +20,14 @@ import webnotes
|
|||||||
|
|
||||||
test_ignore = ["BOM"]
|
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 = [
|
test_records = [
|
||||||
[{
|
[{
|
||||||
"doctype": "Item",
|
"doctype": "Item",
|
||||||
@ -45,7 +53,14 @@ test_records = [
|
|||||||
"warehouse": "_Test Warehouse",
|
"warehouse": "_Test Warehouse",
|
||||||
"warehouse_reorder_level": 20,
|
"warehouse_reorder_level": 20,
|
||||||
"warehouse_reorder_qty": 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",
|
"doctype": "Item",
|
||||||
"item_code": "_Test Item Home Desktop 100",
|
"item_code": "_Test Item Home Desktop 100",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user