[FIX] base_address_city, base_address_extended: usability of res.partner form view

*street fields should be editable only if we modify the main partner address
*creating a res.city through the m2o should has default country and a domain
This commit is contained in:
qdp-odoo
2017-01-13 18:27:37 +01:00
parent 0899e8ada3
commit 9dbe23e038
3 changed files with 12 additions and 9 deletions
@@ -26,8 +26,8 @@ class Partner(models.Model):
replacement_xml = """
<div>
<field name="country_enforce_cities" invisible="1"/>
<field name='city' attrs="{'invisible': [('country_enforce_cities', '=', True), ('city_id', '!=', False)]}"/>
<field name='city_id' attrs="{'invisible': [('country_enforce_cities', '=', False)]}"/>
<field name='city' attrs="{'invisible': [('country_enforce_cities', '=', True), ('city_id', '!=', False)], 'readonly': [('type', '=', 'contact'), ('parent_id', '!=', False)]}"/>
<field name='city_id' attrs="{'invisible': [('country_enforce_cities', '=', False)], 'readonly': [('type', '=', 'contact'), ('parent_id', '!=', False)]}" context="{'default_country_id': country_id}" domain="[('country_id', '=', country_id)]"/>
</div>
"""
city_id_node = etree.fromstring(replacement_xml)
@@ -20,14 +20,13 @@
<field name="arch" type="xml">
<xpath expr="//field[@name='street']" position="replace">
<field name="street" invisible="1"/>
<field name="street_name" placeholder="Street Name..."/>
<field name="street_name" placeholder="Street Name..." attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"/>
<div class="o_row">
<field name="city" invisible="1"/>
<label for="street_number" class="oe_edit_only"/>
<span> </span>
<field name="street_number"/>
<field name="street_number" attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"/>
<label for="street_number2" class="oe_edit_only"/>
<field name="street_number2"/>
<field name="street_number2" attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"/>
</div>
</xpath>
</field>
@@ -40,13 +39,13 @@
<field name="arch" type="xml">
<xpath expr="//field[@name='street']" position="replace">
<field name="street" invisible="1"/>
<field name="street_name" placeholder="Street Name..."/>
<field name="street_name" placeholder="Street Name..." attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"/>
<div class="o_row">
<label for="street_number" class="oe_edit_only"/>
<span> </span>
<field name="street_number"/>
<field name="street_number" attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"/>
<label for="street_number2" class="oe_edit_only"/>
<field name="street_number2"/>
<field name="street_number2" attrs="{'readonly': [('type', '=', 'contact'),('parent_id', '!=', False)]}"/>
</div>
</xpath>
</field>
@@ -258,7 +258,11 @@
</kanban>
<form string="Contact / Address">
<sheet>
<!-- parent_id and type fields needed in attrs in base_address_city module which overwrites
_fields_view_get() of partner. It would be better to put those fields there but the web client
dosen't support when a field is displayed several times in the same view.-->
<field name="type" required="1" widget="radio" options="{'horizontal': true}"/>
<field name="parent_id" invisible="1"/>
<hr/>
<group>
<group attrs="{'invisible': [('type','=', 'contact')]}">