mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 05:05:42 +00:00 
			
		
		
		
	[FR] Add last updated column for supplier parts (#4214)
* Move to updated Meta mixin * [FR] Add last updated column for supplier parts Fixes #3327 * add updated to table * bump API version * add missing migration * incremetn api ;-)
This commit is contained in:
		| @@ -364,6 +364,7 @@ class SupplierPartList(ListCreateDestroyAPIView): | ||||
|         'packaging', | ||||
|         'pack_size', | ||||
|         'in_stock', | ||||
|         'updated', | ||||
|     ] | ||||
|  | ||||
|     ordering_field_aliases = { | ||||
|   | ||||
| @@ -0,0 +1,18 @@ | ||||
| # Generated by Django 3.2.16 on 2023-01-15 14:04 | ||||
|  | ||||
| from django.db import migrations, models | ||||
|  | ||||
|  | ||||
| class Migration(migrations.Migration): | ||||
|  | ||||
|     dependencies = [ | ||||
|         ('company', '0051_alter_supplierpricebreak_price'), | ||||
|     ] | ||||
|  | ||||
|     operations = [ | ||||
|         migrations.AlterField( | ||||
|             model_name='supplierpricebreak', | ||||
|             name='updated', | ||||
|             field=models.DateTimeField(auto_now=True, help_text='Timestamp of last update', null=True, verbose_name='Updated'), | ||||
|         ), | ||||
|     ] | ||||
							
								
								
									
										18
									
								
								InvenTree/company/migrations/0053_supplierpart_updated.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								InvenTree/company/migrations/0053_supplierpart_updated.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,18 @@ | ||||
| # Generated by Django 3.2.16 on 2023-01-17 20:13 | ||||
|  | ||||
| from django.db import migrations, models | ||||
|  | ||||
|  | ||||
| class Migration(migrations.Migration): | ||||
|  | ||||
|     dependencies = [ | ||||
|         ('company', '0052_alter_supplierpricebreak_updated'), | ||||
|     ] | ||||
|  | ||||
|     operations = [ | ||||
|         migrations.AddField( | ||||
|             model_name='supplierpart', | ||||
|             name='updated', | ||||
|             field=models.DateTimeField(auto_now=True, help_text='Timestamp of last update', null=True, verbose_name='Updated'), | ||||
|         ), | ||||
|     ] | ||||
| @@ -396,7 +396,7 @@ class SupplierPartManager(models.Manager): | ||||
|         ) | ||||
|  | ||||
|  | ||||
| class SupplierPart(InvenTreeBarcodeMixin, models.Model): | ||||
| class SupplierPart(InvenTreeBarcodeMixin, common.models.MetaMixin): | ||||
|     """Represents a unique part as provided by a Supplier Each SupplierPart is identified by a SKU (Supplier Part Number) Each SupplierPart is also linked to a Part or ManufacturerPart object. A Part may be available from multiple suppliers. | ||||
|  | ||||
|     Attributes: | ||||
| @@ -412,6 +412,7 @@ class SupplierPart(InvenTreeBarcodeMixin, models.Model): | ||||
|         lead_time: Supplier lead time | ||||
|         packaging: packaging that the part is supplied in, e.g. "Reel" | ||||
|         pack_size: Quantity of item supplied in a single pack (e.g. 30ml in a single tube) | ||||
|         updated: Date that the SupplierPart was last updated | ||||
|     """ | ||||
|  | ||||
|     objects = SupplierPartManager() | ||||
| @@ -683,8 +684,6 @@ class SupplierPriceBreak(common.models.PriceBreak): | ||||
|  | ||||
|     part = models.ForeignKey(SupplierPart, on_delete=models.CASCADE, related_name='pricebreaks', verbose_name=_('Part'),) | ||||
|  | ||||
|     updated = models.DateTimeField(auto_now=True, null=True, verbose_name=_('last updated')) | ||||
|  | ||||
|     class Meta: | ||||
|         """Metaclass defines extra model options""" | ||||
|         unique_together = ("part", "quantity") | ||||
|   | ||||
| @@ -282,6 +282,9 @@ class SupplierPartSerializer(InvenTreeModelSerializer): | ||||
|  | ||||
|     url = serializers.CharField(source='get_absolute_url', read_only=True) | ||||
|  | ||||
|     # Date fields | ||||
|     updated = serializers.DateTimeField(allow_null=True, read_only=True) | ||||
|  | ||||
|     class Meta: | ||||
|         """Metaclass options.""" | ||||
|  | ||||
| @@ -309,6 +312,7 @@ class SupplierPartSerializer(InvenTreeModelSerializer): | ||||
|             'supplier', | ||||
|             'supplier_detail', | ||||
|             'url', | ||||
|             'updated', | ||||
|         ] | ||||
|  | ||||
|         read_only_fields = [ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user