Skip to content

Commit

Permalink
Merge branch 'hotfix'
Browse files Browse the repository at this point in the history
  • Loading branch information
nabinhait committed Jan 20, 2017
2 parents b70767b + a1d3d84 commit b736aaf
Show file tree
Hide file tree
Showing 17 changed files with 180 additions and 48 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.13'
__version__ = '7.2.14'

def get_default_company(user=None):
'''Get default company for user'''
Expand Down
9 changes: 9 additions & 0 deletions erpnext/accounts/doctype/budget/budget.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,18 @@ frappe.ui.form.on('Budget', {
},

budget_against: function(frm) {
frm.trigger("set_null_value")
frm.trigger("toggle_reqd_fields")
},

set_null_value: function(frm) {
if(frm.doc.budget_against == 'Cost Center') {
frm.set_value('project', null)
} else {
frm.set_value('cost_center', null)
}
},

toggle_reqd_fields: function(frm) {
frm.toggle_reqd("cost_center", frm.doc.budget_against=="Cost Center");
frm.toggle_reqd("project", frm.doc.budget_against=="Project");
Expand Down
19 changes: 13 additions & 6 deletions erpnext/accounts/doctype/budget/budget.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def validate(self):
frappe.throw(_("{0} is mandatory").format(self.budget_against))
self.validate_duplicate()
self.validate_accounts()
self.set_null_value()

def validate_duplicate(self):
budget_against_field = frappe.scrub(self.budget_against)
Expand Down Expand Up @@ -54,25 +55,31 @@ def validate_accounts(self):
else:
account_list.append(d.account)

def set_null_value(self):
if self.budget_against == 'Cost Center':
self.project = None
else:
self.cost_center = None

def validate_expense_against_budget(args):
args = frappe._dict(args)
if not args.cost_center and not args.project:
return
for budget_against in [args.project, args.cost_center]:
if budget_against \
for budget_against in ['project', 'cost_center']:
if args.get(budget_against) \
and frappe.db.get_value("Account", {"name": args.account, "root_type": "Expense"}):

if args.project:
if args.project and budget_against == 'project':
condition = "and b.project='%s'" % frappe.db.escape(args.project)
args.budget_against_field = "Project"

elif args.cost_center:
elif args.cost_center and budget_against == 'cost_center':
cc_lft, cc_rgt = frappe.db.get_value("Cost Center", args.cost_center, ["lft", "rgt"])
condition = """and exists(select name from `tabCost Center`
where lft<=%s and rgt>=%s and name=b.cost_center)""" % (cc_lft, cc_rgt)
args.budget_against_field = "Cost Center"
args.budget_against = budget_against

args.budget_against = args.get(budget_against)

budget_records = frappe.db.sql("""
select
Expand Down
3 changes: 1 addition & 2 deletions erpnext/accounts/doctype/sales_invoice/pos.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ def update_pos_profile_data(doc, pos_profile, company_data):
doc.apply_discount_on = pos_profile.get('apply_discount_on') if pos_profile.get('apply_discount') else ''
doc.customer_group = pos_profile.get('customer_group') or get_root('Customer Group')
doc.territory = pos_profile.get('territory') or get_root('Territory')
if pos_profile.get('tc_name'):
doc.terms = frappe.db.get_value('Terms and Conditions', pos_profile.get('tc_name'), 'terms')
doc.terms = frappe.db.get_value('Terms and Conditions', pos_profile.get('tc_name'), 'terms') or doc.terms or ''

def get_root(table):
root = frappe.db.sql(""" select name from `tab%(table)s` having
Expand Down
4 changes: 2 additions & 2 deletions erpnext/accounts/doctype/sales_invoice/sales_invoice.json
Original file line number Diff line number Diff line change
Expand Up @@ -2385,7 +2385,7 @@
"in_standard_filter": 0,
"label": "Sales Invoice Payment",
"length": 0,
"no_copy": 1,
"no_copy": 0,
"options": "Sales Invoice Payment",
"permlevel": 0,
"precision": "",
Expand Down Expand Up @@ -4183,7 +4183,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
"modified": "2017-01-17 11:07:25.814402",
"modified": "2017-01-18 13:21:13.226318",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def validate_filters(filters):

def get_columns(filters):
return [
_("Payment Document") + ":Link/DocType: 100",
_("Payment Document") + ":: 100",
_("Payment Entry") + ":Dynamic Link/"+_("Payment Document")+":140",
_("Party Type") + "::100",
_("Party") + ":Dynamic Link/Party Type:140",
Expand Down
3 changes: 2 additions & 1 deletion erpnext/controllers/buying_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ def update_raw_materials_supplied(self, item, raw_material_table):
})
if not rm.rate:
from erpnext.stock.stock_ledger import get_valuation_rate
rm.rate = get_valuation_rate(bom_item.item_code, self.supplier_warehouse)
rm.rate = get_valuation_rate(bom_item.item_code, self.supplier_warehouse,
self.doctype, self.name)
else:
rm.rate = bom_item.rate

Expand Down
1 change: 1 addition & 0 deletions erpnext/controllers/sales_and_purchase_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ def set_missing_values(source, target):
if tax.charge_type == "Actual":
tax.tax_amount = -1 * tax.tax_amount

doc.discount_amount = -1 * source.discount_amount
doc.run_method("calculate_taxes_and_totals")

def update_item(source_doc, target_doc, source_parent):
Expand Down
5 changes: 2 additions & 3 deletions erpnext/controllers/stock_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ def get_gl_entries(self, warehouse_account=None, default_expense_account=None,

def validate_negative_stock(self, sle):
if sle.qty_after_transaction < 0 and sle.actual_qty < 0:
frappe.throw(_("For the Item {0}, valuation rate not found for warehouse {1}. To be able to do accounting entries (for booking expenses), we need valuation rate for item {2}. Please create an incoming stock transaction, on or before {3} {4}, and then try submiting {5}")
.format(sle.item_code, sle.warehouse,
sle.item_code, sle.posting_date, sle.posting_time, self.name))
frappe.throw(_("Valuation rate not found for the Item {0}, which is required to do accounting entries (for booking expenses). Please create an incoming stock transaction or mention valuation rate in Item record, and then try submiting {1} {2}")
.format(sle.item_code, sle.voucher_type, sle.voucher_no))

def get_voucher_details(self, default_expense_account, default_cost_center, sle_map):
if self.doctype == "Stock Reconciliation":
Expand Down
2 changes: 1 addition & 1 deletion erpnext/hr/doctype/leave_allocation/leave_allocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def validate_against_leave_applications(self):

if flt(leaves_taken) > flt(self.total_leaves_allocated):
if frappe.db.get_value("Leave Type", self.leave_type, "allow_negative"):
frappe.msgprint(_("Note: Total allocated leaves {0} shouldn't be less than already approved leaves {1} for the period").format(self.total_leaves_allocated, leaves_taken), LessAllocationError)
frappe.msgprint(_("Note: Total allocated leaves {0} shouldn't be less than already approved leaves {1} for the period").format(self.total_leaves_allocated, leaves_taken))
else:
frappe.throw(_("Total allocated leaves {0} cannot be less than already approved leaves {1} for the period").format(self.total_leaves_allocated, leaves_taken), LessAllocationError)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ def make_time_logs(self, open_new=False):

def get_operations_data(self, data):
return {
'from_time': data.planned_start_time,
'from_time': get_datetime(data.planned_start_time),
'hours': data.time_in_mins / 60.0,
'to_time': data.planned_end_time,
'to_time': get_datetime(data.planned_end_time),
'project': self.project,
'operation': data.operation,
'operation_id': data.name,
Expand Down
1 change: 1 addition & 0 deletions erpnext/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -362,3 +362,4 @@ execute:frappe.delete_doc('Desktop Icon', {'module_name': 'Profit and Loss Statm
erpnext.patches.v7_2.update_website_for_variant
erpnext.patches.v7_2.update_doctype_status
erpnext.patches.v7_2.update_salary_slips
erpnext.patches.v7_2.set_null_value_to_fields
11 changes: 11 additions & 0 deletions erpnext/patches/v7_2/set_null_value_to_fields.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt

from __future__ import unicode_literals
import frappe

def execute():
fields = {"Cost Center": "project", "Project": "cost_center"}
for budget_against, field in fields.items():
frappe.db.sql(""" update `tabBudget` set {field} = null
where budget_against = %s """.format(field = field), budget_against)
Loading

0 comments on commit b736aaf

Please sign in to comment.