mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-20 13:39:18 +00:00
[minor] merged with master branch
This commit is contained in:
@@ -16,7 +16,17 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend(
|
||||
refresh: function(doc, dt, dn) {
|
||||
this._super();
|
||||
|
||||
if(!doc.__billing_complete && doc.docstatus==1) cur_frm.add_custom_button('Make Invoice', this.make_sales_invoice);
|
||||
if(!doc.__billing_complete && doc.docstatus==1) {
|
||||
// show Make Invoice button only if Delivery Note is not created from Sales Invoice
|
||||
var from_sales_invoice = false;
|
||||
from_sales_invoice = cur_frm.get_doclist({parentfield: "delivery_note_details"})
|
||||
.some(function(item) {
|
||||
return item.prevdoc_doctype==="Sales Invoice" ? true : false;
|
||||
});
|
||||
|
||||
if(!from_sales_invoice)
|
||||
cur_frm.add_custom_button('Make Invoice', this.make_sales_invoice);
|
||||
}
|
||||
|
||||
if(flt(doc.per_installed, 2) < 100 && doc.docstatus==1)
|
||||
cur_frm.add_custom_button('Make Installation Note', this.make_installation_note);
|
||||
|
||||
@@ -35,7 +35,7 @@ class DocType(SellingController):
|
||||
|
||||
def onload(self):
|
||||
billed_qty = webnotes.conn.sql("""select sum(ifnull(qty, 0)) from `tabSales Invoice Item`
|
||||
where delivery_note=%s""", self.doc.name)
|
||||
where docstatus=1 and delivery_note=%s""", self.doc.name)
|
||||
if billed_qty:
|
||||
total_qty = sum((item.qty for item in self.doclist.get({"parentfield": "delivery_note_details"})))
|
||||
self.doc.fields["__billing_complete"] = billed_qty[0][0] == total_qty
|
||||
@@ -344,6 +344,7 @@ def make_sales_invoice(source_name, target_doclist=None):
|
||||
|
||||
def update_accounts(source, target):
|
||||
si = webnotes.bean(target)
|
||||
si.doc.is_pos = 0
|
||||
si.run_method("onload_post_render")
|
||||
|
||||
si.set_doclist(si.doclist.get({"parentfield": ["!=", "entries"]}) +
|
||||
|
||||
@@ -30,8 +30,8 @@ class DocType(DocListController):
|
||||
|
||||
self.check_warehouse_is_set_for_stock_item()
|
||||
self.check_stock_uom_with_bin()
|
||||
self.validate_conversion_factor()
|
||||
self.add_default_uom_in_conversion_factor_table()
|
||||
self.validate_conversion_factor()
|
||||
self.valiadte_item_type()
|
||||
self.check_for_active_boms()
|
||||
self.validate_price_lists()
|
||||
@@ -59,15 +59,37 @@ class DocType(DocListController):
|
||||
ch = addchild(self.doc, 'uom_conversion_details', 'UOM Conversion Detail', self.doclist)
|
||||
ch.uom = self.doc.stock_uom
|
||||
ch.conversion_factor = 1
|
||||
|
||||
for d in self.doclist.get({"parentfield": "uom_conversion_details"}):
|
||||
if d.conversion_factor == 1 and d.uom != self.doc.stock_uom:
|
||||
self.doclist.remove(d)
|
||||
|
||||
|
||||
def check_stock_uom_with_bin(self):
|
||||
if not self.doc.fields.get("__islocal"):
|
||||
bin = webnotes.conn.sql("select stock_uom from `tabBin` where item_code = %s",
|
||||
self.doc.name)
|
||||
if self.doc.stock_uom and bin and cstr(bin[0][0]) \
|
||||
and cstr(bin[0][0]) != cstr(self.doc.stock_uom):
|
||||
msgprint(_("Please Update Stock UOM with the help of Stock UOM Replace Utility."),
|
||||
raise_exception=1)
|
||||
matched=True
|
||||
ref_uom = webnotes.conn.get_value("Stock Ledger Entry",
|
||||
{"item_code": self.doc.name, "is_cancelled": "No"}, "stock_uom")
|
||||
if ref_uom:
|
||||
if cstr(ref_uom) != cstr(self.doc.stock_uom):
|
||||
matched = False
|
||||
else:
|
||||
bin_list = webnotes.conn.sql("select * from tabBin where item_code=%s",
|
||||
self.doc.item_code, as_dict=1)
|
||||
for bin in bin_list:
|
||||
if bin.reserved_qty > 0 or bin.ordered_qty > 0 or bin.indented_qty > 0 \
|
||||
or bin.planned_qty > 0 and cstr(bin.stock_uom) != cstr(self.doc.stock_uom):
|
||||
matched = False
|
||||
break
|
||||
|
||||
if matched and bin_list:
|
||||
webnotes.conn.sql("""update tabBin set stock_uom=%s where item_code=%s""",
|
||||
(self.doc.stock_uom, self.doc.name))
|
||||
|
||||
if not matched:
|
||||
webnotes.throw(_("Default Unit of Measure can not be changed directly \
|
||||
because you have already made some transaction(s) with another UOM.\n \
|
||||
To change default UOM, use 'UOM Replace Utility' tool under Stock module."))
|
||||
|
||||
def validate_conversion_factor(self):
|
||||
check_list = []
|
||||
|
||||
@@ -97,6 +97,12 @@ class DocType(DocListController):
|
||||
|
||||
def validate_serial_no(self):
|
||||
item_det = self.get_item_details()
|
||||
|
||||
if not self.doc.stock_uom:
|
||||
self.doc.stock_uom = item_det.stock_uom
|
||||
|
||||
self.validate_serial_no(item_det)
|
||||
|
||||
if item_det.has_serial_no=="No":
|
||||
if self.doc.serial_no:
|
||||
webnotes.throw(_("Serial Number should be blank for Non Serialized Item" + ": " + self.doc.item),
|
||||
|
||||
@@ -244,6 +244,7 @@ class DocType(StockController):
|
||||
"voucher_type": self.doc.doctype,
|
||||
"voucher_no": self.doc.name,
|
||||
"company": self.doc.company,
|
||||
"stock_uom": webnotes.conn.get_value("Item", row.item_code, "stock_uom"),
|
||||
"voucher_detail_no": row.voucher_detail_no,
|
||||
"fiscal_year": self.doc.fiscal_year,
|
||||
})
|
||||
|
||||
@@ -8,7 +8,7 @@ from webnotes.utils import cstr, flt, now, cint
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.bean import copy_doclist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint
|
||||
from webnotes import msgprint, _
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
@@ -41,11 +41,11 @@ class DocType:
|
||||
raise Exception
|
||||
|
||||
def update_item_master(self):
|
||||
# update stock uom in item master
|
||||
sql("update `tabItem` set stock_uom = '%s' where name = '%s' " % (self.doc.new_stock_uom, self.doc.item_code))
|
||||
item_bean = webnotes.bean("Item", self.doc.item_code)
|
||||
item_bean.doc.stock_uom = self.doc.new_stock_uom
|
||||
item_bean.save()
|
||||
|
||||
# acknowledge user
|
||||
msgprint("New Stock UOM : " + cstr(self.doc.new_stock_uom) + " updated in Item : " + cstr(self.doc.item_code))
|
||||
msgprint(_("Default UOM updated in item ") + self.doc.item_code)
|
||||
|
||||
def update_bin(self):
|
||||
# update bin
|
||||
@@ -80,20 +80,14 @@ class DocType:
|
||||
|
||||
# Update Stock UOM
|
||||
def update_stock_uom(self):
|
||||
# validate mandatory
|
||||
self.validate_mandatory()
|
||||
self.validate_uom_integer_type()
|
||||
|
||||
# update item master
|
||||
self.update_item_master()
|
||||
|
||||
# update stock ledger entry
|
||||
self.update_stock_ledger_entry()
|
||||
|
||||
# update bin
|
||||
self.update_bin()
|
||||
|
||||
get_obj("Item", self.doc.item_code).on_update()
|
||||
|
||||
def validate_uom_integer_type(self):
|
||||
current_is_integer = webnotes.conn.get_value("UOM", self.doc.current_stock_uom, "must_be_whole_number")
|
||||
|
||||
@@ -100,11 +100,11 @@ erpnext.StockLedger = erpnext.StockGridReport.extend({
|
||||
|
||||
toggle_enable_brand: function() {
|
||||
if(!this.filter_inputs.item_code.val()) {
|
||||
this.filter_inputs.brand.removeAttr("disabled");
|
||||
this.filter_inputs.brand.prop("disabled", false);
|
||||
} else {
|
||||
this.filter_inputs.brand
|
||||
.val(this.filter_inputs.brand.get(0).opts.default_value)
|
||||
.attr("disabled", "disabled");
|
||||
.prop("disabled", true);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -115,11 +115,11 @@ erpnext.StockLevel = erpnext.StockGridReport.extend({
|
||||
|
||||
toggle_enable_brand: function() {
|
||||
if(!this.filter_inputs.item_code.val()) {
|
||||
this.filter_inputs.brand.removeAttr("disabled");
|
||||
this.filter_inputs.brand.prop("disabled", false);
|
||||
} else {
|
||||
this.filter_inputs.brand
|
||||
.val(this.filter_inputs.brand.get(0).opts.default_value)
|
||||
.attr("disabled", "disabled");
|
||||
.prop("disabled", true);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user