2
0
mirror of https://github.com/frappe/books.git synced 2024-11-08 14:50:56 +00:00

incr: make flags readonly once set

- remove redundant validation
This commit is contained in:
18alantom 2023-02-27 18:44:50 +05:30
parent 7ae697849e
commit 9646580b38
2 changed files with 15 additions and 24 deletions

View File

@ -76,29 +76,6 @@ export class Item extends Doc {
throw new ValidationError(this.fyo.t`Rate can't be negative.`);
}
},
hasBatchNumber: async (value: DocValue) => {
const { hasBatchNumber } = await this.fyo.db.get(
'Item',
this.name!,
'hasBatchNumber'
);
if (hasBatchNumber && value !== hasBatchNumber) {
const itemEntriesInSLE = await this.fyo.db.count(
ModelNameEnum.StockLedgerEntry,
{
filters: { item: this.name! },
}
);
if (itemEntriesInSLE > 0) {
throw new ValidationError(
this.fyo.t`Cannot change value of Has Batch Number as Item ${this
.name!} already has transactions against it. `
);
}
}
},
};
static getActions(fyo: Fyo): Action[] {

View File

@ -1,5 +1,5 @@
import { Doc } from 'fyo/model/doc';
import { FiltersMap } from 'fyo/model/types';
import { FiltersMap, ReadOnlyMap } from 'fyo/model/types';
import { AccountTypeEnum } from 'models/baseModels/Account/types';
import { ValuationMethod } from './types';
@ -10,6 +10,8 @@ export class InventorySettings extends Doc {
stockReceivedButNotBilled?: string;
costOfGoodsSold?: string;
enableBarcodes?: boolean;
enableBatches?: boolean;
enableUomConversions?: boolean;
static filters: FiltersMap = {
stockInHand: () => ({
@ -25,4 +27,16 @@ export class InventorySettings extends Doc {
accountType: AccountTypeEnum['Cost of Goods Sold'],
}),
};
readOnly: ReadOnlyMap = {
enableBarcodes: () => {
return !!this.enableBarcodes;
},
enableBatches: () => {
return !!this.enableBatches;
},
enableUomConversions: () => {
return !!this.enableUomConversions;
},
};
}