[cleanup] purchase common

This commit is contained in:
Nabin Hait 2013-10-18 17:00:53 +05:30
parent 0bc5ae55d8
commit 5566bcaa0e
11 changed files with 15 additions and 42 deletions

View File

@ -293,20 +293,14 @@ class DocType(BuyingController):
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):

View File

@ -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
},

View File

@ -75,7 +75,7 @@ def get_item_sales_bom():
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)

View File

@ -16,25 +16,6 @@ class DocType(BuyingController):
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"""

View File

@ -147,7 +147,6 @@ class DocType(BuyingController):
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)

View File

@ -26,9 +26,6 @@ class DocType(BuyingController):
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):

View File

@ -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 setup.utils import get_company_currency
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 @@ class BuyingController(StockController):
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 @@ class BuyingController(StockController):
(", ".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"))

View File

@ -69,7 +69,7 @@ class DocType:
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

View File

@ -14,7 +14,8 @@ def execute():
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")

View File

@ -96,9 +96,6 @@ class DocType(BuyingController):
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)

View File

@ -227,7 +227,6 @@ class DocType(BuyingController):
# 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)