Skip to content

feat(datamodel): Add agent fields to Loan and Gift#7190

Merged
grantfitzsimmons merged 8 commits intomainfrom
issue-7090
Aug 14, 2025
Merged

feat(datamodel): Add agent fields to Loan and Gift#7190
grantfitzsimmons merged 8 commits intomainfrom
issue-7090

Conversation

@grantfitzsimmons
Copy link
Member

Fixes #7090

This PR adds 5 agent fields (agent1, agent2, agent3, agent4, and agent5) to both the Loan and Gift tables. This allows users to directly link to agents from these records without using the loanAgents relationship (one-to-many).

This works to address primarily the issues with missing functions for report generation, particularly the getByLoanAgentRole scriptlet. There have been requests from other users to simply have direct relationships to simplify the use of these forms in other contexts.

Warning

This PR affects database migrations. See migration testing instructions.

Checklist

  • Self-review the PR after opening it to make sure the changes look good and
    self-explanatory (or properly documented)
  • Add relevant issue to release milestone
  • Add pr to documentation list
  • Add automated tests
  • Add a reverse migration if a migration is present in the PR

Testing instructions

image image

UX/UI Testers

  • Verify that 5 new agent fields have been added to the schema for both the gift and loan tables
  • Verify that these fields are hidden by default, with schema captions and labels that correspond to the field name (e.g. "Agent 1")
  • Verify that the default "Loan" and "Gift" view definitions have commented out agent fields now
  • Add the 5 agent fields to both forms via the form editor
  • Verify the fields appear in queries
  • Verify that you can, in both tables:
    • Add data to all 5 agent fields (search for existing agents, create a new agent)
    • Upload data to these relationships via the WorkBench
    • Edit existing data in these fields using Batch Edit

Developers

  • Verify the migration runs successfully
specify@6b4f64852cc1:/opt/specify7$ ve/bin/python manage.py migrate specify
Operations to perform:
  Apply all migrations: specify
Running migrations:
  Applying specify.0038_agent_fields_for_loan_and_gift... OK
specify@6b4f64852cc1:/opt/specify7$ 
  • Test the reverse migration
specify@6b4f64852cc1:/opt/specify7$ ve/bin/python manage.py migrate specify 0037
Operations to perform:
  Target specific migration: 0037_make_smushed_default_false, from specify
Running migrations:
  Rendering model states... DONE
  Unapplying specify.0038_agent_fields_for_loan_and_gift...OK
specify@6b4f64852cc1:/opt/specify7$ 

@grantfitzsimmons grantfitzsimmons requested a review from a team August 8, 2025 14:12
@CarolineDenis CarolineDenis added this to the 7.11.2 milestone Aug 8, 2025
Triggered by 217a13b on branch refs/heads/issue-7090
Copy link
Collaborator

@emenslin emenslin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Verify that 5 new agent fields have been added to the schema for both the gift and loan tables
  • Verify that these fields are hidden by default, with schema captions and labels that correspond to the field name (e.g. "Agent 1")
  • Verify that the default "Loan" and "Gift" view definitions have commented out agent fields now
  • Add the 5 agent fields to both forms via the form editor
  • Verify the fields appear in queries
  • Verify that you can, in both tables:
    • Add data to all 5 agent fields (search for existing agents, create a new agent)
    • Upload data to these relationships via the WorkBench
    • Edit existing data in these fields using Batch Edit

Only issue I found is that default gift view definition has the commented out agent fields but the default loan view definition does not.

Additionally I wanted to note that you cannot batch edit Gifts (#5417 (comment)), but batch editing loans with the agent fields works!

@github-project-automation github-project-automation bot moved this from 📋Back Log to Dev Attention Needed in General Tester Board Aug 8, 2025
@grantfitzsimmons
Copy link
Member Author

@emenslin Thanks for your review! Fixed in 0bd978c

Copy link
Collaborator

@emenslin emenslin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Verify that 5 new agent fields have been added to the schema for both the gift and loan tables
  • Verify that these fields are hidden by default, with schema captions and labels that correspond to the field name (e.g. "Agent 1")
  • Verify that the default "Loan" and "Gift" view definitions have commented out agent fields now
  • Add the 5 agent fields to both forms via the form editor
  • Verify the fields appear in queries
  • Verify that you can, in both tables:
    • Add data to all 5 agent fields (search for existing agents, create a new agent)
    • Upload data to these relationships via the WorkBench
    • Edit existing data in these fields using Batch Edit

Looks good, agents are now commented out on the loan view definition!

@emenslin emenslin requested a review from a team August 11, 2025 14:12
Copy link
Collaborator

@lexiclevenger lexiclevenger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Verify that 5 new agent fields have been added to the schema for both the gift and loan tables
  • Verify that these fields are hidden by default, with schema captions and labels that correspond to the field name (e.g. "Agent 1")
  • Verify that the default "Loan" and "Gift" view definitions have commented out agent fields now
  • Add the 5 agent fields to both forms via the form editor
  • Verify the fields appear in queries
  • Verify that you can, in both tables:
    • Add data to all 5 agent fields (search for existing agents, create a new agent)
    • Upload data to these relationships via the WorkBench
    • Edit existing data in these fields using Batch Edit

The agent fields do not appear in schema config. They are visible in the query builder, but running the query causes an error. They are commented out in the gift and loan default forms, but adding these to the form causes an error when you access them.

Screenshot 2025-08-14 at 12 26 39 PM

Crash report:
Specify 7 Crash Report - 2025-08-14T17_23_30.261Z.txt

Database: lsumz_mammals_migration7090_2025_08_14
Collection: Mammals
User: spadmin

@grantfitzsimmons
Copy link
Member Author

grantfitzsimmons commented Aug 14, 2025

@lexiclevenger I think this is the problem:

2025-08-14T16:50:02.089Z CommandError: Conflicting migrations detected; multiple leaf nodes in the migration graph: (0038_agent_fields_for_loan_and_gift, 0038_make_countonly_default_false in specify).

In short, another migration using the 0038 identifier in the specify app on main already was run on that database before it was tested. This PR predates that one, yet that was merged first. That led to the conflict you see.

@lexiclevenger
Copy link
Collaborator

@grantfitzsimmons I reimported the database and tried again but am running into the same problems

Copy link
Collaborator

@lexiclevenger lexiclevenger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Verify that 5 new agent fields have been added to the schema for both the gift and loan tables
  • Verify that these fields are hidden by default, with schema captions and labels that correspond to the field name (e.g. "Agent 1")
  • Verify that the default "Loan" and "Gift" view definitions have commented out agent fields now
  • Add the 5 agent fields to both forms via the form editor
  • Verify the fields appear in queries
  • Verify that you can, in both tables:
    • Add data to all 5 agent fields (search for existing agents, create a new agent)
    • Upload data to these relationships via the WorkBench
    • Edit existing data in these fields using Batch Edit

Looks good now!

@grantfitzsimmons grantfitzsimmons merged commit 2f810b7 into main Aug 14, 2025
13 of 14 checks passed
@grantfitzsimmons grantfitzsimmons deleted the issue-7090 branch August 14, 2025 23:56
@github-project-automation github-project-automation bot moved this from Dev Attention Needed to ✅Done in General Tester Board Aug 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅Done

Development

Successfully merging this pull request may close these issues.

Add agent fields to Loan and Gift tables for scriptlet supplementation

4 participants