[bug] Billing code page can't save a code with a client ("Select a valid choice")
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 86/100
Research direction
Read BillingCodeForm in jobtracker/forms.py and compare its client field widget with InlineBillingCodeForm, which the issue says works. Change the full-page field to use the single-choice widget described in the issue, then add and run a form test that posts a client. Done means the form accepts a valid client and the regression test passes.
Written by the indexing model from the issue text.
Description
Summary
On Operations → Billing Codes → Create (and edit), choosing a client and saving fails with "Select a valid choice. That choice is not one of the available choices." under Client. Codes can only be saved from that page without a client.
BillingCodeForm.client in jobtracker/forms.py is a single-choice forms.ModelChoiceField, but its widget is s2forms.ModelSelect2MultipleWidget. The multiple widget's value_from_datadict returns a list, which ModelChoiceField can't match against the queryset, so validation always fails when a client is chosen.
Reproduced in a Django shell:
BillingCodeForm(data=QueryDict(f"code=Training&client={client.pk}®ion=GB")).errors
# {'client': ['Select a valid choice. That choice is not one of the available choices.']}
InlineBillingCodeForm, used for "create code" inside the Assign Billing Codes modal, uses ModelSelect2Widget and works. Its docstring notes the full-page form has a multiple client widget.
Suggested fix
class BillingCodeForm(forms.ModelForm):
client = forms.ModelChoiceField(
required=False,
queryset=Client.objects.all(),
widget=s2forms.ModelSelect2Widget( # was ModelSelect2MultipleWidget
...
A form test that posts a client would catch a regression.
Workaround
Create the code from a job's Assign Billing Codes dialog, where the client defaults to the job's client, or in the Django admin.
- Dominant language
- HTML
- Stars
- 6
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from brainthee/CHAOTICA
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
[Minor UI Bug] Client page shows account manager photos as squares overlapping the round borderOpen
Difficulty 1/5 Under an hour Newbie friendliness 94/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
All issues in brainthee/CHAOTICA
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
aws/aws-emulator#30 · 1 comment ·
-
tormach-plasma refusal text with no machine reads "no machine is not declared a plasma machine"Openarea:post bug effort:low P2 source:agent
Difficulty 1/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
bug good first issue priority: P2 status: ready
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
RhinoLink-Tech/data-fabric#502 ·
Maintainers usually reply within 1 day
-
dropIndexes by key pattern panics on a shorter pattern and drops the wrong index on a longer oneOpen
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
mega-yfue/ha-eufy-sdk-bridge#198 ·
Maintainers usually reply within 1 day