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
1=== modified file 'openerp/addons/base/res/res_partner.py'
2--- openerp/addons/base/res/res_partner.py 2014-04-14 09:11:37 +0000
3+++ openerp/addons/base/res/res_partner.py 2014-04-17 10:21:27 +0000
4@@ -360,16 +360,18 @@
5 value = {}
6 value['title'] = False
7 if is_company:
8+ value['use_parent_address'] = False
9 domain = {'title': [('domain', '=', 'partner')]}
10 else:
11 domain = {'title': [('domain', '=', 'contact')]}
12 return {'value': value, 'domain': domain}
13
14- def onchange_address(self, cr, uid, ids, use_parent_address, parent_id, context=None):
15+ def onchange_address(self, cr, uid, ids, use_parent_address, parent_id, empty_fields=False, context=None):
16 def value_or_id(val):
17 """ return val or val.id if val is a browse record """
18 return val if isinstance(val, (bool, int, long, float, basestring)) else val.id
19- result = {}
20+ result = {'value': {}}
21+ address_fields = self._address_fields(cr, uid, context=context)
22 if parent_id:
23 if ids:
24 partner = self.browse(cr, uid, ids[0], context=context)
25@@ -379,11 +381,14 @@
26 'was never correctly set. If an existing contact starts working for a new '
27 'company then a new contact should be created under that new '
28 'company. You can use the "Discard" button to abandon this change.')}
29- parent = self.browse(cr, uid, parent_id, context=context)
30- address_fields = self._address_fields(cr, uid, context=context)
31- result['value'] = dict((key, value_or_id(parent[key])) for key in address_fields)
32+ parent_company = self.browse(cr, uid, parent_id, context=context)
33+ if use_parent_address:
34+ result['value'] = dict((key, value_or_id(parent_company[key])) for key in address_fields)
35+ if empty_fields and not use_parent_address:
36+ result['value'] = dict((key,"") for key in address_fields)
37 else:
38- result['value'] = {'use_parent_address': False}
39+ if use_parent_address: result['value'] = dict((key,"") for key in address_fields)
40+ result['value']['use_parent_address'] = False
41 return result
42
43 def onchange_state(self, cr, uid, ids, state_id, context=None):
44
45=== modified file 'openerp/addons/base/res/res_partner_view.xml'
46--- openerp/addons/base/res/res_partner_view.xml 2014-04-01 09:22:54 +0000
47+++ openerp/addons/base/res/res_partner_view.xml 2014-04-17 10:21:27 +0000
48@@ -157,9 +157,9 @@
49 <label for="street" string="Address"/>
50 <div>
51 <field name="use_parent_address" class="oe_edit_only oe_inline"
52- on_change="onchange_address(use_parent_address, parent_id)"
53- attrs="{'invisible': [('parent_id','=', False),('use_parent_address','=',False)]}"/>
54- <label for="use_parent_address" class="oe_edit_only" attrs="{'invisible': [('parent_id','=', False),('use_parent_address','=',False)]}"/>
55+ on_change="onchange_address(use_parent_address, parent_id, True)"
56+ attrs="{'invisible': ['|', ('is_company', '=', True),('parent_id', '=', False)]}"/>
57+ <label for="use_parent_address" class="oe_edit_only" attrs="{'invisible': ['|', ('is_company', '=', True), ('parent_id', '=', False)]}"/>
58 <button name="open_parent" type="object" string="(edit company address)" class="oe_link oe_edit_only"
59 attrs="{'invisible': ['|',('parent_id','=', False),('use_parent_address','=',False)]}"/>
60 <field name="street" placeholder="Street..." attrs="{'readonly': [('use_parent_address','=',True)]}"/>
61@@ -188,7 +188,7 @@
62
63 <notebook colspan="4">
64 <page string="Contacts" attrs="{'invisible': [('is_company','=',False), ('child_ids', '=', [])]}" autofocus="autofocus">
65- <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}">
66+ <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}">
67 <kanban>
68 <field name="color"/>
69 <field name="name"/>