fixed conflict while merging with master branch
This commit is contained in:
commit
f7c506d69e
@ -16,9 +16,9 @@
|
||||
|
||||
report.customize_filters = function() {
|
||||
this.hide_all_filters();
|
||||
filter_list = ['From Voucher Date', 'To Voucher Date', 'Debit To', 'From Posting Date', 'To Posting Date']
|
||||
for(var i=0;i<filter_list.length;i++)
|
||||
this.filter_fields_dict['Sales Invoice'+FILTER_SEP +filter_list[i]].df.filter_hide = 0;
|
||||
filter_list = ['Debit To', 'From Posting Date', 'To Posting Date']
|
||||
for(var i=0;i<filter_list.length;i++)
|
||||
this.filter_fields_dict['Receivable Voucher'+FILTER_SEP +filter_list[i]].df.filter_hide = 0;
|
||||
|
||||
this.filter_fields_dict['Sales Invoice Item'+FILTER_SEP +'Item'].df.filter_hide = 0;
|
||||
this.filter_fields_dict['Sales Invoice Item'+FILTER_SEP +'Item Group'].df.filter_hide = 0;
|
||||
|
@ -157,3 +157,8 @@ cur_frm.fields_dict['bom_materials'].grid.get_field('bom_no').get_query = functi
|
||||
return 'SELECT DISTINCT `tabBOM`.`name`, `tabBOM`.`remarks` FROM `tabBOM` WHERE `tabBOM`.`item` = "' + d.item_code + '" AND `tabBOM`.`is_active` = "Yes" AND `tabBOM`.docstatus = 1 AND `tabBOM`.`name` like "%s" ORDER BY `tabBOM`.`name` LIMIT 50';
|
||||
}
|
||||
|
||||
cur_frm.cscript.validate = function(doc, dt, dn) {
|
||||
calculate_op_cost(doc, dt, dn);
|
||||
calculate_rm_cost(doc, dt, dn);
|
||||
calculate_total(doc);
|
||||
}
|
||||
|
@ -242,14 +242,21 @@ class DocType:
|
||||
|
||||
def make_items_dict(self, item_list):
|
||||
for i in item_list:
|
||||
self.item_dict[i[0]] = [(flt(self.item_dict.get(i[1], 0)) + flt(i[1])), i[2], i[3]]
|
||||
self.item_dict[i[0]] = [(flt(self.item_dict.get(i[0], [0])[0]) + flt(i[1])), i[2], i[3]]
|
||||
|
||||
|
||||
def get_csv(self):
|
||||
item_list = [['Item Code', 'Description', 'Stock UOM', 'Required Qty', 'Quantity Requested for Purchase', 'Ordered Qty', 'Actual Qty']]
|
||||
item_list = [['Item Code', 'Description', 'Stock UOM', 'Required Qty', 'Warehouse', 'Quantity Requested for Purchase', 'Ordered Qty', 'Actual Qty']]
|
||||
for d in self.item_dict:
|
||||
item_qty= sql("select sum(indented_qty), sum(ordered_qty), sum(actual_qty) from `tabBin` where item_code = %s", d)
|
||||
item_list.append([d, self.item_dict[d][1], self.item_dict[d][2], self.item_dict[d][0], flt(item_qty[0][0]), flt(item_qty[0][1]), flt(item_qty[0][2])])
|
||||
item_list.append([d, self.item_dict[d][1], self.item_dict[d][2], self.item_dict[d][0]]),
|
||||
item_qty= sql("select warehouse, indented_qty, ordered_qty, actual_qty from `tabBin` where item_code = %s", d)
|
||||
i_qty, o_qty, a_qty = 0,0,0
|
||||
for w in item_qty:
|
||||
i_qty, o_qty, a_qty = i_qty + flt(w[1]), o_qty + flt(w[2]), a_qty + flt(w[3])
|
||||
item_list.append(['', '', '', '', w[0], flt(w[1]), flt(w[2]), flt(w[3])])
|
||||
if item_qty:
|
||||
item_list.append(['', '', '', '', 'Total', i_qty, o_qty, a_qty])
|
||||
|
||||
return item_list
|
||||
|
||||
|
||||
|
@ -74,7 +74,7 @@ GanttChart.prototype.make_date = function(label,idx) {
|
||||
var w = this.make_filter(label,idx);
|
||||
var i = $a(w, 'input');
|
||||
|
||||
var user_fmt = wn.control_panel.date_format;
|
||||
var user_fmt = wn.boot.sysdefaults.date_format;
|
||||
if(!this.user_fmt)this.user_fmt = 'dd-mm-yy';
|
||||
|
||||
$(i).datepicker({
|
||||
|
@ -122,6 +122,7 @@ var set_dynamic_label_child = function(doc, cdt, cdn, base_curr) {
|
||||
//------------------------------------------------------------------
|
||||
|
||||
cur_frm.cscript.dynamic_label = function(doc, cdt, cdn, base_curr, callback) {
|
||||
cur_frm.cscript.base_currency = base_curr;
|
||||
set_dynamic_label_par(doc, cdt, cdn, base_curr);
|
||||
set_dynamic_label_child(doc, cdt, cdn, base_curr);
|
||||
|
||||
|
@ -184,7 +184,7 @@ cur_frm.fields_dict['quotation_no'].get_query = function(doc) {
|
||||
if(doc.order_type) cond = ' ifnull(`tabQuotation`.order_type, "") = "'+doc.order_type+'" and';
|
||||
if(doc.customer) cond += ' ifnull(`tabQuotation`.customer, "") = "'+doc.customer+'" and';
|
||||
|
||||
return repl('SELECT DISTINCT name, customer, transaction_date FROM `tabQuotation` WHERE `tabQuotation`.company = "' + doc.company + '" and `tabQuotation`.`docstatus` = 1 and `tabQuotation`.status != "Order Lost" and %(cond)s `tabQuotation`.%(key)s LIKE "%s" ORDER BY `tabQuotation`.`name` DESC LIMIT 50', {cond:cond});
|
||||
return repl('SELECT DISTINCT name, customer, transaction_date FROM `tabQuotation` WHERE `tabQuotation`.company = "' + doc.company + '" and `tabQuotation`.`docstatus` = 1 and `tabQuotation`.status != "Order Lost" and %(cond)s `tabQuotation`.%(key)s LIKE "%s" ORDER BY `tabQuotation`.`name` DESC LIMIT 50', {cond:cond});
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,6 +34,8 @@ keydict = {
|
||||
'valuation_method': 'default_valuation_method',
|
||||
'date_format': 'date_format',
|
||||
'currency_format':'default_currency_format',
|
||||
'account_url':'account_url',
|
||||
'allow_negative_stock' : 'allow_negative_stock'
|
||||
}
|
||||
|
||||
class DocType:
|
||||
|
@ -224,6 +224,16 @@
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Default Valuation Method',
|
||||
'options': u'FIFO\nMoving Average'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Applicable only if valuation method is moving average',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'allow_negative_stock',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Allow Negative Stock'
|
||||
},
|
||||
|
||||
# DocField
|
||||
@ -533,4 +543,4 @@
|
||||
'fieldtype': u'Data',
|
||||
'label': u'SMS Sender Name'
|
||||
}
|
||||
]
|
||||
]
|
||||
|
@ -180,18 +180,20 @@ class DocType:
|
||||
# get moving average inventory values
|
||||
# ------------------------------------
|
||||
def get_moving_average_inventory_values(self, val_rate, in_rate, opening_qty, actual_qty, is_cancelled):
|
||||
#msgprint(actual_qty)
|
||||
if flt(in_rate) <= 0: # In case of delivery/stock issue in_rate = 0 or wrong incoming rate
|
||||
in_rate = val_rate
|
||||
if in_rate and val_rate == 0: # First entry
|
||||
val_rate = in_rate
|
||||
|
||||
# val_rate is same as previous entry if :
|
||||
# 1. actual qty is negative(delivery note / stock entry)
|
||||
# 2. cancelled entry
|
||||
# 3. val_rate is negative
|
||||
# Otherwise it will be calculated as per moving average
|
||||
elif actual_qty > 0 and (opening_qty + actual_qty) > 0 and is_cancelled == 'No' and ((opening_qty * val_rate) + (actual_qty * in_rate)) > 0:
|
||||
if actual_qty > 0 and (opening_qty + actual_qty) > 0 and is_cancelled == 'No' and ((opening_qty * val_rate) + (actual_qty * in_rate)) > 0:
|
||||
opening_qty = opening_qty > 0 and opening_qty or 0
|
||||
val_rate = ((opening_qty *val_rate) + (actual_qty * in_rate)) / (opening_qty + actual_qty)
|
||||
elif (opening_qty + actual_qty) <= 0:
|
||||
val_rate = 0
|
||||
stock_val = val_rate
|
||||
return val_rate, stock_val
|
||||
|
||||
@ -245,8 +247,10 @@ class DocType:
|
||||
# get stock value
|
||||
# ----------------
|
||||
def get_stock_value(self, val_method, cqty, stock_val, serial_nos):
|
||||
if val_method == 'Moving Average' or serial_nos:
|
||||
if serial_nos:
|
||||
stock_val = flt(stock_val) * flt(cqty)
|
||||
elif val_method == 'Moving Average':
|
||||
stock_val = flt(cqty) > 0 and flt(stock_val) * flt(cqty) or 0
|
||||
elif val_method == 'FIFO':
|
||||
stock_val = sum([flt(d[0])*flt(d[1]) for d in self.fcfs_bal])
|
||||
return stock_val
|
||||
@ -274,6 +278,11 @@ class DocType:
|
||||
# get valuation method
|
||||
val_method = get_obj('Valuation Control').get_valuation_method(self.doc.item_code)
|
||||
|
||||
# allow negative stock (only for moving average method)
|
||||
from webnotes.utils import get_defaults
|
||||
allow_negative_stock = get_defaults().get('allow_negative_stock', 0)
|
||||
|
||||
|
||||
# recalculate the balances for all stock ledger entries
|
||||
# after the prev sle
|
||||
sll = sql("""
|
||||
@ -286,10 +295,10 @@ class DocType:
|
||||
order by timestamp(posting_date, posting_time) asc, name asc""", \
|
||||
(self.doc.item_code, self.doc.warehouse, \
|
||||
prev_sle.get('posting_date','1900-01-01'), prev_sle.get('posting_time', '12:00')), as_dict = 1)
|
||||
|
||||
for sle in sll:
|
||||
# block if stock level goes negative on any date
|
||||
self.validate_negative_stock(cqty, sle)
|
||||
if val_method != 'Moving Average' or flt(allow_negative_stock) == 0:
|
||||
self.validate_negative_stock(cqty, sle)
|
||||
|
||||
stock_val, in_rate = 0, sle['incoming_rate'] # IN
|
||||
serial_nos = sle["serial_no"] and ("'"+"', '".join(cstr(sle["serial_no"]).split('\n')) \
|
||||
|
@ -322,7 +322,6 @@ class DocType(TransactionBase):
|
||||
def on_submit(self):
|
||||
self.validate_packed_qty()
|
||||
set(self.doc, 'message', 'Items against your Order #%s have been delivered. Delivery #%s: ' % (self.doc.po_no, self.doc.name))
|
||||
self.check_qty_in_stock()
|
||||
# Check for Approving Authority
|
||||
get_obj('Authorization Control').validate_approving_authority(self.doc.doctype, self.doc.company, self.doc.grand_total, self)
|
||||
sl_obj = get_obj("Stock Ledger")
|
||||
@ -361,14 +360,6 @@ class DocType(TransactionBase):
|
||||
webnotes.msgprint("Packing Error:\n" + err_msg, raise_exception=1)
|
||||
|
||||
|
||||
# *********** Checks whether actual quantity is present in warehouse *************
|
||||
def check_qty_in_stock(self):
|
||||
for d in getlist(self.doclist, 'packing_details'):
|
||||
is_stock_item = sql("select is_stock_item from `tabItem` where name = '%s'" % d.item_code)[0][0]
|
||||
if is_stock_item == 'Yes' and d.warehouse and flt(d.qty) > flt(d.actual_qty):
|
||||
msgprint("For Item: " + cstr(d.item_code) + " at Warehouse: " + cstr(d.warehouse) + " Quantity: " + cstr(d.qty) +" is not Available. (Must be less than or equal to " + cstr(d.actual_qty) + " )")
|
||||
raise Exception, "Validation Error"
|
||||
|
||||
|
||||
|
||||
# ON CANCEL
|
||||
|
@ -42,9 +42,9 @@ class DocType :
|
||||
def pull_item_details(self):
|
||||
if self.doc.return_type == 'Sales Return':
|
||||
if self.doc.delivery_note_no:
|
||||
det = sql("select t1.name, t1.item_code, t1.description, t1.qty, t1.uom, t2.basic_rate, t3.customer, t3.customer_name, t3.customer_address, t2.serial_no, t2.batch_no from `tabDelivery Note Packing Item` t1, `tabDelivery Note Item` t2, `tabDelivery Note` t3 where t1.parent = t3.name and t2.parent = t3.name and t1.parent_detail_docname = t2.name and t3.name = '%s' and t3.docstatus = 1" % self.doc.delivery_note_no)
|
||||
det = sql("select t1.name, t1.item_code, t1.description, t1.qty, t1.uom, t2.export_rate * t3.conversion_rate, t3.customer, t3.customer_name, t3.customer_address, t2.serial_no, t2.batch_no from `tabDelivery Note Packing Detail` t1, `tabDelivery Note Detail` t2, `tabDelivery Note` t3 where t1.parent = t3.name and t2.parent = t3.name and t1.parent_detail_docname = t2.name and t3.name = '%s' and t3.docstatus = 1" % self.doc.delivery_note_no)
|
||||
elif self.doc.sales_invoice_no:
|
||||
det = sql("select t1.name, t1.item_code, t1.description, t1.qty, t1.stock_uom, t1.basic_rate, t2.customer, t2.customer_name, t2.customer_address, t1.serial_no from `tabSales Invoice Item` t1, `tabSales Invoice` t2 where t1.parent = t2.name and t2.name = '%s' and t2.docstatus = 1" % self.doc.sales_invoice_no)
|
||||
det = sql("select t1.name, t1.item_code, t1.description, t1.qty, t1.stock_uom, t1.export_rate * t2.conversion_rate, t2.customer, t2.customer_name, t2.customer_address, t1.serial_no from `tabRV Detail` t1, `tabReceivable Voucher` t2 where t1.parent = t2.name and t2.name = '%s' and t2.docstatus = 1" % self.doc.sales_invoice_no)
|
||||
elif self.doc.return_type == 'Purchase Return' and self.doc.purchase_receipt_no:
|
||||
det = sql("select t1.name, t1.item_code, t1.description, t1.received_qty, t1.uom, t1.purchase_rate, t2.supplier, t2.supplier_name, t2.supplier_address, t1.serial_no, t1.batch_no from `tabPurchase Receipt Item` t1, `tabPurchase Receipt` t2 where t1.parent = t2.name and t2.name = '%s' and t2.docstatus = 1" % self.doc.purchase_receipt_no)
|
||||
|
||||
|
@ -265,9 +265,6 @@ class DocType(TransactionBase):
|
||||
if flt(d.transfer_qty) <= 0:
|
||||
msgprint("Transfer Quantity can not be less than or equal to zero at Row No " + cstr(d.idx))
|
||||
raise Exception
|
||||
if d.s_warehouse and flt(d.transfer_qty) > flt(d.actual_qty):
|
||||
msgprint("Transfer Quantity is more than Available Qty at Row No " + cstr(d.idx))
|
||||
raise Exception
|
||||
|
||||
|
||||
def calc_amount(self):
|
||||
|
@ -418,4 +418,4 @@
|
||||
'search_index': 0,
|
||||
'width': u'100px'
|
||||
}
|
||||
]
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user