|
3 | 3 | from django.contrib import messages |
4 | 4 | from django.contrib.auth import get_user_model |
5 | 5 | from django.core.handlers.wsgi import WSGIRequest |
| 6 | +from django.forms.widgets import HiddenInput |
6 | 7 | from django.http import HttpResponseRedirect |
7 | 8 | from django.utils.html import format_html |
8 | 9 | from django.utils.translation import gettext_lazy as _ |
@@ -192,12 +193,21 @@ def changelist_view(self, request, extra_context=None): |
192 | 193 |
|
193 | 194 | def get_form(self, request, obj=None, **kwargs): |
194 | 195 | form = super().get_form(request, obj, **kwargs) |
| 196 | + |
| 197 | + if obj and getattr(obj, "deal", None): |
| 198 | + if "duplicate" in form.base_fields: |
| 199 | + form.base_fields["duplicate"].widget = HiddenInput() |
| 200 | + if "case" in form.base_fields: |
| 201 | + form.base_fields["case"].widget = HiddenInput() |
| 202 | + |
195 | 203 | if request.method == "POST" and '_create-deal' in request.POST: |
196 | 204 | department_id = request.user.department_id |
197 | 205 | works_globally = Department.objects.get( |
198 | | - id=department_id).works_globally |
| 206 | + id=department_id |
| 207 | + ).works_globally |
199 | 208 | if works_globally: |
200 | 209 | form.country_must_be_specified = True |
| 210 | + |
201 | 211 | return form |
202 | 212 |
|
203 | 213 | def get_changeform_initial_data(self, request): |
|
0 commit comments