Deprecate Probability field on Opportunity (#6207)

Closes #5735.
The field probability on opportunity will -
- stop being created for new workspaces (after this PR is merged)
- have "isCustom" value set to true and be displayed as such in the
settings (after this PR is merged + sync-metadata is run on workspace)
- still show in the views (all the time)

This field is deprecated as a standard field but not replaced by another
one, so we are not adding the `(deprecated)` suffix in the label.
This commit is contained in:
Marie
2024-07-11 14:50:33 +02:00
committed by GitHub
parent 8e25a107fd
commit 5ebde33f5f
12 changed files with 34 additions and 111 deletions

View File

@ -1,7 +1,7 @@
import { EntityManager } from 'typeorm';
import { DEV_SEED_PERSON_IDS } from 'src/database/typeorm-seeds/workspace/people';
import { DEV_SEED_COMPANY_IDS } from 'src/database/typeorm-seeds/workspace/companies';
import { DEV_SEED_PERSON_IDS } from 'src/database/typeorm-seeds/workspace/people';
const tableName = 'opportunity';
@ -25,7 +25,6 @@ export const seedOpportunity = async (
'amountAmountMicros',
'amountCurrencyCode',
'closeDate',
'probability',
'stage',
'position',
'pointOfContactId',
@ -39,7 +38,6 @@ export const seedOpportunity = async (
amountAmountMicros: 100000,
amountCurrencyCode: 'USD',
closeDate: new Date(),
probability: 0.5,
stage: 'NEW',
position: 1,
pointOfContactId: DEV_SEED_PERSON_IDS.CHRISTOPH,
@ -51,7 +49,6 @@ export const seedOpportunity = async (
amountAmountMicros: 2000000,
amountCurrencyCode: 'USD',
closeDate: new Date(),
probability: 0.5,
stage: 'MEETING',
position: 2,
pointOfContactId: DEV_SEED_PERSON_IDS.CHRISTOPHER_G,
@ -63,7 +60,6 @@ export const seedOpportunity = async (
amountAmountMicros: 300000,
amountCurrencyCode: 'USD',
closeDate: new Date(),
probability: 0.5,
stage: 'PROPOSAL',
position: 3,
pointOfContactId: DEV_SEED_PERSON_IDS.NICHOLAS,
@ -75,7 +71,6 @@ export const seedOpportunity = async (
amountAmountMicros: 4000000,
amountCurrencyCode: 'USD',
closeDate: new Date(),
probability: 0.5,
stage: 'PROPOSAL',
position: 4,
pointOfContactId: DEV_SEED_PERSON_IDS.MATTHEW,

View File

@ -3,12 +3,6 @@ import { v4 } from 'uuid';
const tableName = 'opportunity';
const getRandomProbability = () => {
const firstDigit = Math.floor(Math.random() * 9) + 1;
return firstDigit / 10;
};
const getRandomStage = () => {
const stages = ['NEW', 'SCREENING', 'MEETING', 'PROPOSAL', 'CUSTOMER'];
@ -28,7 +22,6 @@ const generateOpportunities = (companies) => {
amountCurrencyCode: 'USD',
closeDate: new Date(),
stage: getRandomStage(),
probability: getRandomProbability(),
pointOfContactId: company.personId,
companyId: company.id,
}));
@ -56,7 +49,6 @@ export const opportunityPrefillDemoData = async (
'amountCurrencyCode',
'closeDate',
'stage',
'probability',
'pointOfContactId',
'companyId',
'position',

View File

@ -47,16 +47,6 @@ export const viewOpportunityFields = (
isVisible: true,
size: 150,
},
{
fieldMetadataId:
objectMetadataMap[STANDARD_OBJECT_IDS.opportunity].fields[
OPPORTUNITY_STANDARD_FIELD_IDS.probability
],
viewId: viewId,
position: 4,
isVisible: true,
size: 150,
},
{
fieldMetadataId:
objectMetadataMap[STANDARD_OBJECT_IDS.opportunity].fields[

View File

@ -251,7 +251,7 @@ export const OPPORTUNITY_STANDARD_FIELD_IDS = {
name: '20202020-8609-4f65-a2d9-44009eb422b5',
amount: '20202020-583e-4642-8533-db761d5fa82f',
closeDate: '20202020-527e-44d6-b1ac-c4158d307b97',
probability: '20202020-69d4-45f3-9703-690b09fafcf0',
probabilityDeprecated: '20202020-69d4-45f3-9703-690b09fafcf0',
stage: '20202020-6f76-477d-8551-28cd65b2b4b9',
position: '20202020-806d-493a-bbc6-6313e62958e2',
pointOfContact: '20202020-8dfb-42fc-92b6-01afb759ed16',

View File

@ -96,18 +96,6 @@ export class CompanyWorkspaceEntity extends BaseWorkspaceEntity {
@WorkspaceIsNullable()
annualRecurringRevenue: CurrencyMetadata | null;
@WorkspaceField({
standardId: COMPANY_STANDARD_FIELD_IDS.address_deprecated,
type: FieldMetadataType.TEXT,
label: 'Address (deprecated) ',
description:
"This standard field has been deprecated and migrated as a custom field. Please consider using the new 'address' field type.",
icon: 'IconMap',
})
@WorkspaceIsDeprecated()
@WorkspaceIsNullable()
address_old: string;
@WorkspaceField({
standardId: COMPANY_STANDARD_FIELD_IDS.address,
type: FieldMetadataType.ADDRESS,
@ -231,4 +219,16 @@ export class CompanyWorkspaceEntity extends BaseWorkspaceEntity {
@WorkspaceIsNullable()
@WorkspaceIsSystem()
timelineActivities: Relation<TimelineActivityWorkspaceEntity[]>;
@WorkspaceField({
standardId: COMPANY_STANDARD_FIELD_IDS.address_deprecated,
type: FieldMetadataType.TEXT,
label: 'Address (deprecated) ',
description:
'Address of the company - deprecated in favor of new address field',
icon: 'IconMap',
})
@WorkspaceIsDeprecated()
@WorkspaceIsNullable()
addressOld: string;
}

View File

@ -6,6 +6,15 @@ import {
RelationMetadataType,
RelationOnDeleteAction,
} from 'src/engine/metadata-modules/relation-metadata/relation-metadata.entity';
import { BaseWorkspaceEntity } from 'src/engine/twenty-orm/base.workspace-entity';
import { WorkspaceEntity } from 'src/engine/twenty-orm/decorators/workspace-entity.decorator';
import { WorkspaceField } from 'src/engine/twenty-orm/decorators/workspace-field.decorator';
import { WorkspaceIsDeprecated } from 'src/engine/twenty-orm/decorators/workspace-is-deprecated.decorator';
import { WorkspaceIsNotAuditLogged } from 'src/engine/twenty-orm/decorators/workspace-is-not-audit-logged.decorator';
import { WorkspaceIsNullable } from 'src/engine/twenty-orm/decorators/workspace-is-nullable.decorator';
import { WorkspaceIsSystem } from 'src/engine/twenty-orm/decorators/workspace-is-system.decorator';
import { WorkspaceJoinColumn } from 'src/engine/twenty-orm/decorators/workspace-join-column.decorator';
import { WorkspaceRelation } from 'src/engine/twenty-orm/decorators/workspace-relation.decorator';
import { OPPORTUNITY_STANDARD_FIELD_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
import { STANDARD_OBJECT_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-object-ids';
import { ActivityTargetWorkspaceEntity } from 'src/modules/activity/standard-objects/activity-target.workspace-entity';
@ -14,14 +23,6 @@ import { CompanyWorkspaceEntity } from 'src/modules/company/standard-objects/com
import { FavoriteWorkspaceEntity } from 'src/modules/favorite/standard-objects/favorite.workspace-entity';
import { PersonWorkspaceEntity } from 'src/modules/person/standard-objects/person.workspace-entity';
import { TimelineActivityWorkspaceEntity } from 'src/modules/timeline/standard-objects/timeline-activity.workspace-entity';
import { BaseWorkspaceEntity } from 'src/engine/twenty-orm/base.workspace-entity';
import { WorkspaceEntity } from 'src/engine/twenty-orm/decorators/workspace-entity.decorator';
import { WorkspaceIsNotAuditLogged } from 'src/engine/twenty-orm/decorators/workspace-is-not-audit-logged.decorator';
import { WorkspaceField } from 'src/engine/twenty-orm/decorators/workspace-field.decorator';
import { WorkspaceIsNullable } from 'src/engine/twenty-orm/decorators/workspace-is-nullable.decorator';
import { WorkspaceIsSystem } from 'src/engine/twenty-orm/decorators/workspace-is-system.decorator';
import { WorkspaceRelation } from 'src/engine/twenty-orm/decorators/workspace-relation.decorator';
import { WorkspaceJoinColumn } from 'src/engine/twenty-orm/decorators/workspace-join-column.decorator';
@WorkspaceEntity({
standardId: STANDARD_OBJECT_IDS.opportunity,
@ -62,16 +63,6 @@ export class OpportunityWorkspaceEntity extends BaseWorkspaceEntity {
@WorkspaceIsNullable()
closeDate: Date | null;
@WorkspaceField({
standardId: OPPORTUNITY_STANDARD_FIELD_IDS.probability,
type: FieldMetadataType.TEXT,
label: 'Probability',
description: 'Opportunity probability',
icon: 'IconProgressCheck',
defaultValue: "'0'",
})
probability: string;
@WorkspaceField({
standardId: OPPORTUNITY_STANDARD_FIELD_IDS.stage,
type: FieldMetadataType.SELECT,
@ -185,4 +176,15 @@ export class OpportunityWorkspaceEntity extends BaseWorkspaceEntity {
})
@WorkspaceIsNullable()
timelineActivities: Relation<TimelineActivityWorkspaceEntity[]>;
@WorkspaceField({
standardId: OPPORTUNITY_STANDARD_FIELD_IDS.probabilityDeprecated,
type: FieldMetadataType.TEXT,
label: 'Probability',
description: 'Opportunity probability',
icon: 'IconProgressCheck',
defaultValue: "'0'",
})
@WorkspaceIsDeprecated()
probability: string;
}