[usability] [fixes] stock entry and production order
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order_list.js b/erpnext/buying/doctype/purchase_order/purchase_order_list.js
index 1b27b79..2c28eec 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order_list.js
+++ b/erpnext/buying/doctype/purchase_order/purchase_order_list.js
@@ -11,5 +11,6 @@
} else if(flt(doc.per_received) == 100 && flt(doc.per_billed) == 100 && doc.status!=="Stopped") {
return [__("Completed"), "green", "per_received,=,100|per_billed,=,100|status,!=,Stopped"];
}
- }
+ },
+ order_by: "per_received asc, modified desc"
};
diff --git a/erpnext/manufacturing/doctype/production_order/production_order.js b/erpnext/manufacturing/doctype/production_order/production_order.js
index f7f3e87..3f4e99e 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order.js
+++ b/erpnext/manufacturing/doctype/production_order/production_order.js
@@ -151,18 +151,30 @@
make_se: function(purpose) {
var me = this;
+ var max = (purpose === "Manufacture") ?
+ flt(this.frm.doc.material_transferred_for_qty) - flt(this.frm.doc.produced_qty) :
+ flt(this.frm.doc.qty) - flt(this.frm.doc.material_transferred_for_qty);
- frappe.call({
- method:"erpnext.manufacturing.doctype.production_order.production_order.make_stock_entry",
- args: {
- "production_order_id": me.frm.doc.name,
- "purpose": purpose
- },
- callback: function(r) {
- var doclist = frappe.model.sync(r.message);
- frappe.set_route("Form", doclist[0].doctype, doclist[0].name);
- }
- });
+ frappe.prompt({fieldtype:"Int", label: __("Qty for {0}", [purpose]), fieldname:"qty",
+ description: __("Max: {0}", [max]) },
+ function(data) {
+ if(data.qty > max) {
+ frappe.msgprint(__("Quantity must not be more than {0}", [max]));
+ return;
+ }
+ frappe.call({
+ method:"erpnext.manufacturing.doctype.production_order.production_order.make_stock_entry",
+ args: {
+ "production_order_id": me.frm.doc.name,
+ "purpose": purpose,
+ "qty": data.qty
+ },
+ callback: function(r) {
+ var doclist = frappe.model.sync(r.message);
+ frappe.set_route("Form", doclist[0].doctype, doclist[0].name);
+ }
+ });
+ }, __("Select Quantity"), __("Make"));
},
bom_no: function() {
diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py
index 480d5ef..b7f2ba9 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order.py
+++ b/erpnext/manufacturing/doctype/production_order/production_order.py
@@ -123,17 +123,17 @@
def update_production_order_qty(self):
"""Update **Manufactured Qty** and **Material Transferred for Qty** in Production Order
based on Stock Entry"""
- for status, fieldname in (("Manufacture", "produced_qty"),
+ for purpose, fieldname in (("Manufacture", "produced_qty"),
("Material Transfer for Manufacture", "material_transferred_for_qty")):
qty = flt(frappe.db.sql("""select sum(fg_completed_qty)
from `tabStock Entry` where production_order=%s and docstatus=1
- and purpose=%s""", (self.name, status))[0][0])
+ and purpose=%s""", (self.name, purpose))[0][0])
- if qty > self.qty:
- frappe.throw(_("{0} ({1}) cannot be greater than planned quanitity ({2}) in Production Order {3}").format(\
- self.meta.get_label(fieldname), qty, self.qty, self.name), StockOverProductionError)
+ if qty > self.qty:
+ frappe.throw(_("{0} ({1}) cannot be greater than planned quanitity ({2}) in Production Order {3}").format(\
+ self.meta.get_label(fieldname), qty, self.qty, self.name), StockOverProductionError)
- self.db_set(fieldname, qty)
+ self.db_set(fieldname, qty)
def on_submit(self):
if not self.wip_warehouse:
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index e444eec..17e6435 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -119,3 +119,4 @@
erpnext.patches.v5_0.manufacturing_activity_type
erpnext.patches.v5_0.update_item_description_and_image
erpnext.patches.v5_0.update_material_transferred_for_qty
+erpnext.patches.v5_0.stock_entry_update_value
diff --git a/erpnext/patches/v5_0/stock_entry_update_value.py b/erpnext/patches/v5_0/stock_entry_update_value.py
new file mode 100644
index 0000000..9abd315
--- /dev/null
+++ b/erpnext/patches/v5_0/stock_entry_update_value.py
@@ -0,0 +1,7 @@
+import frappe
+
+def execute():
+ for d in frappe.db.get_all("Stock Entry"):
+ se = frappe.get_doc("Stock Entry", d.name)
+ se.set_total_incoming_outgoing_value()
+ se.db_update()
diff --git a/erpnext/selling/doctype/sales_order/sales_order_list.js b/erpnext/selling/doctype/sales_order/sales_order_list.js
index 17681a3..702c300 100644
--- a/erpnext/selling/doctype/sales_order/sales_order_list.js
+++ b/erpnext/selling/doctype/sales_order/sales_order_list.js
@@ -13,5 +13,6 @@
} else if(flt(doc.per_delivered) == 100 && flt(doc.per_billed) == 100 && doc.status!=="Stopped") {
return [__("Completed"), "green", "per_delivered,=,100|per_billed,=,100|status,!=,Stopped"];
}
- }
+ },
+ order_by: "per_delivered asc, modified desc"
};
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js
index f738c4a..8795524 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.js
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.js
@@ -147,7 +147,7 @@
refresh_field('items');
calculate_total(doc, cdt, cdn);
},
-
+
incoming_rate: function(doc, cdt, cdn) {
calculate_total(doc, cdt, cdn);
},
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.json b/erpnext/stock/doctype/stock_entry/stock_entry.json
index ac6e94b..bcbfb01 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.json
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.json
@@ -266,6 +266,42 @@
"read_only": 0
},
{
+ "fieldname": "section_break_19",
+ "fieldtype": "Section Break",
+ "permlevel": 0,
+ "precision": ""
+ },
+ {
+ "fieldname": "total_incoming_value",
+ "fieldtype": "Currency",
+ "label": "Total Incoming Value",
+ "permlevel": 0,
+ "precision": "",
+ "read_only": 1
+ },
+ {
+ "fieldname": "column_break_22",
+ "fieldtype": "Column Break",
+ "permlevel": 0,
+ "precision": ""
+ },
+ {
+ "fieldname": "total_outgoing_value",
+ "fieldtype": "Currency",
+ "label": "Total Outgoing Value",
+ "permlevel": 0,
+ "precision": "",
+ "read_only": 1
+ },
+ {
+ "fieldname": "value_difference",
+ "fieldtype": "Currency",
+ "label": "Total Value Difference (Out - In)",
+ "permlevel": 0,
+ "precision": "",
+ "read_only": 1
+ },
+ {
"depends_on": "eval:(doc.purpose!==\"Sales Return\" && doc.purpose!==\"Purchase Return\")",
"fieldname": "sb1",
"fieldtype": "Section Break",
@@ -596,7 +632,7 @@
"is_submittable": 1,
"issingle": 0,
"max_attachments": 0,
- "modified": "2015-02-17 00:49:04.294855",
+ "modified": "2015-02-19 04:53:05.361046",
"modified_by": "Administrator",
"module": "Stock",
"name": "Stock Entry",
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 16d045b..8d9f405 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -221,6 +221,16 @@
frappe.throw(_("Total valuation ({0}) for manufactured or repacked item(s) can not be less than total valuation of raw materials ({1})").format(valuation_at_target,
valuation_at_source))
+ def set_total_incoming_outgoing_value(self):
+ self.total_incoming_value = self.total_outgoing_value = 0.0
+ for d in self.get("items"):
+ if d.s_warehouse:
+ self.total_incoming_value += flt(d.amount)
+ if d.t_warehouse:
+ self.total_outgoing_value += flt(d.amount)
+
+ self.value_difference = self.total_outgoing_value - self.total_incoming_value
+
def set_total_amount(self):
self.total_amount = sum([flt(item.amount) for item in self.get("items")])
diff --git a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
index 216be29..750e7d6 100644
--- a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
+++ b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
@@ -60,12 +60,15 @@
"permlevel": 0
},
{
- "fieldname": "item_name",
- "fieldtype": "Data",
- "label": "Item Name",
+ "fieldname": "qty",
+ "fieldtype": "Float",
+ "in_list_view": 1,
+ "label": "Qty",
+ "oldfieldname": "qty",
+ "oldfieldtype": "Currency",
"permlevel": 0,
- "print_hide": 1,
- "read_only": 1
+ "read_only": 0,
+ "reqd": 1
},
{
"fieldname": "section_break_8",
@@ -74,6 +77,14 @@
"precision": ""
},
{
+ "fieldname": "item_name",
+ "fieldtype": "Data",
+ "label": "Item Name",
+ "permlevel": 0,
+ "print_hide": 1,
+ "read_only": 1
+ },
+ {
"fieldname": "description",
"fieldtype": "Text",
"in_list_view": 1,
@@ -115,15 +126,31 @@
"permlevel": 0
},
{
- "fieldname": "qty",
- "fieldtype": "Float",
+ "fieldname": "incoming_rate",
+ "fieldtype": "Currency",
"in_list_view": 1,
- "label": "Qty",
- "oldfieldname": "qty",
+ "label": "Valuation Rate",
+ "oldfieldname": "incoming_rate",
"oldfieldtype": "Currency",
+ "options": "Company:company:default_currency",
"permlevel": 0,
"read_only": 0,
- "reqd": 1
+ "reqd": 0
+ },
+ {
+ "fieldname": "amount",
+ "fieldtype": "Currency",
+ "label": "Amount",
+ "oldfieldname": "amount",
+ "oldfieldtype": "Currency",
+ "options": "Company:company:default_currency",
+ "permlevel": 0,
+ "read_only": 1
+ },
+ {
+ "fieldname": "col_break3",
+ "fieldtype": "Column Break",
+ "permlevel": 0
},
{
"fieldname": "uom",
@@ -138,21 +165,15 @@
"reqd": 1
},
{
- "fieldname": "incoming_rate",
- "fieldtype": "Currency",
- "in_list_view": 1,
- "label": "Valuation Rate",
- "oldfieldname": "incoming_rate",
+ "fieldname": "conversion_factor",
+ "fieldtype": "Float",
+ "label": "Conversion Factor",
+ "oldfieldname": "conversion_factor",
"oldfieldtype": "Currency",
- "options": "Company:company:default_currency",
"permlevel": 0,
- "read_only": 0,
- "reqd": 0
- },
- {
- "fieldname": "col_break3",
- "fieldtype": "Column Break",
- "permlevel": 0
+ "print_hide": 1,
+ "read_only": 1,
+ "reqd": 1
},
{
"fieldname": "stock_uom",
@@ -169,27 +190,6 @@
"search_index": 0
},
{
- "fieldname": "conversion_factor",
- "fieldtype": "Float",
- "label": "Conversion Factor",
- "oldfieldname": "conversion_factor",
- "oldfieldtype": "Currency",
- "permlevel": 0,
- "print_hide": 1,
- "read_only": 1,
- "reqd": 1
- },
- {
- "fieldname": "amount",
- "fieldtype": "Currency",
- "label": "Amount",
- "oldfieldname": "amount",
- "oldfieldtype": "Currency",
- "options": "Company:company:default_currency",
- "permlevel": 0,
- "read_only": 1
- },
- {
"fieldname": "serial_no_batch",
"fieldtype": "Section Break",
"label": "Serial No / Batch",
@@ -331,7 +331,7 @@
],
"idx": 1,
"istable": 1,
- "modified": "2015-02-19 01:07:02.254835",
+ "modified": "2015-02-19 05:33:06.289852",
"modified_by": "Administrator",
"module": "Stock",
"name": "Stock Entry Detail",
diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py
index 7340baf..0f63a64 100644
--- a/erpnext/stock/stock_ledger.py
+++ b/erpnext/stock/stock_ledger.py
@@ -99,7 +99,7 @@
self.precision = get_field_precision(frappe.get_meta("Stock Ledger Entry").get_field("stock_value"),
currency=frappe.db.get_value("Company", self.company, "default_currency"))
- self.prev_stock_value = self.stock_value
+ self.prev_stock_value = self.previous_sle.stock_value or 0.0
self.stock_queue = json.loads(self.previous_sle.stock_queue or "[]")
self.valuation_method = get_valuation_method(self.item_code)
self.stock_value_difference = 0.0
diff --git a/erpnext/support/doctype/maintenance_visit/maintenance_visit.js b/erpnext/support/doctype/maintenance_visit/maintenance_visit.js
index 5427b0f..28c88ef 100644
--- a/erpnext/support/doctype/maintenance_visit/maintenance_visit.js
+++ b/erpnext/support/doctype/maintenance_visit/maintenance_visit.js
@@ -30,7 +30,7 @@
cur_frm.add_custom_button(__('From Warranty Claim'),
function() {
frappe.model.map_current_doc({
- method: "erpnext.support.doctype.customer_issue.customer_issue.make_maintenance_visit",
+ method: "erpnext.support.doctype.warranty_claim.warranty_claim.make_maintenance_visit",
source_doctype: "Warranty Claim",
get_query_filters: {
status: ["in", "Open, Work in Progress"],
diff --git a/erpnext/support/doctype/warranty_claim/warranty_claim.js b/erpnext/support/doctype/warranty_claim/warranty_claim.js
index e062559..0d6d6f5 100644
--- a/erpnext/support/doctype/warranty_claim/warranty_claim.js
+++ b/erpnext/support/doctype/warranty_claim/warranty_claim.js
@@ -21,7 +21,7 @@
make_maintenance_visit: function() {
frappe.model.open_mapped_doc({
- method: "erpnext.support.doctype.customer_issue.customer_issue.make_maintenance_visit",
+ method: "erpnext.support.doctype.warranty_claim.warranty_claim.make_maintenance_visit",
frm: cur_frm
})
}
diff --git a/erpnext/templates/form_grid/stock_entry_grid.html b/erpnext/templates/form_grid/stock_entry_grid.html
index ef465a4..089a6e8 100644
--- a/erpnext/templates/form_grid/stock_entry_grid.html
+++ b/erpnext/templates/form_grid/stock_entry_grid.html
@@ -5,32 +5,34 @@
{% if(!doc) { %}
<div class="row">
- <div class="col-sm-8 col-xs-6">{%= __("Item") %}</div>
+ <div class="col-sm-5 col-xs-4">{%= __("Item") %}</div>
+ <div class="col-sm-3 col-xs-4">{%= __("Warehouse") %}</div>
<div class="col-sm-2 col-xs-2 text-right">{%= __("Qty") %}</div>
- <div class="col-sm-2 col-xs-4 text-right">{%= __("Amount") %}</div>
+ <div class="col-sm-2 col-xs-2 text-right">{%= __("Amount") %}</div>
</div>
{% } else { %}
<div class="row">
- <div class="col-sm-8 col-xs-6"><strong>{%= doc.item_code %}</strong>
+ <div class="col-sm-5 col-xs-4"><strong>{%= doc.item_code %}</strong>
{% if(doc.item_name != doc.item_code) { %}
<br>{%= doc.item_name %}{% } %}
{% if(doc.item_name != doc.description) { %}
<p>{%= doc.description %}</p>{% } %}
{% include "templates/form_grid/includes/visible_cols.html" %}
- <div>
- {% if(doc.s_warehouse) { %}
- <span class="label label-primary">
- {%= doc.s_warehouse || "" %}</span>
- {% } %}
- <i class="octicon octicon-arrow-small-right"></i>
- {% if(doc.t_warehouse) { %}<span class="label label-primary">
- {%= doc.t_warehouse || "" %}</span>{% } %}
- {% if(doc.s_warehouse && doc.actual_qty < doc.qty) { %}
- <span class="text-danger small" style="margin-left: 15px;">
- <span class="octicon octicon-stop" style="font-size: 12px;"></span> Not in Stock
- </span>
- {% } %}
- </div>
+ {% if(frm.doc.docstatus==0 && doc.s_warehouse && doc.actual_qty < doc.qty) { %}
+ <span class="text-danger small" style="margin-left: 15px;">
+ <span class="octicon octicon-stop" style="font-size: 12px;"></span> Not in Stock
+ </span>
+ {% } %}
+ </div>
+
+ <!-- warehouse -->
+ <div class="col-sm-3 col-xs-4">
+ {% if(doc.s_warehouse) { %}
+ <span class="label label-default" title="{% __("Source" )%}">
+ {%= doc.s_warehouse || "" %}</span>
+ {% } %}
+ {% if(doc.t_warehouse) { %}<span class="label label-primary" title="{% __("Target" )%}">
+ {%= doc.t_warehouse || "" %}</span>{% } %}
</div>
<!-- qty -->
@@ -40,7 +42,7 @@
</div>
<!-- amount -->
- <div class="col-sm-2 col-xs-4 text-right">
+ <div class="col-sm-2 col-xs-2 text-right">
{%= doc.get_formatted("amount") %}
<div class="small text-muted">
{%= doc.get_formatted("incoming_rate") %}