[FIX] base: revert and improve 24aba601
It forced to select a coutnry before the state which is not very userfriendly. Cf comments at #13657 Instead restrict only if the country if a country is selected. Courtesy of Pedro M. Baeza, Tecnativa For v10 this is a minimum change and a larger refactoring can be done in master. This replaces and closes #14896
This commit is contained in:
@@ -350,6 +350,13 @@ class Partner(models.Model, FormatAddress):
|
||||
result['value'] = {key: convert(self.parent_id[key]) for key in address_fields}
|
||||
return result
|
||||
|
||||
@api.onchange('country_id')
|
||||
def _onchange_country_id(self):
|
||||
if self.country_id:
|
||||
return {'domain': {'state_id': [('country_id', '=', self.country_id.id)]}}
|
||||
else:
|
||||
return {'domain': {'state_id': []}}
|
||||
|
||||
@api.onchange('email')
|
||||
def onchange_email(self):
|
||||
if not self.image and not self._context.get('yaml_onchange') and self.email:
|
||||
|
||||
@@ -110,9 +110,7 @@
|
||||
<field name="street" placeholder="Street..." class="o_address_street"/>
|
||||
<field name="street2" placeholder="Street 2..." class="o_address_street"/>
|
||||
<field name="city" placeholder="City" class="o_address_city"/>
|
||||
<field name="state_id" class="o_address_state" placeholder="State"
|
||||
options='{"no_open": True}'
|
||||
domain="[('country_id', '=', country_id')]"/>
|
||||
<field name="state_id" class="o_address_state" placeholder="State" options='{"no_open": True}'/>
|
||||
<field name="zip" placeholder="ZIP" class="o_address_zip"/>
|
||||
<field name="country_id" placeholder="Country" class="o_address_country" options='{"no_open": True, "no_create": True}'/>
|
||||
</div>
|
||||
@@ -175,9 +173,7 @@
|
||||
<field name="city" placeholder="City" class="o_address_city"
|
||||
attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"/>
|
||||
<field name="state_id" class="o_address_state" placeholder="State" options='{"no_open": True}'
|
||||
attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"
|
||||
context="{'country_id': country_id, 'zip': zip}"
|
||||
domain="[('country_id', '=', country_id')]"/>
|
||||
attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}" context="{'country_id': country_id, 'zip': zip}"/>
|
||||
<field name="zip" placeholder="ZIP" class="o_address_zip"
|
||||
attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"/>
|
||||
<field name="country_id" placeholder="Country" class="o_address_country" options='{"no_open": True, "no_create": True}'
|
||||
|
||||
Reference in New Issue
Block a user