mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-22 14:39:19 +00:00
Merge branch 'responsive' of github.com:webnotes/erpnext into responsive
This commit is contained in:
@@ -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 = ''):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user