Repository: saleor/saleor

Issue:
TaxRate on the Product model should be a choice field
We're missing `choices` on `tax_rate` field for `Product` model. Should be set the same way as on the ProductType. 


Discussion:
@Pacu2 please, assign me for this
@axce1 How you doing with this issue? 
@Pacu2 almost done, need fix tests
@axce1 That's great! We always encourage to open pull requests as soon as possible, so we can work on them together and eventually propose minor improvements earlier. 
@Pacu2 thank you for your offer about work togethe, i cant understand how fix tests
can you help me?

travis-ci log: https://travis-ci.com/axce1/saleor/jobs/146880154
In `saleor/graphql/core/types/money.py` there's `TaxRateType` Enum
You could import it to your tests and use it like `TaxRateType.STANDARD.name`
That would do the job
@Pacu2 i fix tests but need your review and them i create PR
https://github.com/axce1/saleor/pull/1#issuecomment-425643557
@axce1 Please create a PR first, so I and other contributors can review it. I think that's the usual workflow we have. 

Resolving patch:
diff --git a/saleor/graphql/product/types.py b/saleor/graphql/product/types.py
--- a/saleor/graphql/product/types.py
+++ b/saleor/graphql/product/types.py
@@ -286,6 +286,7 @@ class Product(CountableDjangoObjectType):
         Money,
         description=dedent("""The product's base price (without any discounts
         applied)."""))
+    tax_rate = TaxRateType(description='A type of tax rate.')
     attributes = graphene.List(
         graphene.NonNull(SelectedAttribute), required=True,
         description='List of attributes assigned to this product.')
diff --git a/saleor/product/migrations/0081_auto_20181218_0024.py b/saleor/product/migrations/0081_auto_20181218_0024.py
new file mode 100644
--- /dev/null
+++ b/saleor/product/migrations/0081_auto_20181218_0024.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.1.4 on 2018-12-18 06:24
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('product', '0080_auto_20181214_0440'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='product',
+            name='tax_rate',
+            field=models.CharField(blank=True, choices=[('accommodation', 'accommodation'), ('admission to cultural events', 'admission to cultural events'), ('admission to entertainment events', 'admission to entertainment events'), ('admission to sporting events', 'admission to sporting events'), ('advertising', 'advertising'), ('agricultural supplies', 'agricultural supplies'), ('baby foodstuffs', 'baby foodstuffs'), ('bikes', 'bikes'), ('books', 'books'), ('childrens clothing', 'childrens clothing'), ('domestic fuel', 'domestic fuel'), ('domestic services', 'domestic services'), ('e-books', 'e-books'), ('foodstuffs', 'foodstuffs'), ('hotels', 'hotels'), ('medical', 'medical'), ('newspapers', 'newspapers'), ('passenger transport', 'passenger transport'), ('pharmaceuticals', 'pharmaceuticals'), ('property renovations', 'property renovations'), ('restaurants', 'restaurants'), ('social housing', 'social housing'), ('standard', 'standard'), ('water', 'water')], default='standard', max_length=128),
+        ),
+    ]
diff --git a/saleor/product/models.py b/saleor/product/models.py
--- a/saleor/product/models.py
+++ b/saleor/product/models.py
@@ -129,7 +129,8 @@ class Product(SeoModel):
     updated_at = models.DateTimeField(auto_now=True, null=True)
     charge_taxes = models.BooleanField(default=True)
     tax_rate = models.CharField(
-        max_length=128, default=DEFAULT_TAX_RATE_NAME, blank=True)
+        max_length=128, default=DEFAULT_TAX_RATE_NAME, blank=True,
+        choices=TaxRateType.CHOICES)
     weight = MeasurementField(
         measurement=Weight, unit_choices=WeightUnits.CHOICES,
         blank=True, null=True)


Test patch:
diff --git a/tests/api/test_product.py b/tests/api/test_product.py
--- a/tests/api/test_product.py
+++ b/tests/api/test_product.py
@@ -467,7 +467,7 @@ def test_create_product(
     assert data['product']['description'] == product_description
     assert data['product']['isPublished'] == product_is_published
     assert data['product']['chargeTaxes'] == product_charge_taxes
-    assert data['product']['taxRate'] == product_tax_rate.lower()
+    assert data['product']['taxRate'] == product_tax_rate
     assert data['product']['productType']['name'] == product_type.name
     assert data['product']['category']['name'] == category.name
     values = (
@@ -563,7 +563,7 @@ def test_update_product(
     assert data['product']['description'] == product_description
     assert data['product']['isPublished'] == product_isPublished
     assert data['product']['chargeTaxes'] == product_chargeTaxes
-    assert data['product']['taxRate'] == product_taxRate.lower()
+    assert data['product']['taxRate'] == product_taxRate
     assert not data['product']['category']['name'] == category.name