diff --git a/addons/account/account.py b/addons/account/account.py index 1d3b9b0dc4d..329ae2579e2 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -30,7 +30,7 @@ from osv import fields, osv import decimal_precision as dp from tools.translate import _ -def check_cycle(self, cr, uid, ids): +def check_cycle(self, cr, uid, ids, context=None): """ climbs the ``self._table.parent_id`` chains for 100 levels or until it can't find any more parent(s) @@ -116,7 +116,7 @@ class account_payment_term_line(osv.osv): _order = "sequence" def _check_percent(self, cr, uid, ids, context=None): - obj = self.browse(cr, uid, ids[0]) + obj = self.browse(cr, uid, ids[0], context=context) if obj.value == 'procent' and ( obj.value_amount < 0.0 or obj.value_amount > 1.0): return False return True @@ -194,7 +194,7 @@ class account_account(osv.osv): if not args[pos][2]: del args[pos] continue - jour = self.pool.get('account.journal').browse(cr, uid, args[pos][2]) + jour = self.pool.get('account.journal').browse(cr, uid, args[pos][2], context=context) if (not (jour.account_control_ids or jour.type_control_ids)) or not args[pos][2]: args[pos] = ('type','not in',('consolidation','view')) continue @@ -207,7 +207,7 @@ class account_account(osv.osv): if context and context.has_key('consolidate_childs'): #add consolidated childs of accounts ids = super(account_account, self).search(cr, uid, args, offset, limit, order, context=context, count=count) - for consolidate_child in self.browse(cr, uid, context['account_id']).child_consol_ids: + for consolidate_child in self.browse(cr, uid, context['account_id'], context=context).child_consol_ids: ids.append(consolidate_child.id) return ids @@ -215,8 +215,6 @@ class account_account(osv.osv): order, context=context, count=count) def _get_children_and_consol(self, cr, uid, ids, context=None): - if context is None: - context = {} #this function search for all the children and all consolidated children (recursively) of the given account ids ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)], context=context) ids3 = [] @@ -309,15 +307,15 @@ class account_account(osv.osv): res[id] = sums.get(id, null_result) return res - def _get_company_currency(self, cr, uid, ids, field_name, arg, context={}): + def _get_company_currency(self, cr, uid, ids, field_name, arg, context=None): result = {} - for rec in self.browse(cr, uid, ids, context): + for rec in self.browse(cr, uid, ids, context=context): result[rec.id] = (rec.company_id.currency_id.id,rec.company_id.currency_id.symbol) return result - def _get_child_ids(self, cr, uid, ids, field_name, arg, context={}): + def _get_child_ids(self, cr, uid, ids, field_name, arg, context=None): result = {} - for record in self.browse(cr, uid, ids, context): + for record in self.browse(cr, uid, ids, context=context): if record.child_parent_ids: result[record.id] = [x.id for x in record.child_parent_ids] else: @@ -330,9 +328,9 @@ class account_account(osv.osv): return result - def _get_level(self, cr, uid, ids, field_name, arg, context={}): + def _get_level(self, cr, uid, ids, field_name, arg, context=None): res={} - accounts = self.browse(cr, uid, ids) + accounts = self.browse(cr, uid, ids, context=context) for account in accounts: level = 0 if account.parent_id: @@ -396,8 +394,8 @@ class account_account(osv.osv): 'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'account.account', context=c), } - def _check_recursion(self, cr, uid, ids): - obj_self = self.browse(cr, uid, ids[0]) + def _check_recursion(self, cr, uid, ids, context=None): + obj_self = self.browse(cr, uid, ids[0], context=context) p_id = obj_self.parent_id and obj_self.parent_id.id if (obj_self in obj_self.child_consol_ids) or (p_id and (p_id is obj_self.id)): return False @@ -426,14 +424,12 @@ class account_account(osv.osv): def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100): if not args: args = [] - if not context: - context = {} args = args[:] ids = [] try: if name and str(name).startswith('partner:'): part_id = int(name.split(':')[1]) - part = self.pool.get('res.partner').browse(cr, user, part_id, context) + part = self.pool.get('res.partner').browse(cr, user, part_id, context=context) args += [('id', 'in', (part.property_account_payable.id, part.property_account_receivable.id))] name = False if name and str(name).startswith('type:'): @@ -685,7 +681,7 @@ class account_journal(osv.osv): @return: Returns a list of tupples containing id, name """ - result = self.browse(cr, user, ids, context) + result = self.browse(cr, user, ids, context=context) res = [] for rs in result: name = rs.name @@ -733,7 +729,7 @@ class account_journal(osv.osv): view_id = 'account_journal_bank_view_multi' data_id = obj_data.search(cr, uid, [('model','=','account.journal.view'), ('name','=',view_id)]) - data = obj_data.browse(cr, uid, data_id[0]) + data = obj_data.browse(cr, uid, data_id[0], context=context) res.update({ 'centralisation':type == 'situation', @@ -778,8 +774,8 @@ class account_fiscalyear(osv.osv): return False return True - def _check_duration(self,cr,uid,ids): - obj_fy = self.browse(cr,uid,ids[0]) + def _check_duration(self, cr, uid, ids, context=None): + obj_fy = self.browse(cr, uid, ids[0], context=context) if obj_fy.date_stop < obj_fy.date_start: return False return True @@ -789,11 +785,11 @@ class account_fiscalyear(osv.osv): (_check_fiscal_year, 'Error! You cannot define overlapping fiscal years',['date_start', 'date_stop']) ] - def create_period3(self,cr, uid, ids, context={}): + def create_period3(self,cr, uid, ids, context=None): return self.create_period(cr, uid, ids, context, 3) - def create_period(self,cr, uid, ids, context={}, interval=1): - for fy in self.browse(cr, uid, ids, context): + def create_period(self,cr, uid, ids, context=None, interval=1): + for fy in self.browse(cr, uid, ids, context=context): ds = datetime.strptime(fy.date_start, '%Y-%m-%d') while ds.strftime('%Y-%m-%d')=', dt)]) @@ -856,14 +852,14 @@ class account_period(osv.osv): } _order = "date_start" - def _check_duration(self,cr,uid,ids,context={}): - obj_period=self.browse(cr,uid,ids[0]) + def _check_duration(self,cr,uid,ids,context=None): + obj_period = self.browse(cr, uid, ids[0], context=context) if obj_period.date_stop < obj_period.date_start: return False return True - def _check_year_limit(self,cr,uid,ids,context={}): - for obj_period in self.browse(cr,uid,ids): + def _check_year_limit(self,cr,uid,ids,context=None): + for obj_period in self.browse(cr, uid, ids, context=context): if obj_period.special: continue @@ -884,13 +880,13 @@ class account_period(osv.osv): (_check_year_limit, 'Invalid period ! Some periods overlap or the date period is not in the scope of the fiscal year. ', ['date_stop']) ] - def next(self, cr, uid, period, step, context={}): + def next(self, cr, uid, period, step, context=None): ids = self.search(cr, uid, [('date_start','>',period.date_start)]) if len(ids)>=step: return ids[step-1] return False - def find(self, cr, uid, dt=None, context={}): + def find(self, cr, uid, dt=None, context=None): if not dt: dt = time.strftime('%Y-%m-%d') #CHECKME: shouldn't we check the state of the period? @@ -906,7 +902,7 @@ class account_period(osv.osv): cr.execute('update account_period set state=%s where id=%s', (mode, id)) return True - def name_search(self, cr, user, name, args=None, operator='ilike', context={}, limit=80): + def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100): if args is None: args = [] if context is None: @@ -918,7 +914,7 @@ class account_period(osv.osv): ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit) return self.name_get(cr, user, ids, context=context) - def write(self, cr, uid, ids, vals, context={}): + def write(self, cr, uid, ids, vals, context=None): if 'company_id' in vals: move_lines = self.pool.get('account.move.line').search(cr, uid, [('period_id', 'in', ids)]) if move_lines: @@ -944,7 +940,7 @@ class account_journal_period(osv.osv): _name = "account.journal.period" _description = "Journal Period" - def _icon_get(self, cr, uid, ids, field_name, arg=None, context={}): + def _icon_get(self, cr, uid, ids, field_name, arg=None, context=None): result = {}.fromkeys(ids, 'STOCK_NEW') for r in self.read(cr, uid, ids, ['state']): result[r['id']] = { @@ -966,28 +962,28 @@ class account_journal_period(osv.osv): 'company_id': fields.related('journal_id', 'company_id', type='many2one', relation='res.company', string='Company') } - def _check(self, cr, uid, ids, context={}): - for obj in self.browse(cr, uid, ids, context): + def _check(self, cr, uid, ids, context=None): + for obj in self.browse(cr, uid, ids, context=context): cr.execute('select * from account_move_line where journal_id=%s and period_id=%s limit 1', (obj.journal_id.id, obj.period_id.id)) res = cr.fetchall() if res: raise osv.except_osv(_('Error !'), _('You can not modify/delete a journal with entries for this period !')) return True - def write(self, cr, uid, ids, vals, context={}): - self._check(cr, uid, ids, context) - return super(account_journal_period, self).write(cr, uid, ids, vals, context) + def write(self, cr, uid, ids, vals, context=None): + self._check(cr, uid, ids, context=context) + return super(account_journal_period, self).write(cr, uid, ids, vals, context=context) - def create(self, cr, uid, vals, context={}): + def create(self, cr, uid, vals, context=None): period_id=vals.get('period_id',False) if period_id: - period = self.pool.get('account.period').browse(cr, uid,period_id) + period = self.pool.get('account.period').browse(cr, uid, period_id, context=context) vals['state']=period.state return super(account_journal_period, self).create(cr, uid, vals, context) - def unlink(self, cr, uid, ids, context={}): - self._check(cr, uid, ids, context) - return super(account_journal_period, self).unlink(cr, uid, ids, context) + def unlink(self, cr, uid, ids, context=None): + self._check(cr, uid, ids, context=context) + return super(account_journal_period, self).unlink(cr, uid, ids, context=context) _defaults = { 'state': 'draft', @@ -1038,8 +1034,6 @@ class account_move(osv.osv): if not args: args = [] - if not context: - context = {} ids = [] if name: ids += self.search(cr, user, [('name','ilike',name)]+args, limit=limit, context=context) @@ -1058,7 +1052,7 @@ class account_move(osv.osv): if not ids: return [] res = [] - data_move = self.pool.get('account.move').browse(cursor,user,ids) + data_move = self.pool.get('account.move').browse(cursor, user, ids, context=context) for move in data_move: if move.state=='draft': name = '*' + str(move.id) @@ -1067,7 +1061,7 @@ class account_move(osv.osv): res.append((move.id, name)) return res - def _get_period(self, cr, uid, context): + def _get_period(self, cr, uid, context=None): periods = self.pool.get('account.period').find(cr, uid) if periods: return periods[0] @@ -1128,8 +1122,8 @@ class account_move(osv.osv): 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, } - def _check_centralisation(self, cursor, user, ids): - for move in self.browse(cursor, user, ids): + def _check_centralisation(self, cursor, user, ids, context=None): + for move in self.browse(cursor, user, ids, context=context): if move.journal_id.centralisation: move_ids = self.search(cursor, user, [ ('period_id', '=', move.period_id.id), @@ -1139,8 +1133,8 @@ class account_move(osv.osv): return False return True - def _check_period_journal(self, cursor, user, ids): - for move in self.browse(cursor, user, ids): + def _check_period_journal(self, cursor, user, ids, context=None): + for move in self.browse(cursor, user, ids, context=context): for line in move.line_id: if line.period_id.id != move.period_id.id: return False @@ -1166,7 +1160,7 @@ class account_move(osv.osv): if not valid_moves: raise osv.except_osv(_('Integrity Error !'), _('You cannot validate a non-balanced entry !\nMake sure you have configured Payment Term properly !\nIt should contain atleast one Payment Term Line with type "Balance" !')) obj_sequence = self.pool.get('ir.sequence') - for move in self.browse(cr, uid, valid_moves): + for move in self.browse(cr, uid, valid_moves, context=context): if move.name =='/': new_name = False journal = move.journal_id @@ -1191,7 +1185,7 @@ class account_move(osv.osv): return True def button_validate(self, cursor, user, ids, context=None): - for move in self.browse(cursor, user, ids): + for move in self.browse(cursor, user, ids, context=context): top = None for line in move.line_id: account = line.account_id @@ -1204,8 +1198,8 @@ class account_move(osv.osv): raise osv.except_osv(_('Error !'), _('You cannot validate a Journal Entry unless all journal items are in same chart of accounts !')) return self.post(cursor, user, ids, context=context) - def button_cancel(self, cr, uid, ids, context={}): - for line in self.browse(cr, uid, ids, context): + def button_cancel(self, cr, uid, ids, context=None): + for line in self.browse(cr, uid, ids, context=context): if not line.journal_id.update_posted: raise osv.except_osv(_('Error !'), _('You can not modify a posted entry of this journal !\nYou should set the journal to allow cancelling entries if you want to do that.')) if ids: @@ -1214,18 +1208,21 @@ class account_move(osv.osv): 'WHERE id IN %s', ('draft', tuple(ids),)) return True - def write(self, cr, uid, ids, vals, context={}): + def write(self, cr, uid, ids, vals, context=None): + if context is None: + context = {} c = context.copy() c['novalidate'] = True result = super(osv.osv, self).write(cr, uid, ids, vals, c) - self.validate(cr, uid, ids, context) + self.validate(cr, uid, ids, context=context) return result # # TODO: Check if period is closed ! # def create(self, cr, uid, vals, context=None): - context = context or {} + if context is None: + context = {} if 'line_id' in vals and context.get('copy'): for l in vals['line_id']: if not l[0]: @@ -1265,8 +1262,9 @@ class account_move(osv.osv): result = super(account_move, self).create(cr, uid, vals, context) return result - def copy(self, cr, uid, id, default={}, context={}): - context = context or {} + def copy(self, cr, uid, id, default={}, context=None): + if context is None: + context = {} default.update({ 'state':'draft', 'name':'/', @@ -1277,10 +1275,9 @@ class account_move(osv.osv): return super(account_move, self).copy(cr, uid, id, default, context) def unlink(self, cr, uid, ids, context=None, check=True): - context = context or {} toremove = [] obj_move_line = self.pool.get('account.move.line') - for move in self.browse(cr, uid, ids, context): + for move in self.browse(cr, uid, ids, context=context): if move['state'] != 'draft': raise osv.except_osv(_('UserError'), _('You can not delete posted movement: "%s"!') % \ @@ -1294,8 +1291,8 @@ class account_move(osv.osv): result = super(account_move, self).unlink(cr, uid, toremove, context) return result - def _compute_balance(self, cr, uid, id, context={}): - move = self.browse(cr, uid, [id])[0] + def _compute_balance(self, cr, uid, id, context=None): + move = self.browse(cr, uid, id, context=context) amount = 0 for line in move.line_id: amount+= (line.debit - line.credit) @@ -1358,7 +1355,7 @@ class account_move(osv.osv): # # Validate a balanced move. If it is a centralised journal, create a move. # - def validate(self, cr, uid, ids, context={}): + def validate(self, cr, uid, ids, context=None): if context and ('__last_update' in context): del context['__last_update'] @@ -1472,9 +1469,9 @@ class account_move_reconcile(osv.osv): _defaults = { 'name': lambda self,cr,uid,ctx={}: self.pool.get('ir.sequence').get(cr, uid, 'account.reconcile') or '/', } - def reconcile_partial_check(self, cr, uid, ids, type='auto', context={}): + def reconcile_partial_check(self, cr, uid, ids, type='auto', context=None): total = 0.0 - for rec in self.browse(cr, uid, ids, context): + for rec in self.browse(cr, uid, ids, context=context): for line in rec.line_partial_ids: total += (line.debit or 0.0) - (line.credit or 0.0) if not total: @@ -1488,7 +1485,7 @@ class account_move_reconcile(osv.osv): if not ids: return [] result = [] - for r in self.browse(cr, uid, ids, context): + for r in self.browse(cr, uid, ids, context=context): total = reduce(lambda y,t: (t.debit or 0.0) - (t.credit or 0.0) + y, r.line_partial_ids, 0.0) if total: name = '%s (%.2f)' % (r.name, total) @@ -1537,7 +1534,7 @@ class account_tax_code(osv.osv): (parent_ids,) + where_params) res=dict(cr.fetchall()) obj_precision = self.pool.get('decimal.precision') - for record in self.browse(cr, uid, ids, context): + for record in self.browse(cr, uid, ids, context=context): def _rec_get(record): amount = res.get(record.id, 0.0) for rec in record.child_ids: @@ -1619,7 +1616,7 @@ class account_tax_code(osv.osv): return [(x['id'], (x['code'] and (x['code'] + ' - ') or '') + x['name']) \ for x in reads] - def _default_company(self, cr, uid, context={}): + def _default_company(self, cr, uid, context=None): user = self.pool.get('res.users').browse(cr, uid, uid, context=context) if user.company_id: return user.company_id.id @@ -1723,7 +1720,7 @@ class account_tax(osv.osv): """ if not args: args = [] - if not context: + if context is None: context = {} ids = [] if name: @@ -2062,7 +2059,7 @@ class account_model(osv.osv): raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !')) period_id = period_id[0] - for model in self.browse(cr, uid, ids, context): + for model in self.browse(cr, uid, ids, context=context): entry['name'] = model.name%{'year':time.strftime('%Y'), 'month':time.strftime('%m'), 'date':time.strftime('%Y-%m')} move_id = account_move_obj.create(cr, uid, { 'ref': entry['name'], @@ -2168,13 +2165,13 @@ class account_subscription(osv.osv): 'period_nbr': 1, 'state': 'draft', } - def state_draft(self, cr, uid, ids, context={}): + def state_draft(self, cr, uid, ids, context=None): self.write(cr, uid, ids, {'state':'draft'}) return False - def check(self, cr, uid, ids, context={}): + def check(self, cr, uid, ids, context=None): todone = [] - for sub in self.browse(cr, uid, ids, context): + for sub in self.browse(cr, uid, ids, context=context): ok = True for line in sub.lines_id: if not line.move_id.id: @@ -2186,9 +2183,9 @@ class account_subscription(osv.osv): self.write(cr, uid, todone, {'state':'done'}) return False - def remove_line(self, cr, uid, ids, context={}): + def remove_line(self, cr, uid, ids, context=None): toremove = [] - for sub in self.browse(cr, uid, ids, context): + for sub in self.browse(cr, uid, ids, context=context): for line in sub.lines_id: if not line.move_id.id: toremove.append(line.id) @@ -2197,8 +2194,8 @@ class account_subscription(osv.osv): self.write(cr, uid, ids, {'state':'draft'}) return False - def compute(self, cr, uid, ids, context={}): - for sub in self.browse(cr, uid, ids, context): + def compute(self, cr, uid, ids, context=None): + for sub in self.browse(cr, uid, ids, context=context): ds = sub.date_start for i in range(sub.period_total): self.pool.get('account.subscription.line').create(cr, uid, { @@ -2296,10 +2293,10 @@ class account_account_template(osv.osv): ] - def name_get(self, cr, uid, ids, context={}): + def name_get(self, cr, uid, ids, context=None): if not ids: return [] - reads = self.read(cr, uid, ids, ['name','code'], context) + reads = self.read(cr, uid, ids, ['name','code'], context=context) res = [] for record in reads: name = record['name'] @@ -2316,7 +2313,7 @@ class account_add_tmpl_wizard(osv.osv_memory): With the 'nocreate' option, some accounts may not be created. Use this to add them later.""" _name = 'account.addtmpl.wizard' - def _get_def_cparent(self, cr, uid, context): + def _get_def_cparent(self, cr, uid, context=None): acc_obj=self.pool.get('account.account') tmpl_obj=self.pool.get('account.account.template') tids=tmpl_obj.read(cr, uid, [context['tmpl_ids']], ['parent_id']) @@ -2338,6 +2335,8 @@ class account_add_tmpl_wizard(osv.osv_memory): } def action_create(self,cr,uid,ids,context=None): + if context is None: + context = {} acc_obj = self.pool.get('account.account') tmpl_obj = self.pool.get('account.account.template') data = self.read(cr, uid, ids) @@ -2463,16 +2462,16 @@ class account_tax_template(osv.osv): 'price_include': fields.boolean('Tax Included in Price', help="Check this if the price you use on the product and invoices includes this tax."), } - def name_get(self, cr, uid, ids, context={}): + def name_get(self, cr, uid, ids, context=None): if not ids: return [] res = [] - for record in self.read(cr, uid, ids, ['description','name'], context): + for record in self.read(cr, uid, ids, ['description','name'], context=context): name = record['description'] and record['description'] or record['name'] res.append((record['id'],name )) return res - def _default_company(self, cr, uid, context={}): + def _default_company(self, cr, uid, context=None): user = self.pool.get('res.users').browse(cr, uid, uid, context=context) if user.company_id: return user.company_id.id @@ -2579,7 +2578,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): res['value']["purchase_tax"] = purchase_tax_ids and purchase_tax_ids[0] or False return res - def _get_chart(self, cr, uid, context={}): + def _get_chart(self, cr, uid, context=None): ids = self.pool.get('account.chart.template').search(cr, uid, [], context=context) if ids: return ids[0] @@ -2625,7 +2624,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): #create all the tax code children_tax_code_template = self.pool.get('account.tax.code.template').search(cr, uid, [('parent_id','child_of',[tax_code_root_id])], order='id') children_tax_code_template.sort() - for tax_code_template in self.pool.get('account.tax.code.template').browse(cr, uid, children_tax_code_template): + for tax_code_template in self.pool.get('account.tax.code.template').browse(cr, uid, children_tax_code_template, context=context): vals={ 'name': (tax_code_root_id == tax_code_template.id) and obj_multi.company_id.name or tax_code_template.name, 'code': tax_code_template.code, @@ -2682,7 +2681,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): children_acc_template = obj_acc_template.search(cr, uid, [('parent_id','child_of',[obj_acc_root.id]),('nocreate','!=',True)]) children_acc_template.sort() - for account_template in obj_acc_template.browse(cr, uid, children_acc_template): + for account_template in obj_acc_template.browse(cr, uid, children_acc_template,context=context): tax_ids = [] for tax in account_template.tax_ids: tax_ids.append(tax_template_ref[tax.id]) @@ -2722,7 +2721,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): # Creating Journals Sales and Purchase vals_journal={} data_id = obj_data.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_sp_journal_view')]) - data = obj_data.browse(cr, uid, data_id[0]) + data = obj_data.browse(cr, uid, data_id[0], context=context) view_id = data.res_id seq_id = obj_sequence.search(cr, uid, [('name','=','Account Journal')])[0] @@ -2835,11 +2834,11 @@ class wizard_multi_charts_accounts(osv.osv_memory): # Bank Journals data_id = obj_data.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_journal_bank_view')]) - data = obj_data.browse(cr, uid, data_id[0]) + data = obj_data.browse(cr, uid, data_id[0], context=context) view_id_cash = data.res_id data_id = obj_data.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_journal_bank_view_multi')]) - data = obj_data.browse(cr, uid, data_id[0]) + data = obj_data.browse(cr, uid, data_id[0], context=context) view_id_cur = data.res_id ref_acc_bank = obj_multi.chart_template_id.bank_account_view_id @@ -2932,7 +2931,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): obj_tax_fp = self.pool.get('account.fiscal.position.tax') obj_ac_fp = self.pool.get('account.fiscal.position.account') - for position in obj_fiscal_position_template.browse(cr, uid, fp_ids): + for position in obj_fiscal_position_template.browse(cr, uid, fp_ids, context=context): vals_fp = { 'company_id': company_id, diff --git a/addons/account/account_analytic_line.py b/addons/account/account_analytic_line.py index 329eb59ab05..a8d8044a6c2 100644 --- a/addons/account/account_analytic_line.py +++ b/addons/account/account_analytic_line.py @@ -58,8 +58,8 @@ class account_analytic_line(osv.osv): return super(account_analytic_line, self).search(cr, uid, args, offset, limit, order, context=context, count=count) - def _check_company(self, cr, uid, ids): - lines = self.browse(cr, uid, ids) + def _check_company(self, cr, uid, ids, context=None): + lines = self.browse(cr, uid, ids, context=context) for l in lines: if l.move_id and not l.account_id.company_id.id == l.move_id.account_id.company_id.id: return False @@ -80,7 +80,7 @@ class account_analytic_line(osv.osv): analytic_journal_obj =self.pool.get('account.analytic.journal') product_price_type_obj = self.pool.get('product.price.type') j_id = analytic_journal_obj.browse(cr, uid, journal_id, context=context) - prod = product_obj.browse(cr, uid, prod_id) + prod = product_obj.browse(cr, uid, prod_id, context=context) result = 0.0 if j_id.type <> 'sale': @@ -105,13 +105,13 @@ class account_analytic_line(osv.osv): flag = False # Compute based on pricetype product_price_type_ids = product_price_type_obj.search(cr, uid, [('field','=','standard_price')], context=context) - pricetype = product_price_type_obj.browse(cr, uid, product_price_type_ids, context)[0] + pricetype = product_price_type_obj.browse(cr, uid, product_price_type_ids, context=context)[0] if journal_id: - journal = analytic_journal_obj.browse(cr, uid, journal_id) + journal = analytic_journal_obj.browse(cr, uid, journal_id, context=context) if journal.type == 'sale': product_price_type_ids = product_price_type_obj.search(cr, uid, [('field','=','list_price')], context) if product_price_type_ids: - pricetype = product_price_type_obj.browse(cr, uid, product_price_type_ids, context)[0] + pricetype = product_price_type_obj.browse(cr, uid, product_price_type_ids, context=context)[0] # Take the company currency as the reference one if pricetype.field == 'list_price': flag = True @@ -133,7 +133,9 @@ class account_analytic_line(osv.osv): } } - def view_header_get(self, cr, user, view_id, view_type, context): + def view_header_get(self, cr, user, view_id, view_type, context=None): + if context is None: + context = {} if context.get('account_id', False): # account_id in context may also be pointing to an account.account.id cr.execute('select name from account_analytic_account where id=%s', (context['account_id'],)) diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 93d2a6fb00d..ab2f72e92dd 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -46,7 +46,9 @@ class account_bank_statement(osv.osv): account_bank_statement_line_obj.write(cr, uid, [line.id], {'sequence': seq}, context=context) return res - def _default_journal_id(self, cr, uid, context={}): + def _default_journal_id(self, cr, uid, context=None): + if context is None: + context = {} journal_pool = self.pool.get('account.journal') journal_type = context.get('journal_type', False) journal_id = False @@ -56,11 +58,11 @@ class account_bank_statement(osv.osv): journal_id = ids[0] return journal_id - def _default_balance_start(self, cr, uid, context={}): + def _default_balance_start(self, cr, uid, context=None): cr.execute('select id from account_bank_statement where journal_id=%s order by date desc limit 1', (1,)) res = cr.fetchone() if res: - return self.browse(cr, uid, [res[0]], context)[0].balance_end + return self.browse(cr, uid, res[0], context=context).balance_end return 0.0 def _end_balance(self, cursor, user, ids, name, attr, context=None): @@ -95,7 +97,7 @@ class account_bank_statement(osv.osv): res[r] = round(res[r], 2) return res - def _get_period(self, cr, uid, context={}): + def _get_period(self, cr, uid, context=None): periods = self.pool.get('account.period').find(cr, uid) if periods: return periods[0] @@ -195,11 +197,13 @@ class account_bank_statement(osv.osv): return self.write(cr, uid, ids, {}, context=context) def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, st_line_number, context=None): + if context is None: + context = {} res_currency_obj = self.pool.get('res.currency') account_move_obj = self.pool.get('account.move') account_move_line_obj = self.pool.get('account.move.line') account_bank_statement_line_obj = self.pool.get('account.bank.statement.line') - st_line = account_bank_statement_line_obj.browse(cr, uid, st_line_id, context) + st_line = account_bank_statement_line_obj.browse(cr, uid, st_line_id, context=context) st = st_line.statement_id context.update({'date': st_line.date}) @@ -299,7 +303,7 @@ class account_bank_statement(osv.osv): return st_number + '/' + str(st_line.sequence) def balance_check(self, cr, uid, st_id, journal_type='bank', context=None): - st = self.browse(cr, uid, st_id, context) + st = self.browse(cr, uid, st_id, context=context) if not (abs((st.balance_end or 0.0) - st.balance_end_real) < 0.0001): raise osv.except_osv(_('Error !'), _('The statement balance is incorrect !\n') + @@ -318,7 +322,7 @@ class account_bank_statement(osv.osv): if context is None: context = {} - for st in self.browse(cr, uid, ids, context): + for st in self.browse(cr, uid, ids, context=context): j_type = st.journal_id.type company_currency_id = st.journal_id.company_id.currency_id.id if not self.check_status_condition(cr, uid, st.state, journal_type=j_type): @@ -360,7 +364,7 @@ class account_bank_statement(osv.osv): def button_cancel(self, cr, uid, ids, context=None): done = [] account_move_obj = self.pool.get('account.move') - for st in self.browse(cr, uid, ids, context): + for st in self.browse(cr, uid, ids, context=context): if st.state=='draft': continue ids = [] @@ -381,7 +385,7 @@ class account_bank_statement(osv.osv): return {'value': {'balance_start': balance_start, 'account_id': account_id}} def unlink(self, cr, uid, ids, context=None): - stat = self.read(cr, uid, ids, ['state']) + stat = self.read(cr, uid, ids, ['state'], context=context) unlink_ids = [] for t in stat: if t['state'] in ('draft'): @@ -412,7 +416,7 @@ class account_bank_statement_line(osv.osv): if not partner_id: return res account_id = False - line = self.browse(cr, uid, line_id) + line = self.browse(cr, uid, line_id, context=context) if not line or (line and not line[0].account_id): part = obj_partner.browse(cr, uid, partner_id, context=context) if type == 'supplier': diff --git a/addons/account/account_cash_statement.py b/addons/account/account_cash_statement.py index cf17a799372..86b00ad98b3 100644 --- a/addons/account/account_cash_statement.py +++ b/addons/account/account_cash_statement.py @@ -41,7 +41,7 @@ class account_cashbox_line(osv.osv): @return: Dictionary of values. """ res = {} - for obj in self.browse(cr, uid, ids): + for obj in self.browse(cr, uid, ids, context=context): res[obj.id] = obj.pieces * obj.number return res @@ -76,7 +76,7 @@ class account_cash_statement(osv.osv): @return: Dictionary of values. """ res = {} - for statement in self.browse(cr, uid, ids): + for statement in self.browse(cr, uid, ids, context=context): amount_total = 0.0 if statement.journal_id.type not in('cash'): @@ -96,7 +96,7 @@ class account_cash_statement(osv.osv): @return: Dictionary of values. """ res = {} - for statement in self.browse(cr, uid, ids): + for statement in self.browse(cr, uid, ids, context=context): amount_total = 0.0 for line in statement.ending_details_ids: amount_total += line.pieces * line.number @@ -111,7 +111,7 @@ class account_cash_statement(osv.osv): @return: Dictionary of values. """ res2 = {} - for statement in self.browse(cr, uid, ids): + for statement in self.browse(cr, uid, ids, context=context): encoding_total=0.0 for line in statement.line_ids: encoding_total += line.amount @@ -160,7 +160,7 @@ class account_cash_statement(osv.osv): company_id = company_pool.search(cr, uid, []) return company_id and company_id[0] or False - def _get_cash_open_box_lines(self, cr, uid, context={}): + def _get_cash_open_box_lines(self, cr, uid, context=None): res = [] curr = [1, 2, 5, 10, 20, 50, 100, 500] for rs in curr: @@ -173,14 +173,14 @@ class account_cash_statement(osv.osv): if journal_ids: results = self.search(cr, uid, [('journal_id', 'in', journal_ids),('state', '=', 'confirm')], context=context) if results: - cash_st = self.browse(cr, uid, results, context)[0] + cash_st = self.browse(cr, uid, results, context=context)[0] for cash_line in cash_st.ending_details_ids: for r in res: if cash_line.pieces == r['pieces']: r['number'] = cash_line.number return res - def _get_default_cash_close_box_lines(self, cr, uid, context={}): + def _get_default_cash_close_box_lines(self, cr, uid, context=None): res = [] curr = [1, 2, 5, 10, 20, 50, 100, 500] for rs in curr: @@ -191,7 +191,7 @@ class account_cash_statement(osv.osv): res.append(dct) return res - def _get_cash_close_box_lines(self, cr, uid, context={}): + def _get_cash_close_box_lines(self, cr, uid, context=None): res = [] curr = [1, 2, 5, 10, 20, 50, 100, 500] for rs in curr: @@ -202,11 +202,11 @@ class account_cash_statement(osv.osv): res.append((0, 0, dct)) return res - def _get_cash_open_close_box_lines(self, cr, uid, context={}): + def _get_cash_open_close_box_lines(self, cr, uid, context=None): res = {} start_l = [] end_l = [] - starting_details = self._get_cash_open_box_lines(cr, uid, context) + starting_details = self._get_cash_open_box_lines(cr, uid, context=context) ending_details = self._get_default_cash_close_box_lines(cr, uid, context) for start in starting_details: start_l.append((0, 0, start)) @@ -248,7 +248,7 @@ class account_cash_statement(osv.osv): if open_jrnl: raise osv.except_osv(_('Error'), _('You can not have two open register for the same journal')) - if self.pool.get('account.journal').browse(cr, uid, vals['journal_id']).type == 'cash': + if self.pool.get('account.journal').browse(cr, uid, vals['journal_id'], context=context).type == 'cash': open_close = self._get_cash_open_close_box_lines(cr, uid, context) if vals.get('starting_details_ids', False): for start in vals.get('starting_details_ids'): @@ -283,7 +283,7 @@ class account_cash_statement(osv.osv): @return: True on success, False otherwise """ - super(account_cash_statement, self).write(cr, uid, ids, vals) + super(account_cash_statement, self).write(cr, uid, ids, vals, context=context) res = self._get_starting_balance(cr, uid, ids) for rs in res: super(account_cash_statement, self).write(cr, uid, [rs], res.get(rs)) @@ -338,7 +338,7 @@ class account_cash_statement(osv.osv): 'state': 'open', }) - self.write(cr, uid, [statement.id], vals) + self.write(cr, uid, [statement.id], vals, context=context) return True def balance_check(self, cr, uid, cash_id, journal_type='bank', context=None): diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 2987b3c69d6..02c5abcb130 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -107,9 +107,9 @@ class account_move_line(osv.osv): del data[f] return data - def create_analytic_lines(self, cr, uid, ids, context={}): + def create_analytic_lines(self, cr, uid, ids, context=None): acc_ana_line_obj = self.pool.get('account.analytic.line') - for obj_line in self.browse(cr, uid, ids, context): + for obj_line in self.browse(cr, uid, ids, context=context): if obj_line.analytic_account_id: if not obj_line.journal_id.analytic_journal_id: raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (obj_line.journal_id.name, )) @@ -139,7 +139,9 @@ class account_move_line(osv.osv): del(data['account_tax_id']) return data - def convert_to_period(self, cr, uid, context={}): + def convert_to_period(self, cr, uid, context=None): + if context is None: + context = {} period_obj = self.pool.get('account.period') #check if the period_id changed in the context from client side if context.get('period_id', False): @@ -151,7 +153,9 @@ class account_move_line(osv.osv): }) return context - def _default_get(self, cr, uid, fields, context={}): + def _default_get(self, cr, uid, fields, context=None): + if context is None: + context = {} if not context.get('journal_id', False) and context.get('search_default_journal_id', False): context['journal_id'] = context.get('search_default_journal_id') account_obj = self.pool.get('account.account') @@ -164,7 +168,7 @@ class account_move_line(osv.osv): currency_obj = self.pool.get('res.currency') context = self.convert_to_period(cr, uid, context) # Compute simple values - data = super(account_move_line, self).default_get(cr, uid, fields, context) + data = super(account_move_line, self).default_get(cr, uid, fields, context=context) # Starts: Manual entry from account.move form if context.get('lines',[]): total_new = 0.00 @@ -174,7 +178,7 @@ class account_move_line(osv.osv): for item in i[2]: data[item] = i[2][item] if context['journal']: - journal_data = journal_obj.browse(cr, uid, context['journal']) + journal_data = journal_obj.browse(cr, uid, context['journal'], context=context) if journal_data.type == 'purchase': if total_new > 0: account = journal_data.default_credit_account_id @@ -186,9 +190,9 @@ class account_move_line(osv.osv): else: account = journal_data.default_debit_account_id if account and ((not fields) or ('debit' in fields) or ('credit' in fields)) and 'partner_id' in data and (data['partner_id']): - part = partner_obj.browse(cr, uid, data['partner_id']) + part = partner_obj.browse(cr, uid, data['partner_id'], context=context) account = fiscal_pos_obj.map_account(cr, uid, part and part.property_account_position or False, account.id) - account = account_obj.browse(cr, uid, account) + account = account_obj.browse(cr, uid, account, context=context) data['account_id'] = account.id s = -total_new @@ -236,7 +240,7 @@ class account_move_line(osv.osv): return data total = 0 ref_id = False - move = move_obj.browse(cr, uid, move_id, context) + move = move_obj.browse(cr, uid, move_id, context=context) if 'name' in fields: data.setdefault('name', move.line_id[-1].name) acc1 = False @@ -265,7 +269,7 @@ class account_move_line(osv.osv): # part = False is acceptable for fiscal position. account = fiscal_pos_obj.map_account(cr, uid, part and part.property_account_position or False, account.id) if account: - account = account_obj.browse(cr, uid, account) + account = account_obj.browse(cr, uid, account, context=context) if account and ((not fields) or ('debit' in fields) or ('credit' in fields)): data['account_id'] = account.id @@ -289,10 +293,10 @@ class account_move_line(osv.osv): data['amount_currency'] = v return data - def on_create_write(self, cr, uid, id, context={}): + def on_create_write(self, cr, uid, id, context=None): if not id: return [] - ml = self.browse(cr, uid, id, context) + ml = self.browse(cr, uid, id, context=context) return map(lambda x: x.id, ml.move_id.line_id) def _balance(self, cr, uid, ids, name, arg, context=None): @@ -334,11 +338,11 @@ class account_move_line(osv.osv): res[line_id] = (invoice_id, invoice_names[invoice_id]) return res - def name_get(self, cr, uid, ids, context={}): + def name_get(self, cr, uid, ids, context=None): if not ids: return [] result = [] - for line in self.browse(cr, uid, ids, context): + for line in self.browse(cr, uid, ids, context=context): if line.ref: result.append((line.id, (line.move_id.name or '')+' ('+line.ref+')')) else: @@ -454,6 +458,8 @@ class account_move_line(osv.osv): } def _get_date(self, cr, uid, context=None): + if context is None: + context or {} period_obj = self.pool.get('account.period') dt = time.strftime('%Y-%m-%d') if ('journal_id' in context) and ('period_id' in context): @@ -495,35 +501,35 @@ class account_move_line(osv.osv): ('credit_debit2', 'CHECK (credit+debit>=0)', 'Wrong credit or debit value in accounting entry !'), ] - def _auto_init(self, cr, context={}): - super(account_move_line, self)._auto_init(cr, context) + def _auto_init(self, cr, context=None): + super(account_move_line, self)._auto_init(cr, context=context) cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'account_move_line_journal_id_period_id_index\'') if not cr.fetchone(): cr.execute('CREATE INDEX account_move_line_journal_id_period_id_index ON account_move_line (journal_id, period_id)') - def _check_no_view(self, cr, uid, ids): - lines = self.browse(cr, uid, ids) + def _check_no_view(self, cr, uid, ids, context=None): + lines = self.browse(cr, uid, ids, context=context) for l in lines: if l.account_id.type == 'view': return False return True - def _check_no_closed(self, cr, uid, ids): - lines = self.browse(cr, uid, ids) + def _check_no_closed(self, cr, uid, ids, context=None): + lines = self.browse(cr, uid, ids, context=context) for l in lines: if l.account_id.type == 'closed': return False return True - def _check_company_id(self, cr, uid, ids): - lines = self.browse(cr, uid, ids) + def _check_company_id(self, cr, uid, ids, context=None): + lines = self.browse(cr, uid, ids, context=context) for l in lines: if l.company_id != l.account_id.company_id or l.company_id != l.period_id.company_id: return False return True - def _check_partner_id(self, cr, uid, ids): - lines = self.browse(cr, uid, ids) + def _check_partner_id(self, cr, uid, ids, context=None): + lines = self.browse(cr, uid, ids, context=context) for l in lines: if l.account_id.type in ('receivable', 'payable') and not l.partner_id: return False @@ -546,7 +552,7 @@ class account_move_line(osv.osv): if (not currency_id) or (not account_id): return {} result = {} - acc = account_obj.browse(cr, uid, account_id) + acc = account_obj.browse(cr, uid, account_id, context=context) if (amount>0) and journal: x = journal_obj.browse(cr, uid, journal).default_credit_account_id if x: acc = x @@ -662,7 +668,7 @@ class account_move_line(osv.osv): raise osv.except_osv(_('Warning !'), _('To reconcile the entries company should be the same for all entries')) company_list.append(line.company_id.id) - for line in self.browse(cr, uid, ids, context): + for line in self.browse(cr, uid, ids, context=context): if line.reconcile_id: raise osv.except_osv(_('Warning'), _('Already Reconciled!')) if line.reconcile_partial_id: @@ -808,8 +814,10 @@ class account_move_line(osv.osv): partner_obj.write(cr, uid, [partner_id], {'last_reconciliation_date': time.strftime('%Y-%m-%d %H:%M:%S')}) return r_id - def view_header_get(self, cr, user, view_id, view_type, context): - context = self.convert_to_period(cr, user, context) + def view_header_get(self, cr, user, view_id, view_type, context=None): + if context is None: + context = {} + context = self.convert_to_period(cr, user, context=context) if context.get('account_id', False): cr.execute('SELECT code FROM account_account WHERE id = %s', (context['account_id'], )) res = cr.fetchone() @@ -825,7 +833,7 @@ class account_move_line(osv.osv): return j+(p and (':'+p) or '') return False - def onchange_date(self, cr, user, ids, date, context={}): + def onchange_date(self, cr, user, ids, date, context=None): """ Returns a dict that contains new values and context @param cr: A database cursor @@ -836,6 +844,8 @@ class account_move_line(osv.osv): @return: Returns a dict which contains new values, and context """ res = {} + if context is None: + context = {} period_pool = self.pool.get('account.period') pids = period_pool.search(cr, user, [('date_start','<=',date), ('date_stop','>=',date)]) if pids: @@ -850,9 +860,11 @@ class account_move_line(osv.osv): 'context':context, } - def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False): + def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): journal_pool = self.pool.get('account.journal') - result = super(osv.osv, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu) + if context is None: + context = {} + result = super(osv.osv, self).fields_view_get(cr, uid, view_id, view_type, context=context, toolbar=toolbar, submenu=submenu) if view_type != 'tree': #Remove the toolbar from the form view if view_type == 'form': @@ -871,7 +883,7 @@ class account_move_line(osv.osv): xml = '''\n\n\t''' % (title) ids = journal_pool.search(cr, uid, []) - journals = journal_pool.browse(cr, uid, ids) + journals = journal_pool.browse(cr, uid, ids, context=context) all_journal = [None] common_fields = {} total = len(journals) @@ -952,8 +964,10 @@ class account_move_line(osv.osv): result['fields'] = self.fields_get(cr, uid, flds, context) return result - def _check_moves(self, cr, uid, context): + def _check_moves(self, cr, uid, context=None): # use the first move ever created for this journal and period + if context is None: + context = {} cr.execute('SELECT id, state, name FROM account_move WHERE journal_id = %s AND period_id = %s ORDER BY id limit 1', (context['journal_id'],context['period_id'])) res = cr.fetchone() if res: @@ -981,11 +995,13 @@ class account_move_line(osv.osv): obj_move_rec.unlink(cr, uid, unlink_ids) return True - def unlink(self, cr, uid, ids, context={}, check=True): + def unlink(self, cr, uid, ids, context=None, check=True): + if context is None: + context = {} move_obj = self.pool.get('account.move') self._update_check(cr, uid, ids, context) result = False - for line in self.browse(cr, uid, ids, context): + for line in self.browse(cr, uid, ids, context=context): context['journal_id'] = line.journal_id.id context['period_id'] = line.period_id.id result = super(account_move_line, self).unlink(cr, uid, [line.id], context=context) @@ -1014,9 +1030,9 @@ class account_move_line(osv.osv): journal_id = context.get('journal_id', False) period_id = context.get('period_id', False) if journal_id: - journal = journal_obj.browse(cr, uid, [journal_id])[0] + journal = journal_obj.browse(cr, uid, journal_id, context=context) if journal.allow_date and period_id: - period = period_obj.browse(cr, uid, [period_id])[0] + period = period_obj.browse(cr, uid, period_id, context=context) if not time.strptime(vals['date'][:10],'%Y-%m-%d') >= time.strptime(period.date_start, '%Y-%m-%d') or not time.strptime(vals['date'][:10], '%Y-%m-%d') <= time.strptime(period.date_stop, '%Y-%m-%d'): raise osv.except_osv(_('Error'),_('The date of your Journal Entry is not in the defined period!')) else: @@ -1069,7 +1085,7 @@ class account_move_line(osv.osv): move_obj.write(cr, uid, [line.move_id.id], {'date': todo_date}, context=context) return result - def _update_journal_check(self, cr, uid, journal_id, period_id, context={}): + def _update_journal_check(self, cr, uid, journal_id, period_id, context=None): journal_obj = self.pool.get('account.journal') period_obj = self.pool.get('account.period') jour_period_obj = self.pool.get('account.journal.period') @@ -1079,8 +1095,8 @@ class account_move_line(osv.osv): if state == 'done': raise osv.except_osv(_('Error !'), _('You can not add/modify entries in a closed journal.')) if not result: - journal = journal_obj.browse(cr, uid, journal_id, context) - period = period_obj.browse(cr, uid, period_id, context) + journal = journal_obj.browse(cr, uid, journal_id, context=context) + period = period_obj.browse(cr, uid, period_id, context=context) jour_period_obj.create(cr, uid, { 'name': (journal.code or journal.name)+':'+(period.name or ''), 'journal_id': journal.id, @@ -1088,9 +1104,9 @@ class account_move_line(osv.osv): }) return True - def _update_check(self, cr, uid, ids, context={}): + def _update_check(self, cr, uid, ids, context=None): done = {} - for line in self.browse(cr, uid, ids, context): + for line in self.browse(cr, uid, ids, context=context): if line.move_id.state <> 'draft' and (not line.journal_id.entry_posted): raise osv.except_osv(_('Error !'), _('You can not do this modification on a confirmed entry ! Please note that you can just change some non important fields !')) if line.reconcile_id: @@ -1127,7 +1143,7 @@ class account_move_line(osv.osv): self._update_journal_check(cr, uid, context['journal_id'], context['period_id'], context) move_id = vals.get('move_id', False) - journal = journal_obj.browse(cr, uid, context['journal_id']) + journal = journal_obj.browse(cr, uid, context['journal_id'], context=context) if not move_id: if journal.centralisation: #Check for centralisation @@ -1150,7 +1166,7 @@ class account_move_line(osv.osv): raise osv.except_osv(_('No piece number !'), _('Can not create an automatic sequence for this piece !\n\nPut a sequence in the journal definition for automatic numbering or create a sequence manually for this piece.')) ok = not (journal.type_control_ids or journal.account_control_ids) if ('account_id' in vals): - account = account_obj.browse(cr, uid, vals['account_id']) + account = account_obj.browse(cr, uid, vals['account_id'], context=context) if journal.type_control_ids: type = account.user_type for t in journal.type_control_ids: diff --git a/addons/account/installer.py b/addons/account/installer.py index b1be04f7c70..9dce3186393 100644 --- a/addons/account/installer.py +++ b/addons/account/installer.py @@ -45,7 +45,7 @@ class account_installer(osv.osv_memory): ids = modules.search(cr, uid, [('category_id', '=', 'Account Charts')], context=context) charts = list( sorted(((m.name, m.shortdesc) - for m in modules.browse(cr, uid, ids)), + for m in modules.browse(cr, uid, ids, context=context)), key=itemgetter(1))) charts.insert(0, ('configurable', 'Generic Chart Of Account')) return charts diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 3f675f90a07..57178c03c72 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -60,7 +60,7 @@ class account_invoice(osv.osv): return res and res[0] or False def _get_currency(self, cr, uid, context=None): - user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, [uid])[0] + user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, [uid], context=context)[0] if user.company_id: return user.company_id.currency_id.id return pooler.get_pool(cr.dbname).get('res.currency').search(cr, uid, [('rate','=', 1.0)])[0] @@ -89,11 +89,11 @@ class account_invoice(osv.osv): def _amount_residual(self, cr, uid, ids, name, args, context=None): res = {} - cur_obj = self.pool.get('res.currency') - data_inv = self.browse(cr, uid, ids) if context is None: context = {} + cur_obj = self.pool.get('res.currency') + data_inv = self.browse(cr, uid, ids, context=context) for inv in data_inv: debit = credit = 0.0 context.update({'date':inv.date_invoice}) @@ -168,7 +168,7 @@ class account_invoice(osv.osv): def _compute_lines(self, cr, uid, ids, name, args, context=None): result = {} - for invoice in self.browse(cr, uid, ids, context): + for invoice in self.browse(cr, uid, ids, context=context): src = [] lines = [] if invoice.move_id: @@ -187,7 +187,7 @@ class account_invoice(osv.osv): def _get_invoice_from_line(self, cr, uid, ids, context=None): move = {} - for line in self.pool.get('account.move.line').browse(cr, uid, ids): + for line in self.pool.get('account.move.line').browse(cr, uid, ids, context=context): if line.reconcile_partial_id: for line2 in line.reconcile_partial_id.line_partial_ids: move[line2.move_id.id] = True @@ -201,7 +201,7 @@ class account_invoice(osv.osv): def _get_invoice_from_reconcile(self, cr, uid, ids, context=None): move = {} - for r in self.pool.get('account.move.reconcile').browse(cr, uid, ids): + for r in self.pool.get('account.move.reconcile').browse(cr, uid, ids, context=context): for line in r.line_partial_ids: move[line.move_id.id] = True for line in r.line_id: @@ -328,6 +328,7 @@ class account_invoice(osv.osv): journal_obj = self.pool.get('account.journal') if context is None: context = {} + if context.get('active_model', '') in ['res.partner'] and context.get('active_ids', False) and context['active_ids']: partner = self.pool.get(context['active_model']).read(cr, uid, context['active_ids'], ['supplier','customer'])[0] if not view_type: @@ -395,7 +396,7 @@ class account_invoice(osv.osv): return True def unlink(self, cr, uid, ids, context=None): - invoices = self.read(cr, uid, ids, ['state']) + invoices = self.read(cr, uid, ids, ['state'], context=context) unlink_ids = [] for t in invoices: if t['state'] in ('draft', 'cancel'): @@ -675,7 +676,7 @@ class account_invoice(osv.osv): def button_compute(self, cr, uid, ids, context=None, set_total=False): self.button_reset_taxes(cr, uid, ids, context) - for inv in self.browse(cr, uid, ids): + for inv in self.browse(cr, uid, ids, context=context): if set_total: self.pool.get('account.invoice').write(cr, uid, [inv.id], {'check_total': inv.amount_total}) return True @@ -987,7 +988,7 @@ class account_invoice(osv.osv): #TODO: not correct fix but required a frech values before reading it. self.write(cr, uid, ids, {}) - for obj_inv in self.browse(cr, uid, ids): + for obj_inv in self.browse(cr, uid, ids, context=context): id = obj_inv.id invtype = obj_inv.type number = obj_inv.number @@ -1155,7 +1156,7 @@ class account_invoice(osv.osv): context = {} #TODO check if we can use different period for payment and the writeoff line assert len(ids)==1, "Can only pay one invoice at a time" - invoice = self.browse(cr, uid, ids[0]) + invoice = self.browse(cr, uid, ids[0], context=context) src_account_id = invoice.account_id.id # Take the seq as name for move types = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1, 'in_refund': -1} @@ -1319,9 +1320,9 @@ class account_invoice_line(osv.osv): return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}} else: return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}} - part = self.pool.get('res.partner').browse(cr, uid, partner_id) + part = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context) fpos_obj = self.pool.get('account.fiscal.position') - fpos = fposition_id and fpos_obj.browse(cr, uid, fposition_id) or False + fpos = fposition_id and fpos_obj.browse(cr, uid, fposition_id, context=context) or False if part.lang: context.update({'lang': part.lang}) @@ -1351,7 +1352,7 @@ class account_invoice_line(osv.osv): # Parse the value_reference field to get the ID of the account.account record account_id = int (my_value[0]["value_reference"].split(",")[1]) # Use the ID of the account.account record in the browse for the account.account record - app_acc_in = account_obj.browse(cr, uid, [account_id])[0] + app_acc_in = account_obj.browse(cr, uid, account_id, context=context) if not exp_pro_id: ex_acc = res.product_tmpl_id.property_account_expense ex_acc_cate = res.categ_id.property_account_expense_categ @@ -1360,7 +1361,7 @@ class account_invoice_line(osv.osv): else: app_acc_exp = ex_acc_cate else: - app_acc_exp = account_obj.browse(cr, uid, exp_pro_id)[0] + app_acc_exp = account_obj.browse(cr, uid, exp_pro_id, context=context)[0] if not in_pro_id and not exp_pro_id: in_acc = res.product_tmpl_id.property_account_income in_acc_cate = res.categ_id.property_account_income_categ @@ -1378,8 +1379,8 @@ class account_invoice_line(osv.osv): if not in_res_id and not exp_res_id: raise osv.except_osv(_('Configuration Error !'), _('Can not find account chart for this company, Please Create account.')) - in_obj_acc = account_obj.browse(cr, uid, in_res_id) - exp_obj_acc = account_obj.browse(cr, uid, exp_res_id) + in_obj_acc = account_obj.browse(cr, uid, in_res_id, context=context) + exp_obj_acc = account_obj.browse(cr, uid, exp_res_id, context=context) if in_acc or ex_acc: res.product_tmpl_id.property_account_income = in_obj_acc[0] res.product_tmpl_id.property_account_expense = exp_obj_acc[0] @@ -1427,8 +1428,8 @@ class account_invoice_line(osv.osv): if not company_id or not currency_id: return res_final - company = self.pool.get('res.company').browse(cr, uid, company_id) - currency = self.pool.get('res.currency').browse(cr, uid, currency_id) + company = self.pool.get('res.company').browse(cr, uid, company_id, context=context) + currency = self.pool.get('res.currency').browse(cr, uid, currency_id, context=context) if company.currency_id.id != currency.id: new_price = res_final['value']['price_unit'] * currency.rate @@ -1453,7 +1454,9 @@ class account_invoice_line(osv.osv): res = [] tax_obj = self.pool.get('account.tax') cur_obj = self.pool.get('res.currency') - inv = self.pool.get('account.invoice').browse(cr, uid, invoice_id) + if context is None: + context = {} + inv = self.pool.get('account.invoice').browse(cr, uid, invoice_id, context=context) company_currency = inv.company_id.currency_id.id for line in inv.invoice_line: @@ -1584,11 +1587,11 @@ class account_invoice_tax(osv.osv): 'base_amount': 0.0, 'tax_amount': 0.0, } - def compute(self, cr, uid, invoice_id, context={}): + def compute(self, cr, uid, invoice_id, context=None): tax_grouped = {} tax_obj = self.pool.get('account.tax') cur_obj = self.pool.get('res.currency') - inv = self.pool.get('account.invoice').browse(cr, uid, invoice_id, context) + inv = self.pool.get('account.invoice').browse(cr, uid, invoice_id, context=context) cur = inv.currency_id company_currency = inv.company_id.currency_id.id diff --git a/addons/account/partner.py b/addons/account/partner.py index fb5af0353a5..c710e8949c4 100644 --- a/addons/account/partner.py +++ b/addons/account/partner.py @@ -34,7 +34,7 @@ class account_fiscal_position(osv.osv): 'note': fields.text('Notes', translate=True), } - def map_tax(self, cr, uid, fposition_id, taxes, context={}): + def map_tax(self, cr, uid, fposition_id, taxes, context=None): if not taxes: return [] if not fposition_id: @@ -51,7 +51,7 @@ class account_fiscal_position(osv.osv): result.append(t.id) return result - def map_account(self, cr, uid, fposition_id, account_id, context={}): + def map_account(self, cr, uid, fposition_id, account_id, context=None): if not fposition_id: return account_id for pos in fposition_id.account_ids: @@ -134,10 +134,10 @@ class res_partner(osv.osv): return [('id','=','0')] return [('id','in',map(itemgetter(0), res))] - def _credit_search(self, cr, uid, obj, name, args, context): + def _credit_search(self, cr, uid, obj, name, args, context=None): return self._asset_difference_search(cr, uid, obj, name, 'receivable', args, context=context) - def _debit_search(self, cr, uid, obj, name, args, context): + def _debit_search(self, cr, uid, obj, name, args, context=None): return self._asset_difference_search(cr, uid, obj, name, 'payable', args, context=context) _columns = { diff --git a/addons/account/project/wizard/project_account_analytic_line.py b/addons/account/project/wizard/project_account_analytic_line.py index f99da966634..e6be3bcffd3 100644 --- a/addons/account/project/wizard/project_account_analytic_line.py +++ b/addons/account/project/wizard/project_account_analytic_line.py @@ -29,7 +29,7 @@ class project_account_analytic_line(osv.osv_memory): 'to_date': fields.date('To'), } - def action_open_window(self, cr, uid, ids, context={}): + def action_open_window(self, cr, uid, ids, context=None): mod_obj =self.pool.get('ir.model.data') domain = [] data = self.read(cr, uid, ids, [])[0] diff --git a/addons/account/report/account_report.py b/addons/account/report/account_report.py index a85d25efe5a..8a77ce47280 100644 --- a/addons/account/report/account_report.py +++ b/addons/account/report/account_report.py @@ -27,7 +27,7 @@ import pooler import tools from osv import fields,osv -def _code_get(self, cr, uid, context={}): +def _code_get(self, cr, uid, context=None): acc_type_obj = self.pool.get('account.account.type') ids = acc_type_obj.search(cr, uid, []) res = acc_type_obj.read(cr, uid, ids, ['code', 'name'], context) @@ -98,9 +98,9 @@ class report_aged_receivable(osv.osv): res = super(report_aged_receivable, self).fields_view_get(cr, user, view_id, view_type, context, toolbar=toolbar, submenu=submenu) return res - def _calc_bal(self, cr, uid, ids, name, args, context): + def _calc_bal(self, cr, uid, ids, name, args, context=None): res = {} - for period in self.read(cr,uid,ids,['name']): + for period in self.read(cr, uid, ids, ['name'], context=context): date1,date2 = period['name'].split(' to ') cr.execute("SELECT SUM(credit-debit) FROM account_move_line AS line, account_account as ac \ WHERE (line.account_id=ac.id) AND ac.type='receivable' \ diff --git a/addons/account/wizard/account_automatic_reconcile.py b/addons/account/wizard/account_automatic_reconcile.py index e1ef86b9a65..432a430868c 100644 --- a/addons/account/wizard/account_automatic_reconcile.py +++ b/addons/account/wizard/account_automatic_reconcile.py @@ -42,10 +42,14 @@ class account_automatic_reconcile(osv.osv_memory): 'allow_write_off': fields.boolean('Allow write off') } - def _get_reconciled(self, cr, uid, context={}): + def _get_reconciled(self, cr, uid, context=None): + if context is None: + context = {} return context.get('reconciled', 0) - def _get_unreconciled(self, cr, uid, context={}): + def _get_unreconciled(self, cr, uid, context=None): + if context is None: + context = {} return context.get('unreconciled', 0) _defaults = { @@ -175,7 +179,7 @@ class account_automatic_reconcile(osv.osv_memory): if allow_write_off: move_line_obj.reconcile(cr, uid, line_ids, 'auto', form['writeoff_acc_id'], form['period_id'], form['journal_id'], context) else: - move_line_obj.reconcile_partial(cr, uid, line_ids, 'manual', context={}) + move_line_obj.reconcile_partial(cr, uid, line_ids, 'manual', context=context) # get the list of partners who have more than one unreconciled transaction cr.execute( diff --git a/addons/account/wizard/account_change_currency.py b/addons/account/wizard/account_change_currency.py index b6dccb6e5b1..47f9ac9c2c8 100644 --- a/addons/account/wizard/account_change_currency.py +++ b/addons/account/wizard/account_change_currency.py @@ -51,7 +51,7 @@ class account_change_currency(osv.osv_memory): invoice = obj_inv.browse(cr, uid, context['active_id'], context=context) if invoice.currency_id.id == new_currency: return {} - rate = obj_currency.browse(cr, uid, new_currency).rate + rate = obj_currency.browse(cr, uid, new_currency, context=context).rate for line in invoice.invoice_line: new_price = 0 if invoice.company_id.currency_id.id == invoice.currency_id.id: diff --git a/addons/account/wizard/account_invoice_refund.py b/addons/account/wizard/account_invoice_refund.py index 0ad0cf61999..672e2a28fba 100644 --- a/addons/account/wizard/account_invoice_refund.py +++ b/addons/account/wizard/account_invoice_refund.py @@ -93,7 +93,7 @@ class account_invoice_refund(osv.osv_memory): date = False period = False description = False - company = res_users_obj.browse(cr, uid, uid).company_id + company = res_users_obj.browse(cr, uid, uid, context=context).company_id journal_id = form.get('journal_id', False) for inv in inv_obj.browse(cr, uid, context.get('active_ids'), context=context): if inv.state in ['draft', 'proforma2', 'cancel']: diff --git a/addons/account/wizard/account_move_bank_reconcile.py b/addons/account/wizard/account_move_bank_reconcile.py index 2e6a52e56cd..9be351ed440 100644 --- a/addons/account/wizard/account_move_bank_reconcile.py +++ b/addons/account/wizard/account_move_bank_reconcile.py @@ -32,13 +32,15 @@ class account_move_bank_reconcile(osv.osv_memory): 'journal_id': fields.many2one('account.journal', 'Journal', required=True), } - def action_open_window(self, cr, uid, ids, context={}): + def action_open_window(self, cr, uid, ids, context=None): """ @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: account move bank reconcile’s ID or list of IDs @return: dictionary of Open account move line on given journal_id. """ + if context is None: + context = {} data = self.read(cr, uid, ids, context=context)[0] cr.execute('select default_credit_account_id \ from account_journal where id=%s', (data['journal_id'],)) diff --git a/addons/account/wizard/account_move_journal.py b/addons/account/wizard/account_move_journal.py index 72ae65f83b9..c7adb387724 100644 --- a/addons/account/wizard/account_move_journal.py +++ b/addons/account/wizard/account_move_journal.py @@ -29,7 +29,7 @@ class account_move_journal(osv.osv_memory): _name = "account.move.journal" _description = "Move journal" - def _get_period(self, cr, uid, context={}): + def _get_period(self, cr, uid, context=None): """ Return default account period value """ @@ -40,7 +40,7 @@ class account_move_journal(osv.osv_memory): period_id = ids[0] return period_id - def _get_journal(self, cr, uid, context={}): + def _get_journal(self, cr, uid, context=None): """ Return journal based on the journal type """ @@ -138,8 +138,8 @@ class account_move_journal(osv.osv_memory): ids = period_pool.search(cr, uid, [('journal_id', '=', journal_id), ('period_id', '=', period_id)], context=context) if not ids: - journal = journal_pool.browse(cr, uid, journal_id) - period = account_period_obj.browse(cr, uid, period_id) + journal = journal_pool.browse(cr, uid, journal_id, context=context) + period = account_period_obj.browse(cr, uid, period_id, context=context) name = journal.name state = period.state diff --git a/addons/account/wizard/account_move_line_reconcile_select.py b/addons/account/wizard/account_move_line_reconcile_select.py index d51b78f8db4..8e57c57884d 100644 --- a/addons/account/wizard/account_move_line_reconcile_select.py +++ b/addons/account/wizard/account_move_line_reconcile_select.py @@ -30,7 +30,7 @@ class account_move_line_reconcile_select(osv.osv_memory): domain = [('reconcile', '=', 1)], required=True), } - def action_open_window(self, cr, uid, ids, context={}): + def action_open_window(self, cr, uid, ids, context=None): """ This function Open account move line window for reconcile on given account id @param cr: the current row, from the database cursor, diff --git a/addons/account/wizard/account_move_line_select.py b/addons/account/wizard/account_move_line_select.py index 7ece00ca8b5..12ab0236759 100644 --- a/addons/account/wizard/account_move_line_select.py +++ b/addons/account/wizard/account_move_line_select.py @@ -42,7 +42,7 @@ class account_move_line_select(osv.osv_memory): else: fiscalyear_ids = [context['fiscalyear']] - fiscalyears = fiscalyear_obj.browse(cr, uid, fiscalyear_ids) + fiscalyears = fiscalyear_obj.browse(cr, uid, fiscalyear_ids, context=context) period_ids = [] if fiscalyears: diff --git a/addons/account/wizard/account_move_line_unreconcile_select.py b/addons/account/wizard/account_move_line_unreconcile_select.py index 826a5a654b1..ad59493503d 100644 --- a/addons/account/wizard/account_move_line_unreconcile_select.py +++ b/addons/account/wizard/account_move_line_unreconcile_select.py @@ -27,7 +27,7 @@ class account_move_line_unreconcile_select(osv.osv_memory): _columns ={ 'account_id': fields.many2one('account.account','Account',required=True), } - def action_open_window(self, cr, uid, ids, context={}): + def action_open_window(self, cr, uid, ids, context=None): data = self.read(cr, uid, ids, context=context)[0] return { 'domain': "[('account_id','=',%d),('reconcile_id','<>',False),('state','<>','draft')]" % data['account_id'], diff --git a/addons/account/wizard/account_open_closed_fiscalyear.py b/addons/account/wizard/account_open_closed_fiscalyear.py index 3b7dc0743fc..582bbc36619 100644 --- a/addons/account/wizard/account_open_closed_fiscalyear.py +++ b/addons/account/wizard/account_open_closed_fiscalyear.py @@ -30,12 +30,12 @@ class account_open_closed_fiscalyear(osv.osv_memory): 'Fiscal Year to Open', required=True, help='Select Fiscal Year which you want to remove entries for its End of year entries journal'), } - def remove_entries(self, cr, uid, ids, context={}): + def remove_entries(self, cr, uid, ids, context=None): fy_obj = self.pool.get('account.fiscalyear') move_obj = self.pool.get('account.move') - data = self.read(cr, uid, ids, [])[0] - data_fyear = fy_obj.browse(cr, uid, data['fyear_id']) + data = self.read(cr, uid, ids, [], context=context)[0] + data_fyear = fy_obj.browse(cr, uid, data['fyear_id'], context=context) if not data_fyear.end_journal_period_id: raise osv.except_osv(_('Error'), _('No journal for ending writing has been defined for the fiscal year')) period_journal = data_fyear.end_journal_period_id diff --git a/addons/account/wizard/account_reconcile_partner_process.py b/addons/account/wizard/account_reconcile_partner_process.py index e65ed778ef4..9f91d1ec2d2 100644 --- a/addons/account/wizard/account_reconcile_partner_process.py +++ b/addons/account/wizard/account_reconcile_partner_process.py @@ -73,6 +73,8 @@ class account_partner_reconcile_process(osv.osv_memory): return res def next_partner(self, cr, uid, ids, context=None): + if context is None: + context = {} move_line_obj = self.pool.get('account.move.line') res_partner_obj = self.pool.get('res.partner') diff --git a/addons/account/wizard/account_report_balance_sheet.py b/addons/account/wizard/account_report_balance_sheet.py index 0d64a753f55..6ce36242f47 100644 --- a/addons/account/wizard/account_report_balance_sheet.py +++ b/addons/account/wizard/account_report_balance_sheet.py @@ -57,7 +57,7 @@ class account_bs_report(osv.osv_memory): if context is None: context = {} data = self.pre_print_report(cr, uid, ids, data, context=context) - account = self.pool.get('account.account').browse(cr, uid, data['form']['chart_account_id']) + account = self.pool.get('account.account').browse(cr, uid, data['form']['chart_account_id'], context=context) if not account.company_id.property_reserve_and_surplus_account: raise osv.except_osv(_('Warning'),_('Please define the Reserve and Profit/Loss account for current user company !')) data['form']['reserve_account_id'] = account.company_id.property_reserve_and_surplus_account.id diff --git a/addons/account/wizard/account_report_common_account.py b/addons/account/wizard/account_report_common_account.py index 4ed71ec9389..7205a9e53bf 100644 --- a/addons/account/wizard/account_report_common_account.py +++ b/addons/account/wizard/account_report_common_account.py @@ -38,7 +38,7 @@ class account_common_account_report(osv.osv_memory): def pre_print_report(self, cr, uid, ids, data, context=None): if context is None: context = {} - data['form'].update(self.read(cr, uid, ids, ['display_account'])[0]) + data['form'].update(self.read(cr, uid, ids, ['display_account'], context=context)[0]) return data account_common_account_report() diff --git a/addons/account/wizard/account_report_common_journal.py b/addons/account/wizard/account_report_common_journal.py index 9ec12b16177..8e9db058d31 100644 --- a/addons/account/wizard/account_report_common_journal.py +++ b/addons/account/wizard/account_report_common_journal.py @@ -41,7 +41,7 @@ class account_common_journal_report(osv.osv_memory): def pre_print_report(self, cr, uid, ids, data, context=None): if context is None: context = {} - data['form'].update(self.read(cr, uid, ids, ['amount_currency'])[0]) + data['form'].update(self.read(cr, uid, ids, ['amount_currency'], context=context)[0]) fy_ids = data['form']['fiscalyear_id'] and [data['form']['fiscalyear_id']] or self.pool.get('account.fiscalyear').search(cr, uid, [('state', '=', 'draft')], context=context) period_list = data['form']['periods'] or self.pool.get('account.period').search(cr, uid, [('fiscalyear_id', 'in', fy_ids)], context=context) data['form']['active_ids'] = self.pool.get('account.journal.period').search(cr, uid, [('journal_id', 'in', data['form']['journal_ids']), ('period_id', 'in', period_list)], context=context) diff --git a/addons/account/wizard/account_report_common_partner.py b/addons/account/wizard/account_report_common_partner.py index 3fafb400bb1..05003041eeb 100644 --- a/addons/account/wizard/account_report_common_partner.py +++ b/addons/account/wizard/account_report_common_partner.py @@ -39,7 +39,7 @@ class account_common_partner_report(osv.osv_memory): def pre_print_report(self, cr, uid, ids, data, context=None): if context is None: context = {} - data['form'].update(self.read(cr, uid, ids, ['result_selection'])[0]) + data['form'].update(self.read(cr, uid, ids, ['result_selection'], context=context)[0]) return data account_common_partner_report() diff --git a/addons/account/wizard/account_report_print_journal.py b/addons/account/wizard/account_report_print_journal.py index 6256cca8ab6..b1ca30dc560 100644 --- a/addons/account/wizard/account_report_print_journal.py +++ b/addons/account/wizard/account_report_print_journal.py @@ -39,7 +39,7 @@ class account_print_journal(osv.osv_memory): if context is None: context = {} data = self.pre_print_report(cr, uid, ids, data, context=context) - data['form'].update(self.read(cr, uid, ids, ['sort_selection'])[0]) + data['form'].update(self.read(cr, uid, ids, ['sort_selection'], context=context)[0]) return {'type': 'ir.actions.report.xml', 'report_name': 'account.journal.period.print', 'datas': data} account_print_journal() diff --git a/addons/account/wizard/account_subscription_generate.py b/addons/account/wizard/account_subscription_generate.py index 7a50b49d310..4c99539301b 100644 --- a/addons/account/wizard/account_subscription_generate.py +++ b/addons/account/wizard/account_subscription_generate.py @@ -33,7 +33,7 @@ class account_subscription_generate(osv.osv_memory): _defaults = { 'date': lambda *a: time.strftime('%Y-%m-%d'), } - def action_generate(self, cr, uid, ids, context={}): + def action_generate(self, cr, uid, ids, context=None): mod_obj = self.pool.get('ir.model.data') act_obj = self.pool.get('ir.actions.act_window') moves_created=[] diff --git a/addons/account/wizard/account_unreconcile.py b/addons/account/wizard/account_unreconcile.py index 88b58b68a1e..3a067b4a598 100644 --- a/addons/account/wizard/account_unreconcile.py +++ b/addons/account/wizard/account_unreconcile.py @@ -41,11 +41,11 @@ class account_unreconcile_reconcile(osv.osv_memory): def trans_unrec_reconcile(self, cr, uid, ids, context=None): obj_move_reconcile = self.pool.get('account.move.reconcile') - rec_ids = context['active_ids'] if context is None: context = {} + rec_ids = context['active_ids'] if rec_ids: - obj_move_reconcile.unlink(cr, uid, rec_ids) + obj_move_reconcile.unlink(cr, uid, rec_ids, context=context) return {} account_unreconcile_reconcile() diff --git a/addons/account/wizard/account_use_model.py b/addons/account/wizard/account_use_model.py index 51bd3a96083..15719dcf138 100644 --- a/addons/account/wizard/account_use_model.py +++ b/addons/account/wizard/account_use_model.py @@ -59,9 +59,9 @@ class account_use_model(osv.osv_memory): data = self.read(cr, uid, ids, context=context)[0] record_id = context and context.get('model_line', False) or False if record_id: - data_model = account_model_obj.browse(cr, uid, data['model']) + data_model = account_model_obj.browse(cr, uid, data['model'], context=context) else: - data_model = account_model_obj.browse(cr, uid, context['active_ids']) + data_model = account_model_obj.browse(cr, uid, context['active_ids'], context=context) for model in data_model: entry['name'] = model.name%{'year':time.strftime('%Y'), 'month':time.strftime('%m'), 'date':time.strftime('%d')} period_id = account_period_obj.find(cr, uid, context=context) diff --git a/addons/account/wizard/account_validate_account_move.py b/addons/account/wizard/account_validate_account_move.py index 0f963b44fa6..f840d2b5532 100644 --- a/addons/account/wizard/account_validate_account_move.py +++ b/addons/account/wizard/account_validate_account_move.py @@ -33,11 +33,11 @@ class validate_account_move(osv.osv_memory): obj_move = self.pool.get('account.move') if context is None: context = {} - data = self.read(cr, uid, ids)[0] + data = self.read(cr, uid, ids, context=context)[0] ids_move = obj_move.search(cr, uid, [('state','=','draft'),('journal_id','=',data['journal_id']),('period_id','=',data['period_id'])]) if not ids_move: raise osv.except_osv(_('Warning'), _('Specified Journal does not have any account move entries in draft state for this period')) - obj_move.button_validate(cr, uid, ids_move, context) + obj_move.button_validate(cr, uid, ids_move, context=context) return {} validate_account_move() diff --git a/addons/account_analytic_analysis/account_analytic_analysis.py b/addons/account_analytic_analysis/account_analytic_analysis.py index 55213155168..9c8d657d537 100644 --- a/addons/account_analytic_analysis/account_analytic_analysis.py +++ b/addons/account_analytic_analysis/account_analytic_analysis.py @@ -269,7 +269,7 @@ class account_analytic_account(osv.osv): GROUP BY account_analytic_line.account_id", (child_ids,)) for account_id, sum in cr.fetchall(): res[account_id][name] = round(sum,2) - data = self._compute_level_tree(cr, uid, ids, child_ids, res, [name], context) + data = self._compute_level_tree(cr, uid, ids, child_ids, res, [name], context=context) for i in data: res_final[i] = data[i][name] return res_final @@ -324,7 +324,7 @@ class account_analytic_account(osv.osv): def _revenue_per_hour_calc(self, cr, uid, ids, name, arg, context=None): res = {} - for account in self.browse(cr, uid, ids): + for account in self.browse(cr, uid, ids, context=context): if account.hours_qtt_invoiced == 0: res[account.id]=0.0 else: @@ -335,7 +335,7 @@ class account_analytic_account(osv.osv): def _real_margin_rate_calc(self, cr, uid, ids, name, arg, context=None): res = {} - for account in self.browse(cr, uid, ids): + for account in self.browse(cr, uid, ids, context=context): if account.ca_invoiced == 0: res[account.id]=0.0 elif account.total_cost != 0.0: @@ -348,7 +348,7 @@ class account_analytic_account(osv.osv): def _remaining_ca_calc(self, cr, uid, ids, name, arg, context=None): res = {} - for account in self.browse(cr, uid, ids): + for account in self.browse(cr, uid, ids, context=context): if account.amount_max != 0: res[account.id] = account.amount_max - account.ca_invoiced else: @@ -359,7 +359,7 @@ class account_analytic_account(osv.osv): def _real_margin_calc(self, cr, uid, ids, name, arg, context=None): res = {} - for account in self.browse(cr, uid, ids): + for account in self.browse(cr, uid, ids, context=context): res[account.id] = account.ca_invoiced + account.total_cost for id in ids: res[id] = round(res.get(id, 0.0),2) @@ -367,7 +367,7 @@ class account_analytic_account(osv.osv): def _theorical_margin_calc(self, cr, uid, ids, name, arg, context=None): res = {} - for account in self.browse(cr, uid, ids): + for account in self.browse(cr, uid, ids, context=context): res[account.id] = account.ca_theorical + account.total_cost for id in ids: res[id] = round(res.get(id, 0.0),2) @@ -497,7 +497,7 @@ class account_analytic_account_summary_user(osv.osv): ')') def _read_flat(self, cr, user, ids, fields, context=None, load='_classic_read'): - if not context: + if context is None: context = {} if not ids: return [] @@ -671,7 +671,7 @@ class account_analytic_account_summary_month(osv.osv): ')') def _read_flat(self, cr, user, ids, fields, context=None, load='_classic_read'): - if not context: + if context is None: context = {} if not ids: return [] diff --git a/addons/account_analytic_plans/account_analytic_plans.py b/addons/account_analytic_plans/account_analytic_plans.py index fa3e4a24635..6d8a06755d6 100644 --- a/addons/account_analytic_plans/account_analytic_plans.py +++ b/addons/account_analytic_plans/account_analytic_plans.py @@ -28,7 +28,7 @@ from tools.translate import _ class one2many_mod2(fields.one2many): def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None): - if not context: + if context is None: context = {} res = {} for id in ids: @@ -115,7 +115,7 @@ class account_analytic_plan_instance(osv.osv): return super(account_analytic_plan_instance, self).copy(cr, uid, id, default, context=context) def _default_journal(self, cr, uid, context=None): - if not context: + if context is None: context = {} journal_obj = self.pool.get('account.journal') if context.has_key('journal_id') and context['journal_id']: @@ -148,6 +148,8 @@ class account_analytic_plan_instance(osv.osv): return self.name_get(cr, uid, ids, context or {}) def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): + if context is None: + context = {} wiz_id = self.pool.get('ir.actions.act_window').search(cr, uid, [("name","=","analytic.plan.create.model.action")], context=context) res = super(account_analytic_plan_instance,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu) journal_obj = self.pool.get('account.journal') @@ -214,6 +216,8 @@ class account_analytic_plan_instance(osv.osv): return super(account_analytic_plan_instance, self).create(cr, uid, vals, context=context) def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True): + if context is None: + context = {} this = self.browse(cr, uid, ids[0], context=context) invoice_line_obj = self.pool.get('account.invoice.line') if this.plan_id and not vals.has_key('plan_id'): @@ -307,6 +311,8 @@ class account_move_line(osv.osv): return data def create_analytic_lines(self, cr, uid, ids, context=None): + if context is None: + context = {} super(account_move_line, self).create_analytic_lines(cr, uid, ids, context=context) analytic_line_obj = self.pool.get('account.analytic.line') for line in self.browse(cr, uid, ids, context=context): @@ -336,7 +342,9 @@ class account_move_line(osv.osv): analytic_line_obj.create(cr, uid, al_vals, context=context) return True - def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False): + def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): + if context is None: + context = {} result = super(osv.osv, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu) return result @@ -437,7 +445,7 @@ class account_bank_statement(osv.osv): def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, st_line_number, context=None): account_move_line_pool = self.pool.get('account.move.line') account_bank_statement_line_pool = self.pool.get('account.bank.statement.line') - st_line = account_bank_statement_line_pool.browse(cr, uid, st_line_id, context) + st_line = account_bank_statement_line_pool.browse(cr, uid, st_line_id, context=context) result = super(account_bank_statement,self).create_move_from_st_line(cr, uid, st_line_id, company_currency_id, st_line_number, context=context) move = st_line.move_ids and st_line.move_ids[0] or False if move: @@ -447,7 +455,7 @@ class account_bank_statement(osv.osv): def button_confirm_bank(self, cr, uid, ids, context=None): super(account_bank_statement,self).button_confirm_bank(cr, uid, ids, context=context) - for st in self.browse(cr, uid, ids, context): + for st in self.browse(cr, uid, ids, context=context): for st_line in st.line_ids: if st_line.analytics_id: if not st.journal_id.analytic_journal_id: diff --git a/addons/account_analytic_plans/wizard/analytic_plan_create_model.py b/addons/account_analytic_plans/wizard/analytic_plan_create_model.py index 777421798cd..0581197aaca 100644 --- a/addons/account_analytic_plans/wizard/analytic_plan_create_model.py +++ b/addons/account_analytic_plans/wizard/analytic_plan_create_model.py @@ -30,6 +30,8 @@ class analytic_plan_create_model(osv.osv_memory): plan_obj = self.pool.get('account.analytic.plan.instance') mod_obj = self.pool.get('ir.model.data') anlytic_plan_obj = self.pool.get('account.analytic.plan') + if context is None: + context = {} if 'active_id' in context and context['active_id']: plan = plan_obj.browse(cr, uid, context['active_id'], context=context) if (not plan.name) or (not plan.code): diff --git a/addons/account_anglo_saxon/invoice.py b/addons/account_anglo_saxon/invoice.py index ff356547a83..a0aab8298dc 100644 --- a/addons/account_anglo_saxon/invoice.py +++ b/addons/account_anglo_saxon/invoice.py @@ -27,8 +27,8 @@ class account_invoice_line(osv.osv): _inherit = "account.invoice.line" def move_line_get(self, cr, uid, invoice_id, context=None): - res = super(account_invoice_line,self).move_line_get(cr, uid, invoice_id, context) - inv = self.pool.get('account.invoice').browse(cr, uid, invoice_id) + res = super(account_invoice_line,self).move_line_get(cr, uid, invoice_id, context=context) + inv = self.pool.get('account.invoice').browse(cr, uid, invoice_id, context=context) if inv.type in ('out_invoice','out_refund'): for i_line in inv.invoice_line: if i_line.product_id: @@ -144,7 +144,7 @@ class account_invoice_line(osv.osv): if not oa: oa = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id if oa: - fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False + fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id, context=context) or False a = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, oa) res['value'].update({'account_id':a}) return res diff --git a/addons/account_anglo_saxon/stock.py b/addons/account_anglo_saxon/stock.py index 6b0f367abf0..a544b9a6e2a 100644 --- a/addons/account_anglo_saxon/stock.py +++ b/addons/account_anglo_saxon/stock.py @@ -31,7 +31,7 @@ class stock_picking(osv.osv): def action_invoice_create(self, cr, uid, ids, journal_id=False, group=False, type='out_invoice', context=None): '''Return ids of created invoices for the pickings''' - res = super(stock_picking,self).action_invoice_create(cr, uid, ids, journal_id, group, type, context) + res = super(stock_picking,self).action_invoice_create(cr, uid, ids, journal_id, group, type, context=context) if type == 'in_refund': for inv in self.pool.get('account.invoice').browse(cr, uid, res.values(), context=context): for ol in inv.invoice_line: diff --git a/addons/account_budget/account_budget.py b/addons/account_budget/account_budget.py index 87b7573a68a..f6e7c7e3990 100644 --- a/addons/account_budget/account_budget.py +++ b/addons/account_budget/account_budget.py @@ -108,10 +108,12 @@ crossovered_budget() class crossovered_budget_lines(osv.osv): - def _prac_amt(self, cr, uid, ids, context={}): + def _prac_amt(self, cr, uid, ids, context=None): res = {} result = 0.0 - for line in self.browse(cr, uid, ids): + if context is None: + context = {} + for line in self.browse(cr, uid, ids, context=context): acc_ids = [x.id for x in line.general_budget_id.account_ids] if not acc_ids: raise osv.except_osv(_('Error!'),_("The General Budget '%s' has no Accounts!") % str(line.general_budget_id.name)) @@ -131,15 +133,17 @@ class crossovered_budget_lines(osv.osv): res[line.id] = result return res - def _prac(self, cr, uid, ids, name, args, context): + def _prac(self, cr, uid, ids, name, args, context=None): res={} - for line in self.browse(cr, uid, ids): + for line in self.browse(cr, uid, ids, context=context): res[line.id] = self._prac_amt(cr, uid, [line.id], context=context)[line.id] return res - def _theo_amt(self, cr, uid, ids, context={}): + def _theo_amt(self, cr, uid, ids, context=None): res = {} - for line in self.browse(cr, uid, ids): + if context is None: + context = {} + for line in self.browse(cr, uid, ids, context=context): today = datetime.datetime.today() date_to = today.strftime("%Y-%m-%d") date_from = line.date_from @@ -167,15 +171,15 @@ class crossovered_budget_lines(osv.osv): res[line.id] = theo_amt return res - def _theo(self, cr, uid, ids, name, args, context): + def _theo(self, cr, uid, ids, name, args, context=None): res = {} - for line in self.browse(cr, uid, ids): + for line in self.browse(cr, uid, ids, context=context): res[line.id] = self._theo_amt(cr, uid, [line.id], context=context)[line.id] return res - def _perc(self, cr, uid, ids, name, args, context): + def _perc(self, cr, uid, ids, name, args, context=None): res = {} - for line in self.browse(cr, uid, ids): + for line in self.browse(cr, uid, ids, context=context): if line.theoritical_amount <> 0.00: res[line.id] = float(line.practical_amount or 0.0 / line.theoritical_amount) * 100 else: diff --git a/addons/account_budget/wizard/account_budget_analytic.py b/addons/account_budget/wizard/account_budget_analytic.py index ef970c92904..b2a33434016 100644 --- a/addons/account_budget/wizard/account_budget_analytic.py +++ b/addons/account_budget/wizard/account_budget_analytic.py @@ -39,7 +39,7 @@ class account_budget_analytic(osv.osv_memory): datas = {} if context is None: context = {} - data = self.read(cr, uid, ids)[0] + data = self.read(cr, uid, ids, context=context)[0] datas = { 'ids': context.get('active_ids',[]), 'model': 'account.analytic.account', diff --git a/addons/account_budget/wizard/account_budget_crossovered_report.py b/addons/account_budget/wizard/account_budget_crossovered_report.py index 99c6989e845..5667a264d2a 100644 --- a/addons/account_budget/wizard/account_budget_crossovered_report.py +++ b/addons/account_budget/wizard/account_budget_crossovered_report.py @@ -39,7 +39,7 @@ class account_budget_crossvered_report(osv.osv_memory): datas = {} if context is None: context = {} - data = self.read(cr, uid, ids)[0] + data = self.read(cr, uid, ids, context=context)[0] datas = { 'ids': context.get('active_ids',[]), 'model': 'crossovered.budget', diff --git a/addons/account_budget/wizard/account_budget_crossovered_summary_report.py b/addons/account_budget/wizard/account_budget_crossovered_summary_report.py index ad0237af051..c2e34b2f2da 100644 --- a/addons/account_budget/wizard/account_budget_crossovered_summary_report.py +++ b/addons/account_budget/wizard/account_budget_crossovered_summary_report.py @@ -41,7 +41,7 @@ class account_budget_crossvered_summary_report(osv.osv_memory): datas = {} if context is None: context = {} - data = self.read(cr, uid, ids)[0] + data = self.read(cr, uid, ids, context=context)[0] datas = { 'ids': context.get('active_ids',[]), 'model': 'crossovered.budge', diff --git a/addons/account_budget/wizard/account_budget_report.py b/addons/account_budget/wizard/account_budget_report.py index 67359cf45f1..a85ff42fe4d 100644 --- a/addons/account_budget/wizard/account_budget_report.py +++ b/addons/account_budget/wizard/account_budget_report.py @@ -40,7 +40,7 @@ class account_budget_report(osv.osv_memory): datas = {} if context is None: context = {} - data = self.read(cr, uid, ids)[0] + data = self.read(cr, uid, ids, context=context)[0] datas = { 'ids': context.get('active_ids',[]), 'model': 'account.budget.post', diff --git a/addons/account_coda/account_coda.py b/addons/account_coda/account_coda.py index 0bb7228d821..e2cde58fd5c 100644 --- a/addons/account_coda/account_coda.py +++ b/addons/account_coda/account_coda.py @@ -43,6 +43,8 @@ class account_coda(osv.osv): } def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): + if context is None: + context = {} res = super(account_coda, self).search(cr, user, args=args, offset=offset, limit=limit, order=order, context=context, count=count) if context.get('bank_statement', False) and not res: diff --git a/addons/account_coda/wizard/account_coda_import.py b/addons/account_coda/wizard/account_coda_import.py index a52528e2fa5..6d3743116db 100644 --- a/addons/account_coda/wizard/account_coda_import.py +++ b/addons/account_coda/wizard/account_coda_import.py @@ -66,13 +66,13 @@ class account_coda_import(osv.osv_memory): mod_obj = self.pool.get('ir.model.data') line_obj = self.pool.get('account.move.line') - if not context: + if context is None: context = {} data = self.read(cr, uid, ids)[0] codafile = data['coda'] - journal_code = journal_obj.browse(cr, uid, data['journal_id'], context).code + journal_code = journal_obj.browse(cr, uid, data['journal_id'], context=context).code period = account_period_obj.find(cr, uid, context=context)[0] def_pay_acc = data['def_payable'] @@ -155,7 +155,7 @@ class account_coda_import(osv.osv_memory): bank_ids = partner_bank_obj.search(cr, uid, [('acc_number', '=', st_line_partner_acc)]) bank_statement_lines[st_line_name].update({'cntry_number': cntry_number, 'contry_name': contry_name}) if bank_ids: - bank = partner_bank_obj.browse(cr, uid, bank_ids[0], context) + bank = partner_bank_obj.browse(cr, uid, bank_ids[0], context=context) if line and bank.partner_id: bank_statement_lines[st_line_name].update({'partner_id': bank.partner_id.id}) if bank_statement_lines[st_line_name]['amount'] < 0: @@ -321,7 +321,7 @@ class account_coda_import(osv.osv_memory): } def action_open_window(self, cr, uid, data, context=None): - if not context: + if context is None: context = {} return { diff --git a/addons/account_followup/report/account_followup_print.py b/addons/account_followup/report/account_followup_print.py index 8bfb3fff1a9..30cbe058fd4 100644 --- a/addons/account_followup/report/account_followup_print.py +++ b/addons/account_followup/report/account_followup_print.py @@ -58,7 +58,7 @@ class report_rappel(report_sxw.rml_parse): movelines = moveline_obj.read(self.cr, self.uid, movelines) return movelines - def _get_text(self, partner, followup_id, context={}): + def _get_text(self, partner, followup_id, context=None): fp_obj = pooler.get_pool(self.cr.dbname).get('account_followup.followup') fp_line = fp_obj.browse(self.cr, self.uid, followup_id).followup_line li_delay = [] diff --git a/addons/account_followup/wizard/account_followup_print.py b/addons/account_followup/wizard/account_followup_print.py index 174061438f8..7d296f74f76 100644 --- a/addons/account_followup/wizard/account_followup_print.py +++ b/addons/account_followup/wizard/account_followup_print.py @@ -39,7 +39,7 @@ class account_followup_print(osv.osv_memory): context = {} if context.get('active_model', 'ir.ui.menu') == 'account_followup.followup': return context.get('active_id', False) - company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id + company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id followp_id = self.pool.get('account_followup.followup').search(cr, uid, [('company_id', '=', company_id)], context=context) return followp_id and followp_id[0] or False @@ -48,7 +48,7 @@ class account_followup_print(osv.osv_memory): if context is None: context = {} - data = self.read(cr, uid, ids, [])[0] + data = self.read(cr, uid, ids, [], context=context)[0] model_data_ids = mod_obj.search(cr, uid, [('model','=','ir.ui.view'),('name','=','view_account_followup_print_all')], context=context) resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id'] context.update({'followup_id': data['followup_id'], 'date':data['date']}) @@ -146,7 +146,7 @@ class account_followup_print_all(osv.osv_memory): if context is None: context = {} if ids: - data = self.read(cr, uid, ids, [])[0] + data = self.read(cr, uid, ids, [], context=context)[0] cr.execute( "SELECT l.partner_id, l.followup_line_id,l.date_maturity, l.date, l.id "\ "FROM account_move_line AS l "\ @@ -208,14 +208,14 @@ class account_followup_print_all(osv.osv_memory): if context is None: context = {} - data = self.read(cr, uid, ids, [])[0] + data = self.read(cr, uid, ids, [], context=context)[0] model_data_ids = mod_obj.search(cr, uid, [('model','=','ir.ui.view'),('name','=','view_account_followup_print_all_msg')], context=context) resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id'] if data['email_conf']: msg_sent = '' msg_unsent = '' - data_user = user_obj.browse(cr, uid, uid) - move_lines = line_obj.browse(cr, uid, data['partner_ids']) + data_user = user_obj.browse(cr, uid, uid, context=context) + move_lines = line_obj.browse(cr, uid, data['partner_ids'], context=context) partners = [] dict_lines = {} for line in move_lines: @@ -223,7 +223,7 @@ class account_followup_print_all(osv.osv_memory): dict_lines[line.name.id] =line for partner in partners: ids_lines = move_obj.search(cr,uid,[('partner_id','=',partner.id),('reconcile_id','=',False),('account_id.type','in',['receivable'])]) - data_lines = move_obj.browse(cr, uid, ids_lines) + data_lines = move_obj.browse(cr, uid, ids_lines, context=context) followup_data = dict_lines[partner.id] dest = False if partner.address: @@ -306,7 +306,7 @@ class account_followup_print_all(osv.osv_memory): def do_print(self, cr, uid, ids, context=None): if context is None: context = {} - data = self.read(cr, uid, ids, [])[0] + data = self.read(cr, uid, ids, [], context=context)[0] res = self._get_partners_followp(cr, uid, ids, context)['to_update'] to_update = res data['followup_id'] = 'followup_id' in context and context['followup_id'] or False diff --git a/addons/account_invoice_layout/account_invoice_layout.py b/addons/account_invoice_layout/account_invoice_layout.py index 2c2a02d4b9d..3337710420f 100644 --- a/addons/account_invoice_layout/account_invoice_layout.py +++ b/addons/account_invoice_layout/account_invoice_layout.py @@ -127,13 +127,12 @@ class account_invoice_line(osv.osv): def copy_data(self, cr, uid, id, default=None, context=None): if default is None: default = {} - default['state'] = self.browse(cr, uid, id).state + default['state'] = self.browse(cr, uid, id, context=context).state return super(account_invoice_line, self).copy_data(cr, uid, id, default, context) def _fnct(self, cr, uid, ids, name, args, context=None): res = {} - - lines = self.browse(cr, uid, ids) + lines = self.browse(cr, uid, ids, context=context) account_ids = [line.account_id.id for line in lines] account_names = dict(self.pool.get('account.account').name_get(cr, uid, account_ids, context=context)) for line in lines: @@ -180,7 +179,7 @@ account_invoice_line() class one2many_mod2(fields.one2many): def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None): - if not context: + if context is None: context = {} if not values: values = {} diff --git a/addons/account_invoice_layout/wizard/account_invoice_special_message.py b/addons/account_invoice_layout/wizard/account_invoice_special_message.py index adc3261fa64..a0bd6b328c3 100644 --- a/addons/account_invoice_layout/wizard/account_invoice_special_message.py +++ b/addons/account_invoice_layout/wizard/account_invoice_special_message.py @@ -34,7 +34,7 @@ class account_invoice_special_msg(osv.osv_memory): if context is None: context = {} - data = self.read(cr, uid, ids, [])[0] + data = self.read(cr, uid, ids, [], context=context)[0] datas = { 'ids': context.get('active_ids',[]), 'model': 'account.invoice', diff --git a/addons/account_payment/account_move_line.py b/addons/account_payment/account_move_line.py index 638b75dcaaa..68bb33ca4e5 100644 --- a/addons/account_payment/account_move_line.py +++ b/addons/account_payment/account_move_line.py @@ -26,7 +26,7 @@ from tools.translate import _ class account_move_line(osv.osv): _inherit = "account.move.line" - def amount_to_pay(self, cr, uid, ids, name, arg={}, context={}): + def amount_to_pay(self, cr, uid, ids, name, arg={}, context=None): """ Return the amount still to pay regarding all the payemnt orders (excepting cancelled orders)""" if not ids: @@ -47,7 +47,7 @@ class account_move_line(osv.osv): r = dict(cr.fetchall()) return r - def _to_pay_search(self, cr, uid, obj, name, args, context): + def _to_pay_search(self, cr, uid, obj, name, args, context=None): if not args: return [] line_obj = self.pool.get('account.move.line') diff --git a/addons/account_payment/account_payment.py b/addons/account_payment/account_payment.py index 63d78812946..d5858d94f80 100644 --- a/addons/account_payment/account_payment.py +++ b/addons/account_payment/account_payment.py @@ -39,7 +39,7 @@ class payment_mode(osv.osv): 'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id } - def suitable_bank_types(self, cr, uid, payment_code=None, context={}): + def suitable_bank_types(self, cr, uid, payment_code=None, context=None): """Return the codes of the bank type that are suitable for the given payment type code""" if not payment_code: @@ -267,10 +267,10 @@ class payment_line(osv.osv): line.amount_currency, context=ctx) return res - def _get_currency(self, cr, uid, context): + def _get_currency(self, cr, uid, context=None): user_obj = self.pool.get('res.users') currency_obj = self.pool.get('res.currency') - user = user_obj.browse(cr, uid, uid) + user = user_obj.browse(cr, uid, uid, context=context) if user.company_id: return user.company_id.currency_id.id @@ -284,7 +284,7 @@ class payment_line(osv.osv): date = False if context.get('order_id') and context['order_id']: - order = payment_order_obj.browse(cr, uid, context['order_id'], context) + order = payment_order_obj.browse(cr, uid, context['order_id'], context=context) if order.date_prefered == 'fixed': date = order.date_scheduled else: @@ -364,7 +364,7 @@ class payment_line(osv.osv): data['amount_currency'] = data['communication'] = data['partner_id'] = data['reference'] = data['date_created'] = data['bank_id'] = data['amount'] = False if move_line_id: - line = move_line_obj.browse(cr, uid, move_line_id) + line = move_line_obj.browse(cr, uid, move_line_id, context=context) data['amount_currency'] = line.amount_to_pay res = self.onchange_amount(cr, uid, ids, data['amount_currency'], currency, @@ -413,7 +413,7 @@ class payment_line(osv.osv): data['info_partner'] = data['bank_id'] = False if partner_id: - part_obj = partner_obj.browse(cr, uid, partner_id) + part_obj = partner_obj.browse(cr, uid, partner_id, context=context) partner = part_obj.name or '' if part_obj.address: diff --git a/addons/account_payment/wizard/account_payment_order.py b/addons/account_payment/wizard/account_payment_order.py index 662ed495d31..b8328aee333 100644 --- a/addons/account_payment/wizard/account_payment_order.py +++ b/addons/account_payment/wizard/account_payment_order.py @@ -62,7 +62,7 @@ class payment_order_create(osv.osv_memory): payment_obj = self.pool.get('payment.line') if context is None: context = {} - data = self.read(cr, uid, ids, [])[0] + data = self.read(cr, uid, ids, [], context=context)[0] line_ids = data['entries'] if not line_ids: return {} diff --git a/addons/account_payment/wizard/account_payment_pay.py b/addons/account_payment/wizard/account_payment_pay.py index 8e524c78959..6627ffaa614 100644 --- a/addons/account_payment/wizard/account_payment_pay.py +++ b/addons/account_payment/wizard/account_payment_pay.py @@ -31,6 +31,8 @@ class account_payment_make_payment(osv.osv_memory): If type is manual. just confirm the order. """ obj_payment_order = self.pool.get('payment.order') + if context is None: + context = {} # obj_model = self.pool.get('ir.model.data') # obj_act = self.pool.get('ir.actions.act_window') # order = obj_payment_order.browse(cr, uid, context['active_id'], context) diff --git a/addons/account_payment/wizard/account_payment_populate_statement.py b/addons/account_payment/wizard/account_payment_populate_statement.py index bd61d58be3f..cac06bb472a 100644 --- a/addons/account_payment/wizard/account_payment_populate_statement.py +++ b/addons/account_payment/wizard/account_payment_populate_statement.py @@ -60,7 +60,7 @@ class account_payment_populate_statement(osv.osv_memory): if context is None: context = {} - data = self.read(cr, uid, ids, [])[0] + data = self.read(cr, uid, ids, [], context=context)[0] line_ids = data['lines'] if not line_ids: return {} diff --git a/addons/account_sequence/account_sequence.py b/addons/account_sequence/account_sequence.py index 56accc5f6eb..1649a8890fa 100644 --- a/addons/account_sequence/account_sequence.py +++ b/addons/account_sequence/account_sequence.py @@ -33,7 +33,7 @@ class account_move(osv.osv): obj_sequence = self.pool.get('ir.sequence') res = super(account_move, self).post(cr, uid, ids, context=context) seq_no = False - for move in self.browse(cr, uid, ids, context): + for move in self.browse(cr, uid, ids, context=context): if move.journal_id.internal_sequence_id: seq_no = obj_sequence.get_id(cr, uid, move.journal_id.internal_sequence_id.id, context=context) if seq_no: diff --git a/addons/account_sequence/account_sequence_installer.py b/addons/account_sequence/account_sequence_installer.py index f7bcb113388..d27d0aa9f32 100644 --- a/addons/account_sequence/account_sequence_installer.py +++ b/addons/account_sequence/account_sequence_installer.py @@ -47,7 +47,7 @@ class account_sequence_installer(osv.osv_memory): context = {} jou_obj = self.pool.get('account.journal') obj_sequence = self.pool.get('ir.sequence') - record = self.browse(cr, uid, ids, context)[0] + record = self.browse(cr, uid, ids, context=context)[0] j_ids = [] if record.company_id: company_id = record.company_id.id, @@ -70,7 +70,7 @@ class account_sequence_installer(osv.osv_memory): ir_seq = obj_sequence.create(cr, uid, vals, context) res = super(account_sequence_installer, self).execute(cr, uid, ids, context=context) journal_ids = jou_obj.search(cr, uid, search_criteria, context=context) - for journal in jou_obj.browse(cr, uid, journal_ids, context): + for journal in jou_obj.browse(cr, uid, journal_ids, context=context): if not journal.internal_sequence_id: j_ids.append(journal.id) if j_ids: diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 03ac3b87ba0..9dc496c5ec6 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -30,7 +30,7 @@ from tools.translate import _ class account_move_line(osv.osv): _inherit = 'account.move.line' - def _unreconciled(self, cr, uid, ids, prop, unknow_none, context): + def _unreconciled(self, cr, uid, ids, prop, unknow_none, context=None): res = {} for line in self.browse(cr, uid, ids, context=context): res[line.id] = line.debit - line.credit @@ -49,16 +49,19 @@ account_move_line() class account_voucher(osv.osv): - def _get_type(self, cr, uid, ids, context={}): + def _get_type(self, cr, uid, ids, context=None): + if context is None: context = {} return context.get('type', False) - def _get_period(self, cr, uid, context={}): + def _get_period(self, cr, uid, context=None): + if context is None: context = {} if context.get('period_id', False): return context.get('period_id') periods = self.pool.get('account.period').find(cr, uid) return periods and periods[0] or False - def _get_journal(self, cr, uid, context={}): + def _get_journal(self, cr, uid, context=None): + if context is None: context = {} journal_pool = self.pool.get('account.journal') if context.get('journal_id', False): return context.get('journal_id') @@ -71,7 +74,8 @@ class account_voucher(osv.osv): res = journal_pool.search(cr, uid, [('type', '=', ttype)], limit=1) return res and res[0] or False - def _get_tax(self, cr, uid, context={}): + def _get_tax(self, cr, uid, context=None): + if context is None: context = {} journal_pool = self.pool.get('account.journal') journal_id = context.get('journal_id', False) if not journal_id: @@ -83,39 +87,45 @@ class account_voucher(osv.osv): if not journal_id: return False - journal = journal_pool.browse(cr, uid, journal_id) + journal = journal_pool.browse(cr, uid, journal_id, context=context) account_id = journal.default_credit_account_id or journal.default_debit_account_id if account_id and account_id.tax_ids: tax_id = account_id.tax_ids[0].id return tax_id return False - def _get_currency(self, cr, uid, context): + def _get_currency(self, cr, uid, context=None): + if context is None: context = {} journal_pool = self.pool.get('account.journal') journal_id = context.get('journal_id', False) if journal_id: - journal = journal_pool.browse(cr, uid, journal_id) + journal = journal_pool.browse(cr, uid, journal_id, context=context) # currency_id = journal.company_id.currency_id.id if journal.currency: return journal.currency.id return False - def _get_partner(self, cr, uid, context={}): + def _get_partner(self, cr, uid, context=None): + if context is None: context = {} return context.get('partner_id', False) - def _get_reference(self, cr, uid, context={}): + def _get_reference(self, cr, uid, context=None): + if context is None: context = {} return context.get('reference', False) - def _get_narration(self, cr, uid, context={}): + def _get_narration(self, cr, uid, context=None): + if context is None: context = {} return context.get('narration', False) def name_get(self, cr, uid, ids, context=None): if not ids: return [] + if context is None: context = {} return [(r['id'], (str("%.2f" % r['amount']) or '')) for r in self.read(cr, uid, ids, ['amount'], context, load='_classic_write')] def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False): mod_obj = self.pool.get('ir.model.data') + if context is None: context = {} if not view_id and context.get('invoice_type', False): if context.get('invoice_type', False) in ('out_invoice', 'out_refund'): result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_receipt_form') @@ -232,14 +242,15 @@ class account_voucher(osv.osv): 'comment': 'Write-Off', } - def compute_tax(self, cr, uid, ids, context={}): + def compute_tax(self, cr, uid, ids, context=None): tax_pool = self.pool.get('account.tax') partner_pool = self.pool.get('res.partner') position_pool = self.pool.get('account.fiscal.position') voucher_line_pool = self.pool.get('account.voucher.line') voucher_pool = self.pool.get('account.voucher') + if context is None: context = {} - for voucher in voucher_pool.browse(cr, uid, ids, context): + for voucher in voucher_pool.browse(cr, uid, ids, context=context): voucher_amount = 0.0 for line in voucher.line_ids: voucher_amount += line.untax_amount or line.amount @@ -250,10 +261,10 @@ class account_voucher(osv.osv): self.write(cr, uid, [voucher.id], {'amount':voucher_amount, 'tax_amount':0.0}) continue - tax = [tax_pool.browse(cr, uid, voucher.tax_id.id)] - partner = partner_pool.browse(cr, uid, voucher.partner_id.id) or False + tax = [tax_pool.browse(cr, uid, voucher.tax_id.id, context=context)] + partner = partner_pool.browse(cr, uid, voucher.partner_id.id, context=context) or False taxes = position_pool.map_tax(cr, uid, partner and partner.property_account_position or False, tax) - tax = tax_pool.browse(cr, uid, taxes) + tax = tax_pool.browse(cr, uid, taxes, context=context) total = voucher_amount total_tax = 0.0 @@ -277,7 +288,7 @@ class account_voucher(osv.osv): self.write(cr, uid, [voucher.id], {'amount':total, 'tax_amount':total_tax}) return True - def onchange_price(self, cr, uid, ids, line_ids, tax_id, partner_id=False, context={}): + def onchange_price(self, cr, uid, ids, line_ids, tax_id, partner_id=False, context=None): tax_pool = self.pool.get('account.tax') partner_pool = self.pool.get('res.partner') position_pool = self.pool.get('account.fiscal.position') @@ -299,11 +310,11 @@ class account_voucher(osv.osv): total = voucher_total total_tax = 0.0 if tax_id: - tax = [tax_pool.browse(cr, uid, tax_id)] + tax = [tax_pool.browse(cr, uid, tax_id, context=context)] if partner_id: - partner = partner_pool.browse(cr, uid, partner_id) or False + partner = partner_pool.browse(cr, uid, partner_id, context=context) or False taxes = position_pool.map_tax(cr, uid, partner and partner.property_account_position or False, tax) - tax = tax_pool.browse(cr, uid, taxes) + tax = tax_pool.browse(cr, uid, taxes, context=context) if not tax[0].price_include: for tax_line in tax_pool.compute_all(cr, uid, tax, voucher_total, 1).get('taxes', []): @@ -332,7 +343,7 @@ class account_voucher(osv.osv): }) return {'value':default} - def onchange_journal_voucher(self, cr, uid, ids, line_ids=False, tax_id=False, price=0.0, partner_id=False, journal_id=False, ttype=False, context={}): + def onchange_journal_voucher(self, cr, uid, ids, line_ids=False, tax_id=False, price=0.0, partner_id=False, journal_id=False, ttype=False, context=None): """price Returns a dict that contains new values and context @@ -352,8 +363,8 @@ class account_voucher(osv.osv): partner_pool = self.pool.get('res.partner') journal_pool = self.pool.get('account.journal') - journal = journal_pool.browse(cr, uid, journal_id) - partner = partner_pool.browse(cr, uid, partner_id) + journal = journal_pool.browse(cr, uid, journal_id, context=context) + partner = partner_pool.browse(cr, uid, partner_id, context=context) account_id = False tr_type = False if journal.type in ('sale','sale_refund'): @@ -411,8 +422,8 @@ class account_voucher(osv.osv): line_pool.unlink(cr, uid, line_ids) return default - journal = journal_pool.browse(cr, uid, journal_id) - partner = partner_pool.browse(cr, uid, partner_id) + journal = journal_pool.browse(cr, uid, journal_id, context=context) + partner = partner_pool.browse(cr, uid, partner_id, context=context) account_id = False if journal.type in ('sale','sale_refund'): account_id = partner.property_account_receivable.id @@ -441,7 +452,7 @@ class account_voucher(osv.osv): else: ids = context['move_line_ids'] ids.reverse() - moves = move_line_pool.browse(cr, uid, ids) + moves = move_line_pool.browse(cr, uid, ids, context=context) company_currency = journal.company_id.currency_id.id if company_currency != currency_id and ttype == 'payment': @@ -496,7 +507,7 @@ class account_voucher(osv.osv): return default - def onchange_date(self, cr, user, ids, date, context={}): + def onchange_date(self, cr, user, ids, date, context=None): """ @param date: latest value from user input for field date @param args: other arguments @@ -513,11 +524,11 @@ class account_voucher(osv.osv): } } - def onchange_journal(self, cr, uid, ids, journal_id, line_ids, tax_id, partner_id, context={}): + def onchange_journal(self, cr, uid, ids, journal_id, line_ids, tax_id, partner_id, context=None): if not journal_id: return False journal_pool = self.pool.get('account.journal') - journal = journal_pool.browse(cr, uid, journal_id) + journal = journal_pool.browse(cr, uid, journal_id, context=context) account_id = journal.default_credit_account_id or journal.default_debit_account_id tax_id = False if account_id and account_id.tax_ids: @@ -535,18 +546,18 @@ class account_voucher(osv.osv): self.action_move_line_create(cr, uid, ids, context=context) return True - def action_cancel_draft(self, cr, uid, ids, context={}): + def action_cancel_draft(self, cr, uid, ids, context=None): wf_service = netsvc.LocalService("workflow") for voucher_id in ids: wf_service.trg_create(uid, 'account.voucher', voucher_id, cr) self.write(cr, uid, ids, {'state':'draft'}) return True - def cancel_voucher(self, cr, uid, ids, context={}): + def cancel_voucher(self, cr, uid, ids, context=None): reconcile_pool = self.pool.get('account.move.reconcile') move_pool = self.pool.get('account.move') - for voucher in self.browse(cr, uid, ids): + for voucher in self.browse(cr, uid, ids, context=context): recs = [] for line in voucher.move_ids: if line.reconcile_id: @@ -600,14 +611,14 @@ class account_voucher(osv.osv): terms = term_pool.compute(cr, uid, term_id, amount) return terms return False - if not context: + if context is None: context = {} move_pool = self.pool.get('account.move') move_line_pool = self.pool.get('account.move.line') currency_pool = self.pool.get('res.currency') tax_obj = self.pool.get('account.tax') seq_obj = self.pool.get('ir.sequence') - for inv in self.browse(cr, uid, ids): + for inv in self.browse(cr, uid, ids, context=context): if inv.move_id: continue if inv.number: @@ -787,7 +798,7 @@ class account_voucher_line(osv.osv): def _compute_balance(self, cr, uid, ids, name, args, context=None): currency_pool = self.pool.get('res.currency') rs_data = {} - for line in self.browse(cr, uid, ids): + for line in self.browse(cr, uid, ids, context=context): res = {} company_currency = line.voucher_id.journal_id.company_id.currency_id.id voucher_currency = line.voucher_id.currency_id.id @@ -827,7 +838,7 @@ class account_voucher_line(osv.osv): 'name': '' } - def onchange_move_line_id(self, cr, user, ids, move_line_id, context={}): + def onchange_move_line_id(self, cr, user, ids, move_line_id, context=None): """ Returns a dict that contains new values and context @@ -862,6 +873,8 @@ class account_voucher_line(osv.osv): @return: Returns a dict that contains default values for fields """ + if context is None: + context = {} journal_id = context.get('journal_id', False) partner_id = context.get('partner_id', False) journal_pool = self.pool.get('account.journal') @@ -869,7 +882,7 @@ class account_voucher_line(osv.osv): values = super(account_voucher_line, self).default_get(cr, user, fields_list, context=context) if (not journal_id) or ('account_id' not in fields_list): return values - journal = journal_pool.browse(cr, user, journal_id) + journal = journal_pool.browse(cr, user, journal_id, context=context) account_id = False ttype = 'cr' if journal.type in ('sale', 'sale_refund'): @@ -898,7 +911,7 @@ class account_bank_statement(osv.osv): def button_cancel(self, cr, uid, ids, context=None): voucher_obj = self.pool.get('account.voucher') - for st in self.browse(cr, uid, ids, context): + for st in self.browse(cr, uid, ids, context=context): voucher_ids = [] for line in st.line_ids: if line.voucher_id: @@ -958,7 +971,7 @@ class account_bank_statement_line(osv.osv): def unlink(self, cr, uid, ids, context=None): voucher_obj = self.pool.get('account.voucher') - statement_line = self.browse(cr, uid, ids, context) + statement_line = self.browse(cr, uid, ids, context=context) unlink_ids = [] for st_line in statement_line: if st_line.voucher_id: diff --git a/addons/account_voucher/wizard/account_statement_from_invoice.py b/addons/account_voucher/wizard/account_statement_from_invoice.py index 9b6400b15a9..fa1a66e0135 100644 --- a/addons/account_voucher/wizard/account_statement_from_invoice.py +++ b/addons/account_voucher/wizard/account_statement_from_invoice.py @@ -35,7 +35,8 @@ class account_statement_from_invoice_lines(osv.osv_memory): } def populate_statement(self, cr, uid, ids, context=None): - + if context is None: + context = {} statement_id = context.get('statement_id', False) if not statement_id: return {} @@ -134,7 +135,8 @@ class account_statement_from_invoice(osv.osv_memory): } def search_invoices(self, cr, uid, ids, context=None): - + if context is None: + context = {} line_obj = self.pool.get('account.move.line') statement_obj = self.pool.get('account.bank.statement') journal_obj = self.pool.get('account.journal') diff --git a/addons/account_voucher/wizard/account_voucher_unreconcile.py b/addons/account_voucher/wizard/account_voucher_unreconcile.py index 69aa6e1181d..2bfdfd1ecf8 100644 --- a/addons/account_voucher/wizard/account_voucher_unreconcile.py +++ b/addons/account_voucher/wizard/account_voucher_unreconcile.py @@ -41,7 +41,7 @@ class account_voucher_unreconcile(osv.osv_memory): voucher_pool = self.pool.get('account.voucher') reconcile_pool = self.pool.get('account.move.reconcile') if context.get('active_id'): - voucher = voucher_pool.browse(cr, uid, context.get('active_id'), context) + voucher = voucher_pool.browse(cr, uid, context.get('active_id'), context=context) recs = [] for line in voucher.move_ids: if line.reconcile_id: diff --git a/addons/analytic/analytic.py b/addons/analytic/analytic.py index 58f2357d452..e1c17cfacd5 100644 --- a/addons/analytic/analytic.py +++ b/addons/analytic/analytic.py @@ -183,7 +183,7 @@ class account_analytic_account(osv.osv): def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=100): if not args: args=[] - if not context: + if context is None: context={} account = self.search(cr, uid, [('code', '=', name)]+args, limit=limit, context=context) if not account: diff --git a/addons/auction/auction.py b/addons/auction/auction.py index e14799c9c7c..983bdeb0144 100644 --- a/addons/auction/auction.py +++ b/addons/auction/auction.py @@ -57,18 +57,16 @@ class auction_dates(osv.osv): return res def name_get(self, cr, uid, ids, context=None): - if not context: - context={} if not ids: return [] - reads = self.read(cr, uid, ids, ['name', 'auction1'], context) + reads = self.read(cr, uid, ids, ['name', 'auction1'], context=context) name = [(r['id'], '['+r['auction1']+'] '+ r['name']) for r in reads] return name - def _get_invoice(self, cr, uid, ids, name, arg, context={}): + def _get_invoice(self, cr, uid, ids, name, arg, context=None): lots_obj = self.pool.get('auction.lots') result = {} - for data in self.browse(cr, uid, ids): + for data in self.browse(cr, uid, ids, context=context): buyer_inv_ids = [] seller_inv_ids = [] result[data.id] = { @@ -76,7 +74,7 @@ class auction_dates(osv.osv): 'buyer_invoice_history': seller_inv_ids, } lots_ids = lots_obj.search(cr, uid, [('auction_id','=',data.id)]) - for lot in lots_obj.browse(cr, uid, lots_ids): + for lot in lots_obj.browse(cr, uid, lots_ids, context=context): if lot.ach_inv_id: buyer_inv_ids.append(lot.ach_inv_id.id) if lot.sel_inv_id: @@ -120,8 +118,6 @@ class auction_dates(osv.osv): RETURN: True """ - if not context: - context={} lots_obj = self.pool.get('auction.lots') lots_ids = lots_obj.search(cr, uid, [('auction_id', 'in', ids), ('state', '=', 'draft'), ('obj_price', '>', 0)]) lots_obj.lots_invoice(cr, uid, lots_ids, {}, None) @@ -194,12 +190,10 @@ class aie_category(osv.osv): } def name_get(self, cr, uid, ids, context=None): - if not context: - context = {} res = [] if not ids: return res - reads = self.read(cr, uid, ids, ['name', 'parent_id'], context) + reads = self.read(cr, uid, ids, ['name', 'parent_id'], context=context) for record in reads: name = record['name'] if record['parent_id']: @@ -229,8 +223,6 @@ auction_lot_category() # Lots #---------------------------------------------------------- def _type_get(self, cr, uid, context=None): - if not context: - context = {} obj = self.pool.get('auction.lot.category') ids = obj.search(cr, uid, []) res = obj.read(cr, uid, ids, ['name'], context) @@ -245,23 +237,15 @@ class auction_lots(osv.osv): _description=__doc__ def button_not_bought(self, cr, uid, ids, context=None): - if not context: - context={} return self.write(cr, uid, ids, {'state':'unsold'}) def button_taken_away(self, cr, uid, ids, context=None): - if not context: - context={} return self.write(cr, uid, ids, {'state':'taken_away', 'ach_emp': True}) def button_unpaid(self, cr, uid, ids, context=None): - if not context: - context={} return self.write(cr, uid, ids, {'state':'draft'}) def button_bought(self, cr, uid, ids, context=None): - if not context: - context={} return self.write(cr, uid, ids, {'state':'sold'}) def _getprice(self, cr, uid, ids, fields, args, context=None): @@ -271,12 +255,10 @@ class auction_lots(osv.osv): @param context: A standard dictionary for contextual values @return: Dictionary of function fields value. """ - if not context: - context = {} res = {} account_analytic_line_obj = self.pool.get('account.analytic.line') - lots = self.browse(cr, uid, ids, context) + lots = self.browse(cr, uid, ids, context=context) pt_tax = self.pool.get('account.tax') for lot in lots: taxes = [] @@ -362,8 +344,6 @@ class auction_lots(osv.osv): return res def onchange_obj_ret(self, cr, uid, ids, obj_ret, context=None): - if not context: - context={} if obj_ret: return {'value': {'obj_price': 0}} return {} @@ -430,16 +410,12 @@ class auction_lots(osv.osv): } def name_get(self, cr, user, ids, context=None): - if not context: - context={} if not ids: return [] result = [ (r['id'], str(r['obj_num'])+' - '+r['name']) for r in self.read(cr, user, ids, ['name', 'obj_num'])] return result def name_search(self, cr, user, name, args=None, operator='ilike', context=None): - if not context: - context={} if not args: args = [] ids = [] @@ -583,14 +559,12 @@ class auction_lots(osv.osv): def buyer_proforma(self, cr, uid, ids, context=None): - if not context: - context={} invoices = {} inv_ref = self.pool.get('account.invoice') res_obj = self.pool.get('res.partner') inv_line_obj = self.pool.get('account.invoice.line') wf_service = netsvc.LocalService('workflow') - for lot in self.browse(cr, uid, ids, context): + for lot in self.browse(cr, uid, ids, context=context): if not lot.obj_price>0: continue if not lot.ach_uid.id: @@ -643,12 +617,10 @@ class auction_lots(osv.osv): """ # use each list of object in turn invoices = {} - if not context: - context={} inv_ref=self.pool.get('account.invoice') inv_line_obj = self.pool.get('account.invoice.line') wf_service = netsvc.LocalService('workflow') - for lot in self.browse(cr, uid, ids, context): + for lot in self.browse(cr, uid, ids, context=context): if not lot.auction_id.id: continue if lot.bord_vnd_id.id in invoices: @@ -684,7 +656,7 @@ class auction_lots(osv.osv): } inv_line_obj.create(cr, uid, inv_line, context) inv_ref.button_compute(cr, uid, invoices.values()) - for inv in inv_ref.browse(cr, uid, invoices.values(), context): + for inv in inv_ref.browse(cr, uid, invoices.values(), context=context): inv_ref.write(cr, uid, [inv.id], { 'check_total': inv.amount_total }) diff --git a/addons/auction/report/huissier.py b/addons/auction/report/huissier.py index 2718e8bedc2..1b5f7cc68d7 100644 --- a/addons/auction/report/huissier.py +++ b/addons/auction/report/huissier.py @@ -31,9 +31,9 @@ class report_custom(report_rml): def __init__(self, name, table, tmpl, xsl): report_rml.__init__(self, name, table, tmpl, xsl) - def create_xml(self,cr, uid, ids, datas, context={}): + def create_xml(self,cr, uid, ids, datas, context=None): pool= pooler.get_pool(cr.dbname) - lots = pool.get('auction.lots').browse(cr, uid, ids) + lots = pool.get('auction.lots').browse(cr, uid, ids, context=context) auction = lots[0].auction_id xml = ''' diff --git a/addons/auction/report/report_auction.py b/addons/auction/report/report_auction.py index 25cdab88e89..406aedbed89 100644 --- a/addons/auction/report/report_auction.py +++ b/addons/auction/report/report_auction.py @@ -28,8 +28,6 @@ import time import tools def _type_get(self, cr, uid, context=None): - if not context: - context = {} obj = self.pool.get('auction.lot.category') ids = obj.search(cr, uid, []) res = obj.read(cr, uid, ids, ['name'], context) diff --git a/addons/auction/report/total.py b/addons/auction/report/total.py index a5b937c3ad8..a198a7c4416 100644 --- a/addons/auction/report/total.py +++ b/addons/auction/report/total.py @@ -35,7 +35,7 @@ class report_custom(report_rml): def __init__(self, name, table, tmpl, xsl): report_rml.__init__(self, name, table, tmpl, xsl) - def create_xml(self, cr, uid, ids, datas, context={}): + def create_xml(self, cr, uid, ids, datas, context=None): service = netsvc.LocalService("object_proxy") lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', ids, ['obj_price','ach_login','obj_comm','lot_est1','lot_est2','bord_vnd_id','ach_emp','auction_id']) diff --git a/addons/auction/wizard/auction_aie_send.py b/addons/auction/wizard/auction_aie_send.py index f11c9388021..7c904cf850b 100644 --- a/addons/auction/wizard/auction_aie_send.py +++ b/addons/auction/wizard/auction_aie_send.py @@ -34,7 +34,7 @@ class auction_lots_send_aie(osv.osv_memory): _name = 'auction.lots.send.aie' _descritption = 'Send to website' - def _date_get(self, cr, uid, context={}): + def _date_get(self, cr, uid, context=None): selection = context and context.get('selection') if selection: return [('','')] + selection @@ -50,7 +50,7 @@ class auction_lots_send_aie(osv.osv_memory): 'img_send': fields.boolean('Send Image also ?'), } - def default_get(self, cr, uid, fields, context): + def default_get(self, cr, uid, fields, context=None): """ To get default values for the object. @param self: The object pointer. @@ -60,6 +60,8 @@ class auction_lots_send_aie(osv.osv_memory): @param context: A standard dictionary @return: A dictionary which of fields with values. """ + if context is None: + context = {} res = super(auction_lots_send_aie, self).default_get(cr, uid, fields, context=context) if 'uname' in fields and context.get('uname',False): res['uname'] = context.get('uname') @@ -147,7 +149,9 @@ class auction_lots_send_aie(osv.osv_memory): fname = datas[0]['name'] self._photo_bin_send(uname, passwd, ref, did, fname, bin) - def get_dates(self, cr, uid, ids, context={}): + def get_dates(self, cr, uid, ids, context=None): + if context is None: + context = {} import httplib data_obj = self.pool.get('ir.model.data') conn = httplib.HTTPConnection('www.auction-in-europe.com') @@ -174,14 +178,16 @@ class auction_lots_send_aie(osv.osv_memory): 'context': context } - def _send(self, cr, uid, ids, context={}): + def _send(self, cr, uid, ids, context=None): import pickle, thread, sql_db cr.execute('select name,aie_categ from auction_lot_category') vals = dict(cr.fetchall()) cr.close() + if context is None: + context = {} service = netsvc.LocalService("object_proxy") - lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', context['active_ids'], ['obj_num','lot_num','obj_desc','bord_vnd_id','lot_est1','lot_est2','artist_id','lot_type','aie_categ']) + lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', context.get('active_ids',[]), ['obj_num','lot_num','obj_desc','bord_vnd_id','lot_est1','lot_est2','artist_id','lot_type','aie_categ']) lots_ids = [] datas = self.read(cr, uid, ids[0],['uname','login','lang','numerotation','dates']) for l in lots: @@ -211,7 +217,7 @@ class auction_lots_send_aie(osv.osv_memory): thread.start_new_thread(_photos_send, (cr.dbname, uid, datas['uname'], datas['password'],datas['dates'], lots_ids)) return {} - def send_pdf(self, cr, uid, ids, context): + def send_pdf(self, cr, uid, ids, context=None): threaded_calculation = threading.Thread(target=self._send, args=(cr, uid, ids, context)) threaded_calculation.start() return {} diff --git a/addons/auction/wizard/auction_aie_send_result.py b/addons/auction/wizard/auction_aie_send_result.py index 404881b2d6b..5b2b4eca7fd 100644 --- a/addons/auction/wizard/auction_aie_send_result.py +++ b/addons/auction/wizard/auction_aie_send_result.py @@ -32,7 +32,7 @@ class auction_lots_pay(osv.osv_memory): _description = 'Send results to Auction-in-europe.com' - def _date_get(self, cr, uid, context={}): + def _date_get(self, cr, uid, context=None): selection = context and context.get('selection') if selection: return [('','')] + selection @@ -45,7 +45,7 @@ class auction_lots_pay(osv.osv_memory): 'dates': fields.selection(_date_get,'Auction Date'), } - def default_get(self, cr, uid, fields, context): + def default_get(self, cr, uid, fields, context=None): """ To get default values for the object. @param self: The object pointer. @@ -55,6 +55,8 @@ class auction_lots_pay(osv.osv_memory): @param context: A standard dictionary @return: A dictionary which of fields with values. """ + if context is None: + context = {} res = super(auction_lots_pay, self).default_get(cr, uid, fields, context=context) if 'uname' in fields and context.get('uname',False): res['uname'] = context.get('uname') @@ -96,7 +98,9 @@ class auction_lots_pay(osv.osv_memory): return val return post_multipart('auction-in-europe.com', "/bin/catalog_result.cgi", (('uname',uname),('password',passwd),('did',did)),(('file',catalog),)) - def get_dates(self, cr, uid, ids, context): + def get_dates(self, cr, uid, ids, context=None): + if context is None: + context = {} import httplib conn = httplib.HTTPConnection('www.auction-in-europe.com') data_obj = self.pool.get('ir.model.data') @@ -124,7 +128,9 @@ class auction_lots_pay(osv.osv_memory): 'context': context } - def send(self, cr, uid, ids, context): + def send(self, cr, uid, ids, context=None): + if context is None: + context = {} import pickle service = netsvc.LocalService("object_proxy") datas = self.read(cr, uid, ids[0],['uname','password','dates']) diff --git a/addons/auction/wizard/auction_catalog_flagey_report.py b/addons/auction/wizard/auction_catalog_flagey_report.py index b5bff2d2858..03c8236c55c 100644 --- a/addons/auction/wizard/auction_catalog_flagey_report.py +++ b/addons/auction/wizard/auction_catalog_flagey_report.py @@ -27,7 +27,7 @@ class auction_catalog_flagey(osv.osv_memory): _name = 'auction.catalog.flagey' _description = 'Auction Catalog Flagey' - def default_get(self, cr, uid, fields, context): + def default_get(self, cr, uid, fields, context=None): """ To get default values for the object. @param self: The object pointer. @@ -40,7 +40,7 @@ class auction_catalog_flagey(osv.osv_memory): res = super(auction_catalog_flagey, self).default_get(cr, uid, fields, context=context) return res - def view_init(self, cr, uid, fields, context): + def view_init(self, cr, uid, fields, context=None): """ Creates view dynamically, adding fields at runtime, raises exception at the time of initialization of view. @@ -53,15 +53,17 @@ class auction_catalog_flagey(osv.osv_memory): """ lots_obj = self.pool.get('auction.lots') auc_dates_obj = self.pool.get('auction.dates') + if context is None: + context = {} current_auction = auc_dates_obj.browse(cr, uid, context.get('active_ids', [])) v_lots = lots_obj.search(cr, uid, [('auction_id','=',current_auction.id)]) - v_ids = lots_obj.browse(cr, uid, v_lots) + v_ids = lots_obj.browse(cr, uid, v_lots, context=context) for ab in v_ids: if not ab.auction_id : raise osv.except_osv(_('Error!'), _('No Lots belong to this Auction Date')) pass - def print_report(self, cr, uid, ids, context): + def print_report(self, cr, uid, ids, context=None): """ Prints auction catalog flagey report. @param self: The object pointer. @@ -71,6 +73,8 @@ class auction_catalog_flagey(osv.osv_memory): @param context: A standard dictionary @return: Report """ + if context is None: + context = {} datas = {'ids': context.get('active_ids',[])} return { 'type': 'ir.actions.report.xml', diff --git a/addons/auction/wizard/auction_lots_able.py b/addons/auction/wizard/auction_lots_able.py index 8ddeeca8055..369d762727a 100644 --- a/addons/auction/wizard/auction_lots_able.py +++ b/addons/auction/wizard/auction_lots_able.py @@ -31,14 +31,16 @@ class auction_lots_able(osv.osv_memory): _name = "auction.lots.able" _description = "Lots able" - def confirm_able(self, cr, uid, ids, context={}): + def confirm_able(self, cr, uid, ids, context=None): """ This function Update auction lots object and set taken away field true. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of auction lots able’s IDs. """ - self.pool.get('auction.lots').write(cr, uid, context['active_ids'], {'ach_emp':True}) + if context is None: + context = {} + self.pool.get('auction.lots').write(cr, uid, context.get('active_ids', []), {'ach_emp':True}) return {} auction_lots_able() diff --git a/addons/auction/wizard/auction_lots_auction_move.py b/addons/auction/wizard/auction_lots_auction_move.py index cb19f65172c..97330f922fe 100644 --- a/addons/auction/wizard/auction_lots_auction_move.py +++ b/addons/auction/wizard/auction_lots_auction_move.py @@ -44,13 +44,13 @@ class auction_lots_auction_move(osv.osv_memory): @param uid: the current user’s ID for security checks, @param ids: List of auction lots auction move’s IDs. """ - if not context: + if context is None: context={} auction_bid_line_obj = self.pool.get('auction.bid_line') auction_lot_history_obj = self.pool.get('auction.lot.history') auction_lots_obj = self.pool.get('auction.lots') rec_ids = auction_lots_obj.browse(cr, uid, context.get('active_ids', [])) - for current in self.browse(cr, uid, ids, context): + for current in self.browse(cr, uid, ids, context=context): if not (current.auction_id and len(context.get('active_ids', []))): return {} diff --git a/addons/auction/wizard/auction_lots_buyer_map.py b/addons/auction/wizard/auction_lots_buyer_map.py index 98d26b83b4f..e50f11fd1ec 100644 --- a/addons/auction/wizard/auction_lots_buyer_map.py +++ b/addons/auction/wizard/auction_lots_buyer_map.py @@ -32,7 +32,7 @@ class wiz_auc_lots_buyer_map(osv.osv_memory): 'ach_uid': fields.many2one('res.partner','Buyer', required=True), } - def default_get(self, cr, uid, fields, context): + def default_get(self, cr, uid, fields, context=None): """ To get default values for the object. @param self: The object pointer. @@ -42,14 +42,16 @@ class wiz_auc_lots_buyer_map(osv.osv_memory): @param context: A standard dictionary @return: A dictionary which of fields with values. """ - res = super(wiz_auc_lots_buyer_map,self).default_get(cr, uid, fields, context) + if context is None: + context = {} + res = super(wiz_auc_lots_buyer_map,self).default_get(cr, uid, fields, context=context) auction_lots_obj = self.pool.get('auction.lots') lots_ids = auction_lots_obj.search(cr, uid, [('ach_uid', '=', ''), ('ach_login', '!=', '')]) - for rec in auction_lots_obj.browse(cr, uid, lots_ids, context): + for rec in auction_lots_obj.browse(cr, uid, lots_ids, context=context): if (not rec.ach_uid or not rec.ach_login): - res.update(self._start(cr, uid, context.get('active_ids', []), context)) + res.update(self._start(cr, uid, context.get('active_ids', []), context=context)) return res - res.update(self._start(cr, uid, context.get('active_ids', []), context)) + res.update(self._start(cr, uid, context.get('active_ids', []), context=context)) return res def _start(self, cr, uid, ids, context=None): @@ -62,10 +64,8 @@ class wiz_auc_lots_buyer_map(osv.osv_memory): @param context: A standard dictionary @return: login field from current record. """ - if not context: - context={} lots_obj = self.pool.get('auction.lots') - for rec in lots_obj.browse(cr, uid, ids, context): + for rec in lots_obj.browse(cr, uid, ids, context=context): if (len(ids)==1) and (not rec.ach_uid and not rec.ach_login): raise osv.except_osv(_('Error'), _('No buyer is set for this lot.')) if not rec.ach_uid and rec.ach_login: @@ -81,13 +81,13 @@ class wiz_auc_lots_buyer_map(osv.osv_memory): @param ids: List of ids @param context: A standard dictionary """ - if not context: + if context is None: context={} rec_ids = context and context.get('active_ids',[]) or [] assert rec_ids, _('Active IDs not Found') lots_obj = self.pool.get('auction.lots') - for current in self.browse(cr, uid, ids): - for lots in lots_obj.browse(cr, uid, rec_ids, context): + for current in self.browse(cr, uid, ids, context=context): + for lots in lots_obj.browse(cr, uid, rec_ids, context=context): if lots.ach_login == current.ach_login: lots_obj.write(cr, uid, [lots.id], {'ach_uid': current.ach_uid.id}, context=context) return {} @@ -102,7 +102,7 @@ class wiz_auc_lots_buyer_map(osv.osv_memory): @param context: A standard dictionary @return: New arch of view. """ - if not context: + if context is None: context={} record_ids = context and context.get('active_ids', []) or [] res = super(wiz_auc_lots_buyer_map, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False) @@ -111,7 +111,7 @@ class wiz_auc_lots_buyer_map(osv.osv_memory): lots_obj = self.pool.get('auction.lots') if record_ids: try: - for lots in lots_obj.browse(cr, uid, record_ids): + for lots in lots_obj.browse(cr, uid, record_ids, context=context): if lots.ach_uid: res['arch'] = """
diff --git a/addons/auction/wizard/auction_lots_cancel.py b/addons/auction/wizard/auction_lots_cancel.py index 3d443a98e15..62313315bd9 100644 --- a/addons/auction/wizard/auction_lots_cancel.py +++ b/addons/auction/wizard/auction_lots_cancel.py @@ -40,11 +40,11 @@ class auction_lots_cancel(osv.osv): @param context: A standard dictionary @return: """ - if not context: + if context is None: context={} lots_obj = self.pool.get('auction.lots') invoice_obj = self.pool.get('account.invoice') - lot = lots_obj.browse(cr, uid, context.get('active_id', False), context) + lot = lots_obj.browse(cr, uid, context.get('active_id', False), context=context) if lot.ach_inv_id: supplier_refund_inv_id = invoice_obj.refund(cr, uid, [lot.ach_inv_id.id]) if lot.sel_inv_id: diff --git a/addons/auction/wizard/auction_lots_enable.py b/addons/auction/wizard/auction_lots_enable.py index 65cb0c4d49e..ed6b8950d2e 100644 --- a/addons/auction/wizard/auction_lots_enable.py +++ b/addons/auction/wizard/auction_lots_enable.py @@ -28,14 +28,16 @@ class auction_lots_enable(osv.osv_memory): 'confirm_en':fields.integer('Catalog Number') } - def confirm_enable(self, cr, uid, ids, context={}): + def confirm_enable(self, cr, uid, ids, context=None): """ This function Update auction lots object and set taken away field False. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of auction lots enable’s IDs. """ - self.pool.get('auction.lots').write(cr, uid, context['active_id'], {'ach_emp':False}) + if context is None: + context = {} + self.pool.get('auction.lots').write(cr, uid, context.get('active_id',False), {'ach_emp':False}) return {} auction_lots_enable() diff --git a/addons/auction/wizard/auction_lots_invoice.py b/addons/auction/wizard/auction_lots_invoice.py index 89d66f5f2d5..66bb5e42f2b 100644 --- a/addons/auction/wizard/auction_lots_invoice.py +++ b/addons/auction/wizard/auction_lots_invoice.py @@ -36,7 +36,7 @@ class auction_lots_invoice(osv.osv_memory): 'number': fields.integer('Invoice Number'), } - def default_get(self, cr, uid, fields, context={}): + def default_get(self, cr, uid, fields, context=None): """ To get default values for the object. @param self: The object pointer. @@ -46,6 +46,8 @@ class auction_lots_invoice(osv.osv_memory): @param context: A standard dictionary @return: A dictionary which of fields with values. """ + if context is None: + context = {} res = super(auction_lots_invoice, self).default_get(cr, uid, fields, context=context) service = netsvc.LocalService("object_proxy") lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', context.get('active_ids', [])) @@ -78,7 +80,7 @@ class auction_lots_invoice(osv.osv_memory): #TODO: recuperer id next invoice (de la sequence)??? invoice_number = False - for lot in self.pool.get('auction.lots').browse(cr, uid, context.get('active_ids', [])): + for lot in self.pool.get('auction.lots').browse(cr, uid, context.get('active_ids', []), context=context): if 'objects' in fields: res.update({'objects':len(context.get('active_ids', []))}) if 'amount' in fields: @@ -93,7 +95,7 @@ class auction_lots_invoice(osv.osv_memory): res.update({'number':invoice_number}) return res - def print_report(self, cr, uid, ids, context={}): + def print_report(self, cr, uid, ids, context=None): """ Create an invoice report. @param cr: the current row, from the database cursor. @@ -101,6 +103,8 @@ class auction_lots_invoice(osv.osv_memory): @param ids: List of Auction lots make invoice buyer’s IDs @return: dictionary of account invoice form. """ + if context is None: + context = {} service = netsvc.LocalService("object_proxy") datas = {'ids' : context.get('active_ids',[])} res = self.read(cr, uid, ids, ['number','ach_uid']) diff --git a/addons/auction/wizard/auction_lots_make_invoice.py b/addons/auction/wizard/auction_lots_make_invoice.py index 5d32e644283..3a87a202b74 100644 --- a/addons/auction/wizard/auction_lots_make_invoice.py +++ b/addons/auction/wizard/auction_lots_make_invoice.py @@ -50,11 +50,11 @@ class auction_lots_make_invoice(osv.osv_memory): @param context: A standard dictionary @return: A dictionary which of fields with values. """ - if not context: + if context is None: context={} res = super(auction_lots_make_invoice, self).default_get(cr, uid, fields, context=context) lots_obj = self.pool.get('auction.lots') - for lot in lots_obj.browse(cr, uid, context.get('active_ids', [])): + for lot in lots_obj.browse(cr, uid, context.get('active_ids', []), context=context): if 'amount' in fields: res.update({'amount': lot.seller_price}) if 'objects' in fields: @@ -69,13 +69,13 @@ class auction_lots_make_invoice(osv.osv_memory): @param ids: List of Auction lots make invoice’s IDs @return: dictionary of account invoice form. """ - if not context: + if context is None: context={} order_obj = self.pool.get('auction.lots') mod_obj = self.pool.get('ir.model.data') result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter') id = mod_obj.read(cr, uid, result, ['res_id']) - lots_ids = order_obj.seller_trans_create(cr, uid, context.get('active_ids', []), context) + lots_ids = order_obj.seller_trans_create(cr, uid, context.get('active_ids', []), context=context) return { 'domain': "[('id','in', ["+','.join(map(str, lots_ids))+"])]", 'name': 'Seller invoices', diff --git a/addons/auction/wizard/auction_lots_make_invoice_buyer.py b/addons/auction/wizard/auction_lots_make_invoice_buyer.py index 5eb9a649556..dc39ccbb717 100644 --- a/addons/auction/wizard/auction_lots_make_invoice_buyer.py +++ b/addons/auction/wizard/auction_lots_make_invoice_buyer.py @@ -45,11 +45,11 @@ class auction_lots_make_invoice_buyer(osv.osv_memory): @param context: A standard dictionary @return: A dictionary which of fields with values. """ - if not context: + if context is None: context={} res = super(auction_lots_make_invoice_buyer, self).default_get(cr, uid, fields, context=context) lots_obj=self.pool.get('auction.lots') - for lot in lots_obj.browse(cr, uid, context.get('active_ids', [])): + for lot in lots_obj.browse(cr, uid, context.get('active_ids', []), context=context): if 'amount' in fields: res.update({'amount': lot.buyer_price}) if 'buyer_id' in fields: @@ -58,7 +58,7 @@ class auction_lots_make_invoice_buyer(osv.osv_memory): res.update({'objects': len(context.get('active_ids', []))}) return res - def makeInvoices(self, cr, uid, ids, context): + def makeInvoices(self, cr, uid, ids, context=None): """ Create an invoice for selected lots (IDS) to BUYER_ID . @param cr: the current row, from the database cursor. @@ -70,8 +70,8 @@ class auction_lots_make_invoice_buyer(osv.osv_memory): mod_obj = self.pool.get('ir.model.data') result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter') id = mod_obj.read(cr, uid, result, ['res_id']) - lots = order_obj.browse(cr, uid, context.get('active_ids', [])) - for current in self.browse(cr, uid, ids, context): + lots = order_obj.browse(cr, uid, context.get('active_ids', []), context=context) + for current in self.browse(cr, uid, ids, context=context): invoice_number = current.number for lot in lots: up_auction = order_obj.write(cr, uid, [lot.id], {'ach_uid': current.buyer_id.id}) diff --git a/addons/auction/wizard/auction_lots_numerotate.py b/addons/auction/wizard/auction_lots_numerotate.py index 9c41d1d4f70..0712e21565e 100644 --- a/addons/auction/wizard/auction_lots_numerotate.py +++ b/addons/auction/wizard/auction_lots_numerotate.py @@ -38,7 +38,7 @@ class auction_lots_numerotate_per_lot(osv.osv_memory): 'obj_num': fields.integer('Catalog Number', required=True) } - def default_get(self, cr, uid, fields, context): + def default_get(self, cr, uid, fields, context=None): """ To get default values for the object. @param self: The object pointer. @@ -48,13 +48,14 @@ class auction_lots_numerotate_per_lot(osv.osv_memory): @param context: A standard dictionary @return: A dictionary which of fields with values. """ + if context is None: context = {} res = super(auction_lots_numerotate_per_lot, self).default_get(cr, uid, fields, context=context) active_id = context.get('active_id',False) active_model = context.get('active_model') if active_id and (active_model and active_model!='auction.lots'): return res lots_obj = self.pool.get('auction.lots') - lots = lots_obj.browse(cr, uid, active_id) + lots = lots_obj.browse(cr, uid, active_id, context=context) if 'bord_vnd_id' in fields and context.get('bord_vnd_id',False): res['bord_vnd_id'] = context.get('bord_vnd_id') if 'lot_num' in fields and context.get('lot_num',False): @@ -71,7 +72,7 @@ class auction_lots_numerotate_per_lot(osv.osv_memory): res['obj_num'] = lots.obj_num return res - def open_init_form(self, cr, uid, ids, context={}): + def open_init_form(self, cr, uid, ids, context=None): record_ids = context and context.get('active_ids',False) or False assert record_ids, _('Active IDs not Found') data_obj = self.pool.get('ir.model.data') @@ -89,7 +90,7 @@ class auction_lots_numerotate_per_lot(osv.osv_memory): 'context': context } - def numerotate(self, cr, uid, ids, context={}): + def numerotate(self, cr, uid, ids, context=None): record_ids = context and context.get('active_ids',False) or False assert record_ids, _('Active IDs not Found') datas = self.read(cr, uid, ids[0], ['bord_vnd_id','lot_num','obj_num']) @@ -116,7 +117,7 @@ class auction_lots_numerotate_per_lot(osv.osv_memory): 'context': context } - def read_record(self, cr, uid, ids, context={}): + def read_record(self, cr, uid, ids, context=None): record_ids = context and context.get('active_ids',False) or False assert record_ids, _('Active IDs not Found') datas = self.read(cr, uid, ids[0], ['bord_vnd_id','lot_num']) @@ -131,7 +132,7 @@ class auction_lots_numerotate_per_lot(osv.osv_memory): 'lot_est2', 'obj_desc']) return lots_datas[0] - def test_exist(self, cr, uid, ids, context={}): + def test_exist(self, cr, uid, ids, context=None): record_ids = context and context.get('active_ids',False) or False assert record_ids, _('Active IDs not Found') data_obj = self.pool.get('ir.model.data') @@ -167,13 +168,13 @@ class auction_lots_numerotate(osv.osv_memory): 'number': fields.integer('First Number', required=True) } - def numerotate_cont(self, cr, uid, ids, context={}): + def numerotate_cont(self, cr, uid, ids, context=None): record_ids = context and context.get('active_ids',False) or False assert record_ids, _('Active IDs not Found') datas = self.read(cr, uid, ids[0], ['number']) nbr = int(datas['number']) lots_obj = self.pool.get('auction.lots') - rec_ids = lots_obj.browse(cr, uid, record_ids) + rec_ids = lots_obj.browse(cr, uid, record_ids, context=context) for rec_id in rec_ids: lots_obj.write(cr, uid, [rec_id.id], {'obj_num':nbr}) nbr+=1 diff --git a/addons/auction/wizard/auction_lots_sms_send.py b/addons/auction/wizard/auction_lots_sms_send.py index 094ecea1ca2..93faab41275 100644 --- a/addons/auction/wizard/auction_lots_sms_send.py +++ b/addons/auction/wizard/auction_lots_sms_send.py @@ -34,7 +34,7 @@ class auction_lots_sms_send(osv.osv_memory): 'text':fields.text('SMS Message', required=True) } - def sms_send(self, cr, uid, ids, context): + def sms_send(self, cr, uid, ids, context=None): """ to send sms @@ -44,18 +44,18 @@ class auction_lots_sms_send(osv.osv_memory): @param context: A standard dictionary @return: number indicating the acknowledgement """ - + if context is None: context = {} lot_obj = self.pool.get('auction.lots') partner_obj = self.pool.get('res.partner') partner_address_obj = self.pool.get('res.partner.address') - for data in self.read(cr, uid, ids): - lots = lot_obj.read(cr, uid, context['active_ids'], ['obj_num','obj_price','ach_uid']) + for data in self.read(cr, uid, ids, context=context): + lots = lot_obj.read(cr, uid, context.get('active_ids', []), ['obj_num','obj_price','ach_uid']) res = partner_obj.read(cr, uid, [l['ach_uid'][0] for l in lots if l['ach_uid']], ['gsm'], context) nbr = 0 for r in res: add = partner_obj.address_get(cr, uid, [r['id']])['default'] - addr = partner_address_obj.browse(cr, uid, add) + addr = partner_address_obj.browse(cr, uid, add, context=context) to = addr.mobile if to: tools.smssend(data['user'], data['password'], data['app_id'], unicode(data['text'], 'utf-8').encode('latin1'), to) diff --git a/addons/auction/wizard/auction_pay_buy.py b/addons/auction/wizard/auction_pay_buy.py index bf6a85cf74b..dfad93dc759 100644 --- a/addons/auction/wizard/auction_pay_buy.py +++ b/addons/auction/wizard/auction_pay_buy.py @@ -48,11 +48,11 @@ class auction_pay_buy(osv.osv_memory): @param context: A standard dictionary @return: A dictionary which of fields with values. """ - if not context: + if context is None: context={} res = super(auction_pay_buy, self).default_get(cr, uid, fields, context=context) auction_lots_obj= self.pool.get('auction.lots') - for lot in auction_lots_obj.browse(cr, uid, context.get('active_ids', [])): + for lot in auction_lots_obj.browse(cr, uid, context.get('active_ids', []), context=context): if 'amount' in fields: res.update({'amount': lot.buyer_price}) if 'buyer_id' in fields: @@ -61,7 +61,7 @@ class auction_pay_buy(osv.osv_memory): res.update({'total': lot.buyer_price}) return res - def pay_and_reconcile(self, cr, uid, ids, context): + def pay_and_reconcile(self, cr, uid, ids, context=None): """ Pay and Reconcile @param cr: the current row, from the database cursor. @@ -70,15 +70,16 @@ class auction_pay_buy(osv.osv_memory): @param context: A standard dictionary @return: """ + if context is None: context = {} lot_obj = self.pool.get('auction.lots') bank_statement_line_obj = self.pool.get('account.bank.statement.line') - for datas in self.read(cr, uid, ids): + for datas in self.read(cr, uid, ids, context=context): if not abs(datas['total'] - (datas['amount'] + datas['amount2'] + datas['amount3'])) <0.01: rest = datas['total'] - (datas['amount'] + datas['amount2'] + datas['amount3']) raise osv.except_osv(_('Payment aborted !'), _('You should pay all the total: "%.2f" are missing to accomplish the payment.') %(round(rest, 2))) - lots = lot_obj.browse(cr, uid, context['active_ids'], context) + lots = lot_obj.browse(cr, uid, context.get('active_ids', []), context=context) for lot in lots: if datas['buyer_id']: lot_obj.write(cr, uid, [lot.id], {'ach_uid': datas['buyer_id']}) diff --git a/addons/auction/wizard/auction_pay_sel.py b/addons/auction/wizard/auction_pay_sel.py index a6444f8d646..7265a4e7f98 100644 --- a/addons/auction/wizard/auction_pay_sel.py +++ b/addons/auction/wizard/auction_pay_sel.py @@ -33,7 +33,7 @@ class auction_pay_sel(osv.osv_memory): 'period_id':fields.many2one('account.period', 'Period', required=True), } - def pay_and_reconcile(self, cr, uid, ids, context): + def pay_and_reconcile(self, cr, uid, ids, context=None): """ Pay and Reconcile @param cr: the current row, from the database cursor. @@ -42,9 +42,11 @@ class auction_pay_sel(osv.osv_memory): @param context: A standard dictionary @return: """ - lot = self.pool.get('auction.lots').browse(cr, uid, context['active_id'], context) + if context is None: + context = {} + lot = self.pool.get('auction.lots').browse(cr, uid, context['active_id'], context=context) invoice_obj = self.pool.get('account.invoice') - for datas in self.read(cr, uid, ids): + for datas in self.read(cr, uid, ids, context=context): account_id = datas.get('writeoff_acc_id', False) period_id = datas.get('period_id', False) journal_id = datas.get('journal_id', False) diff --git a/addons/auction/wizard/auction_payer_sel.py b/addons/auction/wizard/auction_payer_sel.py index 087eacce9d7..808826cfc23 100644 --- a/addons/auction/wizard/auction_payer_sel.py +++ b/addons/auction/wizard/auction_payer_sel.py @@ -25,7 +25,9 @@ class auction_payer(osv.osv_memory): _name = "auction.payer" _description = "Auction payer" - def payer(self, cr, uid, ids, context): + def payer(self, cr, uid, ids, context=None): + if context is None: + context = {} self.pool.get('auction.lots').write(cr, uid, context.get('active_ids', []), {'is_ok':True, 'state':'paid'}) return {} @@ -38,14 +40,16 @@ class auction_payer_sel(osv.osv_memory): _name = "auction.payer.sel" _description = "Auction payment for seller" - def payer_sel(self, cr, uid, ids, context): + def payer_sel(self, cr, uid, ids, context=None): """ This function Update auction lots object and seller paid true. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of auction payer sel’s IDs. """ - self.pool.get('auction.lots').write(cr, uid, context['active_ids'], {'paid_vnd':True}) + if context is None: + context = {} + self.pool.get('auction.lots').write(cr, uid, context.get('active_ids', []), {'paid_vnd':True}) return {} auction_payer_sel() diff --git a/addons/auction/wizard/auction_taken.py b/addons/auction/wizard/auction_taken.py index ff79000d898..8ada436ae5d 100644 --- a/addons/auction/wizard/auction_taken.py +++ b/addons/auction/wizard/auction_taken.py @@ -42,10 +42,10 @@ class auction_taken(osv.osv_memory): @param ids: List of Auction taken’s IDs @return: dictionary of lot_ids fields with empty list """ - if not context: + if context is None: context={} lot_obj = self.pool.get('auction.lots') - for current in self.browse(cr, uid, ids, context): + for current in self.browse(cr, uid, ids, context=context): for lot in current.lot_ids: lot_obj.write(cr, uid, lot.id, {'state':'taken_away', 'ach_emp': True}) return {'lot_ids': []} diff --git a/addons/auction/wizard/auction_transfer_unsold_object.py b/addons/auction/wizard/auction_transfer_unsold_object.py index d2b38811daa..8bc0cb8cb5b 100644 --- a/addons/auction/wizard/auction_transfer_unsold_object.py +++ b/addons/auction/wizard/auction_transfer_unsold_object.py @@ -29,7 +29,7 @@ class auction_transfer_unsold_object(osv.osv): _name = 'auction.transfer.unsold.object' _description = 'To transfer unsold objects' - def _start(self, cr, uid, context): + def _start(self, cr, uid, context=None): """ To initialize auction_id_from @param self: The object pointer. @@ -40,7 +40,7 @@ class auction_transfer_unsold_object(osv.osv): @return: auction_id_from """ lots_obj = self.pool.get('auction.lots') - rec = lots_obj.browse(cr, uid, context['active_id'], context) + rec = lots_obj.browse(cr, uid, context.get('active_id', False), context=context) auction_from = rec and rec.auction_id.id or False return auction_from @@ -53,7 +53,7 @@ class auction_transfer_unsold_object(osv.osv): 'auction_id_from': _start, } - def transfer_unsold_object(self, cr, uid, ids, context): + def transfer_unsold_object(self, cr, uid, ids, context=None): """ To Transfer the unsold object @param self: The object pointer. @@ -63,15 +63,16 @@ class auction_transfer_unsold_object(osv.osv): @param context: A standard dictionary @return: """ + if context is None: context = {} bid_line_obj = self.pool.get('auction.bid_line') lots_obj = self.pool.get('auction.lots') lot_history_obj = self.pool.get('auction.lot.history') - line_ids= bid_line_obj.search(cr, uid, [('lot_id','in',context['active_ids'])]) + line_ids= bid_line_obj.search(cr, uid, [('lot_id','in',context.get('active_ids', []))]) bid_line_obj.unlink(cr, uid, line_ids) - res = self.browse(cr, uid, ids) + res = self.browse(cr, uid, ids, context=context) unsold_ids = lots_obj.search(cr,uid,[('auction_id','=',res[0].auction_id_from.id),('state','=','unsold')]) - for rec in lots_obj.browse(cr, uid, unsold_ids, context): + for rec in lots_obj.browse(cr, uid, unsold_ids, context=context): new_id = lot_history_obj.create(cr, uid, {'auction_id':rec.auction_id.id,'lot_id':rec.id,'price': rec.obj_ret, 'name': rec.auction_id.auction1}) up_auction = lots_obj.write(cr, uid, [rec.id], {'auction_id': res[0].auction_id_to.id, 'obj_ret':None, diff --git a/addons/audittrail/wizard/audittrail_view_log.py b/addons/audittrail/wizard/audittrail_view_log.py index f1329b58a0d..65165c1d2d8 100644 --- a/addons/audittrail/wizard/audittrail_view_log.py +++ b/addons/audittrail/wizard/audittrail_view_log.py @@ -42,17 +42,15 @@ class audittrail_view_log(osv.osv_memory): @param ids: List of audittrail view log’s IDs. @return: Dictionary of audittrail log form on given date range. """ - if not context: - context = {} mod_obj = self.pool.get('ir.model.data') act_obj = self.pool.get('ir.actions.act_window') result = mod_obj._get_id(cr, uid, 'audittrail', 'action_audittrail_log_tree') - id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id'] - result = act_obj.read(cr, uid, [id])[0] + id = mod_obj.read(cr, uid, [result], ['res_id'], context=context)[0]['res_id'] + result = act_obj.read(cr, uid, [id], context=context)[0] #start Loop - for datas in self.read(cr, uid, ids): + for datas in self.read(cr, uid, ids, context=context): if not datas.get('from', None): if datas.get('to') <> time.strftime("%Y-%m-%d %H:%M:%S"): result['domain'] = str([('timestamp', '<', datas.get('to'))]) diff --git a/addons/base_action_rule/base_action_rule.py b/addons/base_action_rule/base_action_rule.py index 9a2d720cc1a..bf34c137b5a 100644 --- a/addons/base_action_rule/base_action_rule.py +++ b/addons/base_action_rule/base_action_rule.py @@ -35,7 +35,7 @@ class base_action_rule(osv.osv): _name = 'base.action.rule' _description = 'Action Rules' - def _state_get(self, cr, uid, context={}): + def _state_get(self, cr, uid, context=None): """ Get State @param self: The object pointer @param cr: the current row, from the database cursor, @@ -43,7 +43,7 @@ class base_action_rule(osv.osv): @param context: A standard dictionary for contextual values """ return self.state_get(cr, uid, context=context) - def state_get(self, cr, uid, context={}): + def state_get(self, cr, uid, context=None): """ Get State @param self: The object pointer @param cr: the current row, from the database cursor, @@ -51,7 +51,7 @@ class base_action_rule(osv.osv): @param context: A standard dictionary for contextual values """ return [('', '')] - def priority_get(self, cr, uid, context={}): + def priority_get(self, cr, uid, context=None): """ Get Priority @param self: The object pointer @param cr: the current row, from the database cursor, @@ -157,7 +157,7 @@ the rule to mark CC(mail to any other person defined in actions)."), return True def _create(self, old_create, model, context=None): - if not context: + if context is None: context = {} def make_call_old(cr, uid, vals, context=context): new_id = old_create(cr, uid, vals, context=context) @@ -167,7 +167,7 @@ the rule to mark CC(mail to any other person defined in actions)."), return make_call_old def _write(self, old_write, model, context=None): - if not context: + if context is None: context = {} def make_call_old(cr, uid, ids, vals, context=context): if isinstance(ids, (str, int, long)): @@ -178,7 +178,7 @@ the rule to mark CC(mail to any other person defined in actions)."), return make_call_old def _register_hook(self, cr, uid, ids, context=None): - if not context: + if context is None: context = {} for action_rule in self.browse(cr, uid, ids, context=context): model = action_rule.model_id.model @@ -190,12 +190,12 @@ the rule to mark CC(mail to any other person defined in actions)."), return True def create(self, cr, uid, vals, context=None): - res_id = super(base_action_rule, self).create(cr, uid, vals, context) + res_id = super(base_action_rule, self).create(cr, uid, vals, context=context) self._register_hook(cr, uid, [res_id], context=context) return res_id def write(self, cr, uid, ids, vals, context=None): - res = super(base_action_rule, self).write(cr, uid, ids, vals, context) + res = super(base_action_rule, self).write(cr, uid, ids, vals, context=context) self._register_hook(cr, uid, ids, context=context) return res @@ -396,7 +396,7 @@ the rule to mark CC(mail to any other person defined in actions)."), if not scrit: scrit = [] - for action in self.browse(cr, uid, ids, context): + for action in self.browse(cr, uid, ids, context=context): model_obj = self.pool.get(action.model_id.model) for obj in objects: ok = self.do_check(cr, uid, action, obj, context=context) @@ -454,7 +454,7 @@ the rule to mark CC(mail to any other person defined in actions)."), empty = orm.browse_null() rule_obj = self.pool.get('base.action.rule') - for rule in self.browse(cr, uid, ids): + for rule in self.browse(cr, uid, ids, context=context): if rule.act_mail_body: try: rule_obj.format_mail(empty, rule.act_mail_body) diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index c567105547d..fa85b242f6a 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -106,7 +106,6 @@ def _links_get(self, cr, uid, context=None): @param context: A standard dictionary for contextual values @return: list of dictionary which contain object and name and id. """ - obj = self.pool.get('res.request.link') ids = obj.search(cr, uid, []) res = obj.read(cr, uid, ids, ['object', 'name'], context=context) @@ -222,7 +221,7 @@ class calendar_attendee(osv.osv): name += ':' return (name or '') + (email and ('MAILTO:' + email) or '') - def _compute_data(self, cr, uid, ids, name, arg, context): + def _compute_data(self, cr, uid, ids, name, arg, context=None): """ Compute data on function fields for attendee values . @param cr: the current row, from the database cursor, @@ -300,7 +299,6 @@ class calendar_attendee(osv.osv): @param context: A standard dictionary for contextual values @return: list of dictionary which contain object and name and id. """ - obj = self.pool.get('res.request.link') ids = obj.search(cr, uid, []) res = obj.read(cr, uid, ids, ['object', 'name'], context=context) @@ -649,7 +647,7 @@ true, it will allow you to hide the event alarm information without removing it. model_id = ir_obj.search(cr, uid, [('model', '=', model)])[0] model_obj = self.pool.get(model) - for data in model_obj.browse(cr, uid, ids, context): + for data in model_obj.browse(cr, uid, ids, context=context): basic_alarm = data.alarm_id cal_alarm = data.base_calendar_alarm_id @@ -719,7 +717,7 @@ true, it will allow you to hide the event alarm information without removing it. ir_obj = self.pool.get('ir.model') model_id = ir_obj.search(cr, uid, [('model', '=', model)])[0] model_obj = self.pool.get(model) - for datas in model_obj.browse(cr, uid, ids, context): + for datas in model_obj.browse(cr, uid, ids, context=context): alarm_ids = alarm_obj.search(cr, uid, [('model_id', '=', model_id), ('res_id', '=', datas.id)]) if alarm_ids: alarm_obj.unlink(cr, uid, alarm_ids) @@ -794,7 +792,7 @@ class calendar_alarm(osv.osv): delta = timedelta(minutes=vals['trigger_duration']) trigger_date = dtstart + (vals['trigger_occurs'] == 'after' and delta or -delta) vals['trigger_date'] = trigger_date - res = super(calendar_alarm, self).create(cr, uid, vals, context) + res = super(calendar_alarm, self).create(cr, uid, vals, context=context) return res def do_run_scheduler(self, cr, uid, automatic=False, use_new_cursor=False, \ @@ -1685,7 +1683,7 @@ class calendar_todo(osv.osv): _inherit = "calendar.event" _description = "Calendar Task" - def _get_date(self, cr, uid, ids, name, arg, context): + def _get_date(self, cr, uid, ids, name, arg, context=None): """ Get Date @param self: The object pointer @@ -1701,7 +1699,7 @@ class calendar_todo(osv.osv): res[event.id] = event.date_start return res - def _set_date(self, cr, uid, id, name, value, arg, context): + def _set_date(self, cr, uid, id, name, value, arg, context=None): """ Set Date @param self: The object pointer diff --git a/addons/base_calendar/wizard/base_calendar_invite_attendee.py b/addons/base_calendar/wizard/base_calendar_invite_attendee.py index a18388f5b3c..48f39e609f9 100644 --- a/addons/base_calendar/wizard/base_calendar_invite_attendee.py +++ b/addons/base_calendar/wizard/base_calendar_invite_attendee.py @@ -62,7 +62,7 @@ send an Email to Invited Person') @return: Dictionary of {}. """ - if not context: + if context is None: context = {} model = False @@ -74,7 +74,7 @@ send an Email to Invited Person') model_field = context.get('attendee_field', False) obj = self.pool.get(model) - res_obj = obj.browse(cr, uid, context_id) + res_obj = obj.browse(cr, uid, context_id, context=context) att_obj = self.pool.get('calendar.attendee') user_obj = self.pool.get('res.users') current_user = user_obj.browse(cr, uid, uid, context=context) diff --git a/addons/base_calendar/wizard/base_calendar_set_exrule.py b/addons/base_calendar/wizard/base_calendar_set_exrule.py index 995d2a98dcc..4f5d57235e5 100644 --- a/addons/base_calendar/wizard/base_calendar_set_exrule.py +++ b/addons/base_calendar/wizard/base_calendar_set_exrule.py @@ -82,8 +82,10 @@ class base_calendar_set_exrule(osv.osv_memory): @param fields: List of fields for default value @param context: A standard dictionary for contextual values """ + if context is None: + context = {} event_obj = self.pool.get(context.get('active_model')) - for event in event_obj.browse(cr, uid, context.get('active_ids', [])): + for event in event_obj.browse(cr, uid, context.get('active_ids', []), context=context): if not event.rrule: raise osv.except_osv(_("Warning !"), _("Please Apply Recurrency before applying Exception Rule.")) return False @@ -102,7 +104,9 @@ class base_calendar_set_exrule(osv.osv_memory): weekstring = '' monthstring = '' yearstring = '' - ex_id = base_calendar.base_calendar_id2real_id(context['active_id']) + if context is None: + context = {} + ex_id = base_calendar.base_calendar_id2real_id(context.get('active_id', False)) model = context.get('model', False) model_obj = self.pool.get(model) for datas in self.read(cr, uid, ids, context=context): diff --git a/addons/base_calendar/wizard/calendar_event_edit_all.py b/addons/base_calendar/wizard/calendar_event_edit_all.py index d17195f9a27..a9b0a9f347e 100644 --- a/addons/base_calendar/wizard/calendar_event_edit_all.py +++ b/addons/base_calendar/wizard/calendar_event_edit_all.py @@ -24,7 +24,7 @@ from osv import fields class calendar_event_edit_all(osv.osv_memory): - def _default_values(self, cr, uid, context={}): + def _default_values(self, cr, uid, context=None): """ Get Default value for Start Date @param self: The object pointer @param cr: the current row, from the database cursor, @@ -42,7 +42,7 @@ class calendar_event_edit_all(osv.osv_memory): event = model_obj.read(cr, uid, context_id, ['name', 'location', 'alarm_id']) return event['date'] - def _default_deadline(self, cr, uid, context={}): + def _default_deadline(self, cr, uid, context=None): """ Get Default value for End Date @param self: The object pointer @param cr: the current row, from the database cursor, @@ -69,7 +69,7 @@ class calendar_event_edit_all(osv.osv_memory): @param ids: List of calendar event edit all’s IDs @return: dictionary {} """ - if not context: + if context is None: context = {} context_id = context and context.get('active_id', False) or False diff --git a/addons/base_contact/base_contact.py b/addons/base_contact/base_contact.py index 0147d147134..8a003ec7cf1 100644 --- a/addons/base_contact/base_contact.py +++ b/addons/base_contact/base_contact.py @@ -42,7 +42,7 @@ class res_partner_contact(osv.osv): all_job_ids = res_partner_job_obj.search(cr, uid, []) all_job_names = dict(zip(all_job_ids, res_partner_job_obj.name_get(cr, uid, all_job_ids, context=context))) - for contact in self.browse(cr, uid, ids, context): + for contact in self.browse(cr, uid, ids, context=context): if contact.job_ids: res[contact.id] = all_job_names.get(contact.job_ids[0].id, False) @@ -77,7 +77,7 @@ class res_partner_contact(osv.osv): _order = "name,first_name" - def name_get(self, cr, user, ids, context={}): + def name_get(self, cr, user, ids, context=None): """ will return name and first_name....... @param self: The object pointer @@ -119,7 +119,7 @@ res_partner_contact() class res_partner_address(osv.osv): #overriding of the name_get defined in base in order to remove the old contact name - def name_get(self, cr, user, ids, context={}): + def name_get(self, cr, user, ids, context=None): """ @param self: The object pointer @param cr: the current row, from the database cursor, @@ -131,6 +131,8 @@ class res_partner_address(osv.osv): if not len(ids): return [] res = [] + if context is None: + context = {} for r in self.read(cr, user, ids, ['zip', 'city', 'partner_id', 'street']): if context.get('contact_display', 'contact')=='partner' and r['partner_id']: res.append((r['id'], r['partner_id'][1])) @@ -168,7 +170,7 @@ class res_partner_job(osv.osv): return [] res = [] - jobs = self.browse(cr, uid, ids) + jobs = self.browse(cr, uid, ids, context=context) contact_ids = [rec.contact_id.id for rec in jobs] contact_names = dict(self.pool.get('res.partner.contact').name_get(cr, uid, contact_ids, context=context)) @@ -238,7 +240,7 @@ class res_partner_job(osv.osv): partner_id = False if address_id: address = self.pool.get('res.partner.address')\ - .browse(cr, uid, address_id, context) + .browse(cr, uid, address_id, context=context) partner_id = address.partner_id.id return {'value': {'name': partner_id}} diff --git a/addons/base_contact/base_contact_installer.py b/addons/base_contact/base_contact_installer.py index 4f4e2b2896c..6d979da7a02 100644 --- a/addons/base_contact/base_contact_installer.py +++ b/addons/base_contact/base_contact_installer.py @@ -35,7 +35,7 @@ class base_contact_installer(osv.osv_memory): """ This function is used to create contact and address from existing partner address """ - obj = self.pool.get("base.contact.installer").browse(cr, uid, uid) + obj = self.pool.get("base.contact.installer").browse(cr, uid, uid, context=context) if obj.migrate: cr.execute("""DROP TRIGGER IF EXISTS contactjob on res_partner_contact; DROP LANGUAGE IF EXISTS plpgsql CASCADE; diff --git a/addons/base_iban/base_iban.py b/addons/base_iban/base_iban.py index b632e5f3e47..6f633c7b474 100644 --- a/addons/base_iban/base_iban.py +++ b/addons/base_iban/base_iban.py @@ -73,23 +73,23 @@ def _format_iban(string): class res_partner_bank(osv.osv): _inherit = "res.partner.bank" - def create(self, cr, uid, vals, context={}): + def create(self, cr, uid, vals, context=None): #overwrite to format the iban number correctly if 'iban' in vals and vals['iban']: vals['iban'] = _format_iban(vals['iban']) return super(res_partner_bank, self).create(cr, uid, vals, context) - def write(self, cr, uid, ids, vals, context={}): + def write(self, cr, uid, ids, vals, context=None): #overwrite to format the iban number correctly if 'iban' in vals and vals['iban']: vals['iban'] = _format_iban(vals['iban']) return super(res_partner_bank, self).write(cr, uid, ids, vals, context) - def check_iban(self, cr, uid, ids): + def check_iban(self, cr, uid, ids, context=None): ''' Check the IBAN number ''' - for bank_acc in self.browse(cr, uid, ids): + for bank_acc in self.browse(cr, uid, ids, context=context): if not bank_acc.iban: continue iban = _format_iban(bank_acc.iban).lower() @@ -109,7 +109,7 @@ class res_partner_bank(osv.osv): return False return True - def _construct_constraint_msg(self, cr, uid, ids): + def _construct_constraint_msg(self, cr, uid, ids, context=None): def default_iban_check(iban_cn): return iban_cn[0] in string.ascii_lowercase and iban_cn[1] in string.ascii_lowercase @@ -123,12 +123,12 @@ class res_partner_bank(osv.osv): def name_get(self, cr, uid, ids, context=None): res = [] to_check_ids = [] - for id in self.browse(cr, uid, ids): + for id in self.browse(cr, uid, ids, context=context): if id.state=='iban': res.append((id.id,id.iban)) else: to_check_ids.append(id.id) - res += super(res_partner_bank, self).name_get(cr, uid, to_check_ids, context) + res += super(res_partner_bank, self).name_get(cr, uid, to_check_ids, context=context) return res def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): @@ -158,7 +158,7 @@ class res_partner_bank(osv.osv): 'ch': lambda x: x[9:], 'gb': lambda x: x[14:], } - for record in self.browse(cr, uid, ids, context): + for record in self.browse(cr, uid, ids, context=context): if not record.iban: res[record.id] = False continue diff --git a/addons/base_module_doc_rst/base_module_doc_rst.py b/addons/base_module_doc_rst/base_module_doc_rst.py index 9d86a191177..57b26fd0d44 100755 --- a/addons/base_module_doc_rst/base_module_doc_rst.py +++ b/addons/base_module_doc_rst/base_module_doc_rst.py @@ -35,7 +35,7 @@ class module(osv.osv): 'file_graph': fields.binary('Relationship Graph'), } - def _get_graphical_representation(self, cr, uid, model_ids, level=1, context={}): + def _get_graphical_representation(self, cr, uid, model_ids, level=1, context=None): obj_model = self.pool.get('ir.model') if level == 0: return tuple() @@ -86,7 +86,7 @@ class module(osv.osv): ) return res - def _get_module_objects(self, cr, uid, module, context={}): + def _get_module_objects(self, cr, uid, module, context=None): obj_model = self.pool.get('ir.model') obj_mod_data = self.pool.get('ir.model.data') obj_ids = [] @@ -99,6 +99,7 @@ class module(osv.osv): return obj_ids def get_relation_graph(self, cr, uid, module_name, context=None): + if context is None: context = {} object_ids = self._get_module_objects(cr, uid, module_name, context=context) if not object_ids: return {'module_file': False} diff --git a/addons/base_module_doc_rst/report/report_proximity_graph.py b/addons/base_module_doc_rst/report/report_proximity_graph.py index 6f3db7e3273..2d3704fd5b7 100644 --- a/addons/base_module_doc_rst/report/report_proximity_graph.py +++ b/addons/base_module_doc_rst/report/report_proximity_graph.py @@ -74,7 +74,7 @@ class report_graph(report.interface.report_int): input.close() return output.read() - def create(self, cr, uid, ids, data, context={}): + def create(self, cr, uid, ids, data, context=None): pdf_string = self.get_proximity_graph(cr, uid, data['id']) return (pdf_string, 'pdf') diff --git a/addons/base_module_doc_rst/wizard/generate_relation_graph.py b/addons/base_module_doc_rst/wizard/generate_relation_graph.py index 0d4453b0bcc..7b04f183129 100644 --- a/addons/base_module_doc_rst/wizard/generate_relation_graph.py +++ b/addons/base_module_doc_rst/wizard/generate_relation_graph.py @@ -28,7 +28,7 @@ form_rep = '''