[fix] [minor] merge conflict fixed

This commit is contained in:
Akhilesh Darjee
2013-09-11 14:49:38 +05:30
17 changed files with 115 additions and 57 deletions

View File

@@ -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);

View File

@@ -29,8 +29,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.validate_item_type()
self.check_for_active_boms()
self.fill_customer_code()
@@ -57,15 +57,38 @@ 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 = []

View File

@@ -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")