commit
c58e6c0dff
@ -17,6 +17,7 @@ class BuyingController(StockController):
|
|||||||
self.supplier_name = frappe.db.get_value("Supplier",
|
self.supplier_name = frappe.db.get_value("Supplier",
|
||||||
self.supplier, "supplier_name")
|
self.supplier, "supplier_name")
|
||||||
self.is_item_table_empty()
|
self.is_item_table_empty()
|
||||||
|
self.set_qty_as_per_stock_uom()
|
||||||
self.validate_stock_or_nonstock_items()
|
self.validate_stock_or_nonstock_items()
|
||||||
self.validate_warehouse()
|
self.validate_warehouse()
|
||||||
|
|
||||||
@ -317,3 +318,10 @@ class BuyingController(StockController):
|
|||||||
def is_item_table_empty(self):
|
def is_item_table_empty(self):
|
||||||
if not len(self.get(self.fname)):
|
if not len(self.get(self.fname)):
|
||||||
frappe.throw(_("Item table can not be blank"))
|
frappe.throw(_("Item table can not be blank"))
|
||||||
|
|
||||||
|
def set_qty_as_per_stock_uom(self):
|
||||||
|
for d in self.get(self.fname):
|
||||||
|
if d.meta.get_field("stock_qty") and not d.stock_qty:
|
||||||
|
if not d.conversion_factor:
|
||||||
|
frappe.throw(_("Row {0}: Conversion Factor is mandatory"))
|
||||||
|
d.stock_qty = flt(d.qty) * flt(d.conversion_factor)
|
@ -240,7 +240,7 @@ class StockController(AccountsController):
|
|||||||
else:
|
else:
|
||||||
is_expense_account = frappe.db.get_value("Account",
|
is_expense_account = frappe.db.get_value("Account",
|
||||||
item.get("expense_account"), "report_type")=="Profit and Loss"
|
item.get("expense_account"), "report_type")=="Profit and Loss"
|
||||||
if self.doctype != "Purchase Receipt" and not is_expense_account:
|
if self.doctype not in ("Purchase Receipt", "Stock Reconciliation") and not is_expense_account:
|
||||||
frappe.throw(_("Expense / Difference account ({0}) must be a 'Profit or Loss' account")
|
frappe.throw(_("Expense / Difference account ({0}) must be a 'Profit or Loss' account")
|
||||||
.format(item.get("expense_account")))
|
.format(item.get("expense_account")))
|
||||||
if is_expense_account and not item.get("cost_center"):
|
if is_expense_account and not item.get("cost_center"):
|
||||||
|
@ -71,7 +71,7 @@ $.extend(erpnext.queries, {
|
|||||||
|
|
||||||
warehouse: function(doc) {
|
warehouse: function(doc) {
|
||||||
return {
|
return {
|
||||||
filters: [["Warehouse", "company", "in", ["", doc.company]]]
|
filters: [["Warehouse", "company", "in", ["", cstr(doc.company)]]]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -92,7 +92,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
|
|||||||
set_default_account: function() {
|
set_default_account: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
if(cint(frappe.defaults.get_default("auto_accounting_for_stock"))) {
|
if(cint(frappe.defaults.get_default("auto_accounting_for_stock")) && this.frm.doc.company) {
|
||||||
var account_for = "stock_adjustment_account";
|
var account_for = "stock_adjustment_account";
|
||||||
|
|
||||||
if (this.frm.doc.purpose == "Purchase Return")
|
if (this.frm.doc.purpose == "Purchase Return")
|
||||||
|
@ -152,6 +152,7 @@ def get_basic_details(args, item_doc):
|
|||||||
"min_order_qty": flt(item.min_order_qty) if args.parenttype == "Material Request" else "",
|
"min_order_qty": flt(item.min_order_qty) if args.parenttype == "Material Request" else "",
|
||||||
"conversion_factor": 1.0,
|
"conversion_factor": 1.0,
|
||||||
"qty": 1.0,
|
"qty": 1.0,
|
||||||
|
"stock_qty": 1.0,
|
||||||
"price_list_rate": 0.0,
|
"price_list_rate": 0.0,
|
||||||
"base_price_list_rate": 0.0,
|
"base_price_list_rate": 0.0,
|
||||||
"rate": 0.0,
|
"rate": 0.0,
|
||||||
|
@ -190,3 +190,22 @@ def set_stock_balance_as_per_serial_no(item_code=None, posting_date=None, postin
|
|||||||
"posting_date": posting_date,
|
"posting_date": posting_date,
|
||||||
"posting_time": posting_time
|
"posting_time": posting_time
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def reset_serial_no_status_and_warehouse(serial_nos=None):
|
||||||
|
if not serial_nos:
|
||||||
|
serial_nos = frappe.db.sql_list("""select name from `tabSerial No` where status != 'Not in Use'
|
||||||
|
and docstatus = 0""")
|
||||||
|
for serial_no in serial_nos:
|
||||||
|
try:
|
||||||
|
sr = frappe.get_doc("Serial No", serial_no)
|
||||||
|
last_sle = sr.get_last_sle()
|
||||||
|
if flt(last_sle.actual_qty) > 0:
|
||||||
|
sr.warehouse = last_sle.warehouse
|
||||||
|
|
||||||
|
sr.via_stock_ledger = True
|
||||||
|
sr.save()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
frappe.db.sql("""update `tabSerial No` set warehouse='' where status in ('Delivered', 'Purchase Returned')""")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user