Merge lp:~openerp-dev/openobject-server/trunk-imp-onchange-behave-darshan into lp:openobject-server

Proposed by Darshan Kalola(OpenERP)
Status: Superseded
Proposed branch: lp:~openerp-dev/openobject-server/trunk-imp-onchange-behave-darshan
Merge into: lp:openobject-server
Diff against target: 69 lines (+15/-10)
2 files modified
openerp/addons/base/res/res_partner.py (+11/-6)
openerp/addons/base/res/res_partner_view.xml (+4/-4)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/trunk-imp-onchange-behave-darshan
Reviewer Review Type Date Requested Status
Thibault Delavallée (OpenERP) (community) technical Needs Fixing
Mustufa Rangwala (Open ERP) Pending
Review via email: mp+189002@code.launchpad.net

This proposal supersedes a proposal from 2013-09-17.

This proposal has been superseded by a proposal from 2014-04-17.

Description of the change

Hello MRA Sir,

As per your suggestion, I have improve the variable parent to parent_company in "onchange_use_address" and "onchange_address".

Moreover you talk about else condition. if remove the else condition than execute the for loop of "result['value']" every time even condition is true. that's why I am not change the else condition.

please correct me If I am wrong

Thanks for suggestion.
Darshan

To post a comment you must log in.
Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) wrote : Posted in a previous version of this proposal

Remove else line 23 put value in defaults. Rename parent variable with parent_company.

Regards,
Mustufa Rangwala

review: Needs Fixing
4945. By Darshan Kalola(OpenERP)

[MERGE]sync with trunk.

4946. By Darshan Kalola(OpenERP)

[MERGE]sync with trunk.

4947. By Darshan Kalola(OpenERP)

[MERGE]sync with trunk.

4948. By Darshan Kalola(OpenERP)

[MERGE]sync with trunk.

Revision history for this message
Thibault Delavallée (OpenERP) (tde-openerp) wrote :

Can't u have the whole feature in a single method onchange_address that already receive the two parameters ? This way you won't duplicate code.

review: Needs Fixing (technical)
4949. By Darshan Kalola(OpenERP)

[IMP]removed use_company_address method, added same feature in single method, to achive this added new parameter 'empty_fields' to empty all address field when use compny address is unchecked.

4950. By Darshan Kalola(OpenERP)

[MERGE]sync with trunk.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'openerp/addons/base/res/res_partner.py'
--- openerp/addons/base/res/res_partner.py 2014-04-14 09:11:37 +0000
+++ openerp/addons/base/res/res_partner.py 2014-04-17 10:21:27 +0000
@@ -360,16 +360,18 @@
360 value = {}360 value = {}
361 value['title'] = False361 value['title'] = False
362 if is_company:362 if is_company:
363 value['use_parent_address'] = False
363 domain = {'title': [('domain', '=', 'partner')]}364 domain = {'title': [('domain', '=', 'partner')]}
364 else:365 else:
365 domain = {'title': [('domain', '=', 'contact')]}366 domain = {'title': [('domain', '=', 'contact')]}
366 return {'value': value, 'domain': domain}367 return {'value': value, 'domain': domain}
367368
368 def onchange_address(self, cr, uid, ids, use_parent_address, parent_id, context=None):369 def onchange_address(self, cr, uid, ids, use_parent_address, parent_id, empty_fields=False, context=None):
369 def value_or_id(val):370 def value_or_id(val):
370 """ return val or val.id if val is a browse record """371 """ return val or val.id if val is a browse record """
371 return val if isinstance(val, (bool, int, long, float, basestring)) else val.id372 return val if isinstance(val, (bool, int, long, float, basestring)) else val.id
372 result = {}373 result = {'value': {}}
374 address_fields = self._address_fields(cr, uid, context=context)
373 if parent_id:375 if parent_id:
374 if ids:376 if ids:
375 partner = self.browse(cr, uid, ids[0], context=context)377 partner = self.browse(cr, uid, ids[0], context=context)
@@ -379,11 +381,14 @@
379 'was never correctly set. If an existing contact starts working for a new '381 'was never correctly set. If an existing contact starts working for a new '
380 'company then a new contact should be created under that new '382 'company then a new contact should be created under that new '
381 'company. You can use the "Discard" button to abandon this change.')}383 'company. You can use the "Discard" button to abandon this change.')}
382 parent = self.browse(cr, uid, parent_id, context=context)384 parent_company = self.browse(cr, uid, parent_id, context=context)
383 address_fields = self._address_fields(cr, uid, context=context)385 if use_parent_address:
384 result['value'] = dict((key, value_or_id(parent[key])) for key in address_fields)386 result['value'] = dict((key, value_or_id(parent_company[key])) for key in address_fields)
387 if empty_fields and not use_parent_address:
388 result['value'] = dict((key,"") for key in address_fields)
385 else:389 else:
386 result['value'] = {'use_parent_address': False}390 if use_parent_address: result['value'] = dict((key,"") for key in address_fields)
391 result['value']['use_parent_address'] = False
387 return result392 return result
388393
389 def onchange_state(self, cr, uid, ids, state_id, context=None):394 def onchange_state(self, cr, uid, ids, state_id, context=None):
390395
=== modified file 'openerp/addons/base/res/res_partner_view.xml'
--- openerp/addons/base/res/res_partner_view.xml 2014-04-01 09:22:54 +0000
+++ openerp/addons/base/res/res_partner_view.xml 2014-04-17 10:21:27 +0000
@@ -157,9 +157,9 @@
157 <label for="street" string="Address"/>157 <label for="street" string="Address"/>
158 <div>158 <div>
159 <field name="use_parent_address" class="oe_edit_only oe_inline"159 <field name="use_parent_address" class="oe_edit_only oe_inline"
160 on_change="onchange_address(use_parent_address, parent_id)"160 on_change="onchange_address(use_parent_address, parent_id, True)"
161 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': [('parent_id','=', False),('use_parent_address','=',False)]}"/>162 <label for="use_parent_address" class="oe_edit_only" attrs="{'invisible': ['|', ('is_company', '=', True), ('parent_id', '=', False)]}"/>
163 <button name="open_parent" type="object" string="(edit company address)" class="oe_link oe_edit_only"163 <button name="open_parent" type="object" string="(edit company address)" class="oe_link oe_edit_only"
164 attrs="{'invisible': ['|',('parent_id','=', False),('use_parent_address','=',False)]}"/>164 attrs="{'invisible': ['|',('parent_id','=', False),('use_parent_address','=',False)]}"/>
165 <field name="street" placeholder="Street..." attrs="{'readonly': [('use_parent_address','=',True)]}"/>165 <field name="street" placeholder="Street..." attrs="{'readonly': [('use_parent_address','=',True)]}"/>
@@ -188,7 +188,7 @@
188188
189 <notebook colspan="4">189 <notebook colspan="4">
190 <page string="Contacts" attrs="{'invisible': [('is_company','=',False), ('child_ids', '=', [])]}" autofocus="autofocus">190 <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}">
192 <kanban>192 <kanban>
193 <field name="color"/>193 <field name="color"/>
194 <field name="name"/>194 <field name="name"/>