Merge branch 'responsive' of git://github.com/webnotes/erpnext into responsive

This commit is contained in:
Saurabh
2013-07-09 10:18:39 +05:30
49 changed files with 287 additions and 275 deletions

View File

@@ -17,8 +17,7 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import add_days, cint, cstr, flt
from webnotes.model.doc import addchild
from webnotes.utils import add_days, cstr, flt
from webnotes.model.bean import getlist
from webnotes.model.code import get_obj
from webnotes import msgprint, _
@@ -184,29 +183,6 @@ class DocType(BuyingController):
if item[0][1] != 'Yes' and item[0][2] != 'Yes':
msgprint("Item %s is not a purchase item or sub-contracted item. Please check" % (d.item_code), raise_exception=True)
if d.fields.has_key('prevdoc_docname') and d.prevdoc_docname:
# check warehouse, uom in previous doc and in current doc are same.
data = sql("select item_code, warehouse, uom from `tab%s` where name = '%s'" % ( self.doctype_dict[d.prevdoc_doctype], d.prevdoc_detail_docname), as_dict = 1)
if not data:
msgprint("Please fetch data in Row " + cstr(d.idx) + " once again or please contact Administrator.")
raise Exception
# Check if Item Code has been modified.
if not cstr(data[0]['item_code']) == cstr(d.item_code):
msgprint("Please check Item %s is not present in %s %s ." % (d.item_code, d.prevdoc_doctype, d.prevdoc_docname))
raise Exception
if cstr(data[0]['warehouse']) and \
not cstr(data[0]['warehouse']) == cstr(d.warehouse):
msgprint("""Please check warehouse %s of Item %s
which is not present in %s %s""" % (d.warehouse, d.item_code,
d.prevdoc_doctype, d.prevdoc_docname), raise_exception=1)
# Check if UOM has been modified.
if not cstr(data[0]['uom']) == cstr(d.uom) and not cstr(d.prevdoc_doctype) == 'Material Request':
msgprint("Please check UOM %s of Item %s which is not present in %s %s ." % \
(d.uom, d.item_code, d.prevdoc_doctype, d.prevdoc_docname), raise_exception=True)
# list criteria that should not repeat if item is stock item
e = [d.schedule_date, d.item_code, d.description, d.warehouse, d.uom, d.fields.has_key('prevdoc_docname') and d.prevdoc_docname or '', d.fields.has_key('prevdoc_detail_docname') and d.prevdoc_detail_docname or '', d.fields.has_key('batch_no') and d.batch_no or '']
@@ -215,7 +191,7 @@ class DocType(BuyingController):
ch = sql("select is_stock_item from `tabItem` where name = '%s'"%d.item_code)
if ch and ch[0][0] == 'Yes':
if ch and ch[0][0] == 'Yes':
# check for same items
if e in check_list:
msgprint("""Item %s has been entered more than once with same description, schedule date, warehouse and uom.\n
@@ -239,8 +215,6 @@ class DocType(BuyingController):
msgprint("One cannot do any transaction against %s : %s, it's status is 'Stopped'" %
( doctype, docname), raise_exception=1)
def validate_reference_value(self, obj=None):
pass
# Check Docstatus of Next DocType on Cancel AND of Previous DocType on Submit
def check_docstatus(self, check, doctype, docname , detail_doctype = ''):

View File

@@ -47,15 +47,28 @@ class DocType(BuyingController):
pc_obj = get_obj(dt='Purchase Common')
pc_obj.validate_for_items(self)
pc_obj.get_prevdoc_date(self)
self.validate_doc(pc_obj)
self.check_for_stopped_status(pc_obj)
self.validate_with_previous_doc()
self.validate_for_subcontracting()
self.update_raw_materials_supplied("po_raw_material_details")
def validate_fiscal_year(self):
get_obj(dt = 'Purchase Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.transaction_date,'PO Date')
def validate_with_previous_doc(self):
super(DocType, self).validate_with_previous_doc(self.tname, {
"Supplier Quotation": {
"ref_dn_field": "supplier_quotation",
"compare_fields": [["supplier", "="], ["company", "="], ["currency", "="]],
},
"Supplier Quotation Item": {
"ref_dn_field": "supplier_quotation_item",
"compare_fields": [["export_rate", "="], ["project_name", "="], ["item_code", "="],
["uom", "="]],
"is_child_table": True
}
})
# get available qty at warehouse
def get_bin_details(self, arg = ''):
@@ -69,10 +82,6 @@ class DocType(BuyingController):
def get_last_purchase_rate(self):
get_obj('Purchase Common').get_last_purchase_rate(self)
def validate_doc(self,pc_obj):
# Validate values with reference document
pc_obj.validate_reference_value(obj = self)
# Check for Stopped status
def check_for_stopped_status(self, pc_obj):

View File

@@ -37,6 +37,7 @@ class TestPurchaseOrder(unittest.TestCase):
self.assertEquals(pr[0]["doctype"], "Purchase Receipt")
self.assertEquals(len(pr), len(test_records[0]))
pr[0].naming_series = "_T-Purchase Receipt-"
webnotes.bean(pr).insert()
def test_make_purchase_invocie(self):
@@ -54,6 +55,7 @@ class TestPurchaseOrder(unittest.TestCase):
self.assertEquals(pi[0]["doctype"], "Purchase Invoice")
self.assertEquals(len(pi), len(test_records[0]))
pi[0].bill_no = "NA"
webnotes.bean(pi).insert()
def test_subcontracting(self):
@@ -75,6 +77,7 @@ test_records = [
[
{
"company": "_Test Company",
"naming_series": "_T-Purchase Order-",
"conversion_rate": 1.0,
"currency": "INR",
"doctype": "Purchase Order",
@@ -86,7 +89,6 @@ test_records = [
"net_total": 5000.0,
"grand_total": 5000.0,
"grand_total_import": 5000.0,
},
{
"conversion_factor": 1.0,
@@ -101,6 +103,7 @@ test_records = [
"warehouse": "_Test Warehouse",
"stock_uom": "Nos",
"uom": "_Test UOM",
"schedule_date": "2013-03-01"
}
],
]

View File

@@ -36,6 +36,7 @@ class DocType(BuyingController):
self.validate_fiscal_year()
self.validate_common()
self.validate_with_previous_doc()
def on_submit(self):
purchase_controller = webnotes.get_obj("Purchase Common")
@@ -53,11 +54,24 @@ class DocType(BuyingController):
get_obj(dt = 'Purchase Common').validate_fiscal_year( \
self.doc.fiscal_year, self.doc.transaction_date, 'Quotation Date')
def validate_with_previous_doc(self):
super(DocType, self).validate_with_previous_doc(self.tname, {
"Material Request": {
"ref_dn_field": "prevdoc_docname",
"compare_fields": [["company", "="]],
},
"Material Request Item": {
"ref_dn_field": "prevdoc_detail_docname",
"compare_fields": [["item_code", "="], ["uom", "="]],
"is_child_table": True
}
})
def validate_common(self):
pc = get_obj('Purchase Common')
pc.validate_for_items(self)
pc.get_prevdoc_date(self)
pc.validate_reference_value(self)
@webnotes.whitelist()
def make_purchase_order(source_name, target_doclist=None):

View File

@@ -36,6 +36,12 @@ class TestPurchaseOrder(unittest.TestCase):
self.assertEquals(po[0]["doctype"], "Purchase Order")
self.assertEquals(len(po), len(sq.doclist))
po[0]["naming_series"] = "_T-Purchase Order-"
for doc in po:
if doc.get("item_code"):
doc["schedule_date"] = "2013-04-12"
webnotes.bean(po).insert()
test_records = [
@@ -53,7 +59,7 @@ test_records = [
"net_total": 5000.0,
"grand_total": 5000.0,
"grand_total_import": 5000.0,
"naming_series": "_T-Supplier Quotation-"
},
{
"description": "_Test FG Item",