mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 05:05:42 +00:00 
			
		
		
		
	Allow override of values from calling function
This commit is contained in:
		| @@ -70,6 +70,7 @@ class CompanySerializer(InvenTreeModelSerializer): | ||||
|             'phone', | ||||
|             'address', | ||||
|             'email', | ||||
|             'currency', | ||||
|             'contact', | ||||
|             'link', | ||||
|             'image', | ||||
|   | ||||
| @@ -16,10 +16,7 @@ | ||||
| {% if pagetype == 'manufacturers' and roles.purchase_order.add or pagetype == 'suppliers' and roles.purchase_order.add or pagetype == 'customers' and roles.sales_order.add %} | ||||
| <div id='button-toolbar'> | ||||
|     <button type='button' class="btn btn-success" id='new-company'> | ||||
|         <span class='fas fa-plus-circle'></span> {{ button_text }} (Server Side) | ||||
|     </button> | ||||
|     <button type='button' class="btn btn-success" id='new-company-2'> | ||||
|         <span class='fas fa-plus-circle'></span> {{ button_text }} (Client Side) | ||||
|         <span class='fas fa-plus-circle'></span> {{ button_text }} | ||||
|     </button> | ||||
|     <div class='btn-group'> | ||||
|     </div> | ||||
| @@ -32,60 +29,49 @@ | ||||
| {% endblock %} | ||||
| {% block js_ready %} | ||||
| {{ block.super }} | ||||
|     $('#new-company').click(function () { | ||||
|         launchModalForm("{{ create_url }}", { | ||||
|             follow: true | ||||
|         }); | ||||
|     }); | ||||
|  | ||||
|     $('#new-company-2').click(function() { | ||||
|     $('#new-company').click(function() { | ||||
|  | ||||
|         createCompany({ | ||||
|             fields: { | ||||
|                 is_supplier: { | ||||
|                     value: {% if pagetype == 'suppliers' %}true{% else %}false{% endif %}, | ||||
|                 }, | ||||
|                 is_manufacturer: { | ||||
|                     value: {% if pagetype == 'manufacturers' %}true{% else %}false{% endif %}, | ||||
|                 }, | ||||
|                 is_customer: { | ||||
|                     value: {% if pagetype == 'customers' %}true{% else %}false{% endif %}, | ||||
|                 }, | ||||
|             } | ||||
|         }); | ||||
|  | ||||
|         return; | ||||
|  | ||||
|         constructForm( | ||||
|             '{% url "api-build-list" %}', | ||||
|             '{% url "api-company-list" %}', | ||||
|             { | ||||
|                 method: 'POST', | ||||
|                 title: '{% trans "Edit Part Details" %}', | ||||
|                 title: '{% trans "Create new Company" %}', | ||||
|                 follow: true, | ||||
|                 fields: { | ||||
|                     title: { | ||||
|                         prefix: `<span class='fas fa-user'></span>` | ||||
|                     }, | ||||
|                     reference: {}, | ||||
|                     part: { | ||||
|                         filters: { | ||||
|                         } | ||||
|                     }, | ||||
|                     quantity: {}, | ||||
|                     /* | ||||
|                     name: { | ||||
|                         onEdit: function() { | ||||
|                             console.log('Edited name field'); | ||||
|                         } | ||||
|                     }, | ||||
|                     name: {}, | ||||
|                     description: {}, | ||||
|                     category: { | ||||
|                         filters: { | ||||
|                             parent: 1, | ||||
|                         }, | ||||
|                         secondary: { | ||||
|                             label: '{% trans "New Category" %}', | ||||
|                         }, | ||||
|                     website: {}, | ||||
|                     address: {}, | ||||
|                     currency: {}, | ||||
|                     phone: {}, | ||||
|                     email: {}, | ||||
|                     contact: {}, | ||||
|                     is_supplier: { | ||||
|                         value: {% if pagetype == 'suppliers' %}true{% else %}false{% endif %}, | ||||
|                     }, | ||||
|                     active: { | ||||
|                         onEdit: function() { | ||||
|                             console.log('edited active field'); | ||||
|                         } | ||||
|                     is_manufacturer: { | ||||
|                         value: {% if pagetype == 'manufacturers' %}true{% else %}false{% endif %}, | ||||
|                     }, | ||||
|                     is_customer: { | ||||
|                         value: {% if pagetype == 'customers' %}true{% else %}false{% endif %}, | ||||
|                     }, | ||||
|                     purchaseable: {}, | ||||
|                     salable: {}, | ||||
|                     component: {}, | ||||
|                     'website', | ||||
|                     'address', | ||||
|                     'phone', | ||||
|                     'email', | ||||
|                     'contact', | ||||
|                     'is_supplier', | ||||
|                     'is_manufacturer', | ||||
|                     'is_customer', | ||||
|                     */ | ||||
|                 } | ||||
|             } | ||||
|         ); | ||||
|   | ||||
| @@ -188,21 +188,6 @@ class CompanyViewTest(CompanyViewTestBase): | ||||
|         response = self.client.get(reverse('company-index')) | ||||
|         self.assertEqual(response.status_code, 200) | ||||
|  | ||||
|     def test_company_create(self): | ||||
|         """ | ||||
|         Test the view for creating a company | ||||
|         """ | ||||
|  | ||||
|         # Check that different company types return different form titles | ||||
|         response = self.client.get(reverse('supplier-create'), HTTP_X_REQUESTED_WITH='XMLHttpRequest') | ||||
|         self.assertContains(response, 'Create new Supplier') | ||||
|  | ||||
|         response = self.client.get(reverse('manufacturer-create'), HTTP_X_REQUESTED_WITH='XMLHttpRequest') | ||||
|         self.assertContains(response, 'Create new Manufacturer') | ||||
|  | ||||
|         response = self.client.get(reverse('customer-create'), HTTP_X_REQUESTED_WITH='XMLHttpRequest') | ||||
|         self.assertContains(response, 'Create new Customer') | ||||
|  | ||||
|  | ||||
| class ManufacturerPartViewTests(CompanyViewTestBase): | ||||
|     """ | ||||
|   | ||||
| @@ -63,21 +63,18 @@ class CompanyIndex(InvenTreeRoleMixin, ListView): | ||||
|                 'title': _('Suppliers'), | ||||
|                 'button_text': _('New Supplier'), | ||||
|                 'filters': {'is_supplier': 'true'}, | ||||
|                 'create_url': reverse('supplier-create'), | ||||
|                 'pagetype': 'suppliers', | ||||
|             }, | ||||
|             reverse('manufacturer-index'): { | ||||
|                 'title': _('Manufacturers'), | ||||
|                 'button_text': _('New Manufacturer'), | ||||
|                 'filters': {'is_manufacturer': 'true'}, | ||||
|                 'create_url': reverse('manufacturer-create'), | ||||
|                 'pagetype': 'manufacturers', | ||||
|             }, | ||||
|             reverse('customer-index'): { | ||||
|                 'title': _('Customers'), | ||||
|                 'button_text': _('New Customer'), | ||||
|                 'filters': {'is_customer': 'true'}, | ||||
|                 'create_url': reverse('customer-create'), | ||||
|                 'pagetype': 'customers', | ||||
|             } | ||||
|         } | ||||
| @@ -86,7 +83,6 @@ class CompanyIndex(InvenTreeRoleMixin, ListView): | ||||
|             'title': _('Companies'), | ||||
|             'button_text': _('New Company'), | ||||
|             'filters': {}, | ||||
|             'create_url': reverse('company-create'), | ||||
|             'pagetype': 'companies' | ||||
|         } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user