Add default payable account for expense claims (#15246)

This commit is contained in:
Charles-Henri Decultot 2018-08-30 15:48:26 +02:00 committed by Nabin Hait
parent 8d7c1868d6
commit 7e86d7b014
5 changed files with 50 additions and 6 deletions

View File

@ -136,7 +136,7 @@ frappe.ui.form.on("Expense Claim", {
frm.trigger("set_query_for_cost_center");
frm.trigger("set_query_for_payable_account");
frm.add_fetch("company", "cost_center", "cost_center");
frm.add_fetch("company", "default_payable_account", "payable_account");
frm.add_fetch("company", "default_expense_claim_payable_account", "payable_account");
frm.set_query("employee_advance", "advances", function(doc) {
return {
filters: [

View File

@ -53,11 +53,11 @@ class ExpenseClaim(AccountsController):
def set_payable_account(self):
if not self.payable_account and not self.is_paid:
self.payable_account = frappe.get_cached_value('Company', self.company, "default_payable_account")
self.payable_account = frappe.get_cached_value('Company', self.company, 'default_expense_claim_payable_account')
def set_cost_center(self):
if not self.cost_center:
self.cost_center = frappe.get_cached_value('Company', self.company, 'cost_center')
self.cost_center = frappe.get_cached_value('Company', self.company, 'cost_center')
def on_submit(self):
if self.approval_status=="Draft":

View File

@ -557,6 +557,7 @@ erpnext.patches.v11_0.set_department_for_doctypes
erpnext.patches.v11_0.update_allow_transfer_for_manufacture
erpnext.patches.v11_0.add_item_group_defaults
erpnext.patches.v10_0.update_address_template_for_india
erpnext.patches.v11_0.add_expense_claim_default_account
execute:frappe.delete_doc("Page", "hub")
erpnext.patches.v11_0.reset_publish_in_hub_for_all_items
erpnext.patches.v11_0.update_hub_url

View File

@ -0,0 +1,10 @@
import frappe
def execute():
frappe.reload_doc("setup", "doctype", "company")
companies = frappe.get_all("Company", fields=["name", "default_payable_account"])
for company in companies:
if company.default_payable_account is not None:
frappe.db.set_value("Company", company.name, "default_expense_claim_payable_account", company.default_payable_account)

View File

@ -1388,6 +1388,40 @@
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:!doc.__islocal",
"fieldname": "default_expense_claim_payable_account",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 1,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Default Expense Claim Payable Account",
"length": 0,
"no_copy": 1,
"options": "Account",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
@ -2738,7 +2772,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
"modified": "2018-07-30 12:07:33.016473",
"modified": "2018-08-28 15:47:50.757131",
"modified_by": "Administrator",
"module": "Setup",
"name": "Company",
@ -2884,6 +2918,5 @@
"show_name_in_global_search": 1,
"sort_order": "ASC",
"track_changes": 1,
"track_seen": 0,
"track_views": 0
"track_seen": 0
}