[enhancement] letter head in stock entry #3291
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js
index e954cf6..4670ff8 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.js
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.js
@@ -43,7 +43,7 @@
return erpnext.queries.item({is_stock_item: "Yes"});
}
};
-
+
this.frm.set_query("purchase_order", function() {
return {
"filters": {
@@ -68,8 +68,13 @@
},
onload_post_render: function() {
+ var me = this;
cur_frm.get_field("items").grid.set_multiple_add("item_code", "qty");
- this.set_default_account();
+ this.set_default_account(function() {
+ if(me.frm.doc.__islocal && me.frm.doc.company && !me.frm.doc.amended_from) {
+ cur_frm.script_manager.trigger("company");
+ }
+ });
},
refresh: function() {
@@ -102,7 +107,7 @@
this.clean_up();
},
- set_default_account: function() {
+ set_default_account: function(callback) {
var me = this;
if(cint(frappe.defaults.get_default("auto_accounting_for_stock")) && this.frm.doc.company) {
@@ -122,6 +127,7 @@
$.each(me.frm.doc.items || [], function(i, d) {
if(!d.expense_account) d.expense_account = r.message;
});
+ if(callback) callback();
}
}
});
@@ -521,7 +527,14 @@
}
cur_frm.cscript.company = function(doc, cdt, cdn) {
- erpnext.get_fiscal_year(doc.company, doc.posting_date);
+ if(doc.company) {
+ erpnext.get_fiscal_year(doc.company, doc.posting_date, function() {
+ var company_doc = frappe.get_doc(":Company", doc.company);
+ if(company_doc.default_letter_head) {
+ cur_frm.set_value("letter_head", company_doc.default_letter_head);
+ }
+ });
+ }
}
cur_frm.cscript.posting_date = function(doc, cdt, cdn){
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.json b/erpnext/stock/doctype/stock_entry/stock_entry.json
index 126da73..11898ce 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.json
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.json
@@ -633,6 +633,14 @@
"search_index": 0
},
{
+ "fieldname": "letter_head",
+ "fieldtype": "Link",
+ "label": "Letter Head",
+ "options": "Letter Head",
+ "permlevel": 0,
+ "precision": ""
+ },
+ {
"allow_on_submit": 0,
"fieldname": "amended_from",
"fieldtype": "Link",
@@ -670,7 +678,7 @@
"is_submittable": 1,
"issingle": 0,
"max_attachments": 0,
- "modified": "2015-03-03 18:09:12.035606",
+ "modified": "2015-05-20 07:58:59.025553",
"modified_by": "Administrator",
"module": "Stock",
"name": "Stock Entry",