[cleanup] purchase common
diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.py b/accounts/doctype/purchase_invoice/purchase_invoice.py
index 8bd7e9d..ba6f5a4 100644
--- a/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -293,20 +293,14 @@
reconcile_against_document(lst)
def on_submit(self):
- purchase_controller = webnotes.get_obj("Purchase Common")
- purchase_controller.is_item_table_empty(self)
-
self.check_prev_docstatus()
- # Check for Approving Authority
- get_obj('Authorization Control').validate_approving_authority(self.doc.doctype,self.doc.company, self.doc.grand_total)
-
+ get_obj('Authorization Control').validate_approving_authority(self.doc.doctype,
+ self.doc.company, self.doc.grand_total)
# this sequence because outstanding may get -negative
self.make_gl_entries()
-
self.update_against_document_in_jv()
-
self.update_prevdoc_status()
def make_gl_entries(self):
diff --git a/accounts/doctype/sales_invoice/sales_invoice.txt b/accounts/doctype/sales_invoice/sales_invoice.txt
index 331a503..3419188 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.txt
+++ b/accounts/doctype/sales_invoice/sales_invoice.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-05-24 19:29:05",
"docstatus": 0,
- "modified": "2013-10-11 13:12:38",
+ "modified": "2013-10-18 13:12:38",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -323,7 +323,7 @@
"fieldname": "packing_details",
"fieldtype": "Table",
"label": "Packing Details",
- "options": "Delivery Note Packing Item",
+ "options": "Packed Item",
"print_hide": 1,
"read_only": 0
},
diff --git a/accounts/report/gross_profit/gross_profit.py b/accounts/report/gross_profit/gross_profit.py
index 9917b69..6d01af4 100644
--- a/accounts/report/gross_profit/gross_profit.py
+++ b/accounts/report/gross_profit/gross_profit.py
@@ -75,7 +75,7 @@
for d in webnotes.conn.sql("""select parenttype, parent, parent_item,
item_code, warehouse, -1*qty as total_qty, parent_detail_docname
- from `tabDelivery Note Packing Item` where docstatus=1""", as_dict=True):
+ from `tabPacked Item` where docstatus=1""", as_dict=True):
item_sales_bom.setdefault(d.parenttype, webnotes._dict()).setdefault(d.parent,
webnotes._dict()).setdefault(d.parent_item, []).append(d)
diff --git a/buying/doctype/purchase_common/purchase_common.py b/buying/doctype/purchase_common/purchase_common.py
index 8637e5f..4d2bc00 100644
--- a/buying/doctype/purchase_common/purchase_common.py
+++ b/buying/doctype/purchase_common/purchase_common.py
@@ -16,25 +16,6 @@
def __init__(self, doc, doclist=None):
self.doc = doc
self.doclist = doclist
-
- def is_item_table_empty(self, obj):
- if not len(obj.doclist.get({"parentfield": obj.fname})):
- msgprint(_("You need to put at least one item in the item table."), raise_exception=True)
-
- def get_supplier_details(self, name = ''):
- details = webnotes.conn.sql("select supplier_name,address from `tabSupplier` where name = '%s' and docstatus != 2" %(name), as_dict = 1)
- if details:
- ret = {
- 'supplier_name' : details and details[0]['supplier_name'] or '',
- 'supplier_address' : details and details[0]['address'] or ''
- }
- # ********** get primary contact details (this is done separately coz. , in case there is no primary contact thn it would not be able to fetch customer details in case of join query)
- contact_det = webnotes.conn.sql("select contact_name, contact_no, email_id from `tabContact` where supplier = '%s' and is_supplier = 1 and is_primary_contact = 'Yes' and docstatus != 2" %(name), as_dict = 1)
- ret['contact_person'] = contact_det and contact_det[0]['contact_name'] or ''
- return ret
- else:
- msgprint("Supplier : %s does not exists" % (name))
- raise Exception
def update_last_purchase_rate(self, obj, is_submit):
"""updates last_purchase_rate in item table for each item"""
diff --git a/buying/doctype/purchase_order/purchase_order.py b/buying/doctype/purchase_order/purchase_order.py
index cf207bb..d3555fc 100644
--- a/buying/doctype/purchase_order/purchase_order.py
+++ b/buying/doctype/purchase_order/purchase_order.py
@@ -147,7 +147,6 @@
def on_submit(self):
purchase_controller = webnotes.get_obj("Purchase Common")
- purchase_controller.is_item_table_empty(self)
self.update_prevdoc_status()
self.update_bin(is_submit = 1, is_stopped = 0)
diff --git a/buying/doctype/supplier_quotation/supplier_quotation.py b/buying/doctype/supplier_quotation/supplier_quotation.py
index 8c5224e..67c8360 100644
--- a/buying/doctype/supplier_quotation/supplier_quotation.py
+++ b/buying/doctype/supplier_quotation/supplier_quotation.py
@@ -26,9 +26,6 @@
self.validate_uom_is_integer("uom", "qty")
def on_submit(self):
- purchase_controller = webnotes.get_obj("Purchase Common")
- purchase_controller.is_item_table_empty(self)
-
webnotes.conn.set(self.doc, "status", "Submitted")
def on_cancel(self):
diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py
index c42eda5..2677252 100644
--- a/controllers/buying_controller.py
+++ b/controllers/buying_controller.py
@@ -2,7 +2,7 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
-import webnotes, json
+import webnotes
from webnotes import _, msgprint
from webnotes.utils import flt, _round
@@ -12,7 +12,6 @@
from controllers.stock_controller import StockController
class BuyingController(StockController):
-
def onload_post_render(self):
# contact, address, item details
self.set_missing_values()
@@ -22,6 +21,7 @@
if self.doc.supplier and not self.doc.supplier_name:
self.doc.supplier_name = webnotes.conn.get_value("Supplier",
self.doc.supplier, "supplier_name")
+ self.is_item_table_empty()
self.validate_stock_or_nonstock_items()
self.validate_warehouse()
@@ -279,3 +279,8 @@
(", ".join((["%s"]*len(item_codes))),), item_codes)]
return self._purchase_items
+
+
+ def is_item_table_empty(self):
+ if not len(self.doclist.get({"parentfield": self.fname})):
+ webnotes.throw(_("Item table can not be blank"))
\ No newline at end of file
diff --git a/manufacturing/doctype/production_order/production_order.py b/manufacturing/doctype/production_order/production_order.py
index 36cbc64..9d4ff32 100644
--- a/manufacturing/doctype/production_order/production_order.py
+++ b/manufacturing/doctype/production_order/production_order.py
@@ -69,7 +69,7 @@
where parent = %s and item_code = %s""",
(self.doc.sales_order, self.doc.production_item))[0][0]
# get qty from Packing Item table
- dnpi_qty = webnotes.conn.sql("""select sum(qty) from `tabDelivery Note Packing Item`
+ dnpi_qty = webnotes.conn.sql("""select sum(qty) from `tabPacked Item`
where parent = %s and parenttype = 'Sales Order' and item_code = %s""",
(self.doc.sales_order, self.doc.production_item))[0][0]
# total qty in SO
diff --git a/patches/october_2013/p06_rename_packing_list_doctype.py b/patches/october_2013/p06_rename_packing_list_doctype.py
index a7a11e4..d7c5c12 100644
--- a/patches/october_2013/p06_rename_packing_list_doctype.py
+++ b/patches/october_2013/p06_rename_packing_list_doctype.py
@@ -14,7 +14,8 @@
webnotes.reload_doc("stock", "doctype", "packed_item")
- os.system("rm -rf app/stock/doctype/delivery_note_packing_item")
+ if os.path.exists("app/stock/doctype/delivery_note_packing_item"):
+ os.system("rm -rf app/stock/doctype/delivery_note_packing_item")
if webnotes.conn.exists("DocType", "Delivery Note Packing Item"):
webnotes.delete_doc("DocType", "Delivery Note Packing Item")
\ No newline at end of file
diff --git a/stock/doctype/material_request/material_request.py b/stock/doctype/material_request/material_request.py
index 7aea336..4af86da 100644
--- a/stock/doctype/material_request/material_request.py
+++ b/stock/doctype/material_request/material_request.py
@@ -96,9 +96,6 @@
update_bin(args)
def on_submit(self):
- purchase_controller = webnotes.get_obj("Purchase Common")
- purchase_controller.is_item_table_empty(self)
-
webnotes.conn.set(self.doc,'status','Submitted')
self.update_bin(is_submit = 1, is_stopped = 0)
diff --git a/stock/doctype/purchase_receipt/purchase_receipt.py b/stock/doctype/purchase_receipt/purchase_receipt.py
index 1379406..99cbd0b 100644
--- a/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -227,7 +227,6 @@
# on submit
def on_submit(self):
purchase_controller = webnotes.get_obj("Purchase Common")
- purchase_controller.is_item_table_empty(self)
# Check for Approving Authority
get_obj('Authorization Control').validate_approving_authority(self.doc.doctype, self.doc.company, self.doc.grand_total)