From 91f6c693e0336fa0d29a55b77cb271b1a12c053e Mon Sep 17 00:00:00 2001 From: sahil28297 <37302950+sahil28297@users.noreply.github.com> Date: Tue, 11 Sep 2018 17:02:28 +0530 Subject: [PATCH] Create a default party account (#66) --- models/doctype/Invoice/Invoice.js | 1 + models/doctype/Party/Party.js | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/models/doctype/Invoice/Invoice.js b/models/doctype/Invoice/Invoice.js index 330baa05..a2252381 100644 --- a/models/doctype/Invoice/Invoice.js +++ b/models/doctype/Invoice/Invoice.js @@ -38,6 +38,7 @@ module.exports = { label: 'Account', fieldtype: 'Link', target: 'Account', + formula : (doc) => doc.getFrom('Party', doc.customer , 'default_account'), getFilters: (query, control) => { return { keywords: ['like', query], diff --git a/models/doctype/Party/Party.js b/models/doctype/Party/Party.js index 7be02d8a..5cf6b0a3 100644 --- a/models/doctype/Party/Party.js +++ b/models/doctype/Party/Party.js @@ -13,6 +13,19 @@ module.exports = { "fieldtype": "Data", "required": 1 }, + { + fieldname: 'default_account', + label: 'Default Account', + fieldtype: 'Link', + target: 'Account', + getFilters: (query, control) => { + return { + keywords: ['like', query], + isGroup: 0, + accountType: 'Receivable' + }; + } + }, { "fieldname": "customer", "label": "Customer",