Merge branch 'hotfix'

This commit is contained in:
Nabin Hait 2017-02-16 14:37:49 +05:30
commit d5d0b36973
4 changed files with 29 additions and 12 deletions

View File

@ -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'''

View File

@ -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));
@ -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);
@ -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");
@ -741,4 +750,4 @@ frappe.ui.form.on('Payment Entry Deduction', {
deductions_remove: function(frm) {
frm.events.set_difference_amount(frm);
}
})
})

View File

@ -451,24 +451,32 @@ class Item(WebsiteGenerator):
"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}):

View File

@ -15,7 +15,7 @@
{% 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>