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:
parent
7ae697849e
commit
9646580b38
@ -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[] {
|
||||
|
@ -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;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user