Merge lp:~therp-nl/eficent-openerp-project-management/6.1-remove_mutable_defaults_in_method_args into lp:eficent-openerp-project-management/6.1

Proposed by Stefan Rijnhart (Opener)
Status: Needs review
Proposed branch: lp:~therp-nl/eficent-openerp-project-management/6.1-remove_mutable_defaults_in_method_args
Merge into: lp:eficent-openerp-project-management/6.1
Diff against target: 263 lines (+36/-28)
10 files modified
project_category/analytic_account_category.py (+2/-2)
project_communications_mailgate/project_communications_mailgate.py (+6/-2)
project_cost/account_analytic_account.py (+8/-4)
project_cost_plan_purchase/account_analytic_line_plan.py (+4/-4)
project_cost_plan_sale/account_analytic_line_plan.py (+4/-4)
project_hr_stakeholder/project_hr_stakeholder.py (+1/-1)
project_invoice/invoice.py (+1/-1)
project_procurement/purchase_requisition.py (+2/-2)
project_scope_wbs/project_scope_wbs.py (+7/-7)
project_time_sequence/project_time_sequence.py (+1/-1)
To merge this branch: bzr merge lp:~therp-nl/eficent-openerp-project-management/6.1-remove_mutable_defaults_in_method_args
Reviewer Review Type Date Requested Status
Eficent Pending
Review via email: mp+141922@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

9. By Stefan Rijnhart (Opener)

[FIX] Remove mutable defaults from function arguments

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'project_category/analytic_account_category.py'
2--- project_category/analytic_account_category.py 2012-10-18 23:30:03 +0000
3+++ project_category/analytic_account_category.py 2013-01-04 14:24:25 +0000
4@@ -40,7 +40,7 @@
5 def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=100):
6 if not args:
7 args=[]
8- if not context:
9+ if context is None:
10 context={}
11 if name:
12 # Be sure name_search is symetric to name_get
13@@ -77,4 +77,4 @@
14 _parent_order = 'name'
15 _order = 'parent_left'
16
17-analytic_account_category()
18\ No newline at end of file
19+analytic_account_category()
20
21=== modified file 'project_communications_mailgate/project_communications_mailgate.py'
22--- project_communications_mailgate/project_communications_mailgate.py 2012-10-02 20:55:15 +0000
23+++ project_communications_mailgate/project_communications_mailgate.py 2013-01-04 14:24:25 +0000
24@@ -70,7 +70,9 @@
25 #
26 return res
27
28- def message_update(self, cr, uid, id, msg, data={}, context=None):
29+ def message_update(self, cr, uid, id, msg, data=None, context=None):
30+ if data is None:
31+ data = {}
32 mailgate_obj = self.pool.get('email.server.tools')
33 subject = data.get('subject')
34 body = data.get('body')
35@@ -114,7 +116,9 @@
36 def msg_send(self, cr, uid, id, *args, **argv):
37 return True
38
39- def _history(self, cr, uid, cases, keyword, history=False, subject=None, email=False, details=None, email_from=False, message_id=False, attach=[], context=None):
40+ def _history(self, cr, uid, cases, keyword, history=False, subject=None, email=False, details=None, email_from=False, message_id=False, attach=None, context=None):
41+ if attach is None:
42+ attach = []
43 mailgate_pool = self.pool.get('mailgate.thread')
44 return mailgate_pool.history(cr, uid, cases, keyword, history=history,\
45 subject=subject, email=email, \
46
47=== modified file 'project_cost/account_analytic_account.py'
48--- project_cost/account_analytic_account.py 2012-10-02 20:55:15 +0000
49+++ project_cost/account_analytic_account.py 2013-01-04 14:24:25 +0000
50@@ -33,7 +33,9 @@
51 _inherit = 'account.analytic.account'
52
53 def _compute_level_tree_plan(self, cr, uid, ids, child_ids, res, field_names, context=None):
54- def recursive_computation(account_id, res, repeated_account_ids=[]):
55+ def recursive_computation(account_id, res, repeated_account_ids=None):
56+ if repeated_account_ids is None:
57+ repeated_account_ids = []
58 currency_obj = self.pool.get('res.currency')
59 account = self.browse(cr, uid, account_id)
60 for son in account.child_ids:
61@@ -54,7 +56,9 @@
62 return res
63
64 def _compute_level_tree_commit(self, cr, uid, ids, child_ids, res, field_names, context=None):
65- def recursive_computation(account_id, res, repeated_account_ids=[]):
66+ def recursive_computation(account_id, res, repeated_account_ids=None):
67+ if repeated_account_ids is None:
68+ repeated_account_ids = []
69 currency_obj = self.pool.get('res.currency')
70 account = self.browse(cr, uid, account_id)
71 for son in account.child_ids:
72@@ -200,11 +204,11 @@
73 return True
74
75 def copy(self, cr, uid, id, default=None, context=None):
76- if not default:
77+ if default is None:
78 default = {}
79 default['plan_line_ids'] = []
80 default['commit_line_ids'] = []
81 return super(account_analytic_account, self).copy(cr, uid, id, default, context=context)
82
83
84-account_analytic_account()
85\ No newline at end of file
86+account_analytic_account()
87
88=== modified file 'project_cost_plan_purchase/account_analytic_line_plan.py'
89--- project_cost_plan_purchase/account_analytic_line_plan.py 2012-10-02 20:55:15 +0000
90+++ project_cost_plan_purchase/account_analytic_line_plan.py 2013-01-04 14:24:25 +0000
91@@ -43,23 +43,23 @@
92 }
93
94
95- def copy(self, cr, uid, id, default={}, context=None):
96+ def copy(self, cr, uid, id, default=None, context=None):
97 if context is None:
98 context = {}
99
100- if not default:
101+ if default is None:
102 default = {}
103
104 default['purchase_line_id'] = False
105
106 return super(account_analytic_line_plan, self).copy(cr, uid, id, default, context)
107
108- def copy_data(self, cr, uid, id, default={}, context=None):
109+ def copy_data(self, cr, uid, id, default=None, context=None):
110
111 if context is None:
112 context = {}
113
114- if not default:
115+ if default is None:
116 default = {}
117
118 default['purchase_line_id'] = False
119
120=== modified file 'project_cost_plan_sale/account_analytic_line_plan.py'
121--- project_cost_plan_sale/account_analytic_line_plan.py 2012-10-02 20:55:15 +0000
122+++ project_cost_plan_sale/account_analytic_line_plan.py 2013-01-04 14:24:25 +0000
123@@ -43,11 +43,11 @@
124 }
125
126
127- def copy(self, cr, uid, id, default={}, context=None):
128+ def copy(self, cr, uid, id, default=None, context=None):
129 if context is None:
130 context = {}
131
132- if not default:
133+ if default is None:
134 default = {}
135
136 default['sale_line_id'] = False
137@@ -55,11 +55,11 @@
138 res = super(account_analytic_line_plan, self).copy(cr, uid, id, default, context)
139 return res
140
141- def copy_data(self, cr, uid, id, default={}, context=None):
142+ def copy_data(self, cr, uid, id, default=None, context=None):
143
144 if context is None:
145 context = {}
146- if not default:
147+ if default is None:
148 default = {}
149
150 default['sale_line_id'] = False
151
152=== modified file 'project_hr_stakeholder/project_hr_stakeholder.py'
153--- project_hr_stakeholder/project_hr_stakeholder.py 2012-10-02 20:55:15 +0000
154+++ project_hr_stakeholder/project_hr_stakeholder.py 2013-01-04 14:24:25 +0000
155@@ -106,7 +106,7 @@
156
157 }
158
159- def name_get(self, cr, uid, ids, context={}):
160+ def name_get(self, cr, uid, ids, context=None):
161 if not ids:
162 return []
163 res = []
164
165=== modified file 'project_invoice/invoice.py'
166--- project_invoice/invoice.py 2012-10-02 20:55:15 +0000
167+++ project_invoice/invoice.py 2013-01-04 14:24:25 +0000
168@@ -32,7 +32,7 @@
169 class account_invoice(osv.osv):
170 _inherit = "account.invoice"
171
172- def _line_analytic_accounts_get(self, cr, uid, ids, field_name, arg, context={}):
173+ def _line_analytic_accounts_get(self, cr, uid, ids, field_name, arg, context=None):
174 result = {}
175 for inv in self.browse(cr, uid, ids, context):
176 str_data = ''
177
178=== modified file 'project_procurement/purchase_requisition.py'
179--- project_procurement/purchase_requisition.py 2012-10-02 20:55:15 +0000
180+++ project_procurement/purchase_requisition.py 2013-01-04 14:24:25 +0000
181@@ -25,8 +25,8 @@
182 class purchase_requisition(osv.osv):
183 _inherit = "purchase.requisition"
184
185- def copy_data(self, cr, uid, id, default={}, context=None):
186- if not default:
187+ def copy_data(self, cr, uid, id, default=None, context=None):
188+ if default is None:
189 default = {}
190 default.update({
191 'state':'draft',
192
193=== modified file 'project_scope_wbs/project_scope_wbs.py'
194--- project_scope_wbs/project_scope_wbs.py 2012-12-13 04:18:54 +0000
195+++ project_scope_wbs/project_scope_wbs.py 2013-01-04 14:24:25 +0000
196@@ -29,7 +29,7 @@
197 class task(osv.osv):
198 _inherit = 'project.task'
199
200- def _project_complete_wbs_name(self, cr, uid, ids, prop, unknow_none, unknow_dict):
201+ def _project_complete_wbs_name(self, cr, uid, ids, prop, unknow_none, context=None):
202
203 if not ids:
204 return []
205@@ -45,14 +45,14 @@
206 for task in tasks:
207 if task.project_id:
208 task_project_id = task.project_id.id
209- data_project = project_obj.read(cr, uid, task_project_id, ['complete_wbs_name'], context=[])
210+ data_project = project_obj.read(cr, uid, task_project_id, ['complete_wbs_name'], context=context)
211 if data_project:
212 res.append((task.id, data_project['complete_wbs_name']))
213 else:
214 res.append((task.id, ''))
215 return dict(res)
216
217- def _project_complete_wbs_code(self, cr, uid, ids, prop, unknow_none, unknow_dict):
218+ def _project_complete_wbs_code(self, cr, uid, ids, prop, unknow_none, context=None):
219
220 if not ids:
221 return []
222@@ -68,7 +68,7 @@
223 for task in tasks:
224 if task.project_id:
225 task_project_id = task.project_id.id
226- data_project = project_obj.read(cr, uid, task_project_id, ['complete_wbs_code'], context=[])
227+ data_project = project_obj.read(cr, uid, task_project_id, ['complete_wbs_code'], context=context)
228 if data_project:
229 res.append((task.id, data_project['complete_wbs_code']))
230 else:
231@@ -81,11 +81,11 @@
232 _columns = {
233 'project_complete_wbs_name': fields.function(_project_complete_wbs_name, method=True, type='char', string='WBS path name', size=250, help='Project Complete WBS path name',
234 store={
235- 'project.task': (lambda self, cr, uid, ids, c={}: ids, ['project_id'], 10),
236+ 'project.task': (lambda self, cr, uid, ids, c=None: ids, ['project_id'], 10),
237 }),
238 'project_complete_wbs_code': fields.function(_project_complete_wbs_code, method=True, type='char', string='WBS path code', size=250, help='Project Complete WBS path code',
239 store={
240- 'project.task': (lambda self, cr, uid, ids, c={}: ids, ['project_id'], 10),
241+ 'project.task': (lambda self, cr, uid, ids, c=None: ids, ['project_id'], 10),
242 }),
243
244 }
245@@ -327,4 +327,4 @@
246
247 project()
248
249-
250\ No newline at end of file
251+
252
253=== modified file 'project_time_sequence/project_time_sequence.py'
254--- project_time_sequence/project_time_sequence.py 2012-10-02 20:55:15 +0000
255+++ project_time_sequence/project_time_sequence.py 2013-01-04 14:24:25 +0000
256@@ -112,7 +112,7 @@
257
258 }
259
260- def do_link_predecessors(self, cr, uid, task_id, link_predecessors_data={}, context=None):
261+ def do_link_predecessors(self, cr, uid, task_id, link_predecessors_data, context=None):
262
263 task_br = self.browse(cr, uid, task_id, context=context)
264

Subscribers

People subscribed via source and target branches

to all changes: