Repository: saleor/saleor

Issue:
Product form tax_rate
### What I'm trying to achieve
When I edit a product on the dashboard I would like to have the product tax_rate as the selected option. Instead the product type tax_rate is selected.

### Steps to reproduce the problem
1. Set a tax_rate on a product type
2. Set a different tax rate on a product
3. Go to the dashboard and edit the product
4. When you look at the tax_rate select field, the selected value is the product type tax_rate 

### What I expected to happen
When I edit a product I would like to have the product tax_rate (if set) as the selected option.

### Screenshots
![issue_saleor](https://user-images.githubusercontent.com/5839095/45964444-1cd7e000-c026-11e8-9d91-21a53e32881d.jpg)


**System information**
Operating system: OSX 10.13
Browser: Firefox


Thank you.


Discussion:
Blocked by #2829 
I think that product_type tax rate should be set as the placeholder, and a product's tax_rate should be blank by default
@Pacu2 I can resolve that issue but can you tell me what do you mean by poduct_type tax_rate as placeholder and tax_rate as blanked? 
@tomcio1205 `tax_rate` field's widget should have a [placeholder](https://www.w3schools.com/tags/att_input_placeholder.asp), which should be equal to product's product type tax rate
Then, if no tax rate is assigned on the Product, it should be set to no value, so we will display a placeholder

Resolving patch:
diff --git a/saleor/dashboard/product/forms.py b/saleor/dashboard/product/forms.py
--- a/saleor/dashboard/product/forms.py
+++ b/saleor/dashboard/product/forms.py
@@ -259,7 +259,8 @@ class Meta:
     def __init__(self, *args, **kwargs):
         super().__init__(*args, **kwargs)
         product_type = self.instance.product_type
-        self.initial['tax_rate'] = product_type.tax_rate
+        self.initial['tax_rate'] = (
+            self.instance.tax_rate or product_type.tax_rate)
         self.available_attributes = (
             product_type.product_attributes.prefetch_related('values').all())
         self.prepare_fields_for_attributes()
diff --git a/saleor/product/migrations/0090_auto_20190328_0608.py b/saleor/product/migrations/0090_auto_20190328_0608.py
new file mode 100644
--- /dev/null
+++ b/saleor/product/migrations/0090_auto_20190328_0608.py
@@ -0,0 +1,23 @@
+# Generated by Django 2.1.7 on 2019-03-28 11:08
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('product', '0089_auto_20190225_0252'),
+    ]
+
+    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'), ('wine', 'wine')], max_length=128),
+        ),
+        migrations.AlterField(
+            model_name='producttype',
+            name='tax_rate',
+            field=models.CharField(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'), ('wine', 'wine')], 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
@@ -21,7 +21,7 @@
 from ..core import TaxRateType
 from ..core.exceptions import InsufficientStock
 from ..core.models import PublishableModel, SortableModel
-from ..core.utils.taxes import DEFAULT_TAX_RATE_NAME, apply_tax_to_price
+from ..core.utils.taxes import apply_tax_to_price
 from ..core.utils.translations import TranslationProxy
 from ..core.weight import WeightUnits, zero_weight
 from ..discount.utils import calculate_discounted_price
@@ -77,9 +77,7 @@ class ProductType(models.Model):
     name = models.CharField(max_length=128)
     has_variants = models.BooleanField(default=True)
     is_shipping_required = models.BooleanField(default=True)
-    tax_rate = models.CharField(
-        max_length=128, default=DEFAULT_TAX_RATE_NAME,
-        choices=TaxRateType.CHOICES)
+    tax_rate = models.CharField(max_length=128, choices=TaxRateType.CHOICES)
     weight = MeasurementField(
         measurement=Weight, unit_choices=WeightUnits.CHOICES,
         default=zero_weight)
@@ -112,7 +110,7 @@ class Product(SeoModel, PublishableModel):
     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, blank=True,
         choices=TaxRateType.CHOICES)
     weight = MeasurementField(
         measurement=Weight, unit_choices=WeightUnits.CHOICES,


Test patch:
diff --git a/tests/conftest.py b/tests/conftest.py
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -20,6 +20,7 @@
 from saleor.checkout import utils
 from saleor.checkout.models import Cart
 from saleor.checkout.utils import add_variant_to_cart
+from saleor.core.utils.taxes import DEFAULT_TAX_RATE_NAME
 from saleor.dashboard.menu.utils import update_menu
 from saleor.dashboard.order.utils import fulfill_order_line
 from saleor.discount import VoucherType
@@ -314,7 +315,8 @@ def permission_manage_orders():
 @pytest.fixture
 def product_type(color_attribute, size_attribute):
     product_type = ProductType.objects.create(
-        name='Default Type', has_variants=True, is_shipping_required=True)
+        name='Default Type', has_variants=True, is_shipping_required=True,
+        tax_rate=DEFAULT_TAX_RATE_NAME)
     product_type.product_attributes.add(color_attribute)
     product_type.variant_attributes.add(size_attribute)
     return product_type
@@ -335,7 +337,8 @@ def product(product_type, category):
 
     product = Product.objects.create(
         name='Test product', price=Money('10.00', 'USD'),
-        product_type=product_type, attributes=attributes, category=category)
+        product_type=product_type, attributes=attributes, category=category,
+        tax_rate=DEFAULT_TAX_RATE_NAME)
 
     variant_attr = product_type.variant_attributes.first()
     variant_attr_value = variant_attr.values.first()