Skip to content

Commit

Permalink
[MERGE] [IMP] res_partner: correctly take the 'use parent address'
Browse files Browse the repository at this point in the history
into account in the onchange. Slightly updated the view that was weird with this parameter.

bzr revid: tde@openerp.com-20140417145522-yte3976um2a1t0dr
  • Loading branch information
dka-odoo authored and tde-banana-odoo committed Apr 17, 2014
2 parents 8befd23 + 19d2466 commit 37bf72a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions openerp/addons/base/res/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ def onchange_type(self, cr, uid, ids, is_company, context=None):
value = {}
value['title'] = False
if is_company:
value['use_parent_address'] = False
domain = {'title': [('domain', '=', 'partner')]}
else:
domain = {'title': [('domain', '=', 'contact')]}
Expand All @@ -379,9 +380,10 @@ def value_or_id(val):
'was never correctly set. If an existing contact starts working for a new '
'company then a new contact should be created under that new '
'company. You can use the "Discard" button to abandon this change.')}
parent = self.browse(cr, uid, parent_id, context=context)
address_fields = self._address_fields(cr, uid, context=context)
result['value'] = dict((key, value_or_id(parent[key])) for key in address_fields)
if use_parent_address:
parent = self.browse(cr, uid, parent_id, context=context)
address_fields = self._address_fields(cr, uid, context=context)
result['value'] = dict((key, value_or_id(parent[key])) for key in address_fields)
else:
result['value'] = {'use_parent_address': False}
return result
Expand Down
6 changes: 3 additions & 3 deletions openerp/addons/base/res/res_partner_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@
<div>
<field name="use_parent_address" class="oe_edit_only oe_inline"
on_change="onchange_address(use_parent_address, parent_id)"
attrs="{'invisible': [('parent_id','=', False),('use_parent_address','=',False)]}"/>
<label for="use_parent_address" class="oe_edit_only" attrs="{'invisible': [('parent_id','=', False),('use_parent_address','=',False)]}"/>
attrs="{'invisible': ['|', ('is_company', '=', True),('parent_id', '=', False)]}"/>
<label for="use_parent_address" class="oe_edit_only" attrs="{'invisible': ['|', ('is_company', '=', True), ('parent_id', '=', False)]}"/>
<button name="open_parent" type="object" string="(edit company address)" class="oe_link oe_edit_only"
attrs="{'invisible': ['|',('parent_id','=', False),('use_parent_address','=',False)]}"/>
<field name="street" placeholder="Street..." attrs="{'readonly': [('use_parent_address','=',True)]}"/>
Expand Down Expand Up @@ -188,7 +188,7 @@

<notebook colspan="4">
<page string="Contacts" attrs="{'invisible': [('is_company','=',False), ('child_ids', '=', [])]}" autofocus="autofocus">
<field name="child_ids" mode="kanban" context="{'default_parent_id': active_id, 'default_street': street, 'default_street2': street2, 'default_city': city, 'default_state_id': state_id, 'default_zip': zip, 'default_country_id': country_id, 'default_supplier': supplier, 'default_customer': customer}">
<field name="child_ids" mode="kanban" context="{'default_parent_id': active_id, 'default_street': street, 'default_street2': street2, 'default_city': city, 'default_state_id': state_id, 'default_zip': zip, 'default_country_id': country_id, 'default_supplier': supplier, 'default_customer': customer, 'default_use_parent_address': True}">
<kanban>
<field name="color"/>
<field name="name"/>
Expand Down

0 comments on commit 37bf72a

Please sign in to comment.