[manufacturing] Added New Reports

This commit is contained in:
Rushabh Mehta
2013-08-12 14:18:09 +05:30
parent cf2cf3897b
commit 4c17f9420e
14 changed files with 219 additions and 70 deletions

View File

@@ -4,34 +4,7 @@
wn.require("public/app/js/controllers/stock_controller.js");
wn.provide("erpnext.stock");
erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
onload: function() {
this.set_default_account();
},
set_default_account: function() {
var me = this;
if (cint(wn.defaults.get_default("auto_inventory_accounting")) && !this.frm.doc.expense_adjustment_account) {
if (this.frm.doc.purpose == "Sales Return")
account_for = "stock_in_hand_account";
else if (this.frm.doc.purpose == "Purchase Return")
account_for = "stock_received_but_not_billed";
else account_for = "stock_adjustment_account";
return this.frm.call({
method: "accounts.utils.get_company_default",
args: {
"fieldname": account_for,
"company": this.frm.doc.company
},
callback: function(r) {
if (!r.exc) me.frm.set_value("expense_adjustment_account", r.message);
}
});
}
},
erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
setup: function() {
var me = this;
@@ -80,11 +53,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
},
onload_post_render: function() {
if(this.frm.doc.__islocal && (this.frm.doc.production_order || this.frm.doc.bom_no)
&& !getchildren('Stock Entry Detail', this.frm.doc.name, 'mtn_details').length) {
// if production order / bom is mentioned, get items
this.get_items();
}
this.set_default_account();
},
refresh: function() {
@@ -115,6 +84,33 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
after_cancel: function() {
this.clean_up();
},
set_default_account: function() {
var me = this;
if (cint(wn.defaults.get_default("auto_inventory_accounting")) && !this.frm.doc.expense_adjustment_account) {
var account_for = "stock_adjustment_account";
if (this.frm.doc.purpose == "Sales Return")
account_for = "stock_in_hand_account";
else if (this.frm.doc.purpose == "Purchase Return")
account_for = "stock_received_but_not_billed";
return this.frm.call({
method: "accounts.utils.get_company_default",
args: {
"fieldname": account_for,
"company": this.frm.doc.company
},
callback: function(r) {
if (!r.exc) me.frm.set_value("expense_adjustment_account", r.message);
me.get_items();
}
});
} else {
me.get_items();
}
},
clean_up: function() {
// Clear Production Order record from locals, because it is updated via Stock Entry
@@ -126,13 +122,17 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
},
get_items: function() {
return this.frm.call({
doc: this.frm.doc,
method: "get_items",
callback: function(r) {
if(!r.exc) refresh_field("mtn_details");
}
});
if(this.frm.doc.__islocal && (this.frm.doc.production_order || this.frm.doc.bom_no)
&& !getchildren('Stock Entry Detail', this.frm.doc.name, 'mtn_details').length) {
// if production order / bom is mentioned, get items
return this.frm.call({
doc: this.frm.doc,
method: "get_items",
callback: function(r) {
if(!r.exc) refresh_field("mtn_details");
}
});
}
},
qty: function(doc, cdt, cdn) {
@@ -212,7 +212,6 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
});
loaddoc("Journal Voucher", jv_name);
}
}
});
}

View File

@@ -19,6 +19,7 @@ sql = webnotes.conn.sql
class NotUpdateStockError(webnotes.ValidationError): pass
class StockOverReturnError(webnotes.ValidationError): pass
class IncorrectValuationRateError(webnotes.ValidationError): pass
from controllers.stock_controller import StockController
@@ -245,7 +246,7 @@ class DocType(StockController):
def validate_incoming_rate(self):
for d in getlist(self.doclist, 'mtn_details'):
if d.t_warehouse:
self.validate_value("incoming_rate", ">", 0, d)
self.validate_value("incoming_rate", ">", 0, d, raise_exception=IncorrectValuationRateError)
def validate_bom(self):
for d in getlist(self.doclist, 'mtn_details'):

View File

@@ -8,6 +8,7 @@ from stock.utils import get_valuation_method
import json
# future reposting
class NegativeStockError(webnotes.ValidationError): pass
_exceptions = []
def update_entries_after(args, verbose=1):
@@ -253,9 +254,9 @@ def _raise_exceptions(args, verbose=1):
_exceptions[0]["voucher_type"], _exceptions[0]["voucher_no"],
abs(deficiency))
if verbose:
msgprint(msg, raise_exception=1)
msgprint(msg, raise_exception=NegativeStockError)
else:
raise webnotes.ValidationError, msg
raise NegativeStockError, msg
def get_previous_sle(args, for_update=False):
"""

View File

@@ -69,7 +69,7 @@ def get_incoming_rate(args):
if valuation_method == 'FIFO':
if not previous_sle:
return 0.0
previous_stock_queue = json.loads(previous_sle.get('stock_queue', '[]'))
previous_stock_queue = json.loads(previous_sle.get('stock_queue', '[]') or '[]')
in_rate = previous_stock_queue and \
get_fifo_rate(previous_stock_queue, args.get("qty") or 0) or 0
elif valuation_method == 'Moving Average':