diff --git a/models/doctype/Party/Party.js b/models/doctype/Party/Party.js index 336cc716..3eab7e76 100644 --- a/models/doctype/Party/Party.js +++ b/models/doctype/Party/Party.js @@ -1,5 +1,4 @@ -import frappe from 'frappe'; -import { t } from 'frappe'; +import frappe, { t } from 'frappe'; export default { name: 'Party', @@ -21,12 +20,12 @@ export default { }, { fieldname: 'customer', - label: 'Customer', + label: 'Is Customer', fieldtype: 'Check', }, { fieldname: 'supplier', - label: 'Supplier', + label: 'Is Supplier', fieldtype: 'Check', }, { diff --git a/models/doctype/Party/PartyServer.js b/models/doctype/Party/PartyServer.js index e572a630..174811c5 100644 --- a/models/doctype/Party/PartyServer.js +++ b/models/doctype/Party/PartyServer.js @@ -14,6 +14,10 @@ export default class PartyServer extends BaseDocument { throw new Error(); } + if (!this.customer && !this.supplier) { + this.supplier = 1; + } + if (this.gstin && ['Unregistered', 'Consumer'].includes(this.gstType)) { this.gstin = ''; } diff --git a/src/pages/QuickEditForm.vue b/src/pages/QuickEditForm.vue index 584318a6..ee28d6ec 100644 --- a/src/pages/QuickEditForm.vue +++ b/src/pages/QuickEditForm.vue @@ -84,14 +84,11 @@ import StatusBadge from '@/components/StatusBadge'; import FormControl from '@/components/Controls/FormControl'; import TwoColumnForm from '@/components/TwoColumnForm'; import DropdownWithActions from '@/components/DropdownWithActions'; -import { - openQuickEdit, - getActionsForDocument, -} from '@/utils'; +import { openQuickEdit, getActionsForDocument } from '@/utils'; export default { name: 'QuickEditForm', - props: ['doctype', 'name', 'values', 'hideFields'], + props: ['doctype', 'name', 'values', 'hideFields', 'showFields'], components: { Button, FormControl, @@ -126,14 +123,23 @@ export default { }, status() { if (this.doc && this.doc._notInserted) { - return "Draft"; + return 'Draft'; } - return ""; + return ''; }, fields() { - return this.meta + const fields = this.meta .getQuickEditFields() .filter((df) => !(this.hideFields || []).includes(df.fieldname)); + + if (this.showFields) { + fields.push( + ...this.meta.fields.filter(({ fieldname }) => + this.showFields.includes(fieldname) + ) + ); + } + return fields; }, actions() { return getActionsForDocument(this.doc); @@ -204,7 +210,7 @@ export default { await this.$refs.form.submit(); } catch (e) { this.statusText = null; - console.error(e) + console.error(e); } }, routeToPrevious() { diff --git a/src/utils.js b/src/utils.js index bf05e281..654e7df4 100644 --- a/src/utils.js +++ b/src/utils.js @@ -120,7 +120,20 @@ export function partyWithAvatar(party) { }; } -export function openQuickEdit({ doctype, name, hideFields, defaults = {} }) { +function getShowFields(doctype) { + if (doctype === 'Party') { + return ['customer']; + } + return []; +} + +export function openQuickEdit({ + doctype, + name, + hideFields, + showFields, + defaults = {}, +}) { let currentRoute = router.currentRoute; let query = currentRoute.query; let method = 'push'; @@ -135,6 +148,7 @@ export function openQuickEdit({ doctype, name, hideFields, defaults = {} }) { edit: 1, doctype, name, + showFields: showFields ?? getShowFields(doctype), hideFields, values: defaults, lastRoute: currentRoute,