From 0277b7c0e745d5269cae80b7d6371845bfb2b7b4 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Mon, 16 Dec 2019 18:04:10 +0530 Subject: [PATCH] fix: Set Party defaults - Set default Account and Currency - Reorder fields --- models/doctype/Party/Party.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/models/doctype/Party/Party.js b/models/doctype/Party/Party.js index e6128ed3..c965a6ff 100644 --- a/models/doctype/Party/Party.js +++ b/models/doctype/Party/Party.js @@ -1,3 +1,4 @@ +const frappe = require('frappejs'); let { _ } = require('frappejs/utils'); module.exports = { @@ -17,7 +18,7 @@ module.exports = { { fieldname: 'image', label: 'Image', - fieldtype: 'AttachImage', + fieldtype: 'AttachImage' }, { fieldname: 'customer', @@ -39,6 +40,14 @@ module.exports = { isGroup: 0, accountType: doc.customer ? 'Receivable' : 'Payable' }; + }, + formula: doc => { + if (doc.customer) { + return 'Debtors'; + } + if (doc.supplier) { + return 'Creditors'; + } } }, { @@ -51,7 +60,8 @@ module.exports = { label: 'Currency', fieldtype: 'Link', target: 'Currency', - placeholder: 'INR' + placeholder: 'INR', + formula: () => frappe.AccountingSettings.currency }, { fieldname: 'email', @@ -86,7 +96,7 @@ module.exports = { } ], - quickEditFields: ['defaultAccount', 'currency', 'email', 'phone', 'address'], + quickEditFields: ['email', 'phone', 'address', 'defaultAccount', 'currency'], getFormTitle(doc) { if (doc.customer) return 'Customer';