Przeglądaj źródła

Allow a product to have multiple stockrecords

master
David Winterbottom 12 lat temu
rodzic
commit
b96c089b2d

+ 2
- 2
oscar/apps/partner/abstract_models.py Wyświetl plik

@@ -101,8 +101,8 @@ class AbstractStockRecord(models.Model):
101 101
     We deliberately don't store tax information to allow each project
102 102
     to subclass this model and put its own fields for convey tax.
103 103
     """
104
-    product = models.OneToOneField(
105
-        'catalogue.Product', related_name="stockrecord",
104
+    product = models.ForeignKey(
105
+        'catalogue.Product', related_name="stockrecords",
106 106
         verbose_name=_("Product"))
107 107
     partner = models.ForeignKey('partner.Partner', verbose_name=_("Partner"))
108 108
 

+ 209
- 0
oscar/apps/partner/migrations/0009_auto__chg_field_stockrecord_product__del_unique_stockrecord_product.py Wyświetl plik

@@ -0,0 +1,209 @@
1
+# -*- coding: utf-8 -*-
2
+import datetime
3
+from south.db import db
4
+from south.v2 import SchemaMigration
5
+from django.db import models
6
+
7
+
8
+class Migration(SchemaMigration):
9
+
10
+    def forwards(self, orm):
11
+        # Removing unique constraint on 'StockRecord', fields ['product']
12
+        db.delete_unique('partner_stockrecord', ['product_id'])
13
+
14
+
15
+        # Changing field 'StockRecord.product'
16
+        db.alter_column('partner_stockrecord', 'product_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['catalogue.Product']))
17
+
18
+    def backwards(self, orm):
19
+
20
+        # Changing field 'StockRecord.product'
21
+        db.alter_column('partner_stockrecord', 'product_id', self.gf('django.db.models.fields.related.OneToOneField')(unique=True, to=orm['catalogue.Product']))
22
+        # Adding unique constraint on 'StockRecord', fields ['product']
23
+        db.create_unique('partner_stockrecord', ['product_id'])
24
+
25
+
26
+    models = {
27
+        'auth.group': {
28
+            'Meta': {'object_name': 'Group'},
29
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
30
+            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
31
+            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
32
+        },
33
+        'auth.permission': {
34
+            'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
35
+            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
36
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
37
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
38
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
39
+        },
40
+        'auth.user': {
41
+            'Meta': {'object_name': 'User'},
42
+            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
43
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
44
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
45
+            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
46
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
47
+            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
48
+            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
49
+            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
50
+            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
51
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
52
+            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
53
+            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
54
+            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
55
+        },
56
+        'catalogue.attributeentity': {
57
+            'Meta': {'object_name': 'AttributeEntity'},
58
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
59
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
60
+            'slug': ('django.db.models.fields.SlugField', [], {'max_length': '255', 'blank': 'True'}),
61
+            'type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'entities'", 'to': "orm['catalogue.AttributeEntityType']"})
62
+        },
63
+        'catalogue.attributeentitytype': {
64
+            'Meta': {'object_name': 'AttributeEntityType'},
65
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
66
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
67
+            'slug': ('django.db.models.fields.SlugField', [], {'max_length': '255', 'blank': 'True'})
68
+        },
69
+        'catalogue.attributeoption': {
70
+            'Meta': {'object_name': 'AttributeOption'},
71
+            'group': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'options'", 'to': "orm['catalogue.AttributeOptionGroup']"}),
72
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
73
+            'option': ('django.db.models.fields.CharField', [], {'max_length': '255'})
74
+        },
75
+        'catalogue.attributeoptiongroup': {
76
+            'Meta': {'object_name': 'AttributeOptionGroup'},
77
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
78
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '128'})
79
+        },
80
+        'catalogue.category': {
81
+            'Meta': {'ordering': "['full_name']", 'object_name': 'Category'},
82
+            'depth': ('django.db.models.fields.PositiveIntegerField', [], {}),
83
+            'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
84
+            'full_name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
85
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
86
+            'image': ('django.db.models.fields.files.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
87
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}),
88
+            'numchild': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
89
+            'path': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
90
+            'slug': ('django.db.models.fields.SlugField', [], {'max_length': '255'})
91
+        },
92
+        'catalogue.option': {
93
+            'Meta': {'object_name': 'Option'},
94
+            'code': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '128'}),
95
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
96
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
97
+            'type': ('django.db.models.fields.CharField', [], {'default': "'Required'", 'max_length': '128'})
98
+        },
99
+        'catalogue.product': {
100
+            'Meta': {'ordering': "['-date_created']", 'object_name': 'Product'},
101
+            'attributes': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['catalogue.ProductAttribute']", 'through': "orm['catalogue.ProductAttributeValue']", 'symmetrical': 'False'}),
102
+            'categories': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['catalogue.Category']", 'through': "orm['catalogue.ProductCategory']", 'symmetrical': 'False'}),
103
+            'date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
104
+            'date_updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'db_index': 'True', 'blank': 'True'}),
105
+            'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
106
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
107
+            'is_discountable': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
108
+            'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'variants'", 'null': 'True', 'to': "orm['catalogue.Product']"}),
109
+            'product_class': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.ProductClass']", 'null': 'True'}),
110
+            'product_options': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['catalogue.Option']", 'symmetrical': 'False', 'blank': 'True'}),
111
+            'rating': ('django.db.models.fields.FloatField', [], {'null': 'True'}),
112
+            'recommended_products': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['catalogue.Product']", 'symmetrical': 'False', 'through': "orm['catalogue.ProductRecommendation']", 'blank': 'True'}),
113
+            'related_products': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'relations'", 'blank': 'True', 'to': "orm['catalogue.Product']"}),
114
+            'score': ('django.db.models.fields.FloatField', [], {'default': '0.0', 'db_index': 'True'}),
115
+            'slug': ('django.db.models.fields.SlugField', [], {'max_length': '255'}),
116
+            'status': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '128', 'null': 'True', 'blank': 'True'}),
117
+            'title': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
118
+            'upc': ('django.db.models.fields.CharField', [], {'max_length': '64', 'unique': 'True', 'null': 'True', 'blank': 'True'})
119
+        },
120
+        'catalogue.productattribute': {
121
+            'Meta': {'ordering': "['code']", 'object_name': 'ProductAttribute'},
122
+            'code': ('django.db.models.fields.SlugField', [], {'max_length': '128'}),
123
+            'entity_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.AttributeEntityType']", 'null': 'True', 'blank': 'True'}),
124
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
125
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
126
+            'option_group': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.AttributeOptionGroup']", 'null': 'True', 'blank': 'True'}),
127
+            'product_class': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'attributes'", 'null': 'True', 'to': "orm['catalogue.ProductClass']"}),
128
+            'required': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
129
+            'type': ('django.db.models.fields.CharField', [], {'default': "'text'", 'max_length': '20'})
130
+        },
131
+        'catalogue.productattributevalue': {
132
+            'Meta': {'object_name': 'ProductAttributeValue'},
133
+            'attribute': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.ProductAttribute']"}),
134
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
135
+            'product': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'attribute_values'", 'to': "orm['catalogue.Product']"}),
136
+            'value_boolean': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
137
+            'value_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
138
+            'value_entity': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.AttributeEntity']", 'null': 'True', 'blank': 'True'}),
139
+            'value_float': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}),
140
+            'value_integer': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
141
+            'value_option': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.AttributeOption']", 'null': 'True', 'blank': 'True'}),
142
+            'value_richtext': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
143
+            'value_text': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'})
144
+        },
145
+        'catalogue.productcategory': {
146
+            'Meta': {'ordering': "['-is_canonical']", 'object_name': 'ProductCategory'},
147
+            'category': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.Category']"}),
148
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
149
+            'is_canonical': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
150
+            'product': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.Product']"})
151
+        },
152
+        'catalogue.productclass': {
153
+            'Meta': {'ordering': "['name']", 'object_name': 'ProductClass'},
154
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
155
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
156
+            'options': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['catalogue.Option']", 'symmetrical': 'False', 'blank': 'True'}),
157
+            'requires_shipping': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
158
+            'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '128'}),
159
+            'track_stock': ('django.db.models.fields.BooleanField', [], {'default': 'True'})
160
+        },
161
+        'catalogue.productrecommendation': {
162
+            'Meta': {'object_name': 'ProductRecommendation'},
163
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
164
+            'primary': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'primary_recommendations'", 'to': "orm['catalogue.Product']"}),
165
+            'ranking': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '0'}),
166
+            'recommendation': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.Product']"})
167
+        },
168
+        'contenttypes.contenttype': {
169
+            'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
170
+            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
171
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
172
+            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
173
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
174
+        },
175
+        'partner.partner': {
176
+            'Meta': {'object_name': 'Partner'},
177
+            'code': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '128'}),
178
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
179
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}),
180
+            'users': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'partners'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['auth.User']"})
181
+        },
182
+        'partner.stockalert': {
183
+            'Meta': {'ordering': "('-date_created',)", 'object_name': 'StockAlert'},
184
+            'date_closed': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
185
+            'date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
186
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
187
+            'status': ('django.db.models.fields.CharField', [], {'default': "'Open'", 'max_length': '128'}),
188
+            'stockrecord': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'alerts'", 'to': "orm['partner.StockRecord']"}),
189
+            'threshold': ('django.db.models.fields.PositiveIntegerField', [], {})
190
+        },
191
+        'partner.stockrecord': {
192
+            'Meta': {'unique_together': "(('partner', 'partner_sku'),)", 'object_name': 'StockRecord'},
193
+            'cost_price': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '12', 'decimal_places': '2', 'blank': 'True'}),
194
+            'date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
195
+            'date_updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'db_index': 'True', 'blank': 'True'}),
196
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
197
+            'low_stock_threshold': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),
198
+            'num_allocated': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
199
+            'num_in_stock': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),
200
+            'partner': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['partner.Partner']"}),
201
+            'partner_sku': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
202
+            'price_currency': ('django.db.models.fields.CharField', [], {'default': "'GBP'", 'max_length': '12'}),
203
+            'price_excl_tax': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '12', 'decimal_places': '2', 'blank': 'True'}),
204
+            'price_retail': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '12', 'decimal_places': '2', 'blank': 'True'}),
205
+            'product': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'stockrecords'", 'to': "orm['catalogue.Product']"})
206
+        }
207
+    }
208
+
209
+    complete_apps = ['partner']

Ładowanie…
Anuluj
Zapisz