Skip to content

Commit

Permalink
fix: set numberSeries as readOnly after insert
Browse files Browse the repository at this point in the history
  • Loading branch information
18alantom committed Apr 4, 2022
1 parent 54628bb commit ceb45b5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
4 changes: 4 additions & 0 deletions frappe/model/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ export default class Document extends Observable {
return;
}

if (fieldname === 'numberSeries' && !this._notInserted) {
return;
}

if (this[fieldname] !== value) {
this._dirty = true;
// if child is dirty, parent is dirty too
Expand Down
10 changes: 7 additions & 3 deletions src/components/TwoColumnForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@
</div>
</template>
<script>
import frappe from 'frappe';
import FormControl from '@/components/Controls/FormControl';
import Button from '@/components/Button';
import { handleErrorWithDialog, getErrorMessage } from '../errorHandling';
import FormControl from '@/components/Controls/FormControl';
import frappe from 'frappe';
import { getErrorMessage, handleErrorWithDialog } from '../errorHandling';
let TwoColumnForm = {
name: 'TwoColumnForm',
Expand Down Expand Up @@ -153,6 +153,10 @@ let TwoColumnForm = {
}
},
evaluateReadOnly(df) {
if (df.fieldname === 'numberSeries' && !this.doc._notInserted) {
return true;
}
if (this.submitted) {
return true;
}
Expand Down
12 changes: 6 additions & 6 deletions src/pages/InvoiceForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
:df="meta.getField('numberSeries')"
:value="doc.numberSeries"
@change="(value) => doc.set('numberSeries', value)"
:read-only="doc.submitted"
:read-only="!doc._notInserted || doc.submitted"
/>
</div>
</div>
Expand Down Expand Up @@ -205,11 +205,11 @@ import DropdownWithActions from '@/components/DropdownWithActions';
import PageHeader from '@/components/PageHeader';
import StatusBadge from '@/components/StatusBadge';
import {
getActionsForDocument,
getInvoiceStatus,
openSettings,
routeTo,
showMessageDialog
getActionsForDocument,
getInvoiceStatus,
openSettings,
routeTo,
showMessageDialog,
} from '@/utils';
import frappe from 'frappe';
import { handleErrorWithDialog } from '../errorHandling';
Expand Down
2 changes: 1 addition & 1 deletion src/pages/JournalEntryForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
:value="doc.numberSeries"
@change="(value) => doc.set('numberSeries', value)"
input-class="bg-gray-100 p-2 text-base"
:read-only="doc.submitted"
:read-only="!doc._notInserted || doc.submitted"
:class="doc.submitted && 'pointer-events-none'"
/>
</div>
Expand Down

0 comments on commit ceb45b5

Please sign in to comment.