Skip to content

Commit 37bf72a

Browse files
dka-odootde-banana-odoo
authored andcommittedApr 17, 2014
[MERGE] [IMP] res_partner: correctly take the 'use parent address'
into account in the onchange. Slightly updated the view that was weird with this parameter. bzr revid: [email protected]
2 parents 8befd23 + 19d2466 commit 37bf72a

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed
 

‎openerp/addons/base/res/res_partner.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ def onchange_type(self, cr, uid, ids, is_company, context=None):
360360
value = {}
361361
value['title'] = False
362362
if is_company:
363+
value['use_parent_address'] = False
363364
domain = {'title': [('domain', '=', 'partner')]}
364365
else:
365366
domain = {'title': [('domain', '=', 'contact')]}
@@ -379,9 +380,10 @@ def value_or_id(val):
379380
'was never correctly set. If an existing contact starts working for a new '
380381
'company then a new contact should be created under that new '
381382
'company. You can use the "Discard" button to abandon this change.')}
382-
parent = self.browse(cr, uid, parent_id, context=context)
383-
address_fields = self._address_fields(cr, uid, context=context)
384-
result['value'] = dict((key, value_or_id(parent[key])) for key in address_fields)
383+
if use_parent_address:
384+
parent = self.browse(cr, uid, parent_id, context=context)
385+
address_fields = self._address_fields(cr, uid, context=context)
386+
result['value'] = dict((key, value_or_id(parent[key])) for key in address_fields)
385387
else:
386388
result['value'] = {'use_parent_address': False}
387389
return result

‎openerp/addons/base/res/res_partner_view.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@
158158
<div>
159159
<field name="use_parent_address" class="oe_edit_only oe_inline"
160160
on_change="onchange_address(use_parent_address, parent_id)"
161-
attrs="{'invisible': [('parent_id','=', False),('use_parent_address','=',False)]}"/>
162-
<label for="use_parent_address" class="oe_edit_only" attrs="{'invisible': [('parent_id','=', False),('use_parent_address','=',False)]}"/>
161+
attrs="{'invisible': ['|', ('is_company', '=', True),('parent_id', '=', False)]}"/>
162+
<label for="use_parent_address" class="oe_edit_only" attrs="{'invisible': ['|', ('is_company', '=', True), ('parent_id', '=', False)]}"/>
163163
<button name="open_parent" type="object" string="(edit company address)" class="oe_link oe_edit_only"
164164
attrs="{'invisible': ['|',('parent_id','=', False),('use_parent_address','=',False)]}"/>
165165
<field name="street" placeholder="Street..." attrs="{'readonly': [('use_parent_address','=',True)]}"/>
@@ -188,7 +188,7 @@
188188

189189
<notebook colspan="4">
190190
<page string="Contacts" attrs="{'invisible': [('is_company','=',False), ('child_ids', '=', [])]}" autofocus="autofocus">
191-
<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}">
191+
<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}">
192192
<kanban>
193193
<field name="color"/>
194194
<field name="name"/>

0 commit comments

Comments
 (0)