Merge branch 'develop' of github.com:webnotes/erpnext into hotfix

This commit is contained in:
Nabin Hait
2013-12-18 10:42:04 +05:30
82 changed files with 1057 additions and 1644 deletions

View File

@@ -73,6 +73,9 @@ class DocType(SellingController):
self.update_current_stock()
self.validate_with_previous_doc()
from stock.doctype.packed_item.packed_item import make_packing_list
self.doclist = make_packing_list(self, 'delivery_note_details')
self.doc.status = 'Draft'
if not self.doc.installation_status: self.doc.installation_status = 'Not Installed'
@@ -142,10 +145,6 @@ class DocType(SellingController):
bin = webnotes.conn.sql("select actual_qty, projected_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0
d.projected_qty = bin and flt(bin[0]['projected_qty']) or 0
def on_update(self):
from stock.doctype.packed_item.packed_item import make_packing_list
self.doclist = make_packing_list(self, 'delivery_note_details')
def on_submit(self):
self.validate_packed_qty()

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-05-24 19:29:09",
"docstatus": 0,
"modified": "2013-11-03 14:20:19",
"modified": "2013-12-14 17:26:12",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -229,7 +229,7 @@
"doctype": "DocField",
"fieldname": "po_date",
"fieldtype": "Date",
"hidden": 1,
"hidden": 0,
"label": "Customer's Purchase Order Date",
"no_copy": 0,
"oldfieldname": "po_date",
@@ -1058,7 +1058,7 @@
},
{
"doctype": "DocPerm",
"match": "customer_name",
"match": "customer",
"role": "Customer"
}
]

View File

@@ -4,7 +4,7 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cstr, flt, cint
from webnotes.utils import cstr, flt
from webnotes.model.doc import addchild
from webnotes.model.bean import getlist
from webnotes import msgprint, _
@@ -116,40 +116,29 @@ class DocType(DocListController, WebsiteGenerator):
self.doc.is_pro_applicable = "No"
if self.doc.is_pro_applicable == 'Yes' and self.doc.is_stock_item == 'No':
msgprint("As Production Order can be made for this Item, then Is Stock Item Should be 'Yes' as we maintain it's stock. Refer Manufacturing and Inventory section.", raise_exception=1)
webnotes.throw(_("As Production Order can be made for this item, \
it must be a stock item."))
if self.doc.has_serial_no == 'Yes' and self.doc.is_stock_item == 'No':
msgprint("'Has Serial No' can not be 'Yes' for non-stock item", raise_exception=1)
def check_for_active_boms(self):
def _check_for_active_boms(field_label):
if field_label in ['Is Active', 'Is Purchase Item']:
bom_mat = webnotes.conn.sql("""select distinct t1.parent
from `tabBOM Item` t1, `tabBOM` t2 where t2.name = t1.parent
and t1.item_code =%s and ifnull(t1.bom_no, '') = '' and t2.is_active = 1
and t2.docstatus = 1 and t1.docstatus =1 """, self.doc.name)
if bom_mat and bom_mat[0][0]:
msgprint(_(field_label) + _(" should be 'Yes'. As Item: ") + self.doc.name +
_(" is present in one or many Active BOMs"), raise_exception=1)
if ((field_label == 'Allow Production Order'
and self.doc.is_sub_contracted_item != 'Yes')
or (field_label == 'Is Sub Contracted Item'
and self.doc.is_manufactured_item != 'Yes')):
bom = webnotes.conn.sql("""select name from `tabBOM` where item = %s
and is_active = 1""", (self.doc.name,))
if bom and bom[0][0]:
msgprint(_(field_label) + _(" should be 'Yes'. As Item: ") + self.doc.name +
_(" is present in one or many Active BOMs"), raise_exception=1)
if not cint(self.doc.fields.get("__islocal")):
fl = {'is_manufactured_item' :'Allow Bill of Materials',
'is_sub_contracted_item':'Is Sub Contracted Item',
'is_purchase_item' :'Is Purchase Item',
'is_pro_applicable' :'Allow Production Order'}
for d in fl:
if cstr(self.doc.fields.get(d)) != 'Yes':
_check_for_active_boms(fl[d])
if self.doc.is_active != "Yes" or self.doc.is_purchase_item != "Yes":
bom_mat = webnotes.conn.sql("""select distinct t1.parent
from `tabBOM Item` t1, `tabBOM` t2 where t2.name = t1.parent
and t1.item_code =%s and ifnull(t1.bom_no, '') = '' and t2.is_active = 1
and t2.docstatus = 1 and t1.docstatus =1 """, self.doc.name)
if bom_mat and bom_mat[0][0]:
webnotes.throw(_("Item must be active and purchase item, \
as it is present in one or many Active BOMs"))
if self.doc.is_manufactured_item != "Yes":
bom = webnotes.conn.sql("""select name from `tabBOM` where item = %s
and is_active = 1""", (self.doc.name,))
if bom and bom[0][0]:
webnotes.throw(_("""Allow Bill of Materials should be 'Yes'. Because one or many \
active BOMs present for this item"""))
def fill_customer_code(self):
""" Append all the customer codes and insert into "customer_code" field of item table """

View File

@@ -37,20 +37,25 @@ class DocType(BuyingController):
for so_no in so_items.keys():
for item in so_items[so_no].keys():
already_indented = webnotes.conn.sql("select sum(qty) from `tabMaterial Request Item` where item_code = '%s' and sales_order_no = '%s' and docstatus = 1 and parent != '%s'" % (item, so_no, self.doc.name))
already_indented = webnotes.conn.sql("""select sum(qty) from `tabMaterial Request Item`
where item_code = %s and sales_order_no = %s and
docstatus = 1 and parent != %s""", (item, so_no, self.doc.name))
already_indented = already_indented and flt(already_indented[0][0]) or 0
actual_so_qty = webnotes.conn.sql("select sum(qty) from `tabSales Order Item` where parent = '%s' and item_code = '%s' and docstatus = 1 group by parent" % (so_no, item))
actual_so_qty = webnotes.conn.sql("""select sum(qty) from `tabSales Order Item`
where parent = %s and item_code = %s and docstatus = 1
group by parent""", (so_no, item))
actual_so_qty = actual_so_qty and flt(actual_so_qty[0][0]) or 0
if flt(so_items[so_no][item]) + already_indented > actual_so_qty:
msgprint("You can raise indent of maximum qty: %s for item: %s against sales order: %s\n Anyway, you can add more qty in new row for the same item." % (actual_so_qty - already_indented, item, so_no), raise_exception=1)
if actual_so_qty and (flt(so_items[so_no][item]) + already_indented > actual_so_qty):
webnotes.throw("You can raise indent of maximum qty: %s for item: %s against sales order: %s\
\n Anyway, you can add more qty in new row for the same item."
% (actual_so_qty - already_indented, item, so_no))
def validate_schedule_date(self):
for d in getlist(self.doclist, 'indent_details'):
if d.schedule_date < self.doc.transaction_date:
msgprint("Expected Date cannot be before Material Request Date")
raise Exception
webnotes.throw(_("Expected Date cannot be before Material Request Date"))
# Validate
# ---------------------
@@ -80,8 +85,8 @@ class DocType(BuyingController):
for d in getlist(self.doclist, 'indent_details'):
if webnotes.conn.get_value("Item", d.item_code, "is_stock_item") == "Yes":
if not d.warehouse:
msgprint("Please Enter Warehouse for Item %s as it is stock item"
% cstr(d.item_code), raise_exception=1)
webnotes.throw("Please Enter Warehouse for Item %s as it is stock item"
% cstr(d.item_code))
qty =flt(d.qty)
if is_stopped:
@@ -96,16 +101,17 @@ class DocType(BuyingController):
update_bin(args)
def on_submit(self):
webnotes.conn.set(self.doc,'status','Submitted')
webnotes.conn.set(self.doc, 'status', 'Submitted')
self.update_bin(is_submit = 1, is_stopped = 0)
def check_modified_date(self):
mod_db = webnotes.conn.sql("select modified from `tabMaterial Request` where name = '%s'" % self.doc.name)
date_diff = webnotes.conn.sql("select TIMEDIFF('%s', '%s')" % ( mod_db[0][0],cstr(self.doc.modified)))
mod_db = webnotes.conn.sql("""select modified from `tabMaterial Request` where name = %s""",
self.doc.name)
date_diff = webnotes.conn.sql("""select TIMEDIFF('%s', '%s')"""
% (mod_db[0][0], cstr(self.doc.modified)))
if date_diff and date_diff[0][0]:
msgprint(cstr(self.doc.doctype) +" => "+ cstr(self.doc.name) +" has been modified. Please Refresh. ")
raise Exception
webnotes.throw(cstr(self.doc.doctype) + " => " + cstr(self.doc.name) + " has been modified. Please Refresh.")
def update_status(self, status):
self.check_modified_date()
@@ -113,10 +119,10 @@ class DocType(BuyingController):
self.update_bin(is_submit = (status == 'Submitted') and 1 or 0, is_stopped = 1)
# Step 2:=> Set status
webnotes.conn.set(self.doc,'status',cstr(status))
webnotes.conn.set(self.doc, 'status', cstr(status))
# Step 3:=> Acknowledge User
msgprint(self.doc.doctype + ": " + self.doc.name + " has been %s." % ((status == 'Submitted') and 'Unstopped' or cstr(status)) )
msgprint(self.doc.doctype + ": " + self.doc.name + " has been %s." % ((status == 'Submitted') and 'Unstopped' or cstr(status)))
def on_cancel(self):
@@ -177,9 +183,9 @@ def update_completed_qty(controller, caller_method):
mr_doctype = webnotes.get_doctype("Material Request")
if mr_obj.doc.status in ["Stopped", "Cancelled"]:
msgprint(_("Material Request") + ": %s, " % mr_obj.doc.name
webnotes.throw(_("Material Request") + ": %s, " % mr_obj.doc.name
+ _(mr_doctype.get_label("status")) + " = %s. " % _(mr_obj.doc.status)
+ _("Cannot continue."), raise_exception=webnotes.InvalidStatusError)
+ _("Cannot continue."), exc=webnotes.InvalidStatusError)
_update_requested_qty(controller, mr_obj, mr_items)

View File

@@ -56,9 +56,6 @@ def update_packing_list_item(obj, packing_item_code, qty, warehouse, line, packi
pi.batch_no = cstr(line.batch_no)
pi.idx = packing_list_idx
# saved, since this function is called on_update of delivery note
pi.save()
packing_list_idx += 1
@@ -87,19 +84,13 @@ def cleanup_packing_list(obj, parent_items):
for d in obj.doclist.get({"parentfield": "packing_details"}):
if [d.parent_item, d.parent_detail_docname] not in parent_items:
# mark for deletion from doclist
delete_list.append(d.name)
delete_list.append([d.parent_item, d.parent_detail_docname])
if not delete_list:
return obj.doclist
# delete from doclist
obj.doclist = webnotes.doclist(filter(lambda d: d.name not in delete_list, obj.doclist))
# delete from db
webnotes.conn.sql("""\
delete from `tabPacked Item`
where name in (%s)"""
% (", ".join(["%s"] * len(delete_list))),
tuple(delete_list))
obj.doclist = webnotes.doclist(filter(lambda d: [d.parent_item, d.parent_detail_docname]
not in delete_list, obj.doclist))
return obj.doclist

View File

@@ -150,7 +150,7 @@ class DocType(StockController):
where serial_no like %s and item_code=%s and ifnull(is_cancelled, 'No')='No'
order by posting_date desc, posting_time desc, name desc""",
("%%%s%%" % self.doc.name, self.doc.item_code), as_dict=1):
if self.doc.name in get_serial_nos(sle.serial_no):
if self.doc.name.upper() in get_serial_nos(sle.serial_no):
if sle.actual_qty > 0:
sle_dict.setdefault("incoming", []).append(sle)
else:
@@ -268,7 +268,8 @@ def get_item_details(item_code):
from tabItem where name=%s""", item_code, as_dict=True)[0]
def get_serial_nos(serial_no):
return [s.strip() for s in cstr(serial_no).strip().replace(',', '\n').split('\n') if s.strip()]
return [s.strip() for s in cstr(serial_no).strip().upper().replace(',', '\n').split('\n')
if s.strip()]
def make_serial_no(serial_no, sle):
sr = webnotes.new_bean("Serial No")

View File

@@ -106,7 +106,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
},
callback: function(r) {
if (!r.exc) {
for(d in getchildren('Stock Entry Detail',doc.name,'mtn_details')) {
for(d in getchildren('Stock Entry Detail', me.frm.doc.name, 'mtn_details')) {
if(!d.expense_account) d.expense_account = r.message;
}
}
@@ -244,7 +244,7 @@ cur_frm.script_manager.make(erpnext.stock.StockEntry);
cur_frm.cscript.toggle_related_fields = function(doc) {
disable_from_warehouse = inList(["Material Receipt", "Sales Return"], doc.purpose);
disable_to_warehouse = inList(["Material Issue", "Purchase Return"], doc.purpose)
disable_to_warehouse = inList(["Material Issue", "Purchase Return"], doc.purpose);
cur_frm.toggle_enable("from_warehouse", !disable_from_warehouse);
cur_frm.toggle_enable("to_warehouse", !disable_to_warehouse);
@@ -302,7 +302,7 @@ cur_frm.fields_dict['production_order'].get_query = function(doc) {
}
cur_frm.cscript.purpose = function(doc, cdt, cdn) {
cur_frm.cscript.toggle_related_fields(doc, cdt, cdn);
cur_frm.cscript.toggle_related_fields(doc);
}
// Overloaded query for link batch_no

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-04-09 11:43:55",
"docstatus": 0,
"modified": "2013-11-03 14:11:42",
"modified": "2013-12-09 16:24:10",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -108,7 +108,7 @@
"doctype": "DocField",
"fieldname": "delivery_note_no",
"fieldtype": "Link",
"hidden": 1,
"hidden": 0,
"in_filter": 0,
"label": "Delivery Note No",
"no_copy": 1,
@@ -126,7 +126,7 @@
"doctype": "DocField",
"fieldname": "sales_invoice_no",
"fieldtype": "Link",
"hidden": 1,
"hidden": 0,
"label": "Sales Invoice No",
"no_copy": 1,
"options": "Sales Invoice",
@@ -139,7 +139,7 @@
"doctype": "DocField",
"fieldname": "purchase_receipt_no",
"fieldtype": "Link",
"hidden": 1,
"hidden": 0,
"in_filter": 0,
"label": "Purchase Receipt No",
"no_copy": 1,
@@ -299,7 +299,7 @@
"doctype": "DocField",
"fieldname": "production_order",
"fieldtype": "Link",
"hidden": 1,
"hidden": 0,
"in_filter": 1,
"label": "Production Order",
"no_copy": 0,