Skip to content

Commit

Permalink
Merge branch 'hotfix'
Browse files Browse the repository at this point in the history
  • Loading branch information
nabinhait committed Feb 16, 2017
2 parents efd5ead + 7677b56 commit d5d0b36
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
2 changes: 1 addition & 1 deletion erpnext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import unicode_literals
import frappe

__version__ = '7.2.19'
__version__ = '7.2.20'

def get_default_company(user=None):
'''Get default company for user'''
Expand Down
15 changes: 12 additions & 3 deletions erpnext/accounts/doctype/payment_entry/payment_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,13 @@ frappe.ui.form.on('Payment Entry', {
frm.events.show_general_ledger(frm);
},

company: function(frm) {
frm.events.hide_unhide_fields(frm);
frm.events.set_dynamic_labels(frm);
},

hide_unhide_fields: function(frm) {
var company_currency = frappe.get_doc(":Company", frm.doc.company).default_currency;
var company_currency = frm.doc.company? frappe.get_doc(":Company", frm.doc.company).default_currency: "";

frm.toggle_display("source_exchange_rate",
(frm.doc.paid_amount && frm.doc.paid_from_account_currency != company_currency));
Expand Down Expand Up @@ -118,7 +123,7 @@ frappe.ui.form.on('Payment Entry', {
},

set_dynamic_labels: function(frm) {
var company_currency = frappe.get_doc(":Company", frm.doc.company).default_currency;
var company_currency = frm.doc.company? frappe.get_doc(":Company", frm.doc.company).default_currency: "";

frm.set_currency_labels(["base_paid_amount", "base_received_amount", "base_total_allocated_amount",
"difference_amount"], company_currency);
Expand All @@ -131,6 +136,10 @@ frappe.ui.form.on('Payment Entry', {

frm.set_currency_labels(["total_allocated_amount", "unallocated_amount"], party_account_currency);

var currency_field = (frm.doc.payment_type=="Receive") ? "paid_from_account_currency" : "paid_to_account_currency"
frm.set_df_property("total_allocated_amount", "options", currency_field);
frm.set_df_property("unallocated_amount", "options", currency_field);

frm.set_currency_labels(["total_amount", "outstanding_amount", "allocated_amount"],
party_account_currency, "references");

Expand Down Expand Up @@ -741,4 +750,4 @@ frappe.ui.form.on('Payment Entry Deduction', {
deductions_remove: function(frm) {
frm.events.set_difference_amount(frm);
}
})
})
22 changes: 15 additions & 7 deletions erpnext/stock/doctype/item/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,24 +451,32 @@ def cant_change(self):
"valuation_method", "has_batch_no", "is_fixed_asset")

vals = frappe.db.get_value("Item", self.name, to_check, as_dict=True)
if not vals.get('valuation_method') and self.get('valuation_method'):
vals['valuation_method'] = frappe.db.get_single_value("Stock Settings", "valuation_method") or "FIFO"

if vals:
for key in to_check:
if self.get(key) != vals.get(key):
if not self.check_if_linked_document_exists():
if cstr(self.get(key)) != cstr(vals.get(key)):
if not self.check_if_linked_document_exists(key):
break # no linked document, allowed
else:
frappe.throw(_("As there are existing transactions for this item, you can not change the value of {0}").format(frappe.bold(self.meta.get_label(key))))
frappe.throw(_("As there are existing transactions against item {0}, you can not change the value of {1}").format(self.name, frappe.bold(self.meta.get_label(key))))

if vals and not self.is_fixed_asset and self.is_fixed_asset != vals.is_fixed_asset:
asset = frappe.db.get_all("Asset", filters={"item_code": self.name, "docstatus": 1}, limit=1)
if asset:
frappe.throw(_('"Is Fixed Asset" cannot be unchecked, as Asset record exists against the item'))

def check_if_linked_document_exists(self):
for doctype in ("Sales Order Item", "Delivery Note Item", "Sales Invoice Item",
"Material Request Item", "Purchase Order Item", "Purchase Receipt Item",
"Purchase Invoice Item", "Stock Entry Detail", "Stock Reconciliation Item"):
def check_if_linked_document_exists(self, key):
linked_doctypes = ["Delivery Note Item", "Sales Invoice Item", "Purchase Receipt Item",
"Purchase Invoice Item", "Stock Entry Detail", "Stock Reconciliation Item"]

# For "Is Stock Item", following doctypes is important
# because reserved_qty, ordered_qty and requested_qty updated from these doctypes
if key == "is_stock_item":
linked_doctypes += ["Sales Order Item", "Purchase Order Item", "Material Request Item"]

for doctype in linked_doctypes:
if frappe.db.get_value(doctype, filters={"item_code": self.name, "docstatus": 1}) or \
frappe.db.get_value("Production Order",
filters={"production_item": self.name, "docstatus": 1}):
Expand Down
2 changes: 1 addition & 1 deletion erpnext/templates/generators/job_opening.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h1>{{ job_title }}</h1>
{% endif %}
<p style='margin-top: 30px'>
<a class='btn btn-primary'
href='/job_application?job_title={{ doc.name }}'>
href='/job_application?new=1&job_title={{ doc.name }}'>
{{ _("Apply Now") }}</a>
</p>

Expand Down

0 comments on commit d5d0b36

Please sign in to comment.