Merge pull request #4397 from rmehta/setup-wizard-fixes
[minor] system settings in setup wizard moved to frappe
diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.js b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.js
index 9ffed71..3de8241 100644
--- a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.js
+++ b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.js
@@ -4,7 +4,7 @@
frappe.ui.form.on("Bank Reconciliation", {
setup: function(frm) {
frm.get_docfield("journal_entries").allow_bulk_edit = 1;
- frm.add_fetch("bank_account", "company", "company");
+ frm.add_fetch("bank_account", "account_currency", "account_currency");
},
onload: function(frm) {
diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.json b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.json
index df18ab9..59a3cfc 100644
--- a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.json
+++ b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.json
@@ -19,10 +19,12 @@
"in_filter": 0,
"in_list_view": 1,
"label": "Bank Account",
+ "length": 0,
"no_copy": 0,
"options": "Account",
"permlevel": 0,
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 1,
@@ -34,17 +36,19 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
- "fieldname": "company",
+ "fieldname": "account_currency",
"fieldtype": "Link",
"hidden": 1,
"ignore_user_permissions": 0,
"in_filter": 0,
- "in_list_view": 1,
- "label": "Company",
+ "in_list_view": 0,
+ "label": "Account Currency",
+ "length": 0,
"no_copy": 0,
- "options": "Company",
+ "options": "Currency",
"permlevel": 0,
"print_hide": 1,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@@ -63,9 +67,11 @@
"in_filter": 0,
"in_list_view": 1,
"label": "From Date",
+ "length": 0,
"no_copy": 0,
"permlevel": 0,
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 1,
@@ -84,9 +90,11 @@
"in_filter": 0,
"in_list_view": 1,
"label": "To Date",
+ "length": 0,
"no_copy": 0,
"permlevel": 0,
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 1,
@@ -105,9 +113,11 @@
"in_filter": 0,
"in_list_view": 1,
"label": "Include Reconciled Entries",
+ "length": 0,
"no_copy": 0,
"permlevel": 0,
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@@ -126,10 +136,12 @@
"in_filter": 0,
"in_list_view": 0,
"label": "Get Relevant Entries",
+ "length": 0,
"no_copy": 0,
"options": "",
"permlevel": 0,
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@@ -148,10 +160,12 @@
"in_filter": 0,
"in_list_view": 0,
"label": "Journal Entries",
+ "length": 0,
"no_copy": 0,
"options": "Bank Reconciliation Detail",
"permlevel": 0,
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@@ -170,10 +184,12 @@
"in_filter": 0,
"in_list_view": 0,
"label": "Update Clearance Date",
+ "length": 0,
"no_copy": 0,
"options": "",
"permlevel": 0,
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@@ -192,10 +208,12 @@
"in_filter": 0,
"in_list_view": 0,
"label": "Total Amount",
+ "length": 0,
"no_copy": 0,
- "options": "Company:company:default_currency",
+ "options": "account_currency",
"permlevel": 0,
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
@@ -213,7 +231,9 @@
"is_submittable": 0,
"issingle": 1,
"istable": 0,
- "modified": "2015-02-05 05:11:34.776660",
+ "max_attachments": 0,
+ "menu_index": 0,
+ "modified": "2015-11-30 12:44:45.105451",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Bank Reconciliation",
@@ -241,5 +261,6 @@
}
],
"read_only": 1,
- "read_only_onload": 0
+ "read_only_onload": 0,
+ "version": 0
}
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py
index 731425c..3c280bd 100644
--- a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py
+++ b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py
@@ -18,9 +18,8 @@
condition = "and (clearance_date is null or clearance_date='0000-00-00')"
- dl = frappe.db.sql("""select t1.name, t1.cheque_no, t1.cheque_date, t2.debit,
- t2.credit, t1.posting_date, t2.against_account, t1.clearance_date,
- t2.reference_type, t2.reference_name
+ dl = frappe.db.sql("""select t1.name, t1.cheque_no, t1.cheque_date, t2.debit_in_account_currency,
+ t2.credit_in_account_currency, t1.posting_date, t2.against_account, t1.clearance_date
from
`tabJournal Entry` t1, `tabJournal Entry Account` t2
where
@@ -39,11 +38,11 @@
nl.voucher_id = d.name
nl.cheque_number = d.cheque_no
nl.cheque_date = d.cheque_date
- nl.debit = d.debit
- nl.credit = d.credit
+ nl.debit = d.debit_in_account_currency
+ nl.credit = d.credit_in_account_currency
nl.against_account = d.against_account
nl.clearance_date = d.clearance_date
- self.total_amount += flt(d.debit) - flt(d.credit)
+ self.total_amount += flt(d.debit_in_account_currency) - flt(d.credit_in_account_currency)
def update_details(self):
vouchers = []
diff --git a/erpnext/accounts/doctype/bank_reconciliation_detail/bank_reconciliation_detail.json b/erpnext/accounts/doctype/bank_reconciliation_detail/bank_reconciliation_detail.json
index ca4523c..d510f63 100644
--- a/erpnext/accounts/doctype/bank_reconciliation_detail/bank_reconciliation_detail.json
+++ b/erpnext/accounts/doctype/bank_reconciliation_detail/bank_reconciliation_detail.json
@@ -25,30 +25,7 @@
"options": "Journal Entry",
"permlevel": 0,
"print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- },
- {
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "fieldname": "clearance_date",
- "fieldtype": "Date",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 1,
- "label": "Clearance Date",
- "length": 0,
- "no_copy": 0,
- "oldfieldname": "clearance_date",
- "oldfieldtype": "Date",
- "permlevel": 0,
- "print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@@ -73,6 +50,108 @@
"oldfieldtype": "Data",
"permlevel": 0,
"print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 1,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "fieldname": "debit",
+ "fieldtype": "Currency",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 1,
+ "label": "Debit",
+ "length": 0,
+ "no_copy": 0,
+ "oldfieldname": "debit",
+ "oldfieldtype": "Currency",
+ "options": "account_currency",
+ "permlevel": 0,
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 1,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "fieldname": "credit",
+ "fieldtype": "Currency",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 1,
+ "label": "Credit",
+ "length": 0,
+ "no_copy": 0,
+ "oldfieldname": "credit",
+ "oldfieldtype": "Currency",
+ "options": "account_currency",
+ "permlevel": 0,
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 1,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "fieldname": "column_break_5",
+ "fieldtype": "Column Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0,
+ "width": "50%"
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "fieldname": "posting_date",
+ "fieldtype": "Date",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "label": "Posting Date",
+ "length": 0,
+ "no_copy": 0,
+ "oldfieldname": "posting_date",
+ "oldfieldtype": "Date",
+ "permlevel": 0,
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
@@ -97,128 +176,7 @@
"oldfieldtype": "Data",
"permlevel": 0,
"print_hide": 0,
- "read_only": 1,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- },
- {
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "fieldname": "debit",
- "fieldtype": "Currency",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 1,
- "label": "Debit",
- "length": 0,
- "no_copy": 0,
- "oldfieldname": "debit",
- "oldfieldtype": "Currency",
- "options": "Company:company:default_currency",
- "permlevel": 0,
- "print_hide": 0,
- "read_only": 1,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- },
- {
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "fieldname": "credit",
- "fieldtype": "Currency",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 1,
- "label": "Credit",
- "length": 0,
- "no_copy": 0,
- "oldfieldname": "credit",
- "oldfieldtype": "Currency",
- "options": "Company:company:default_currency",
- "permlevel": 0,
- "print_hide": 0,
- "read_only": 1,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- },
- {
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "fieldname": "reference_type",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "Reference Type",
- "length": 0,
- "no_copy": 0,
- "options": "DocType",
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "read_only": 1,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- },
- {
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "fieldname": "reference_name",
- "fieldtype": "Dynamic Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "Reference Name",
- "length": 0,
- "no_copy": 0,
- "options": "reference_type",
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "read_only": 1,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- },
- {
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "fieldname": "posting_date",
- "fieldtype": "Date",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "Posting Date",
- "length": 0,
- "no_copy": 0,
- "oldfieldname": "posting_date",
- "oldfieldtype": "Date",
- "permlevel": 0,
- "print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
@@ -243,12 +201,38 @@
"oldfieldtype": "Date",
"permlevel": 0,
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "fieldname": "clearance_date",
+ "fieldtype": "Date",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 1,
+ "label": "Clearance Date",
+ "length": 0,
+ "no_copy": 0,
+ "oldfieldname": "clearance_date",
+ "oldfieldtype": "Date",
+ "permlevel": 0,
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
}
],
"hide_heading": 0,
@@ -260,12 +244,14 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2015-11-16 06:29:42.254366",
+ "menu_index": 0,
+ "modified": "2015-11-30 12:52:01.090839",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Bank Reconciliation Detail",
"owner": "Administrator",
"permissions": [],
"read_only": 0,
- "read_only_onload": 0
+ "read_only_onload": 0,
+ "version": 0
}
\ No newline at end of file
diff --git a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py
index e11878e..d57bf07 100644
--- a/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py
+++ b/erpnext/accounts/report/bank_reconciliation_statement/bank_reconciliation_statement.py
@@ -12,16 +12,18 @@
columns = get_columns()
if not filters.get("account"): return columns, []
+
+ account_currency = frappe.db.get_value("Account", filters.account, "account_currency")
data = get_entries(filters)
-
+
from erpnext.accounts.utils import get_balance_on
balance_as_per_system = get_balance_on(filters["account"], filters["report_date"])
total_debit, total_credit = 0,0
for d in data:
- total_debit += flt(d[2])
- total_credit += flt(d[3])
+ total_debit += flt(d.debit_in_account_currency)
+ total_credit += flt(d.credit_in_account_currency)
amounts_not_reflected_in_system = frappe.db.sql("""
select sum(jvd.debit_in_account_currency - jvd.credit_in_account_currency)
@@ -37,39 +39,112 @@
+ amounts_not_reflected_in_system
data += [
- get_balance_row(_("System Balance"), balance_as_per_system),
- [""]*len(columns),
- ["", '"' + _("Amounts not reflected in bank") + '"', total_debit, total_credit, "", "", "", "", ""],
- get_balance_row(_("Amounts not reflected in system"), amounts_not_reflected_in_system),
- [""]*len(columns),
- get_balance_row(_("Expected balance as per bank"), bank_bal)
+ get_balance_row(_("System Balance"), balance_as_per_system, account_currency),
+ {},
+ {
+ "journal_entry": '"' + _("Amounts not reflected in bank") + '"',
+ "debit": total_debit,
+ "credit": total_credit,
+ "account_currency": account_currency
+ },
+ get_balance_row(_("Amounts not reflected in system"), amounts_not_reflected_in_system,
+ account_currency),
+ {},
+ get_balance_row(_("Expected balance as per bank"), bank_bal, account_currency)
]
return columns, data
def get_columns():
- return [_("Posting Date") + ":Date:100", _("Journal Entry") + ":Link/Journal Entry:220",
- _("Debit") + ":Currency:120", _("Credit") + ":Currency:120",
- _("Against Account") + ":Link/Account:200", _("Reference") + "::100",
- _("Ref Date") + ":Date:110", _("Clearance Date") + ":Date:110", _("Currency") + ":Link/Currency:70"
+ return [
+ {
+ "fieldname": "posting_date",
+ "label": _("Posting Date"),
+ "fieldtype": "Date",
+ "width": 100
+ },
+ {
+ "fieldname": "journal_entry",
+ "label": _("Journal Entry"),
+ "fieldtype": "Link",
+ "options": "Journal Entry",
+ "width": 220
+ },
+ {
+ "fieldname": "debit",
+ "label": _("Debit"),
+ "fieldtype": "Currency",
+ "options": "account_currency",
+ "width": 120
+ },
+ {
+ "fieldname": "credit",
+ "label": _("Credit"),
+ "fieldtype": "Currency",
+ "options": "account_currency",
+ "width": 120
+ },
+ {
+ "fieldname": "against_account",
+ "label": _("Against Account"),
+ "fieldtype": "Link",
+ "options": "Account",
+ "width": 200
+ },
+ {
+ "fieldname": "reference",
+ "label": _("Reference"),
+ "fieldtype": "Data",
+ "width": 100
+ },
+ {
+ "fieldname": "ref_date",
+ "label": _("Ref Date"),
+ "fieldtype": "Date",
+ "width": 110
+ },
+ {
+ "fieldname": "clearance_date",
+ "label": _("Clearance Date"),
+ "fieldtype": "Date",
+ "width": 110
+ },
+ {
+ "fieldname": "account_currency",
+ "label": _("Currency"),
+ "fieldtype": "Link",
+ "options": "Currency",
+ "width": 100
+ }
]
def get_entries(filters):
entries = frappe.db.sql("""select
- jv.posting_date, jv.name, jvd.debit_in_account_currency, jvd.credit_in_account_currency,
- jvd.against_account, jv.cheque_no, jv.cheque_date, jv.clearance_date, jvd.account_currency
+ jv.posting_date, jv.name as journal_entry, jvd.debit_in_account_currency as debit,
+ jvd.credit_in_account_currency as credit, jvd.against_account,
+ jv.cheque_no as reference, jv.cheque_date as ref_date, jv.clearance_date, jvd.account_currency
from
`tabJournal Entry Account` jvd, `tabJournal Entry` jv
where jvd.parent = jv.name and jv.docstatus=1
and jvd.account = %(account)s and jv.posting_date <= %(report_date)s
and ifnull(jv.clearance_date, '4000-01-01') > %(report_date)s
and ifnull(jv.is_opening, 'No') = 'No'
- order by jv.name DESC""", filters, as_list=1)
+ order by jv.name DESC""", filters, as_dict=1)
return entries
-def get_balance_row(label, amount):
+def get_balance_row(label, amount, account_currency):
if amount > 0:
- return ["", '"' + label + '"', amount, 0, "", "", "", "", ""]
+ return {
+ "journal_entry": '"' + label + '"',
+ "debit": amount,
+ "credit": 0,
+ "account_currency": account_currency
+ }
else:
- return ["", '"' + label + '"', 0, abs(amount), "", "", "", "", ""]
+ return {
+ "journal_entry": '"' + label + '"',
+ "debit": 0,
+ "credit": abs(amount),
+ "account_currency": account_currency
+ }
\ No newline at end of file
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js
index 0d139df..9ee8062 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.js
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.js
@@ -60,7 +60,7 @@
}
if(doc.docstatus == 1 && !in_list(["Stopped", "Closed"], doc.status)) {
- if(flt(doc.per_received, 2) < 100 && this.frm.doc.__onload.has_stock_item && allow_receipt) {
+ if(flt(doc.per_received, 2) < 100 && allow_receipt) {
cur_frm.add_custom_button(__('Receive'), this.make_purchase_receipt).addClass("btn-primary");
if(doc.is_subcontracted==="Yes") {
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py
index 4670e35..2f155d2 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.py
@@ -33,9 +33,6 @@
'overflow_type': 'order'
}]
- def onload(self):
- self.set_onload("has_stock_item", len(self.get_stock_items()) > 0)
-
def validate(self):
super(PurchaseOrder, self).validate()
diff --git a/erpnext/docs/user/guides/setting-up/stock-reconciliation-for-non-serialized-item.md b/erpnext/docs/user/guides/setting-up/stock-reconciliation-for-non-serialized-item.md
index 9bcafe3..955c83d 100644
--- a/erpnext/docs/user/guides/setting-up/stock-reconciliation-for-non-serialized-item.md
+++ b/erpnext/docs/user/guides/setting-up/stock-reconciliation-for-non-serialized-item.md
@@ -33,11 +33,7 @@

-The csv format is case-sensitive. Do not edit the headers which are preset in the template. In the Item Code and Warehouse column, enter exact Item Code and Warehouse as created in your ERPNext account. For quatity, enter stock level you wish to set for that item, in a specific warehouse. If you do not want to change the quantity or valuation rate of an Item, you should leave it blank.
-
-Note: Make sure you do not put zero if you do not want to change the quantity
-amount or valuation amount. The system will calculate zero as zero quantity.
-So leave the field blank.
+The csv format is case-sensitive. Do not edit the headers which are preset in the template. In the Item Code and Warehouse column, enter exact Item Code and Warehouse as created in your ERPNext account. For quatity, enter stock level you wish to set for that item, in a specific warehouse.
#### **Step 3: Upload file and Enter Values in Stock Reconciliation Form
diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
index 13e7e5b..535e397 100644
--- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
+++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
@@ -5,28 +5,89 @@
frappe.require("assets/erpnext/js/utils.js");
frappe.provide("erpnext.stock");
-frappe.ui.form.on("Stock Reconciliation", "get_items", function(frm) {
- frappe.prompt({label:"Warehouse", fieldtype:"Link", options:"Warehouse", reqd: 1},
- function(data) {
+frappe.ui.form.on("Stock Reconciliation", {
+ onload: function(frm) {
+ // end of life
+ frm.set_query("item_code", "items", function(doc, cdt, cdn) {
+ return {
+ filters:[
+ ['Item', 'end_of_life', '>=', frappe.datetime.nowdate()]
+ ]
+ }
+ });
+ },
+
+ refresh: function(frm) {
+ if(frm.doc.docstatus < 1) {
+ frm.add_custom_button(__("Get Items"), function() {
+ frm.events.get_items(frm);
+ });
+ }
+ },
+
+ company: function(frm) {
+ erpnext.get_fiscal_year(frm.doc.company, frm.doc.posting_date);
+ },
+
+ posting_date: function(frm) {
+ erpnext.get_fiscal_year(frm.doc.company, frm.doc.posting_date);
+ },
+
+ get_items: function(frm) {
+ frappe.prompt({label:"Warehouse", fieldtype:"Link", options:"Warehouse", reqd: 1},
+ function(data) {
+ frappe.call({
+ method:"erpnext.stock.doctype.stock_reconciliation.stock_reconciliation.get_items",
+ args: {
+ warehouse: data.warehouse,
+ posting_date: frm.doc.posting_date,
+ posting_time: frm.doc.posting_time
+ },
+ callback: function(r) {
+ var items = [];
+ frm.clear_table("items");
+ for(var i=0; i< r.message.length; i++) {
+ var d = frm.add_child("items");
+ $.extend(d, r.message[i]);
+ if(!d.qty) d.qty = null;
+ if(!d.valuation_rate) d.valuation_rate = null;
+ }
+ frm.refresh_field("items");
+ }
+ });
+ }
+ , __("Get Items"), __("Update"));
+ },
+
+ set_valuation_rate_and_qty: function(frm, cdt, cdn) {
+ var d = frappe.model.get_doc(cdt, cdn);
+ if(d.item_code && d.warehouse) {
frappe.call({
- method:"erpnext.stock.doctype.stock_reconciliation.stock_reconciliation.get_items",
+ method: "erpnext.stock.doctype.stock_reconciliation.stock_reconciliation.get_stock_balance_for",
args: {
- warehouse: data.warehouse,
+ item_code: d.item_code,
+ warehouse: d.warehouse,
posting_date: frm.doc.posting_date,
posting_time: frm.doc.posting_time
},
callback: function(r) {
- var items = [];
- frm.clear_table("items");
- for(var i=0; i< r.message.length; i++) {
- var d = frm.add_child("items");
- $.extend(d, r.message[i]);
- }
- frm.refresh_field("items");
+ frappe.model.set_value(cdt, cdn, "qty", r.message.qty);
+ frappe.model.set_value(cdt, cdn, "valuation_rate", r.message.rate);
+ frappe.model.set_value(cdt, cdn, "current_qty", r.message.qty);
+ frappe.model.set_value(cdt, cdn, "current_valuation_rate", r.message.rate);
}
});
}
- , __("Get Items"), __("Update"));
+ }
+});
+
+frappe.ui.form.on("Stock Reconciliation Item", {
+ warehouse: function(frm, cdt, cdn) {
+ frm.events.set_valuation_rate_and_qty(frm, cdt, cdn);
+ },
+ item_code: function(frm, cdt, cdn) {
+ frm.events.set_valuation_rate_and_qty(frm, cdt, cdn);
+ }
});
erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
@@ -93,19 +154,3 @@
});
cur_frm.cscript = new erpnext.stock.StockReconciliation({frm: cur_frm});
-
-cur_frm.cscript.company = function(doc, cdt, cdn) {
- erpnext.get_fiscal_year(doc.company, doc.posting_date);
-}
-
-cur_frm.cscript.posting_date = function(doc, cdt, cdn){
- erpnext.get_fiscal_year(doc.company, doc.posting_date);
-}
-
-cur_frm.fields_dict.items.grid.get_field('item_code').get_query = function(doc, cdt, cdn) {
- return {
- filters:[
- ['Item', 'end_of_life', '>=', frappe.datetime.nowdate()]
- ]
- }
-}
\ No newline at end of file
diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.json b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.json
index e38af5f..2e9db86 100644
--- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.json
+++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.json
@@ -27,6 +27,7 @@
"oldfieldtype": "Date",
"permlevel": 0,
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 1,
@@ -51,6 +52,7 @@
"oldfieldtype": "Time",
"permlevel": 0,
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 1,
@@ -72,6 +74,7 @@
"no_copy": 0,
"permlevel": 0,
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@@ -95,6 +98,7 @@
"options": "Stock Reconciliation",
"permlevel": 0,
"print_hide": 1,
+ "print_hide_if_no_value": 0,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
@@ -118,6 +122,7 @@
"options": "Company",
"permlevel": 0,
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 1,
@@ -140,6 +145,7 @@
"permlevel": 0,
"precision": "",
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@@ -164,6 +170,7 @@
"permlevel": 0,
"precision": "",
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 1,
@@ -175,29 +182,6 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
- "fieldname": "get_items",
- "fieldtype": "Button",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "Get Items",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- },
- {
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
"fieldname": "section_break_9",
"fieldtype": "Section Break",
"hidden": 0,
@@ -209,6 +193,7 @@
"permlevel": 0,
"precision": "",
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@@ -233,6 +218,7 @@
"options": "Account",
"permlevel": 0,
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@@ -257,6 +243,7 @@
"options": "Cost Center",
"permlevel": 0,
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@@ -279,6 +266,7 @@
"no_copy": 1,
"permlevel": 0,
"print_hide": 1,
+ "print_hide_if_no_value": 0,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
@@ -301,6 +289,7 @@
"permlevel": 0,
"precision": "",
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@@ -324,6 +313,7 @@
"permlevel": 0,
"precision": "",
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
@@ -346,6 +336,7 @@
"permlevel": 0,
"precision": "",
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@@ -368,6 +359,7 @@
"permlevel": 0,
"precision": "",
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@@ -391,6 +383,7 @@
"options": "Fiscal Year",
"permlevel": 0,
"print_hide": 1,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 1,
@@ -409,7 +402,8 @@
"issingle": 0,
"istable": 0,
"max_attachments": 1,
- "modified": "2015-11-16 06:29:58.376911",
+ "menu_index": 0,
+ "modified": "2015-11-30 02:35:31.373161",
"modified_by": "Administrator",
"module": "Stock",
"name": "Stock Reconciliation",
diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
index cff0041..22946b7 100644
--- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
+++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
@@ -45,6 +45,13 @@
if (item.qty==None or item.qty==qty) and (item.valuation_rate==None or item.valuation_rate==rate):
return False
else:
+ # set default as current rates
+ if item.qty==None:
+ item.qty = qty
+
+ if item.valuation_rate==None:
+ item.valuation_rate = rate
+
item.current_qty = qty
item.current_valuation_rate = rate
self.difference_amount += (flt(item.qty or qty) * flt(item.valuation_rate or rate) - (flt(qty) * flt(rate)))
@@ -254,3 +261,15 @@
del item["name"]
return items
+
+@frappe.whitelist()
+def get_stock_balance_for(item_code, warehouse, posting_date, posting_time):
+ frappe.has_permission("Stock Reconciliation", "write", throw = True)
+
+ qty, rate = get_stock_balance(item_code, warehouse,
+ posting_date, posting_time, with_valuation_rate=True)
+
+ return {
+ 'qty': qty,
+ 'rate': rate
+ }
diff --git a/erpnext/stock/doctype/stock_reconciliation_item/stock_reconciliation_item.json b/erpnext/stock/doctype/stock_reconciliation_item/stock_reconciliation_item.json
index 4f761f1..ddc7087 100644
--- a/erpnext/stock/doctype/stock_reconciliation_item/stock_reconciliation_item.json
+++ b/erpnext/stock/doctype/stock_reconciliation_item/stock_reconciliation_item.json
@@ -25,6 +25,7 @@
"permlevel": 0,
"precision": "",
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 1,
@@ -49,6 +50,7 @@
"permlevel": 0,
"precision": "",
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 1,
@@ -71,6 +73,7 @@
"permlevel": 0,
"precision": "",
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@@ -82,7 +85,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
- "description": "Leave blank if no change",
+ "description": "",
"fieldname": "qty",
"fieldtype": "Float",
"hidden": 0,
@@ -95,6 +98,7 @@
"permlevel": 0,
"precision": "",
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@@ -106,7 +110,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
- "description": "Leave blank if no change",
+ "description": "",
"fieldname": "valuation_rate",
"fieldtype": "Currency",
"hidden": 0,
@@ -119,6 +123,7 @@
"permlevel": 0,
"precision": "",
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@@ -141,6 +146,7 @@
"permlevel": 0,
"precision": "",
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@@ -165,6 +171,7 @@
"permlevel": 0,
"precision": "",
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
@@ -189,6 +196,7 @@
"permlevel": 0,
"precision": "",
"print_hide": 0,
+ "print_hide_if_no_value": 0,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
@@ -199,13 +207,15 @@
],
"hide_heading": 0,
"hide_toolbar": 0,
+ "idx": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2015-11-16 06:29:58.445507",
+ "menu_index": 0,
+ "modified": "2015-11-30 02:34:10.385030",
"modified_by": "Administrator",
"module": "Stock",
"name": "Stock Reconciliation Item",