diff --git a/supplier_app/forms.py b/supplier_app/forms.py index 4fb9afd..f5704f6 100644 --- a/supplier_app/forms.py +++ b/supplier_app/forms.py @@ -152,7 +152,6 @@ class TaxPayerArgentinaBaseForm(ModelForm): widget=forms.RadioSelect(attrs={"class": "form-check-input"}), choices=get_eb_entities(), label=_("Eventbrite entities to bill"), - initial=1, ) diff --git a/supplier_app/tests/test_view.py b/supplier_app/tests/test_view.py index c9d9342..2e91801 100644 --- a/supplier_app/tests/test_view.py +++ b/supplier_app/tests/test_view.py @@ -1002,6 +1002,7 @@ def tearDown(self): rmtree('file') def test_get_success_url_should_redirect_to_details_view_when_click_in_update_button(self): + TaxPayerEBEntityFactory(taxpayer=self.taxpayer) response = self.client.get( reverse( self.taxpayer_edit_url, @@ -1179,7 +1180,7 @@ def test_post_edit_active_taxpayer_as_ap_dont_chang_state(self): status_approved ) - def test_taxpayer_edit_view_should_render_eb_entities_related(self): + def test_taxpayer_edit_view_should_render_last_eb_entities(self): taxpayer = TaxPayerArgentinaFactory( company=self.taxpayer.company, ) @@ -1194,7 +1195,7 @@ def test_taxpayer_edit_view_should_render_eb_entities_related(self): ), ) self.assertEqual( - [taxpayer_eb_entity_1.eb_entity, taxpayer_eb_entity_2.eb_entity], + taxpayer_eb_entity_2.eb_entity.id, response.context_data['form'].fields['eb_entities'].initial) def test_form_valid_method_should_update_eb_entities(self): @@ -1232,6 +1233,7 @@ def test_edit_taxpayer_view_should_populate_file_fields_with_existing_files(self self.taxpayer.iibb_no_retention_taxes_file = self.file_mock self.taxpayer.iibb_registration_file = self.file_mock self.taxpayer.save() + TaxPayerEBEntityFactory(taxpayer=self.taxpayer) response = self.client.get( reverse( diff --git a/supplier_app/views.py b/supplier_app/views.py index 46c5e5f..dfae7f9 100644 --- a/supplier_app/views.py +++ b/supplier_app/views.py @@ -410,7 +410,8 @@ def get_context_data(self, **kwargs): form.fields['afip_registration_file'].initial = taxpayer.afip_registration_file form.fields['witholding_taxes_file'].initial = taxpayer.witholding_taxes_file - form.fields['eb_entities'].initial = taxpayer.eb_entities + # Todo: migrate relation to OneToOne + form.fields['eb_entities'].initial = taxpayer.eb_entities.pop().id return context def handle_no_permission(self):