Merge branch 'master' of github.com:webnotes/erpnext

This commit is contained in:
Rushabh Mehta
2012-12-25 15:09:58 +05:30
38 changed files with 470 additions and 431 deletions

View File

@@ -350,7 +350,7 @@ class DocType:
reaches re-order level when %s %s was created""" % (doc_type,doc_name)
indent.save(1)
indent_obj = get_obj('Purchase Request',indent.name,with_children=1)
indent_details_child = addchild(indent_obj.doc,'indent_details','Purchase Request Item',0)
indent_details_child = addchild(indent_obj.doc,'indent_details','Purchase Request Item')
indent_details_child.item_code = self.doc.item_code
indent_details_child.uom = self.doc.stock_uom
indent_details_child.warehouse = self.doc.warehouse

View File

@@ -70,7 +70,8 @@ class DocType:
raise Exception
if not cstr(self.doc.stock_uom) in check_list :
child = addchild( self.doc, 'uom_conversion_details', 'UOM Conversion Detail', 1, self.doclist)
child = addchild( self.doc, 'uom_conversion_details',
'UOM Conversion Detail', self.doclist)
child.uom = self.doc.stock_uom
child.conversion_factor = 1
child.save()

View File

@@ -51,7 +51,8 @@ class DocType:
msgprint("Please enter date of shorter duration as there are too many purchase receipt, hence it cannot be loaded.", raise_exception=1)
for i in pr:
ch = addchild(self.doc, 'lc_pr_details', 'Landed Cost Purchase Receipt', 1, self.doclist)
ch = addchild(self.doc, 'lc_pr_details', 'Landed Cost Purchase Receipt',
self.doclist)
ch.purchase_receipt = i and i['name'] or ''
ch.save()
@@ -62,7 +63,8 @@ class DocType:
idx = 0
landed_cost = sql("select account_head, description from `tabLanded Cost Master Detail` where parent=%s", (self.doc.landed_cost), as_dict = 1)
for cost in landed_cost:
lct = addchild(self.doc, 'landed_cost_details', 'Landed Cost Item', 1, self.doclist)
lct = addchild(self.doc, 'landed_cost_details', 'Landed Cost Item',
self.doclist)
lct.account_head = cost['account_head']
lct.description = cost['description']
@@ -100,7 +102,7 @@ class DocType:
pr_oc_row = sql("select name from `tabPurchase Taxes and Charges` where parent = %s and category = 'Valuation' and add_deduct_tax = 'Add' and charge_type = 'Actual' and account_head = %s",(pr, lc.account_head))
if not pr_oc_row: # add if not exists
ch = addchild(pr_obj.doc, 'purchase_tax_details', 'Purchase Taxes and Charges', 1)
ch = addchild(pr_obj.doc, 'purchase_tax_details', 'Purchase Taxes and Charges')
ch.category = 'Valuation'
ch.add_deduct_tax = 'Add'
ch.charge_type = 'Actual'

View File

@@ -390,7 +390,7 @@ class DocType(TransactionBase):
if i and not sql("select name from `tabPurchase Receipt Item Supplied` where reference_name = '%s' and bom_detail_no = '%s' and parent = '%s' " %(d.name, i[6], self.doc.name)):
rm_child = addchild(self.doc, 'pr_raw_material_details', 'Purchase Receipt Item Supplied', 1, self.doclist)
rm_child = addchild(self.doc, 'pr_raw_material_details', 'Purchase Receipt Item Supplied', self.doclist)
rm_child.reference_name = d.name
rm_child.bom_detail_no = i and i[6] or ''

View File

@@ -8,11 +8,11 @@
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import webnotes
@@ -26,45 +26,46 @@ sql = webnotes.conn.sql
class DocType :
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
# Pull Item Details
# ---------------------------
def pull_item_details(self):
if self.doc.return_type == 'Sales Return':
if self.doc.delivery_note_no:
det = sql("select t1.name, t1.item_code, t1.description, t1.qty, t1.uom, t2.export_rate * t3.conversion_rate, t3.customer, t3.customer_name, t3.customer_address, t2.serial_no, t2.batch_no from `tabDelivery Note Packing Item` t1, `tabDelivery Note Item` t2, `tabDelivery Note` t3 where t1.parent = t3.name and t2.parent = t3.name and t1.parent_detail_docname = t2.name and t3.name = '%s' and t3.docstatus = 1" % self.doc.delivery_note_no)
elif self.doc.sales_invoice_no:
det = sql("select t1.name, t1.item_code, t1.description, t1.qty, t1.stock_uom, t1.export_rate * t2.conversion_rate, t2.customer, t2.customer_name, t2.customer_address, t1.serial_no from `tabSales Invoice Item` t1, `tabSales Invoice` t2 where t1.parent = t2.name and t2.name = '%s' and t2.docstatus = 1" % self.doc.sales_invoice_no)
elif self.doc.return_type == 'Purchase Return' and self.doc.purchase_receipt_no:
det = sql("select t1.name, t1.item_code, t1.description, t1.received_qty, t1.uom, t1.purchase_rate, t2.supplier, t2.supplier_name, t2.supplier_address, t1.serial_no, t1.batch_no from `tabPurchase Receipt Item` t1, `tabPurchase Receipt` t2 where t1.parent = t2.name and t2.name = '%s' and t2.docstatus = 1" % self.doc.purchase_receipt_no)
# Pull Item Details
# ---------------------------
def pull_item_details(self):
if self.doc.return_type == 'Sales Return':
if self.doc.delivery_note_no:
det = sql("select t1.name, t1.item_code, t1.description, t1.qty, t1.uom, t2.export_rate * t3.conversion_rate, t3.customer, t3.customer_name, t3.customer_address, t2.serial_no, t2.batch_no from `tabDelivery Note Packing Item` t1, `tabDelivery Note Item` t2, `tabDelivery Note` t3 where t1.parent = t3.name and t2.parent = t3.name and t1.parent_detail_docname = t2.name and t3.name = '%s' and t3.docstatus = 1" % self.doc.delivery_note_no)
elif self.doc.sales_invoice_no:
det = sql("select t1.name, t1.item_code, t1.description, t1.qty, t1.stock_uom, t1.export_rate * t2.conversion_rate, t2.customer, t2.customer_name, t2.customer_address, t1.serial_no from `tabSales Invoice Item` t1, `tabSales Invoice` t2 where t1.parent = t2.name and t2.name = '%s' and t2.docstatus = 1" % self.doc.sales_invoice_no)
elif self.doc.return_type == 'Purchase Return' and self.doc.purchase_receipt_no:
det = sql("select t1.name, t1.item_code, t1.description, t1.received_qty, t1.uom, t1.purchase_rate, t2.supplier, t2.supplier_name, t2.supplier_address, t1.serial_no, t1.batch_no from `tabPurchase Receipt Item` t1, `tabPurchase Receipt` t2 where t1.parent = t2.name and t2.name = '%s' and t2.docstatus = 1" % self.doc.purchase_receipt_no)
self.doc.cust_supp = det and det[0][6] or ''
self.doc.cust_supp_name = det and det[0][7] or ''
self.doc.cust_supp_address = det and det[0][8] or ''
self.create_item_table(det)
self.doc.save()
# Create Item Table
# -----------------------------
def create_item_table(self, det):
self.doclist = self.doc.clear_table(self.doclist, 'return_details', 1)
for i in det:
ch = addchild(self.doc, 'return_details', 'Sales and Purchase Return Item', 1, self.doclist)
ch.detail_name = i and i[0] or ''
ch.item_code = i and i[1] or ''
ch.description = i and i[2] or ''
ch.qty = i and flt(i[3]) or 0
ch.uom = i and i[4] or ''
ch.rate = i and flt(i[5]) or 0
ch.serial_no = i and i[9] or ''
ch.batch_no = (len(i) == 11) and i[10] or ''
ch.save()
self.doc.cust_supp = det and det[0][6] or ''
self.doc.cust_supp_name = det and det[0][7] or ''
self.doc.cust_supp_address = det and det[0][8] or ''
self.create_item_table(det)
self.doc.save()
# Create Item Table
# -----------------------------
def create_item_table(self, det):
self.doclist = self.doc.clear_table(self.doclist, 'return_details', 1)
for i in det:
ch = addchild(self.doc, 'return_details', 'Sales and Purchase Return Item',
self.doclist)
ch.detail_name = i and i[0] or ''
ch.item_code = i and i[1] or ''
ch.description = i and i[2] or ''
ch.qty = i and flt(i[3]) or 0
ch.uom = i and i[4] or ''
ch.rate = i and flt(i[5]) or 0
ch.serial_no = i and i[9] or ''
ch.batch_no = (len(i) == 11) and i[10] or ''
ch.save()
# Clear return table
# --------------------------------
def clear_return_table(self):
self.doclist = self.doc.clear_table(self.doclist, 'return_details', 1)
self.doc.save()
# Clear return table
# --------------------------------
def clear_return_table(self):
self.doclist = self.doc.clear_table(self.doclist, 'return_details', 1)
self.doc.save()

View File

@@ -160,6 +160,7 @@ fld.get_query = function(doc, cdt, cdn) {
return 'SELECT tabItem.name, tabItem.description, tabBin.actual_qty '
+ 'FROM tabItem, tabBin '
+ 'WHERE tabItem.name = tabBin.item_code '
+ 'AND tabItem.is_stock_item = "Yes"'
+ 'AND ifnull(`tabBin`.`actual_qty`,0) > 0 '
+ 'AND tabBin.warehouse="'+ d.s_warehouse +'" '
+ 'AND tabItem.docstatus < 2 '
@@ -171,6 +172,7 @@ fld.get_query = function(doc, cdt, cdn) {
return 'SELECT tabItem.name, tabItem.description '
+ 'FROM tabItem '
+ 'WHERE tabItem.docstatus < 2 '
+ 'AND tabItem.is_stock_item = "Yes"'
+ 'AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") '
+ 'AND tabItem.%(key)s LIKE "%s" '
+ 'ORDER BY tabItem.name ASC '

View File

@@ -36,7 +36,6 @@ class DocType(TransactionBase):
def validate(self):
self.validate_serial_nos()
pro_obj = self.doc.production_order and \
get_obj('Production Order', self.doc.production_order) or None
@@ -467,7 +466,8 @@ class DocType(TransactionBase):
def add_to_stock_entry_detail(self, source_wh, target_wh, item_dict, bom_no=None):
for d in item_dict:
se_child = addchild(self.doc, 'mtn_details', 'Stock Entry Detail', 0, self.doclist)
se_child = addchild(self.doc, 'mtn_details', 'Stock Entry Detail',
self.doclist)
se_child.s_warehouse = source_wh
se_child.t_warehouse = target_wh
se_child.item_code = cstr(d)
@@ -543,6 +543,6 @@ class DocType(TransactionBase):
@webnotes.whitelist()
def get_production_order_details(production_order):
result = webnotes.conn.sql("""select bom_no,
ifnull(qty, 0) - ifnull(produced_qty, 0) as fg_completed_qty
ifnull(qty, 0) - ifnull(produced_qty, 0) as fg_completed_qty, use_multi_level_bom
from `tabProduction Order` where name = %s""", production_order, as_dict=1)
return result and result[0] or {}

View File

@@ -28,6 +28,14 @@ class DocType:
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
def validate(self):
self.validate_mandatory()
self.validate_posting_time()
self.validate_item()
self.actual_amt_check()
self.check_stock_frozen_date()
self.scrub_posting_time()
#check for item quantity available in stock
def actual_amt_check(self):
@@ -53,13 +61,19 @@ class DocType:
msgprint("Warehouse: '%s' does not exist in the system. Please check." % self.doc.fields.get(k), raise_exception = 1)
def validate_item(self):
item_det = sql("select name, has_batch_no, docstatus from tabItem where name = '%s'" % self.doc.item_code)
item_det = sql("""select name, has_batch_no, docstatus,
ifnull(is_stock_item, 'No') from tabItem where name=%s""",
self.doc.item_code)
# check item exists
if item_det:
item_det = item_det and item_det[0]
else:
msgprint("Item: '%s' does not exist in the system. Please check." % self.doc.item_code, raise_exception = 1)
if item_det[3]!='Yes':
webnotes.msgprint("""Item: "%s" is not a Stock Item.""" % self.doc.item_code,
raise_exception=1)
# check if item is trashed
if cint(item_det[2])==2:
@@ -96,12 +110,4 @@ class DocType:
self.doc.posting_time = '00:00'
if len(self.doc.posting_time.split(':')) > 2:
self.doc.posting_time = '00:00'
def validate(self):
self.validate_mandatory()
self.validate_posting_time()
self.validate_item()
self.actual_amt_check()
self.check_stock_frozen_date()
self.scrub_posting_time()