[IMP] : Added context=None on methods used for _constraints and replaced context={} with context=None.

bzr revid: uco@tinyerp.com-20101119134801-974ev29j4tu46pq2
This commit is contained in:
uco (OpenERP) 2010-11-19 19:18:01 +05:30
parent 58e9ba97bb
commit 12fcd1be2f
179 changed files with 1657 additions and 968 deletions

View File

@ -116,7 +116,7 @@ class account_payment_term_line(osv.osv):
_order = "sequence" _order = "sequence"
def _check_percent(self, cr, uid, ids, context=None): 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): if obj.value == 'procent' and ( obj.value_amount < 0.0 or obj.value_amount > 1.0):
return False return False
return True return True
@ -182,7 +182,7 @@ class account_account(osv.osv):
def search(self, cr, uid, args, offset=0, limit=None, order=None, def search(self, cr, uid, args, offset=0, limit=None, order=None,
context=None, count=False): context=None, count=False):
if context is None: if not context:
context = {} context = {}
pos = 0 pos = 0
@ -215,7 +215,7 @@ class account_account(osv.osv):
order, context=context, count=count) order, context=context, count=count)
def _get_children_and_consol(self, cr, uid, ids, context=None): def _get_children_and_consol(self, cr, uid, ids, context=None):
if context is None: if not context:
context = {} context = {}
#this function search for all the children and all consolidated children (recursively) of the given account ids #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) ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)], context=context)
@ -309,15 +309,19 @@ class account_account(osv.osv):
res[id] = sums.get(id, null_result) res[id] = sums.get(id, null_result)
return res 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):
if not context:
context = {}
result = {} 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.code) result[rec.id] = (rec.company_id.currency_id.id,rec.company_id.currency_id.code)
return result 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):
if not context:
context = {}
result = {} 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: if record.child_parent_ids:
result[record.id] = [x.id for x in record.child_parent_ids] result[record.id] = [x.id for x in record.child_parent_ids]
else: else:
@ -330,9 +334,11 @@ class account_account(osv.osv):
return result 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):
if not context:
context = {}
res={} res={}
accounts = self.browse(cr, uid, ids) accounts = self.browse(cr, uid, ids, context=context)
for account in accounts: for account in accounts:
level = 0 level = 0
if account.parent_id: if account.parent_id:
@ -396,8 +402,10 @@ 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), '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): def _check_recursion(self, cr, uid, ids, context=None):
obj_self = self.browse(cr, uid, ids[0]) if not context:
context = {}
obj_self = self.browse(cr, uid, ids[0], context=context)
p_id = obj_self.parent_id and obj_self.parent_id.id 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)): if (obj_self in obj_self.child_consol_ids) or (p_id and (p_id is obj_self.id)):
return False return False
@ -433,7 +441,7 @@ class account_account(osv.osv):
try: try:
if name and str(name).startswith('partner:'): if name and str(name).startswith('partner:'):
part_id = int(name.split(':')[1]) 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))] args += [('id', 'in', (part.property_account_payable.id, part.property_account_receivable.id))]
name = False name = False
if name and str(name).startswith('type:'): if name and str(name).startswith('type:'):
@ -491,6 +499,8 @@ class account_account(osv.osv):
return super(account_account, self).copy(cr, uid, id, default, context=context) return super(account_account, self).copy(cr, uid, id, default, context=context)
def _check_moves(self, cr, uid, ids, method, context=None): def _check_moves(self, cr, uid, ids, method, context=None):
if not context:
context = {}
line_obj = self.pool.get('account.move.line') line_obj = self.pool.get('account.move.line')
account_ids = self.search(cr, uid, [('id', 'child_of', ids)]) account_ids = self.search(cr, uid, [('id', 'child_of', ids)])
@ -507,6 +517,8 @@ class account_account(osv.osv):
return True return True
def _check_allow_type_change(self, cr, uid, ids, new_type, context=None): def _check_allow_type_change(self, cr, uid, ids, new_type, context=None):
if not context:
context = {}
group1 = ['payable', 'receivable', 'other'] group1 = ['payable', 'receivable', 'other']
group2 = ['consolidation','view'] group2 = ['consolidation','view']
line_obj = self.pool.get('account.move.line') line_obj = self.pool.get('account.move.line')
@ -523,7 +535,7 @@ class account_account(osv.osv):
return True return True
def write(self, cr, uid, ids, vals, context=None): def write(self, cr, uid, ids, vals, context=None):
if context is None: if not context:
context = {} context = {}
if 'company_id' in vals: if 'company_id' in vals:
@ -697,7 +709,7 @@ class account_journal(osv.osv):
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100): def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100):
if not args: if not args:
args = [] args = []
if context is None: if not context:
context = {} context = {}
ids = [] ids = []
if context.get('journal_type', False): if context.get('journal_type', False):
@ -778,8 +790,10 @@ class account_fiscalyear(osv.osv):
return False return False
return True return True
def _check_duration(self,cr,uid,ids): def _check_duration(self, cr, uid, ids, context=None):
obj_fy = self.browse(cr,uid,ids[0]) if not context:
context = {}
obj_fy = self.browse(cr, uid, ids[0], context=context)
if obj_fy.date_stop < obj_fy.date_start: if obj_fy.date_stop < obj_fy.date_start:
return False return False
return True return True
@ -789,11 +803,11 @@ class account_fiscalyear(osv.osv):
(_check_fiscal_year, 'Error! You cannot define overlapping fiscal years',['date_start', 'date_stop']) (_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) return self.create_period(cr, uid, ids, context, 3)
def create_period(self,cr, uid, ids, context={}, interval=1): def create_period(self,cr, uid, ids, context=None, interval=1):
for fy in self.browse(cr, uid, ids, context): for fy in self.browse(cr, uid, ids, context=context):
ds = datetime.strptime(fy.date_start, '%Y-%m-%d') ds = datetime.strptime(fy.date_start, '%Y-%m-%d')
while ds.strftime('%Y-%m-%d')<fy.date_stop: while ds.strftime('%Y-%m-%d')<fy.date_stop:
de = ds + relativedelta(months=interval, days=-1) de = ds + relativedelta(months=interval, days=-1)
@ -811,7 +825,7 @@ class account_fiscalyear(osv.osv):
ds = ds + relativedelta(months=interval) ds = ds + relativedelta(months=interval)
return True return True
def find(self, cr, uid, dt=None, exception=True, context={}): def find(self, cr, uid, dt=None, exception=True, context=None):
if not dt: if not dt:
dt = time.strftime('%Y-%m-%d') dt = time.strftime('%Y-%m-%d')
ids = self.search(cr, uid, [('date_start', '<=', dt), ('date_stop', '>=', dt)]) ids = self.search(cr, uid, [('date_start', '<=', dt), ('date_stop', '>=', dt)])
@ -825,7 +839,7 @@ class account_fiscalyear(osv.osv):
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80): def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
if args is None: if args is None:
args = [] args = []
if context is None: if not context:
context = {} context = {}
ids = [] ids = []
if name: if name:
@ -856,14 +870,18 @@ class account_period(osv.osv):
} }
_order = "date_start" _order = "date_start"
def _check_duration(self,cr,uid,ids,context={}): def _check_duration(self,cr,uid,ids,context=None):
obj_period=self.browse(cr,uid,ids[0]) if not context:
context = {}
obj_period = self.browse(cr, uid, ids[0], context=context)
if obj_period.date_stop < obj_period.date_start: if obj_period.date_stop < obj_period.date_start:
return False return False
return True return True
def _check_year_limit(self,cr,uid,ids,context={}): def _check_year_limit(self,cr,uid,ids,context=None):
for obj_period in self.browse(cr,uid,ids): if not context:
context = {}
for obj_period in self.browse(cr, uid, ids, context=context):
if obj_period.special: if obj_period.special:
continue continue
@ -884,13 +902,17 @@ 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']) (_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):
if not context:
context = {}
ids = self.search(cr, uid, [('date_start','>',period.date_start)]) ids = self.search(cr, uid, [('date_start','>',period.date_start)])
if len(ids)>=step: if len(ids)>=step:
return ids[step-1] return ids[step-1]
return False return False
def find(self, cr, uid, dt=None, context={}): def find(self, cr, uid, dt=None, context=None):
if not context:
context = {}
if not dt: if not dt:
dt = time.strftime('%Y-%m-%d') dt = time.strftime('%Y-%m-%d')
#CHECKME: shouldn't we check the state of the period? #CHECKME: shouldn't we check the state of the period?
@ -906,10 +928,10 @@ class account_period(osv.osv):
cr.execute('update account_period set state=%s where id=%s', (mode, id)) cr.execute('update account_period set state=%s where id=%s', (mode, id))
return True 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=80):
if args is None: if args is None:
args = [] args = []
if context is None: if not context:
context = {} context = {}
ids = [] ids = []
if name: if name:
@ -918,7 +940,9 @@ class account_period(osv.osv):
ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit) ids = self.search(cr, user, [('name',operator,name)]+ args, limit=limit)
return self.name_get(cr, user, ids, context=context) 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 not context:
context = {}
if 'company_id' in vals: if 'company_id' in vals:
move_lines = self.pool.get('account.move.line').search(cr, uid, [('period_id', 'in', ids)]) move_lines = self.pool.get('account.move.line').search(cr, uid, [('period_id', 'in', ids)])
if move_lines: if move_lines:
@ -944,7 +968,9 @@ class account_journal_period(osv.osv):
_name = "account.journal.period" _name = "account.journal.period"
_description = "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):
if not context:
context = {}
result = {}.fromkeys(ids, 'STOCK_NEW') result = {}.fromkeys(ids, 'STOCK_NEW')
for r in self.read(cr, uid, ids, ['state']): for r in self.read(cr, uid, ids, ['state']):
result[r['id']] = { result[r['id']] = {
@ -966,28 +992,32 @@ class account_journal_period(osv.osv):
'company_id': fields.related('journal_id', 'company_id', type='many2one', relation='res.company', string='Company') 'company_id': fields.related('journal_id', 'company_id', type='many2one', relation='res.company', string='Company')
} }
def _check(self, cr, uid, ids, context={}): def _check(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context): if not context:
context = {}
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)) 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() res = cr.fetchall()
if res: if res:
raise osv.except_osv(_('Error !'), _('You can not modify/delete a journal with entries for this period !')) raise osv.except_osv(_('Error !'), _('You can not modify/delete a journal with entries for this period !'))
return True return True
def write(self, cr, uid, ids, vals, context={}): def write(self, cr, uid, ids, vals, context=None):
self._check(cr, uid, ids, context) self._check(cr, uid, ids, context=context)
return super(account_journal_period, self).write(cr, uid, ids, vals, 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):
if not context:
context = {}
period_id=vals.get('period_id',False) period_id=vals.get('period_id',False)
if period_id: 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 vals['state']=period.state
return super(account_journal_period, self).create(cr, uid, vals, context) return super(account_journal_period, self).create(cr, uid, vals, context)
def unlink(self, cr, uid, ids, context={}): def unlink(self, cr, uid, ids, context=None):
self._check(cr, uid, ids, context) self._check(cr, uid, ids, context=context)
return super(account_journal_period, self).unlink(cr, uid, ids, context) return super(account_journal_period, self).unlink(cr, uid, ids, context=context)
_defaults = { _defaults = {
'state': 'draft', 'state': 'draft',
@ -1057,8 +1087,10 @@ class account_move(osv.osv):
ids = [ids] ids = [ids]
if not ids: if not ids:
return [] return []
if not context:
context = {}
res = [] 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: for move in data_move:
if move.state=='draft': if move.state=='draft':
name = '*' + str(move.id) name = '*' + str(move.id)
@ -1067,7 +1099,9 @@ class account_move(osv.osv):
res.append((move.id, name)) res.append((move.id, name))
return res return res
def _get_period(self, cr, uid, context): def _get_period(self, cr, uid, context=None):
if not context:
context = {}
periods = self.pool.get('account.period').find(cr, uid) periods = self.pool.get('account.period').find(cr, uid)
if periods: if periods:
return periods[0] return periods[0]
@ -1128,8 +1162,9 @@ 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, '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): def _check_centralisation(self, cursor, user, ids, context=None):
for move in self.browse(cursor, user, ids): if not context: context = {}
for move in self.browse(cursor, user, ids, context=context):
if move.journal_id.centralisation: if move.journal_id.centralisation:
move_ids = self.search(cursor, user, [ move_ids = self.search(cursor, user, [
('period_id', '=', move.period_id.id), ('period_id', '=', move.period_id.id),
@ -1139,8 +1174,9 @@ class account_move(osv.osv):
return False return False
return True return True
def _check_period_journal(self, cursor, user, ids): def _check_period_journal(self, cursor, user, ids, context=None):
for move in self.browse(cursor, user, ids): if not context: context = {}
for move in self.browse(cursor, user, ids, context=context):
for line in move.line_id: for line in move.line_id:
if line.period_id.id != move.period_id.id: if line.period_id.id != move.period_id.id:
return False return False
@ -1158,7 +1194,7 @@ class account_move(osv.osv):
] ]
def post(self, cr, uid, ids, context=None): def post(self, cr, uid, ids, context=None):
if context is None: if not context:
context = {} context = {}
invoice = context.get('invoice', False) invoice = context.get('invoice', False)
valid_moves = self.validate(cr, uid, ids, context) valid_moves = self.validate(cr, uid, ids, context)
@ -1166,7 +1202,7 @@ class account_move(osv.osv):
if not valid_moves: 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" !')) 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') 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 =='/': if move.name =='/':
new_name = False new_name = False
journal = move.journal_id journal = move.journal_id
@ -1191,7 +1227,9 @@ class account_move(osv.osv):
return True return True
def button_validate(self, cursor, user, ids, context=None): def button_validate(self, cursor, user, ids, context=None):
for move in self.browse(cursor, user, ids): if not context:
context = {}
for move in self.browse(cursor, user, ids, context=context):
top = None top = None
for line in move.line_id: for line in move.line_id:
account = line.account_id account = line.account_id
@ -1204,8 +1242,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 !')) 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) return self.post(cursor, user, ids, context=context)
def button_cancel(self, cr, uid, ids, context={}): def button_cancel(self, cr, uid, ids, context=None):
for line in self.browse(cr, uid, ids, context): for line in self.browse(cr, uid, ids, context=context):
if not line.journal_id.update_posted: 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.')) 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: if ids:
@ -1214,11 +1252,13 @@ class account_move(osv.osv):
'WHERE id IN %s', ('draft', tuple(ids),)) 'WHERE id IN %s', ('draft', tuple(ids),))
return True return True
def write(self, cr, uid, ids, vals, context={}): def write(self, cr, uid, ids, vals, context=None):
if not context:
context = {}
c = context.copy() c = context.copy()
c['novalidate'] = True c['novalidate'] = True
result = super(osv.osv, self).write(cr, uid, ids, vals, c) 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 return result
# #
@ -1265,7 +1305,7 @@ class account_move(osv.osv):
result = super(account_move, self).create(cr, uid, vals, context) result = super(account_move, self).create(cr, uid, vals, context)
return result return result
def copy(self, cr, uid, id, default={}, context={}): def copy(self, cr, uid, id, default={}, context=None):
context = context or {} context = context or {}
default.update({ default.update({
'state':'draft', 'state':'draft',
@ -1280,7 +1320,7 @@ class account_move(osv.osv):
context = context or {} context = context or {}
toremove = [] toremove = []
obj_move_line = self.pool.get('account.move.line') 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': if move['state'] != 'draft':
raise osv.except_osv(_('UserError'), raise osv.except_osv(_('UserError'),
_('You can not delete posted movement: "%s"!') % \ _('You can not delete posted movement: "%s"!') % \
@ -1294,8 +1334,9 @@ class account_move(osv.osv):
result = super(account_move, self).unlink(cr, uid, toremove, context) result = super(account_move, self).unlink(cr, uid, toremove, context)
return result return result
def _compute_balance(self, cr, uid, id, context={}): def _compute_balance(self, cr, uid, id, context=None):
move = self.browse(cr, uid, [id])[0] context = context or {}
move = self.browse(cr, uid, [id], context=context)[0]
amount = 0 amount = 0
for line in move.line_id: for line in move.line_id:
amount+= (line.debit - line.credit) amount+= (line.debit - line.credit)
@ -1358,7 +1399,7 @@ class account_move(osv.osv):
# #
# Validate a balanced move. If it is a centralised journal, create a move. # 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): if context and ('__last_update' in context):
del context['__last_update'] del context['__last_update']
@ -1472,9 +1513,9 @@ class account_move_reconcile(osv.osv):
_defaults = { _defaults = {
'name': lambda self,cr,uid,ctx={}: self.pool.get('ir.sequence').get(cr, uid, 'account.reconcile') or '/', '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 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: for line in rec.line_partial_ids:
total += (line.debit or 0.0) - (line.credit or 0.0) total += (line.debit or 0.0) - (line.credit or 0.0)
if not total: if not total:
@ -1485,10 +1526,11 @@ class account_move_reconcile(osv.osv):
return True return True
def name_get(self, cr, uid, ids, context=None): def name_get(self, cr, uid, ids, context=None):
context = context or {}
if not ids: if not ids:
return [] return []
result = [] 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) total = reduce(lambda y,t: (t.debit or 0.0) - (t.credit or 0.0) + y, r.line_partial_ids, 0.0)
if total: if total:
name = '%s (%.2f)' % (r.name, total) name = '%s (%.2f)' % (r.name, total)
@ -1537,7 +1579,7 @@ class account_tax_code(osv.osv):
(parent_ids,) + where_params) (parent_ids,) + where_params)
res=dict(cr.fetchall()) res=dict(cr.fetchall())
obj_precision = self.pool.get('decimal.precision') 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): def _rec_get(record):
amount = res.get(record.id, 0.0) amount = res.get(record.id, 0.0)
for rec in record.child_ids: for rec in record.child_ids:
@ -1609,6 +1651,7 @@ class account_tax_code(osv.osv):
def name_get(self, cr, uid, ids, context=None): def name_get(self, cr, uid, ids, context=None):
context = context or {}
if isinstance(ids, (int, long)): if isinstance(ids, (int, long)):
ids = [ids] ids = [ids]
if not ids: if not ids:
@ -1619,7 +1662,8 @@ class account_tax_code(osv.osv):
return [(x['id'], (x['code'] and (x['code'] + ' - ') or '') + x['name']) \ return [(x['id'], (x['code'] and (x['code'] + ' - ') or '') + x['name']) \
for x in reads] for x in reads]
def _default_company(self, cr, uid, context={}): def _default_company(self, cr, uid, context=None):
context = context or {}
user = self.pool.get('res.users').browse(cr, uid, uid, context=context) user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
if user.company_id: if user.company_id:
return user.company_id.id return user.company_id.id
@ -1760,6 +1804,7 @@ class account_tax(osv.osv):
return res return res
def _default_company(self, cr, uid, context=None): def _default_company(self, cr, uid, context=None):
context = context or {}
user = self.pool.get('res.users').browse(cr, uid, uid, context=context) user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
if user.company_id: if user.company_id:
return user.company_id.id return user.company_id.id
@ -2163,13 +2208,13 @@ class account_subscription(osv.osv):
'period_nbr': 1, 'period_nbr': 1,
'state': 'draft', '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'}) self.write(cr, uid, ids, {'state':'draft'})
return False return False
def check(self, cr, uid, ids, context={}): def check(self, cr, uid, ids, context=None):
todone = [] todone = []
for sub in self.browse(cr, uid, ids, context): for sub in self.browse(cr, uid, ids, context=context):
ok = True ok = True
for line in sub.lines_id: for line in sub.lines_id:
if not line.move_id.id: if not line.move_id.id:
@ -2181,9 +2226,9 @@ class account_subscription(osv.osv):
self.write(cr, uid, todone, {'state':'done'}) self.write(cr, uid, todone, {'state':'done'})
return False return False
def remove_line(self, cr, uid, ids, context={}): def remove_line(self, cr, uid, ids, context=None):
toremove = [] 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: for line in sub.lines_id:
if not line.move_id.id: if not line.move_id.id:
toremove.append(line.id) toremove.append(line.id)
@ -2192,8 +2237,8 @@ class account_subscription(osv.osv):
self.write(cr, uid, ids, {'state':'draft'}) self.write(cr, uid, ids, {'state':'draft'})
return False return False
def compute(self, cr, uid, ids, context={}): def compute(self, cr, uid, ids, context=None):
for sub in self.browse(cr, uid, ids, context): for sub in self.browse(cr, uid, ids, context=context):
ds = sub.date_start ds = sub.date_start
for i in range(sub.period_total): for i in range(sub.period_total):
self.pool.get('account.subscription.line').create(cr, uid, { self.pool.get('account.subscription.line').create(cr, uid, {
@ -2291,10 +2336,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: if not ids:
return [] return []
reads = self.read(cr, uid, ids, ['name','code'], context) reads = self.read(cr, uid, ids, ['name','code'], context=context)
res = [] res = []
for record in reads: for record in reads:
name = record['name'] name = record['name']
@ -2311,7 +2356,8 @@ class account_add_tmpl_wizard(osv.osv_memory):
With the 'nocreate' option, some accounts may not be created. Use this to add them later.""" With the 'nocreate' option, some accounts may not be created. Use this to add them later."""
_name = 'account.addtmpl.wizard' _name = 'account.addtmpl.wizard'
def _get_def_cparent(self, cr, uid, context): def _get_def_cparent(self, cr, uid, context=None):
context = context or {}
acc_obj=self.pool.get('account.account') acc_obj=self.pool.get('account.account')
tmpl_obj=self.pool.get('account.account.template') tmpl_obj=self.pool.get('account.account.template')
tids=tmpl_obj.read(cr, uid, [context['tmpl_ids']], ['parent_id']) tids=tmpl_obj.read(cr, uid, [context['tmpl_ids']], ['parent_id'])
@ -2333,6 +2379,7 @@ class account_add_tmpl_wizard(osv.osv_memory):
} }
def action_create(self,cr,uid,ids,context=None): def action_create(self,cr,uid,ids,context=None):
context = context or {}
acc_obj = self.pool.get('account.account') acc_obj = self.pool.get('account.account')
tmpl_obj = self.pool.get('account.account.template') tmpl_obj = self.pool.get('account.account.template')
data = self.read(cr, uid, ids) data = self.read(cr, uid, ids)
@ -2380,6 +2427,7 @@ class account_tax_code_template(osv.osv):
} }
def name_get(self, cr, uid, ids, context=None): def name_get(self, cr, uid, ids, context=None):
context = context or {}
if not ids: if not ids:
return [] return []
if isinstance(ids, (int, long)): if isinstance(ids, (int, long)):
@ -2457,16 +2505,18 @@ class account_tax_template(osv.osv):
'type_tax_use': fields.selection([('sale','Sale'),('purchase','Purchase'),('all','All')], 'Tax Use In', required=True,) 'type_tax_use': fields.selection([('sale','Sale'),('purchase','Purchase'),('all','All')], 'Tax Use In', required=True,)
} }
def name_get(self, cr, uid, ids, context={}): def name_get(self, cr, uid, ids, context=None):
context = context or {}
if not ids: if not ids:
return [] return []
res = [] 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'] name = record['description'] and record['description'] or record['name']
res.append((record['id'],name )) res.append((record['id'],name ))
return res return res
def _default_company(self, cr, uid, context={}): def _default_company(self, cr, uid, context=None):
context = context or {}
user = self.pool.get('res.users').browse(cr, uid, uid, context=context) user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
if user.company_id: if user.company_id:
return user.company_id.id return user.company_id.id
@ -2572,7 +2622,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
res['value']["purchase_tax"] = purchase_tax_ids and purchase_tax_ids[0] or False res['value']["purchase_tax"] = purchase_tax_ids and purchase_tax_ids[0] or False
return res 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) ids = self.pool.get('account.chart.template').search(cr, uid, [], context=context)
if ids: if ids:
return ids[0] return ids[0]
@ -2593,6 +2643,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
} }
def execute(self, cr, uid, ids, context=None): def execute(self, cr, uid, ids, context=None):
context = context or {}
obj_multi = self.browse(cr, uid, ids[0]) obj_multi = self.browse(cr, uid, ids[0])
obj_acc = self.pool.get('account.account') obj_acc = self.pool.get('account.account')
obj_acc_tax = self.pool.get('account.tax') obj_acc_tax = self.pool.get('account.tax')
@ -2618,7 +2669,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
#create all the tax code #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 = 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() 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={ vals={
'name': (tax_code_root_id == tax_code_template.id) and obj_multi.company_id.name or tax_code_template.name, '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, 'code': tax_code_template.code,
@ -2674,7 +2725,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 = obj_acc_template.search(cr, uid, [('parent_id','child_of',[obj_acc_root.id]),('nocreate','!=',True)])
children_acc_template.sort() 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 = [] tax_ids = []
for tax in account_template.tax_ids: for tax in account_template.tax_ids:
tax_ids.append(tax_template_ref[tax.id]) tax_ids.append(tax_template_ref[tax.id])
@ -2827,11 +2878,11 @@ class wizard_multi_charts_accounts(osv.osv_memory):
# Bank Journals # Bank Journals
data_id = obj_data.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_journal_bank_view')]) 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 view_id_cash = data.res_id
data_id = obj_data.search(cr, uid, [('model','=','account.journal.view'), ('name','=','account_journal_bank_view_multi')]) 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 view_id_cur = data.res_id
ref_acc_bank = obj_multi.chart_template_id.bank_account_view_id ref_acc_bank = obj_multi.chart_template_id.bank_account_view_id
@ -2924,7 +2975,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
obj_tax_fp = self.pool.get('account.fiscal.position.tax') obj_tax_fp = self.pool.get('account.fiscal.position.tax')
obj_ac_fp = self.pool.get('account.fiscal.position.account') 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 = { vals_fp = {
'company_id': company_id, 'company_id': company_id,

View File

@ -58,8 +58,9 @@ class account_analytic_line(osv.osv):
return super(account_analytic_line, self).search(cr, uid, args, offset, limit, return super(account_analytic_line, self).search(cr, uid, args, offset, limit,
order, context=context, count=count) order, context=context, count=count)
def _check_company(self, cr, uid, ids): def _check_company(self, cr, uid, ids, context=None):
lines = self.browse(cr, uid, ids) context = context or {}
lines = self.browse(cr, uid, ids, context=context)
for l in lines: for l in lines:
if l.move_id and not l.account_id.company_id.id == l.move_id.account_id.company_id.id: if l.move_id and not l.account_id.company_id.id == l.move_id.account_id.company_id.id:
return False return False
@ -80,7 +81,7 @@ class account_analytic_line(osv.osv):
analytic_journal_obj =self.pool.get('account.analytic.journal') analytic_journal_obj =self.pool.get('account.analytic.journal')
product_price_type_obj = self.pool.get('product.price.type') product_price_type_obj = self.pool.get('product.price.type')
j_id = analytic_journal_obj.browse(cr, uid, journal_id, context=context) 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 result = 0.0
if j_id.type <> 'sale': if j_id.type <> 'sale':
@ -105,13 +106,13 @@ class account_analytic_line(osv.osv):
flag = False flag = False
# Compute based on pricetype # Compute based on pricetype
product_price_type_ids = product_price_type_obj.search(cr, uid, [('field','=','standard_price')], context=context) 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: 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': if journal.type == 'sale':
product_price_type_ids = product_price_type_obj.search(cr, uid, [('field','=','list_price')], context) product_price_type_ids = product_price_type_obj.search(cr, uid, [('field','=','list_price')], context)
if product_price_type_ids: 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 # Take the company currency as the reference one
if pricetype.field == 'list_price': if pricetype.field == 'list_price':
flag = True flag = True
@ -133,7 +134,8 @@ 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):
context = context or {}
if context.get('account_id', False): if context.get('account_id', False):
# account_id in context may also be pointing to an account.account.id # 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'],)) cr.execute('select name from account_analytic_account where id=%s', (context['account_id'],))

View File

@ -46,7 +46,8 @@ class account_bank_statement(osv.osv):
account_bank_statement_line_obj.write(cr, uid, [line.id], {'sequence': seq}, context=context) account_bank_statement_line_obj.write(cr, uid, [line.id], {'sequence': seq}, context=context)
return res return res
def _default_journal_id(self, cr, uid, context={}): def _default_journal_id(self, cr, uid, context=None):
context = context or {}
journal_pool = self.pool.get('account.journal') journal_pool = self.pool.get('account.journal')
journal_type = context.get('journal_type', False) journal_type = context.get('journal_type', False)
journal_id = False journal_id = False
@ -56,14 +57,16 @@ class account_bank_statement(osv.osv):
journal_id = ids[0] journal_id = ids[0]
return journal_id return journal_id
def _default_balance_start(self, cr, uid, context={}): def _default_balance_start(self, cr, uid, context=None):
context = context or {}
cr.execute('select id from account_bank_statement where journal_id=%s order by date desc limit 1', (1,)) cr.execute('select id from account_bank_statement where journal_id=%s order by date desc limit 1', (1,))
res = cr.fetchone() res = cr.fetchone()
if res: if res:
return self.browse(cr, uid, [res[0]], context)[0].balance_end return self.browse(cr, uid, [res[0]], context=context)[0].balance_end
return 0.0 return 0.0
def _end_balance(self, cursor, user, ids, name, attr, context=None): def _end_balance(self, cursor, user, ids, name, attr, context=None):
context = context or {}
res_currency_obj = self.pool.get('res.currency') res_currency_obj = self.pool.get('res.currency')
res_users_obj = self.pool.get('res.users') res_users_obj = self.pool.get('res.users')
res = {} res = {}
@ -95,13 +98,14 @@ class account_bank_statement(osv.osv):
res[r] = round(res[r], 2) res[r] = round(res[r], 2)
return res 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) periods = self.pool.get('account.period').find(cr, uid)
if periods: if periods:
return periods[0] return periods[0]
return False return False
def _currency(self, cursor, user, ids, name, args, context=None): def _currency(self, cursor, user, ids, name, args, context=None):
context = context or {}
res = {} res = {}
res_currency_obj = self.pool.get('res.currency') res_currency_obj = self.pool.get('res.currency')
res_users_obj = self.pool.get('res.users') res_users_obj = self.pool.get('res.users')
@ -194,11 +198,12 @@ class account_bank_statement(osv.osv):
return self.write(cr, uid, ids, {}, context=context) 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): def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, st_line_number, context=None):
context = context or {}
res_currency_obj = self.pool.get('res.currency') res_currency_obj = self.pool.get('res.currency')
account_move_obj = self.pool.get('account.move') account_move_obj = self.pool.get('account.move')
account_move_line_obj = self.pool.get('account.move.line') account_move_line_obj = self.pool.get('account.move.line')
account_bank_statement_line_obj = self.pool.get('account.bank.statement.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 st = st_line.statement_id
context.update({'date': st_line.date}) context.update({'date': st_line.date})
@ -298,7 +303,8 @@ class account_bank_statement(osv.osv):
return st_number + '/' + str(st_line.sequence) return st_number + '/' + str(st_line.sequence)
def balance_check(self, cr, uid, st_id, journal_type='bank', context=None): def balance_check(self, cr, uid, st_id, journal_type='bank', context=None):
st = self.browse(cr, uid, st_id, context) context = context or {}
st = self.browse(cr, uid, st_id, context=context)
if not (abs((st.balance_end or 0.0) - st.balance_end_real) < 0.0001): if not (abs((st.balance_end or 0.0) - st.balance_end_real) < 0.0001):
raise osv.except_osv(_('Error !'), raise osv.except_osv(_('Error !'),
_('The statement balance is incorrect !\n') + _('The statement balance is incorrect !\n') +
@ -317,7 +323,7 @@ class account_bank_statement(osv.osv):
if context is None: if context is None:
context = {} 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 j_type = st.journal_id.type
company_currency_id = st.journal_id.company_id.currency_id.id 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): if not self.check_status_condition(cr, uid, st.state, journal_type=j_type):
@ -359,7 +365,7 @@ class account_bank_statement(osv.osv):
def button_cancel(self, cr, uid, ids, context=None): def button_cancel(self, cr, uid, ids, context=None):
done = [] done = []
account_move_obj = self.pool.get('account.move') 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': if st.state=='draft':
continue continue
ids = [] ids = []
@ -410,7 +416,7 @@ class account_bank_statement_line(osv.osv):
if not partner_id: if not partner_id:
return res return res
account_id = False 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): if not line or (line and not line[0].account_id):
part = obj_partner.browse(cr, uid, partner_id, context=context) part = obj_partner.browse(cr, uid, partner_id, context=context)
if type == 'supplier': if type == 'supplier':

View File

@ -41,7 +41,8 @@ class account_cashbox_line(osv.osv):
@return: Dictionary of values. @return: Dictionary of values.
""" """
res = {} res = {}
for obj in self.browse(cr, uid, ids): context = context or {}
for obj in self.browse(cr, uid, ids, context=context):
res[obj.id] = obj.pieces * obj.number res[obj.id] = obj.pieces * obj.number
return res return res
@ -76,7 +77,8 @@ class account_cash_statement(osv.osv):
@return: Dictionary of values. @return: Dictionary of values.
""" """
res = {} res = {}
for statement in self.browse(cr, uid, ids): context = context or {}
for statement in self.browse(cr, uid, ids, context=context):
amount_total = 0.0 amount_total = 0.0
if statement.journal_id.type not in('cash'): if statement.journal_id.type not in('cash'):
@ -96,7 +98,8 @@ class account_cash_statement(osv.osv):
@return: Dictionary of values. @return: Dictionary of values.
""" """
res ={} res ={}
for statement in self.browse(cr, uid, ids): context = context or {}
for statement in self.browse(cr, uid, ids, context=context):
amount_total = 0.0 amount_total = 0.0
for line in statement.ending_details_ids: for line in statement.ending_details_ids:
amount_total += line.pieces * line.number amount_total += line.pieces * line.number
@ -111,7 +114,8 @@ class account_cash_statement(osv.osv):
@return: Dictionary of values. @return: Dictionary of values.
""" """
res2={} res2={}
for statement in self.browse(cr, uid, ids): context = context or {}
for statement in self.browse(cr, uid, ids, context=context):
encoding_total=0.0 encoding_total=0.0
for line in statement.line_ids: for line in statement.line_ids:
encoding_total += line.amount encoding_total += line.amount
@ -119,6 +123,7 @@ class account_cash_statement(osv.osv):
return res2 return res2
def _end_balance(self, cursor, user, ids, name, attr, context=None): def _end_balance(self, cursor, user, ids, name, attr, context=None):
context = context or {}
res_currency_obj = self.pool.get('res.currency') res_currency_obj = self.pool.get('res.currency')
res_users_obj = self.pool.get('res.users') res_users_obj = self.pool.get('res.users')
res = {} res = {}
@ -152,6 +157,7 @@ class account_cash_statement(osv.osv):
return res return res
def _get_company(self, cr, uid, context=None): def _get_company(self, cr, uid, context=None):
context = context or {}
user_pool = self.pool.get('res.users') user_pool = self.pool.get('res.users')
company_pool = self.pool.get('res.company') company_pool = self.pool.get('res.company')
user = user_pool.browse(cr, uid, uid, context=context) user = user_pool.browse(cr, uid, uid, context=context)
@ -160,7 +166,7 @@ class account_cash_statement(osv.osv):
company_id = company_pool.search(cr, uid, []) company_id = company_pool.search(cr, uid, [])
return company_id and company_id[0] or False 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 = [] res = []
curr = [1, 2, 5, 10, 20, 50, 100, 500] curr = [1, 2, 5, 10, 20, 50, 100, 500]
for rs in curr: for rs in curr:
@ -173,14 +179,14 @@ class account_cash_statement(osv.osv):
if journal_ids: if journal_ids:
results = self.search(cr, uid, [('journal_id', 'in', journal_ids),('state', '=', 'confirm')], context=context) results = self.search(cr, uid, [('journal_id', 'in', journal_ids),('state', '=', 'confirm')], context=context)
if results: 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 cash_line in cash_st.ending_details_ids:
for r in res: for r in res:
if cash_line.pieces == r['pieces']: if cash_line.pieces == r['pieces']:
r['number'] = cash_line.number r['number'] = cash_line.number
return res 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 = [] res = []
curr = [1, 2, 5, 10, 20, 50, 100, 500] curr = [1, 2, 5, 10, 20, 50, 100, 500]
for rs in curr: for rs in curr:
@ -191,7 +197,7 @@ class account_cash_statement(osv.osv):
res.append(dct) res.append(dct)
return res return res
def _get_cash_close_box_lines(self, cr, uid, context={}): def _get_cash_close_box_lines(self, cr, uid, context=None):
res = [] res = []
curr = [1, 2, 5, 10, 20, 50, 100, 500] curr = [1, 2, 5, 10, 20, 50, 100, 500]
for rs in curr: for rs in curr:
@ -202,11 +208,11 @@ class account_cash_statement(osv.osv):
res.append((0, 0, dct)) res.append((0, 0, dct))
return res 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 = {} res = {}
start_l = [] start_l = []
end_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) ending_details = self._get_default_cash_close_box_lines(cr, uid, context)
for start in starting_details: for start in starting_details:
start_l.append((0, 0, start)) start_l.append((0, 0, start))
@ -240,6 +246,7 @@ class account_cash_statement(osv.osv):
} }
def create(self, cr, uid, vals, context=None): def create(self, cr, uid, vals, context=None):
context = context or {}
sql = [ sql = [
('journal_id', '=', vals.get('journal_id', False)), ('journal_id', '=', vals.get('journal_id', False)),
('state', '=', 'open') ('state', '=', 'open')
@ -248,7 +255,7 @@ class account_cash_statement(osv.osv):
if open_jrnl: if open_jrnl:
raise osv.except_osv('Error', _('You can not have two open register for the same journal')) 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) open_close = self._get_cash_open_close_box_lines(cr, uid, context)
if vals.get('starting_details_ids', False): if vals.get('starting_details_ids', False):
for start in vals.get('starting_details_ids'): for start in vals.get('starting_details_ids'):

View File

@ -107,9 +107,10 @@ class account_move_line(osv.osv):
del data[f] del data[f]
return data return data
def create_analytic_lines(self, cr, uid, ids, context={}): def create_analytic_lines(self, cr, uid, ids, context=None):
context = context or {}
acc_ana_line_obj = self.pool.get('account.analytic.line') 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 obj_line.analytic_account_id:
if not obj_line.journal_id.analytic_journal_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, )) 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 +140,8 @@ class account_move_line(osv.osv):
del(data['account_tax_id']) del(data['account_tax_id'])
return data return data
def convert_to_period(self, cr, uid, context={}): def convert_to_period(self, cr, uid, context=None):
context = context or {}
period_obj = self.pool.get('account.period') period_obj = self.pool.get('account.period')
#check if the period_id changed in the context from client side #check if the period_id changed in the context from client side
if context.get('period_id', False): if context.get('period_id', False):
@ -151,7 +153,8 @@ class account_move_line(osv.osv):
}) })
return context return context
def _default_get(self, cr, uid, fields, context={}): def _default_get(self, cr, uid, fields, context=None):
context = context or {}
if not context.get('journal_id', False) and context.get('search_default_journal_id', False): if not context.get('journal_id', False) and context.get('search_default_journal_id', False):
context['journal_id'] = context.get('search_default_journal_id') context['journal_id'] = context.get('search_default_journal_id')
account_obj = self.pool.get('account.account') account_obj = self.pool.get('account.account')
@ -164,7 +167,7 @@ class account_move_line(osv.osv):
currency_obj = self.pool.get('res.currency') currency_obj = self.pool.get('res.currency')
context = self.convert_to_period(cr, uid, context) context = self.convert_to_period(cr, uid, context)
# Compute simple values # 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 # Starts: Manual entry from account.move form
if context.get('lines',[]): if context.get('lines',[]):
total_new = 0.00 total_new = 0.00
@ -174,7 +177,7 @@ class account_move_line(osv.osv):
for item in i[2]: for item in i[2]:
data[item] = i[2][item] data[item] = i[2][item]
if context['journal']: 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 journal_data.type == 'purchase':
if total_new > 0: if total_new > 0:
account = journal_data.default_credit_account_id account = journal_data.default_credit_account_id
@ -186,9 +189,9 @@ class account_move_line(osv.osv):
else: else:
account = journal_data.default_debit_account_id 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']): 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 = 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 data['account_id'] = account.id
s = -total_new s = -total_new
@ -236,7 +239,7 @@ class account_move_line(osv.osv):
return data return data
total = 0 total = 0
ref_id = False 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: if 'name' in fields:
data.setdefault('name', move.line_id[-1].name) data.setdefault('name', move.line_id[-1].name)
acc1 = False acc1 = False
@ -265,7 +268,7 @@ class account_move_line(osv.osv):
# part = False is acceptable for fiscal position. # 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) account = fiscal_pos_obj.map_account(cr, uid, part and part.property_account_position or False, account.id)
if account: 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)): if account and ((not fields) or ('debit' in fields) or ('credit' in fields)):
data['account_id'] = account.id data['account_id'] = account.id
@ -289,7 +292,8 @@ class account_move_line(osv.osv):
data['amount_currency'] = v data['amount_currency'] = v
return data return data
def on_create_write(self, cr, uid, id, context={}): def on_create_write(self, cr, uid, id, context=None):
context = context or {}
if not id: if not id:
return [] return []
ml = self.browse(cr, uid, id, context) ml = self.browse(cr, uid, id, context)
@ -338,7 +342,8 @@ class account_move_line(osv.osv):
res[line_id] = (invoice_id, invoice_names[invoice_id]) res[line_id] = (invoice_id, invoice_names[invoice_id])
return res return res
def name_get(self, cr, uid, ids, context={}): def name_get(self, cr, uid, ids, context=None):
context = context or {}
if not ids: if not ids:
return [] return []
result = [] result = []
@ -408,6 +413,7 @@ class account_move_line(osv.osv):
return [('id', 'in', [x[0] for x in res])] return [('id', 'in', [x[0] for x in res])]
def _get_move_lines(self, cr, uid, ids, context=None): def _get_move_lines(self, cr, uid, ids, context=None):
context = context or {}
result = [] result = []
for move in self.pool.get('account.move').browse(cr, uid, ids, context=context): for move in self.pool.get('account.move').browse(cr, uid, ids, context=context):
for line in move.line_id: for line in move.line_id:
@ -458,6 +464,7 @@ class account_move_line(osv.osv):
} }
def _get_date(self, cr, uid, context=None): def _get_date(self, cr, uid, context=None):
context = context or {}
period_obj = self.pool.get('account.period') period_obj = self.pool.get('account.period')
dt = time.strftime('%Y-%m-%d') dt = time.strftime('%Y-%m-%d')
if ('journal_id' in context) and ('period_id' in context): if ('journal_id' in context) and ('period_id' in context):
@ -498,35 +505,40 @@ class account_move_line(osv.osv):
('credit_debit2', 'CHECK (credit+debit>=0)', 'Wrong credit or debit value in accounting entry !'), ('credit_debit2', 'CHECK (credit+debit>=0)', 'Wrong credit or debit value in accounting entry !'),
] ]
def _auto_init(self, cr, context={}): def _auto_init(self, cr, context=None):
super(account_move_line, self)._auto_init(cr, context) context = context or {}
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\'') cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'account_move_line_journal_id_period_id_index\'')
if not cr.fetchone(): if not cr.fetchone():
cr.execute('CREATE INDEX account_move_line_journal_id_period_id_index ON account_move_line (journal_id, period_id)') 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): def _check_no_view(self, cr, uid, ids, context=None):
lines = self.browse(cr, uid, ids) context = context or {}
lines = self.browse(cr, uid, ids, context=context)
for l in lines: for l in lines:
if l.account_id.type == 'view': if l.account_id.type == 'view':
return False return False
return True return True
def _check_no_closed(self, cr, uid, ids): def _check_no_closed(self, cr, uid, ids, context=None):
lines = self.browse(cr, uid, ids) context = context or {}
lines = self.browse(cr, uid, ids, context=context)
for l in lines: for l in lines:
if l.account_id.type == 'closed': if l.account_id.type == 'closed':
return False return False
return True return True
def _check_company_id(self, cr, uid, ids): def _check_company_id(self, cr, uid, ids, context=None):
lines = self.browse(cr, uid, ids) context = context or {}
lines = self.browse(cr, uid, ids, context=context)
for l in lines: for l in lines:
if l.company_id != l.account_id.company_id or l.company_id != l.period_id.company_id: if l.company_id != l.account_id.company_id or l.company_id != l.period_id.company_id:
return False return False
return True return True
def _check_partner_id(self, cr, uid, ids): def _check_partner_id(self, cr, uid, ids, context=None):
lines = self.browse(cr, uid, ids) context = context or {}
lines = self.browse(cr, uid, ids, context=context)
for l in lines: for l in lines:
if l.account_id.type in ('receivable', 'payable') and not l.partner_id: if l.account_id.type in ('receivable', 'payable') and not l.partner_id:
return False return False
@ -825,7 +837,7 @@ class account_move_line(osv.osv):
return j+(p and (':'+p) or '') return j+(p and (':'+p) or '')
return False 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 Returns a dict that contains new values and context
@param cr: A database cursor @param cr: A database cursor
@ -836,6 +848,7 @@ class account_move_line(osv.osv):
@return: Returns a dict which contains new values, and context @return: Returns a dict which contains new values, and context
""" """
res = {} res = {}
context = context or {}
period_pool = self.pool.get('account.period') period_pool = self.pool.get('account.period')
pids = period_pool.search(cr, user, [('date_start','<=',date), ('date_stop','>=',date)]) pids = period_pool.search(cr, user, [('date_start','<=',date), ('date_stop','>=',date)])
if pids: if pids:
@ -850,9 +863,10 @@ class account_move_line(osv.osv):
'context':context, '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') 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) context = context or {}
result = super(osv.osv, self).fields_view_get(cr, uid, view_id, view_type, context=context, toolbar=toolbar, submenu=submenu)
if view_type != 'tree': if view_type != 'tree':
#Remove the toolbar from the form view #Remove the toolbar from the form view
if view_type == 'form': if view_type == 'form':
@ -871,7 +885,7 @@ class account_move_line(osv.osv):
xml = '''<?xml version="1.0"?>\n<tree string="%s" editable="top" refresh="5" on_write="on_create_write" colors="red:state==\'draft\';black:state==\'valid\'">\n\t''' % (title) xml = '''<?xml version="1.0"?>\n<tree string="%s" editable="top" refresh="5" on_write="on_create_write" colors="red:state==\'draft\';black:state==\'valid\'">\n\t''' % (title)
ids = journal_pool.search(cr, uid, []) 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] all_journal = [None]
common_fields = {} common_fields = {}
total = len(journals) total = len(journals)
@ -952,8 +966,9 @@ class account_move_line(osv.osv):
result['fields'] = self.fields_get(cr, uid, flds, context) result['fields'] = self.fields_get(cr, uid, flds, context)
return result 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 # use the first move ever created for this journal and period
context = context or {}
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'])) 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() res = cr.fetchone()
if res: if res:
@ -968,6 +983,7 @@ class account_move_line(osv.osv):
obj_move_line = self.pool.get('account.move.line') obj_move_line = self.pool.get('account.move.line')
obj_move_rec = self.pool.get('account.move.reconcile') obj_move_rec = self.pool.get('account.move.reconcile')
unlink_ids = [] unlink_ids = []
context = context or {}
if not move_ids: if not move_ids:
return True return True
recs = obj_move_line.read(cr, uid, move_ids, ['reconcile_id', 'reconcile_partial_id']) recs = obj_move_line.read(cr, uid, move_ids, ['reconcile_id', 'reconcile_partial_id'])
@ -981,7 +997,8 @@ class account_move_line(osv.osv):
obj_move_rec.unlink(cr, uid, unlink_ids) obj_move_rec.unlink(cr, uid, unlink_ids)
return True return True
def unlink(self, cr, uid, ids, context={}, check=True): def unlink(self, cr, uid, ids, context=None, check=True):
context = context or {}
move_obj = self.pool.get('account.move') move_obj = self.pool.get('account.move')
self._update_check(cr, uid, ids, context) self._update_check(cr, uid, ids, context)
result = False result = False
@ -1014,7 +1031,7 @@ class account_move_line(osv.osv):
journal_id = context.get('journal_id', False) journal_id = context.get('journal_id', False)
period_id = context.get('period_id', False) period_id = context.get('period_id', False)
if journal_id: if journal_id:
journal = journal_obj.browse(cr, uid, [journal_id])[0] journal = journal_obj.browse(cr, uid, [journal_id], context=context)[0]
if journal.allow_date and period_id: if journal.allow_date and period_id:
period = period_obj.browse(cr, uid, [period_id])[0] period = period_obj.browse(cr, uid, [period_id])[0]
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'): 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'):
@ -1069,18 +1086,19 @@ class account_move_line(osv.osv):
move_obj.write(cr, uid, [line.move_id.id], {'date': todo_date}, context=context) move_obj.write(cr, uid, [line.move_id.id], {'date': todo_date}, context=context)
return result 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') journal_obj = self.pool.get('account.journal')
period_obj = self.pool.get('account.period') period_obj = self.pool.get('account.period')
jour_period_obj = self.pool.get('account.journal.period') jour_period_obj = self.pool.get('account.journal.period')
cr.execute('SELECT state FROM account_journal_period WHERE journal_id = %s AND period_id = %s', (journal_id, period_id)) cr.execute('SELECT state FROM account_journal_period WHERE journal_id = %s AND period_id = %s', (journal_id, period_id))
result = cr.fetchall() result = cr.fetchall()
context = context or {}
for (state,) in result: for (state,) in result:
if state == 'done': if state == 'done':
raise osv.except_osv(_('Error !'), _('You can not add/modify entries in a closed journal.')) raise osv.except_osv(_('Error !'), _('You can not add/modify entries in a closed journal.'))
if not result: if not result:
journal = journal_obj.browse(cr, uid, journal_id, context) journal = journal_obj.browse(cr, uid, journal_id, context=context)
period = period_obj.browse(cr, uid, period_id, context) period = period_obj.browse(cr, uid, period_id, context=context)
jour_period_obj.create(cr, uid, { jour_period_obj.create(cr, uid, {
'name': (journal.code or journal.name)+':'+(period.name or ''), 'name': (journal.code or journal.name)+':'+(period.name or ''),
'journal_id': journal.id, 'journal_id': journal.id,
@ -1088,9 +1106,10 @@ class account_move_line(osv.osv):
}) })
return True return True
def _update_check(self, cr, uid, ids, context={}): def _update_check(self, cr, uid, ids, context=None):
done = {} done = {}
for line in self.browse(cr, uid, ids, context): context = context or {}
for line in self.browse(cr, uid, ids, context=context):
if line.move_id.state <> 'draft': if line.move_id.state <> 'draft':
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 !')) 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: if line.reconcile_id:
@ -1127,7 +1146,7 @@ class account_move_line(osv.osv):
self._update_journal_check(cr, uid, context['journal_id'], context['period_id'], context) self._update_journal_check(cr, uid, context['journal_id'], context['period_id'], context)
move_id = vals.get('move_id', False) 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 not move_id:
if journal.centralisation: if journal.centralisation:
#Check for centralisation #Check for centralisation
@ -1150,7 +1169,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.')) 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) ok = not (journal.type_control_ids or journal.account_control_ids)
if ('account_id' in vals): 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: if journal.type_control_ids:
type = account.user_type type = account.user_type
for t in journal.type_control_ids: for t in journal.type_control_ids:

View File

@ -89,11 +89,11 @@ class account_invoice(osv.osv):
def _amount_residual(self, cr, uid, ids, name, args, context=None): def _amount_residual(self, cr, uid, ids, name, args, context=None):
res = {} res = {}
cur_obj = self.pool.get('res.currency')
data_inv = self.browse(cr, uid, ids)
if context is None: if context is None:
context = {} context = {}
cur_obj = self.pool.get('res.currency')
data_inv = self.browse(cr, uid, ids, context=context)
for inv in data_inv: for inv in data_inv:
debit = credit = 0.0 debit = credit = 0.0
context.update({'date':inv.date_invoice}) 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): def _compute_lines(self, cr, uid, ids, name, args, context=None):
result = {} result = {}
for invoice in self.browse(cr, uid, ids, context): for invoice in self.browse(cr, uid, ids, context=context):
src = [] src = []
lines = [] lines = []
if invoice.move_id: if invoice.move_id:
@ -187,7 +187,10 @@ class account_invoice(osv.osv):
def _get_invoice_from_line(self, cr, uid, ids, context=None): def _get_invoice_from_line(self, cr, uid, ids, context=None):
move = {} move = {}
for line in self.pool.get('account.move.line').browse(cr, uid, ids): if context is None:
context = {}
for line in self.pool.get('account.move.line').browse(cr, uid, ids, context=context):
if line.reconcile_partial_id: if line.reconcile_partial_id:
for line2 in line.reconcile_partial_id.line_partial_ids: for line2 in line.reconcile_partial_id.line_partial_ids:
move[line2.move_id.id] = True move[line2.move_id.id] = True
@ -201,7 +204,10 @@ class account_invoice(osv.osv):
def _get_invoice_from_reconcile(self, cr, uid, ids, context=None): def _get_invoice_from_reconcile(self, cr, uid, ids, context=None):
move = {} move = {}
for r in self.pool.get('account.move.reconcile').browse(cr, uid, ids): if context is None:
context = {}
for r in self.pool.get('account.move.reconcile').browse(cr, uid, ids, context=context):
for line in r.line_partial_ids: for line in r.line_partial_ids:
move[line.move_id.id] = True move[line.move_id.id] = True
for line in r.line_id: for line in r.line_id:
@ -326,6 +332,9 @@ class account_invoice(osv.osv):
def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False): def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False):
journal_obj = self.pool.get('account.journal') journal_obj = self.pool.get('account.journal')
if context is None:
context = {}
if context.get('active_model','') in ['res.partner']: if context.get('active_model','') in ['res.partner']:
partner = self.pool.get(context['active_model']).read(cr,uid,context['active_ids'],['supplier','customer'])[0] partner = self.pool.get(context['active_model']).read(cr,uid,context['active_ids'],['supplier','customer'])[0]
if not view_type: if not view_type:
@ -668,8 +677,10 @@ class account_invoice(osv.osv):
return True return True
def button_compute(self, cr, uid, ids, context=None, set_total=False): def button_compute(self, cr, uid, ids, context=None, set_total=False):
if context is None:
context = {}
self.button_reset_taxes(cr, uid, ids, context) 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: if set_total:
self.pool.get('account.invoice').write(cr, uid, [inv.id], {'check_total': inv.amount_total}) self.pool.get('account.invoice').write(cr, uid, [inv.id], {'check_total': inv.amount_total})
return True return True
@ -981,7 +992,7 @@ class account_invoice(osv.osv):
#TODO: not correct fix but required a frech values before reading it. #TODO: not correct fix but required a frech values before reading it.
self.write(cr, uid, ids, {}) 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 id = obj_inv.id
invtype = obj_inv.type invtype = obj_inv.type
number = obj_inv.number number = obj_inv.number
@ -1149,7 +1160,7 @@ class account_invoice(osv.osv):
context = {} context = {}
#TODO check if we can use different period for payment and the writeoff line #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" 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 src_account_id = invoice.account_id.id
# Take the seq as name for move # Take the seq as name for move
types = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1, 'in_refund': -1} types = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1, 'in_refund': -1}
@ -1313,9 +1324,9 @@ class account_invoice_line(osv.osv):
return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}} return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}}
else: else:
return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}} 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_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: if part.lang:
context.update({'lang': part.lang}) context.update({'lang': part.lang})
@ -1345,7 +1356,7 @@ class account_invoice_line(osv.osv):
# Parse the value_reference field to get the ID of the account.account record # Parse the value_reference field to get the ID of the account.account record
account_id = int (my_value[0]["value_reference"].split(",")[1]) 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 # 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)[0]
if not exp_pro_id: if not exp_pro_id:
ex_acc = res.product_tmpl_id.property_account_expense ex_acc = res.product_tmpl_id.property_account_expense
ex_acc_cate = res.categ_id.property_account_expense_categ ex_acc_cate = res.categ_id.property_account_expense_categ
@ -1354,7 +1365,7 @@ class account_invoice_line(osv.osv):
else: else:
app_acc_exp = ex_acc_cate app_acc_exp = ex_acc_cate
else: 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: if not in_pro_id and not exp_pro_id:
in_acc = res.product_tmpl_id.property_account_income in_acc = res.product_tmpl_id.property_account_income
in_acc_cate = res.categ_id.property_account_income_categ in_acc_cate = res.categ_id.property_account_income_categ
@ -1372,8 +1383,8 @@ class account_invoice_line(osv.osv):
if not in_res_id and not exp_res_id: if not in_res_id and not exp_res_id:
raise osv.except_osv(_('Configuration Error !'), raise osv.except_osv(_('Configuration Error !'),
_('Can not find account chart for this company, Please Create account.')) _('Can not find account chart for this company, Please Create account.'))
in_obj_acc = account_obj.browse(cr, uid, in_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) exp_obj_acc = account_obj.browse(cr, uid, exp_res_id, context=context)
if in_acc or ex_acc: if in_acc or ex_acc:
res.product_tmpl_id.property_account_income = in_obj_acc[0] res.product_tmpl_id.property_account_income = in_obj_acc[0]
res.product_tmpl_id.property_account_expense = exp_obj_acc[0] res.product_tmpl_id.property_account_expense = exp_obj_acc[0]
@ -1421,8 +1432,8 @@ class account_invoice_line(osv.osv):
if not company_id or not currency_id: if not company_id or not currency_id:
return res_final return res_final
company = self.pool.get('res.company').browse(cr, uid, company_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) currency = self.pool.get('res.currency').browse(cr, uid, currency_id, context=context)
if company.currency_id.id != currency.id: if company.currency_id.id != currency.id:
new_price = res_final['value']['price_unit'] * currency.rate new_price = res_final['value']['price_unit'] * currency.rate
@ -1447,7 +1458,9 @@ class account_invoice_line(osv.osv):
res = [] res = []
tax_obj = self.pool.get('account.tax') tax_obj = self.pool.get('account.tax')
cur_obj = self.pool.get('res.currency') 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 company_currency = inv.company_id.currency_id.id
for line in inv.invoice_line: for line in inv.invoice_line:
@ -1514,6 +1527,9 @@ class account_invoice_tax(osv.osv):
def _count_factor(self, cr, uid, ids, name, args, context=None): def _count_factor(self, cr, uid, ids, name, args, context=None):
res = {} res = {}
if context is None:
context = {}
for invoice_tax in self.browse(cr, uid, ids, context=context): for invoice_tax in self.browse(cr, uid, ids, context=context):
res[invoice_tax.id] = { res[invoice_tax.id] = {
'factor_base': 1.0, 'factor_base': 1.0,
@ -1578,11 +1594,14 @@ class account_invoice_tax(osv.osv):
'base_amount': 0.0, 'base_amount': 0.0,
'tax_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_grouped = {}
if context is None:
context = {}
tax_obj = self.pool.get('account.tax') tax_obj = self.pool.get('account.tax')
cur_obj = self.pool.get('res.currency') 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 cur = inv.currency_id
company_currency = inv.company_id.currency_id.id company_currency = inv.company_id.currency_id.id

View File

@ -34,7 +34,10 @@ class account_fiscal_position(osv.osv):
'note': fields.text('Notes', translate=True), '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 context is None:
context = {}
if not taxes: if not taxes:
return [] return []
if not fposition_id: if not fposition_id:
@ -51,7 +54,9 @@ class account_fiscal_position(osv.osv):
result.append(t.id) result.append(t.id)
return result 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 context is None:
context = {}
if not fposition_id: if not fposition_id:
return account_id return account_id
for pos in fposition_id.account_ids: for pos in fposition_id.account_ids:

View File

@ -29,7 +29,9 @@ class project_account_analytic_line(osv.osv_memory):
'to_date': fields.date('To'), 'to_date': fields.date('To'),
} }
def action_open_window(self, cr, uid, ids, context={}): def action_open_window(self, cr, uid, ids, context=None):
if context is None:
context = {}
mod_obj =self.pool.get('ir.model.data') mod_obj =self.pool.get('ir.model.data')
domain = [] domain = []
data = self.read(cr, uid, ids, [])[0] data = self.read(cr, uid, ids, [])[0]

View File

@ -27,7 +27,9 @@ import pooler
import tools import tools
from osv import fields,osv from osv import fields,osv
def _code_get(self, cr, uid, context={}): def _code_get(self, cr, uid, context=None):
if context is None:
context = {}
acc_type_obj = self.pool.get('account.account.type') acc_type_obj = self.pool.get('account.account.type')
ids = acc_type_obj.search(cr, uid, []) ids = acc_type_obj.search(cr, uid, [])
res = acc_type_obj.read(cr, uid, ids, ['code', 'name'], context) res = acc_type_obj.read(cr, uid, ids, ['code', 'name'], context)
@ -98,9 +100,11 @@ 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) res = super(report_aged_receivable, self).fields_view_get(cr, user, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
return res return res
def _calc_bal(self, cr, uid, ids, name, args, context): def _calc_bal(self, cr, uid, ids, name, args, context=None):
res = {} res = {}
for period in self.read(cr,uid,ids,['name']): if context is None:
context = {}
for period in self.read(cr,uid,ids,['name'],context=context):
date1,date2 = period['name'].split(' to ') date1,date2 = period['name'].split(' to ')
cr.execute("SELECT SUM(credit-debit) FROM account_move_line AS line, account_account as ac \ 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' \ WHERE (line.account_id=ac.id) AND ac.type='receivable' \

View File

@ -42,10 +42,14 @@ class account_automatic_reconcile(osv.osv_memory):
'allow_write_off': fields.boolean('Allow write off') '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) 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) return context.get('unreconciled', 0)
_defaults = { _defaults = {
@ -175,7 +179,7 @@ class account_automatic_reconcile(osv.osv_memory):
if allow_write_off: if allow_write_off:
move_line_obj.reconcile(cr, uid, line_ids, 'auto', form['writeoff_acc_id'], form['period_id'], form['journal_id'], context) move_line_obj.reconcile(cr, uid, line_ids, 'auto', form['writeoff_acc_id'], form['period_id'], form['journal_id'], context)
else: 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 # get the list of partners who have more than one unreconciled transaction
cr.execute( cr.execute(

View File

@ -32,13 +32,15 @@ class account_move_bank_reconcile(osv.osv_memory):
'journal_id': fields.many2one('account.journal', 'Journal', required=True), '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 cr: the current row, from the database cursor,
@param uid: the current users ID for security checks, @param uid: the current users ID for security checks,
@param ids: account move bank reconciles ID or list of IDs @param ids: account move bank reconciles ID or list of IDs
@return: dictionary of Open account move line on given journal_id. @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] data = self.read(cr, uid, ids, context=context)[0]
cr.execute('select default_credit_account_id \ cr.execute('select default_credit_account_id \
from account_journal where id=%s', (data['journal_id'],)) from account_journal where id=%s', (data['journal_id'],))

View File

@ -29,10 +29,12 @@ class account_move_journal(osv.osv_memory):
_name = "account.move.journal" _name = "account.move.journal"
_description = "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 Return default account period value
""" """
if context is None:
context = {}
account_period_obj = self.pool.get('account.period') account_period_obj = self.pool.get('account.period')
ids = account_period_obj.find(cr, uid, context=context) ids = account_period_obj.find(cr, uid, context=context)
period_id = False period_id = False
@ -40,12 +42,14 @@ class account_move_journal(osv.osv_memory):
period_id = ids[0] period_id = ids[0]
return period_id 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 Return journal based on the journal type
""" """
journal_id = False journal_id = False
if context is None:
context = {}
journal_pool = self.pool.get('account.journal') journal_pool = self.pool.get('account.journal')
if context.get('journal_type', False): if context.get('journal_type', False):

View File

@ -30,7 +30,7 @@ class account_move_line_reconcile_select(osv.osv_memory):
domain = [('reconcile', '=', 1)], required=True), 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 This function Open account move line window for reconcile on given account id
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@ -39,6 +39,8 @@ class account_move_line_reconcile_select(osv.osv_memory):
@return: dictionary of Open account move line window for reconcile on given account id @return: dictionary of Open account move line window for reconcile on given account id
""" """
if context is None:
context = {}
data = self.read(cr, uid, ids, context=context)[0] data = self.read(cr, uid, ids, context=context)[0]
return { return {
'domain': "[('account_id','=',%d),('reconcile_id','=',False),('state','<>','draft')]" % data['account_id'], 'domain': "[('account_id','=',%d),('reconcile_id','=',False),('state','<>','draft')]" % data['account_id'],

View File

@ -27,7 +27,9 @@ class account_move_line_unreconcile_select(osv.osv_memory):
_columns ={ _columns ={
'account_id': fields.many2one('account.account','Account',required=True), '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):
if context is None:
context = {}
data = self.read(cr, uid, ids, context=context)[0] data = self.read(cr, uid, ids, context=context)[0]
return { return {
'domain': "[('account_id','=',%d),('reconcile_id','<>',False),('state','<>','draft')]" % data['account_id'], 'domain': "[('account_id','=',%d),('reconcile_id','<>',False),('state','<>','draft')]" % data['account_id'],

View File

@ -30,12 +30,14 @@ 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'), '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):
if context is None:
context = {}
fy_obj = self.pool.get('account.fiscalyear') fy_obj = self.pool.get('account.fiscalyear')
move_obj = self.pool.get('account.move') move_obj = self.pool.get('account.move')
data = self.read(cr, uid, ids, [])[0] data = self.read(cr, uid, ids, [])[0]
data_fyear = fy_obj.browse(cr, uid, data['fyear_id']) data_fyear = fy_obj.browse(cr, uid, data['fyear_id'], context=context)
if not data_fyear.end_journal_period_id: 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')) 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 period_journal = data_fyear.end_journal_period_id

View File

@ -33,7 +33,9 @@ class account_subscription_generate(osv.osv_memory):
_defaults = { _defaults = {
'date': lambda *a: time.strftime('%Y-%m-%d'), '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):
if context is None:
context = {}
mod_obj = self.pool.get('ir.model.data') mod_obj = self.pool.get('ir.model.data')
act_obj = self.pool.get('ir.actions.act_window') act_obj = self.pool.get('ir.actions.act_window')
moves_created=[] moves_created=[]

View File

@ -33,6 +33,8 @@ class account_analytic_account(osv.osv):
def _analysis_all(self, cr, uid, ids, fields, arg, context=None): def _analysis_all(self, cr, uid, ids, fields, arg, context=None):
dp = 2 dp = 2
res = dict([(i, {}) for i in ids]) res = dict([(i, {}) for i in ids])
if context is None:
context = {}
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)], context=context)) parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)], context=context))
accounts = self.browse(cr, uid, ids, context=context) accounts = self.browse(cr, uid, ids, context=context)
@ -251,6 +253,8 @@ class account_analytic_account(osv.osv):
def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context=None): def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context=None):
res = {} res = {}
res_final = {} res_final = {}
if context is None:
context = {}
child_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)], context=context)) child_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)], context=context))
for i in child_ids: for i in child_ids:
res[i] = {} res[i] = {}
@ -269,7 +273,7 @@ class account_analytic_account(osv.osv):
GROUP BY account_analytic_line.account_id", (child_ids,)) GROUP BY account_analytic_line.account_id", (child_ids,))
for account_id, sum in cr.fetchall(): for account_id, sum in cr.fetchall():
res[account_id][name] = round(sum,2) 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: for i in data:
res_final[i] = data[i][name] res_final[i] = data[i][name]
return res_final return res_final
@ -277,6 +281,8 @@ class account_analytic_account(osv.osv):
def _total_cost_calc(self, cr, uid, ids, name, arg, context=None): def _total_cost_calc(self, cr, uid, ids, name, arg, context=None):
res = {} res = {}
res_final = {} res_final = {}
if context is None:
context = {}
child_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)], context=context)) child_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)], context=context))
for i in child_ids: for i in child_ids:
@ -303,6 +309,8 @@ class account_analytic_account(osv.osv):
def _remaining_hours_calc(self, cr, uid, ids, name, arg, context=None): def _remaining_hours_calc(self, cr, uid, ids, name, arg, context=None):
res = {} res = {}
if context is None:
context = {}
for account in self.browse(cr, uid, ids, context=context): for account in self.browse(cr, uid, ids, context=context):
if account.quantity_max != 0: if account.quantity_max != 0:
res[account.id] = account.quantity_max - account.hours_quantity res[account.id] = account.quantity_max - account.hours_quantity
@ -314,6 +322,8 @@ class account_analytic_account(osv.osv):
def _hours_qtt_invoiced_calc(self, cr, uid, ids, name, arg, context=None): def _hours_qtt_invoiced_calc(self, cr, uid, ids, name, arg, context=None):
res = {} res = {}
if context is None:
context = {}
for account in self.browse(cr, uid, ids, context=context): for account in self.browse(cr, uid, ids, context=context):
res[account.id] = account.hours_quantity - account.hours_qtt_non_invoiced res[account.id] = account.hours_quantity - account.hours_qtt_non_invoiced
if res[account.id] < 0: if res[account.id] < 0:
@ -324,7 +334,9 @@ class account_analytic_account(osv.osv):
def _revenue_per_hour_calc(self, cr, uid, ids, name, arg, context=None): def _revenue_per_hour_calc(self, cr, uid, ids, name, arg, context=None):
res = {} res = {}
for account in self.browse(cr, uid, ids): if context is None:
context = {}
for account in self.browse(cr, uid, ids, context=context):
if account.hours_qtt_invoiced == 0: if account.hours_qtt_invoiced == 0:
res[account.id]=0.0 res[account.id]=0.0
else: else:
@ -335,7 +347,9 @@ class account_analytic_account(osv.osv):
def _real_margin_rate_calc(self, cr, uid, ids, name, arg, context=None): def _real_margin_rate_calc(self, cr, uid, ids, name, arg, context=None):
res = {} res = {}
for account in self.browse(cr, uid, ids): if context is None:
context = {}
for account in self.browse(cr, uid, ids, context=context):
if account.ca_invoiced == 0: if account.ca_invoiced == 0:
res[account.id]=0.0 res[account.id]=0.0
elif account.total_cost != 0.0: elif account.total_cost != 0.0:
@ -348,7 +362,9 @@ class account_analytic_account(osv.osv):
def _remaining_ca_calc(self, cr, uid, ids, name, arg, context=None): def _remaining_ca_calc(self, cr, uid, ids, name, arg, context=None):
res = {} res = {}
for account in self.browse(cr, uid, ids): if context is None:
context = {}
for account in self.browse(cr, uid, ids, context=context):
if account.amount_max != 0: if account.amount_max != 0:
res[account.id] = account.amount_max - account.ca_invoiced res[account.id] = account.amount_max - account.ca_invoiced
else: else:
@ -359,7 +375,9 @@ class account_analytic_account(osv.osv):
def _real_margin_calc(self, cr, uid, ids, name, arg, context=None): def _real_margin_calc(self, cr, uid, ids, name, arg, context=None):
res = {} res = {}
for account in self.browse(cr, uid, ids): if context is None:
context = {}
for account in self.browse(cr, uid, ids, context=context):
res[account.id] = account.ca_invoiced + account.total_cost res[account.id] = account.ca_invoiced + account.total_cost
for id in ids: for id in ids:
res[id] = round(res.get(id, 0.0),2) res[id] = round(res.get(id, 0.0),2)
@ -367,7 +385,9 @@ class account_analytic_account(osv.osv):
def _theorical_margin_calc(self, cr, uid, ids, name, arg, context=None): def _theorical_margin_calc(self, cr, uid, ids, name, arg, context=None):
res = {} res = {}
for account in self.browse(cr, uid, ids): if context is None:
context = {}
for account in self.browse(cr, uid, ids, context=context):
res[account.id] = account.ca_theorical + account.total_cost res[account.id] = account.ca_theorical + account.total_cost
for id in ids: for id in ids:
res[id] = round(res.get(id, 0.0),2) res[id] = round(res.get(id, 0.0),2)
@ -430,6 +450,8 @@ class account_analytic_account_summary_user(osv.osv):
def _unit_amount(self, cr, uid, ids, name, arg, context=None): def _unit_amount(self, cr, uid, ids, name, arg, context=None):
res = {} res = {}
if context is None:
context = {}
account_obj = self.pool.get('account.analytic.account') account_obj = self.pool.get('account.analytic.account')
cr.execute('SELECT MAX(id) FROM res_users') cr.execute('SELECT MAX(id) FROM res_users')
max_user = cr.fetchone()[0] max_user = cr.fetchone()[0]
@ -596,6 +618,8 @@ class account_analytic_account_summary_month(osv.osv):
def _unit_amount(self, cr, uid, ids, name, arg, context=None): def _unit_amount(self, cr, uid, ids, name, arg, context=None):
res = {} res = {}
if context is None:
context = {}
account_obj = self.pool.get('account.analytic.account') account_obj = self.pool.get('account.analytic.account')
account_ids = [int(str(int(x))[:-6]) for x in ids] account_ids = [int(str(int(x))[:-6]) for x in ids]
month_ids = [int(str(int(x))[-6:]) for x in ids] month_ids = [int(str(int(x))[-6:]) for x in ids]

View File

@ -41,6 +41,8 @@ class account_analytic_default(osv.osv):
def account_get(self, cr, uid, product_id=None, partner_id=None, user_id=None, date=None, context=None): def account_get(self, cr, uid, product_id=None, partner_id=None, user_id=None, date=None, context=None):
domain = [] domain = []
if context is None:
context = {}
if product_id: if product_id:
domain += ['|', ('product_id', '=', product_id)] domain += ['|', ('product_id', '=', product_id)]
domain += [('product_id','=', False)] domain += [('product_id','=', False)]
@ -104,6 +106,8 @@ class sale_order_line(osv.osv):
# Method overridden to set the analytic account by default on criterion match # Method overridden to set the analytic account by default on criterion match
def invoice_line_create(self, cr, uid, ids, context=None): def invoice_line_create(self, cr, uid, ids, context=None):
if context is None:
context = {}
create_ids = super(sale_order_line, self).invoice_line_create(cr, uid, ids, context=context) create_ids = super(sale_order_line, self).invoice_line_create(cr, uid, ids, context=context)
if not ids: if not ids:
return create_ids return create_ids

View File

@ -148,6 +148,8 @@ class account_analytic_plan_instance(osv.osv):
return self.name_get(cr, uid, ids, context or {}) 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): 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) 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) 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') 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) 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): 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) this = self.browse(cr, uid, ids[0], context=context)
invoice_line_obj = self.pool.get('account.invoice.line') invoice_line_obj = self.pool.get('account.invoice.line')
if this.plan_id and not vals.has_key('plan_id'): if this.plan_id and not vals.has_key('plan_id'):
@ -307,6 +311,8 @@ class account_move_line(osv.osv):
return data return data
def create_analytic_lines(self, cr, uid, ids, context=None): 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) super(account_move_line, self).create_analytic_lines(cr, uid, ids, context=context)
analytic_line_obj = self.pool.get('account.analytic.line') analytic_line_obj = self.pool.get('account.analytic.line')
for line in self.browse(cr, uid, ids, context=context): 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) analytic_line_obj.create(cr, uid, al_vals, context=context)
return True 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) result = super(osv.osv, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
return result return result
@ -347,6 +355,8 @@ class account_invoice(osv.osv):
_inherit = "account.invoice" _inherit = "account.invoice"
def line_get_convert(self, cr, uid, x, part, date, context=None): def line_get_convert(self, cr, uid, x, part, date, context=None):
if context is None:
context = {}
res=super(account_invoice,self).line_get_convert(cr, uid, x, part, date, context=context) res=super(account_invoice,self).line_get_convert(cr, uid, x, part, date, context=context)
res['analytics_id'] = x.get('analytics_id', False) res['analytics_id'] = x.get('analytics_id', False)
return res return res
@ -415,6 +425,8 @@ class sale_order_line(osv.osv):
# Method overridden to set the analytic account by default on criterion match # Method overridden to set the analytic account by default on criterion match
def invoice_line_create(self, cr, uid, ids, context=None): def invoice_line_create(self, cr, uid, ids, context=None):
if context is None:
context = {}
create_ids = super(sale_order_line,self).invoice_line_create(cr, uid, ids, context=context) create_ids = super(sale_order_line,self).invoice_line_create(cr, uid, ids, context=context)
inv_line_obj = self.pool.get('account.invoice.line') inv_line_obj = self.pool.get('account.invoice.line')
acct_anal_def_obj = self.pool.get('account.analytic.default') acct_anal_def_obj = self.pool.get('account.analytic.default')
@ -435,9 +447,11 @@ class account_bank_statement(osv.osv):
_name = "account.bank.statement" _name = "account.bank.statement"
def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, st_line_number, context=None): 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 = {}
account_move_line_pool = self.pool.get('account.move.line') account_move_line_pool = self.pool.get('account.move.line')
account_bank_statement_line_pool = self.pool.get('account.bank.statement.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) 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 move = st_line.move_ids and st_line.move_ids[0] or False
if move: if move:
@ -446,6 +460,8 @@ class account_bank_statement(osv.osv):
return result return result
def button_confirm_bank(self, cr, uid, ids, context=None): def button_confirm_bank(self, cr, uid, ids, context=None):
if context is None:
context = {}
super(account_bank_statement,self).button_confirm_bank(cr, uid, ids, context=context) 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):
for st_line in st.line_ids: for st_line in st.line_ids:

View File

@ -27,8 +27,10 @@ class account_invoice_line(osv.osv):
_inherit = "account.invoice.line" _inherit = "account.invoice.line"
def move_line_get(self, cr, uid, invoice_id, context=None): 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) if context is None:
inv = self.pool.get('account.invoice').browse(cr, uid, invoice_id) context = {}
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'): if inv.type in ('out_invoice','out_refund'):
for i_line in inv.invoice_line: for i_line in inv.invoice_line:
if i_line.product_id: if i_line.product_id:
@ -128,6 +130,8 @@ class account_invoice_line(osv.osv):
return res return res
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None):
if context is None:
context = {}
if not product: if not product:
return super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id, context) return super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id, context)
else: else:
@ -144,7 +148,7 @@ class account_invoice_line(osv.osv):
if not oa: if not oa:
oa = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id oa = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id
if oa: 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) a = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, oa)
res['value'].update({'account_id':a}) res['value'].update({'account_id':a})
return res return res

View File

@ -31,7 +31,8 @@ class stock_picking(osv.osv):
def action_invoice_create(self, cr, uid, ids, journal_id=False, def action_invoice_create(self, cr, uid, ids, journal_id=False,
group=False, type='out_invoice', context=None): group=False, type='out_invoice', context=None):
'''Return ids of created invoices for the pickings''' '''Return ids of created invoices for the pickings'''
res = super(stock_picking,self).action_invoice_create(cr, uid, ids, journal_id, group, type, context) if not context: context = {}
res = super(stock_picking,self).action_invoice_create(cr, uid, ids, journal_id, group, type, context=context)
if type == 'in_refund': if type == 'in_refund':
for inv in self.pool.get('account.invoice').browse(cr, uid, res.values(), context=context): for inv in self.pool.get('account.invoice').browse(cr, uid, res.values(), context=context):
for ol in inv.invoice_line: for ol in inv.invoice_line:

View File

@ -108,10 +108,11 @@ crossovered_budget()
class crossovered_budget_lines(osv.osv): class crossovered_budget_lines(osv.osv):
def _prac_amt(self, cr, uid, ids, context={}): def _prac_amt(self, cr, uid, ids, context=None):
res = {} res = {}
result = 0.0 result = 0.0
for line in self.browse(cr, uid, ids): if not context: context = {}
for line in self.browse(cr, uid, ids, context=context):
acc_ids = [x.id for x in line.general_budget_id.account_ids] acc_ids = [x.id for x in line.general_budget_id.account_ids]
if not acc_ids: if not acc_ids:
raise osv.except_osv(_('Error!'),_("The General Budget '%s' has no Accounts!") % str(line.general_budget_id.name)) raise osv.except_osv(_('Error!'),_("The General Budget '%s' has no Accounts!") % str(line.general_budget_id.name))
@ -131,15 +132,17 @@ class crossovered_budget_lines(osv.osv):
res[line.id] = result res[line.id] = result
return res return res
def _prac(self, cr, uid, ids, name, args, context): def _prac(self, cr, uid, ids, name, args, context=None):
res={} res={}
for line in self.browse(cr, uid, ids): if not context: context = {}
for line in self.browse(cr, uid, ids, context=context):
res[line.id] = self._prac_amt(cr, uid, [line.id], context=context)[line.id] res[line.id] = self._prac_amt(cr, uid, [line.id], context=context)[line.id]
return res return res
def _theo_amt(self, cr, uid, ids, context={}): def _theo_amt(self, cr, uid, ids, context=None):
res = {} res = {}
for line in self.browse(cr, uid, ids): if not context: context = {}
for line in self.browse(cr, uid, ids, context=context):
today = datetime.datetime.today() today = datetime.datetime.today()
date_to = today.strftime("%Y-%m-%d") date_to = today.strftime("%Y-%m-%d")
date_from = line.date_from date_from = line.date_from
@ -167,15 +170,16 @@ class crossovered_budget_lines(osv.osv):
res[line.id] = theo_amt res[line.id] = theo_amt
return res return res
def _theo(self, cr, uid, ids, name, args, context): def _theo(self, cr, uid, ids, name, args, context=None):
res = {} res = {}
for line in self.browse(cr, uid, ids): if not context: context = {}
for line in self.browse(cr, uid, ids, context=context):
res[line.id] = self._theo_amt(cr, uid, [line.id], context=context)[line.id] res[line.id] = self._theo_amt(cr, uid, [line.id], context=context)[line.id]
return res return res
def _perc(self, cr, uid, ids, name, args, context): def _perc(self, cr, uid, ids, name, args, context=None):
res = {} 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: if line.theoritical_amount <> 0.00:
res[line.id] = float(line.practical_amount or 0.0 / line.theoritical_amount) * 100 res[line.id] = float(line.practical_amount or 0.0 / line.theoritical_amount) * 100
else: else:

View File

@ -43,6 +43,7 @@ class account_coda(osv.osv):
} }
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False):
if not context: context = {}
res = super(account_coda, self).search(cr, user, args=args, offset=offset, limit=limit, order=order, res = super(account_coda, self).search(cr, user, args=args, offset=offset, limit=limit, order=order,
context=context, count=count) context=context, count=count)
if context.get('bank_statement', False) and not res: if context.get('bank_statement', False) and not res:

View File

@ -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_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}) bank_statement_lines[st_line_name].update({'cntry_number': cntry_number, 'contry_name': contry_name})
if bank_ids: 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: if line and bank.partner_id:
bank_statement_lines[st_line_name].update({'partner_id': bank.partner_id.id}) bank_statement_lines[st_line_name].update({'partner_id': bank.partner_id.id})
if bank_statement_lines[st_line_name]['amount'] < 0: if bank_statement_lines[st_line_name]['amount'] < 0:

View File

@ -58,7 +58,7 @@ class report_rappel(report_sxw.rml_parse):
movelines = moveline_obj.read(self.cr, self.uid, movelines) movelines = moveline_obj.read(self.cr, self.uid, movelines)
return 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_obj = pooler.get_pool(self.cr.dbname).get('account_followup.followup')
fp_line = fp_obj.browse(self.cr, self.uid, followup_id).followup_line fp_line = fp_obj.browse(self.cr, self.uid, followup_id).followup_line
li_delay = [] li_delay = []

View File

@ -214,8 +214,8 @@ class account_followup_print_all(osv.osv_memory):
if data['email_conf']: if data['email_conf']:
msg_sent = '' msg_sent = ''
msg_unsent = '' msg_unsent = ''
data_user = user_obj.browse(cr, uid, uid) data_user = user_obj.browse(cr, uid, uid, context=context)
move_lines = line_obj.browse(cr, uid, data['partner_ids']) move_lines = line_obj.browse(cr, uid, data['partner_ids'], context=context)
partners = [] partners = []
dict_lines = {} dict_lines = {}
for line in move_lines: for line in move_lines:
@ -223,7 +223,7 @@ class account_followup_print_all(osv.osv_memory):
dict_lines[line.name.id] =line dict_lines[line.name.id] =line
for partner in partners: for partner in partners:
ids_lines = move_obj.search(cr,uid,[('partner_id','=',partner.id),('reconcile_id','=',False),('account_id.type','in',['receivable'])]) 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] followup_data = dict_lines[partner.id]
dest = False dest = False
if partner.address: if partner.address:

View File

@ -127,13 +127,14 @@ class account_invoice_line(osv.osv):
def copy_data(self, cr, uid, id, default=None, context=None): def copy_data(self, cr, uid, id, default=None, context=None):
if default is None: if default is None:
default = {} default = {}
default['state'] = self.browse(cr, uid, id).state if not context: context = {}
default['state'] = self.browse(cr, uid, id, context=context).state
return super(account_invoice_line, self).copy_data(cr, uid, id, default, context) return super(account_invoice_line, self).copy_data(cr, uid, id, default, context)
def _fnct(self, cr, uid, ids, name, args, context=None): def _fnct(self, cr, uid, ids, name, args, context=None):
res = {} res = {}
if not context: context = {}
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_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)) account_names = dict(self.pool.get('account.account').name_get(cr, uid, account_ids, context=context))
for line in lines: for line in lines:

View File

@ -31,6 +31,7 @@ class Invoice(osv.osv):
if not ids: if not ids:
return {} return {}
res = {} res = {}
if not context: context = {}
for invoice in self.browse(cursor, user, ids, context=context): for invoice in self.browse(cursor, user, ids, context=context):
res[invoice.id] = 0.0 res[invoice.id] = 0.0
if invoice.move_id: if invoice.move_id:

View File

@ -26,7 +26,7 @@ from tools.translate import _
class account_move_line(osv.osv): class account_move_line(osv.osv):
_inherit = "account.move.line" _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 """ Return the amount still to pay regarding all the payemnt orders
(excepting cancelled orders)""" (excepting cancelled orders)"""
if not ids: if not ids:
@ -47,9 +47,10 @@ class account_move_line(osv.osv):
r = dict(cr.fetchall()) r = dict(cr.fetchall())
return r 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: if not args:
return [] return []
if not context: context = {}
line_obj = self.pool.get('account.move.line') line_obj = self.pool.get('account.move.line')
query = line_obj._query_get(cr, uid, context={}) query = line_obj._query_get(cr, uid, context={})
where = ' and '.join(map(lambda x: '''(SELECT where = ' and '.join(map(lambda x: '''(SELECT
@ -88,6 +89,7 @@ class account_move_line(osv.osv):
""" """
payment_mode_obj = self.pool.get('payment.mode') payment_mode_obj = self.pool.get('payment.mode')
line2bank = {} line2bank = {}
if not context: context = {}
if not ids: if not ids:
return {} return {}
bank_type = payment_mode_obj.suitable_bank_types(cr, uid, payment_type, bank_type = payment_mode_obj.suitable_bank_types(cr, uid, payment_type,

View File

@ -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 '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 """Return the codes of the bank type that are suitable
for the given payment type code""" for the given payment type code"""
if not payment_code: if not payment_code:
@ -67,6 +67,7 @@ class payment_order(osv.osv):
if not ids: if not ids:
return {} return {}
res = {} res = {}
if not context: context = {}
for order in self.browse(cursor, user, ids, context=context): for order in self.browse(cursor, user, ids, context=context):
if order.line_ids: if order.line_ids:
res[order.id] = reduce(lambda x, y: x + y.amount, order.line_ids, 0.0) res[order.id] = reduce(lambda x, y: x + y.amount, order.line_ids, 0.0)
@ -127,6 +128,7 @@ class payment_order(osv.osv):
return True return True
def copy(self, cr, uid, id, default={}, context=None): def copy(self, cr, uid, id, default={}, context=None):
if not context: context = {}
default.update({ default.update({
'state': 'draft', 'state': 'draft',
'line_ids': [], 'line_ids': [],
@ -267,10 +269,11 @@ class payment_line(osv.osv):
line.amount_currency, context=ctx) line.amount_currency, context=ctx)
return res return res
def _get_currency(self, cr, uid, context): def _get_currency(self, cr, uid, context=None):
user_obj = self.pool.get('res.users') user_obj = self.pool.get('res.users')
currency_obj = self.pool.get('res.currency') currency_obj = self.pool.get('res.currency')
user = user_obj.browse(cr, uid, uid) if not context: context = {}
user = user_obj.browse(cr, uid, uid, context=context)
if user.company_id: if user.company_id:
return user.company_id.currency_id.id return user.company_id.currency_id.id
@ -284,7 +287,7 @@ class payment_line(osv.osv):
date = False date = False
if context.get('order_id') and context['order_id']: 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': if order.date_prefered == 'fixed':
date = order.date_scheduled date = order.date_scheduled
else: else:
@ -407,13 +410,14 @@ class payment_line(osv.osv):
def onchange_partner(self, cr, uid, ids, partner_id, payment_type, context=None): def onchange_partner(self, cr, uid, ids, partner_id, payment_type, context=None):
data = {} data = {}
if not context: context = {}
partner_zip_obj = self.pool.get('res.partner.zip') partner_zip_obj = self.pool.get('res.partner.zip')
partner_obj = self.pool.get('res.partner') partner_obj = self.pool.get('res.partner')
payment_mode_obj = self.pool.get('payment.mode') payment_mode_obj = self.pool.get('payment.mode')
data['info_partner'] = data['bank_id'] = False data['info_partner'] = data['bank_id'] = False
if partner_id: 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 '' partner = part_obj.name or ''
if part_obj.address: if part_obj.address:

View File

@ -30,10 +30,11 @@ class account_move(osv.osv):
} }
def post(self, cr, uid, ids, context=None): def post(self, cr, uid, ids, context=None):
if not context: context = {}
obj_sequence = self.pool.get('ir.sequence') obj_sequence = self.pool.get('ir.sequence')
res = super(account_move, self).post(cr, uid, ids, context=context) res = super(account_move, self).post(cr, uid, ids, context=context)
seq_no = False seq_no = False
for line in self.browse(cr, uid, ids): for line in self.browse(cr, uid, ids, context=context):
if line.journal_id.internal_sequence: if line.journal_id.internal_sequence:
seq_no = obj_sequence.get_id(cr, uid, line.journal_id.internal_sequence.id, context=context) seq_no = obj_sequence.get_id(cr, uid, line.journal_id.internal_sequence.id, context=context)
if seq_no: if seq_no:

View File

@ -30,8 +30,9 @@ from tools.translate import _
class account_move_line(osv.osv): class account_move_line(osv.osv):
_inherit = 'account.move.line' _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 = {} res = {}
if not context: context = {}
for line in self.browse(cr, uid, ids, context=context): for line in self.browse(cr, uid, ids, context=context):
res[line.id] = line.debit - line.credit res[line.id] = line.debit - line.credit
if line.reconcile_partial_id: if line.reconcile_partial_id:
@ -49,16 +50,19 @@ account_move_line()
class account_voucher(osv.osv): class account_voucher(osv.osv):
def _get_type(self, cr, uid, ids, context={}): def _get_type(self, cr, uid, ids, context=None):
if not context: context = {}
return context.get('type', False) return context.get('type', False)
def _get_period(self, cr, uid, context={}): def _get_period(self, cr, uid, context=None):
if not context: context = {}
if context.get('period_id', False): if context.get('period_id', False):
return context.get('period_id') return context.get('period_id')
periods = self.pool.get('account.period').find(cr, uid) periods = self.pool.get('account.period').find(cr, uid)
return periods and periods[0] or False return periods and periods[0] or False
def _get_journal(self, cr, uid, context={}): def _get_journal(self, cr, uid, context=None):
if not context: context = {}
journal_pool = self.pool.get('account.journal') journal_pool = self.pool.get('account.journal')
if context.get('journal_id', False): if context.get('journal_id', False):
return context.get('journal_id') return context.get('journal_id')
@ -71,7 +75,8 @@ class account_voucher(osv.osv):
res = journal_pool.search(cr, uid, [('type', '=', ttype)], limit=1) res = journal_pool.search(cr, uid, [('type', '=', ttype)], limit=1)
return res and res[0] or False return res and res[0] or False
def _get_tax(self, cr, uid, context={}): def _get_tax(self, cr, uid, context=None):
if not context: context = {}
journal_pool = self.pool.get('account.journal') journal_pool = self.pool.get('account.journal')
journal_id = context.get('journal_id', False) journal_id = context.get('journal_id', False)
if not journal_id: if not journal_id:
@ -83,39 +88,45 @@ class account_voucher(osv.osv):
if not journal_id: if not journal_id:
return False 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 account_id = journal.default_credit_account_id or journal.default_debit_account_id
if account_id and account_id.tax_ids: if account_id and account_id.tax_ids:
tax_id = account_id.tax_ids[0].id tax_id = account_id.tax_ids[0].id
return tax_id return tax_id
return False return False
def _get_currency(self, cr, uid, context): def _get_currency(self, cr, uid, context=None):
if not context: context = {}
journal_pool = self.pool.get('account.journal') journal_pool = self.pool.get('account.journal')
journal_id = context.get('journal_id', False) journal_id = context.get('journal_id', False)
if journal_id: 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 # currency_id = journal.company_id.currency_id.id
if journal.currency: if journal.currency:
return journal.currency.id return journal.currency.id
return False return False
def _get_partner(self, cr, uid, context={}): def _get_partner(self, cr, uid, context=None):
if not context: context = {}
return context.get('partner_id', False) return context.get('partner_id', False)
def _get_reference(self, cr, uid, context={}): def _get_reference(self, cr, uid, context=None):
if not context: context = {}
return context.get('reference', False) return context.get('reference', False)
def _get_narration(self, cr, uid, context={}): def _get_narration(self, cr, uid, context=None):
if not context: context = {}
return context.get('narration', False) return context.get('narration', False)
def name_get(self, cr, uid, ids, context=None): def name_get(self, cr, uid, ids, context=None):
if not ids: if not ids:
return [] return []
if not context: context = {}
return [(r['id'], (str("%.2f" % r['amount']) or '')) for r in self.read(cr, uid, ids, ['amount'], context, load='_classic_write')] 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): 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') mod_obj = self.pool.get('ir.model.data')
if not context: context = {}
if not view_id and context.get('invoice_type', False): if not view_id and context.get('invoice_type', False):
if context.get('invoice_type', False) in ('out_invoice', 'out_refund'): 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') result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_receipt_form')
@ -207,14 +218,15 @@ class account_voucher(osv.osv):
'tax_id': _get_tax, 'tax_id': _get_tax,
} }
def compute_tax(self, cr, uid, ids, context={}): def compute_tax(self, cr, uid, ids, context=None):
tax_pool = self.pool.get('account.tax') tax_pool = self.pool.get('account.tax')
partner_pool = self.pool.get('res.partner') partner_pool = self.pool.get('res.partner')
position_pool = self.pool.get('account.fiscal.position') position_pool = self.pool.get('account.fiscal.position')
voucher_line_pool = self.pool.get('account.voucher.line') voucher_line_pool = self.pool.get('account.voucher.line')
voucher_pool = self.pool.get('account.voucher') voucher_pool = self.pool.get('account.voucher')
if not context: 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 voucher_amount = 0.0
for line in voucher.line_ids: for line in voucher.line_ids:
voucher_amount += line.untax_amount or line.amount voucher_amount += line.untax_amount or line.amount
@ -225,10 +237,10 @@ class account_voucher(osv.osv):
self.write(cr, uid, [voucher.id], {'amount':voucher_amount, 'tax_amount':0.0}) self.write(cr, uid, [voucher.id], {'amount':voucher_amount, 'tax_amount':0.0})
continue continue
tax = [tax_pool.browse(cr, uid, voucher.tax_id.id)] tax = [tax_pool.browse(cr, uid, voucher.tax_id.id, context=context)]
partner = partner_pool.browse(cr, uid, voucher.partner_id.id) or False 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) 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 = voucher_amount
total_tax = 0.0 total_tax = 0.0
@ -252,7 +264,7 @@ class account_voucher(osv.osv):
self.write(cr, uid, [voucher.id], {'amount':total, 'tax_amount':total_tax}) self.write(cr, uid, [voucher.id], {'amount':total, 'tax_amount':total_tax})
return True 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') tax_pool = self.pool.get('account.tax')
partner_pool = self.pool.get('res.partner') partner_pool = self.pool.get('res.partner')
position_pool = self.pool.get('account.fiscal.position') position_pool = self.pool.get('account.fiscal.position')
@ -262,6 +274,7 @@ class account_voucher(osv.osv):
} }
voucher_total = 0.0 voucher_total = 0.0
voucher_line_ids = [] voucher_line_ids = []
if not context: context = {}
total = 0.0 total = 0.0
total_tax = 0.0 total_tax = 0.0
@ -274,11 +287,11 @@ class account_voucher(osv.osv):
total = voucher_total total = voucher_total
total_tax = 0.0 total_tax = 0.0
if tax_id: if tax_id:
tax = [tax_pool.browse(cr, uid, tax_id)] tax = [tax_pool.browse(cr, uid, tax_id, context=context)]
if partner_id: 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) 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: if not tax[0].price_include:
for tax_line in tax_pool.compute_all(cr, uid, tax, voucher_total, 1).get('taxes', []): for tax_line in tax_pool.compute_all(cr, uid, tax, voucher_total, 1).get('taxes', []):
@ -307,7 +320,7 @@ class account_voucher(osv.osv):
}) })
return {'value':default} 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 """price
Returns a dict that contains new values and context Returns a dict that contains new values and context
@ -320,6 +333,7 @@ class account_voucher(osv.osv):
default = { default = {
'value':{}, 'value':{},
} }
if not context: context = {}
if not partner_id or not journal_id: if not partner_id or not journal_id:
return default return default
@ -327,8 +341,8 @@ class account_voucher(osv.osv):
partner_pool = self.pool.get('res.partner') partner_pool = self.pool.get('res.partner')
journal_pool = self.pool.get('account.journal') 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)
partner = partner_pool.browse(cr, uid, partner_id) partner = partner_pool.browse(cr, uid, partner_id, context=context)
account_id = False account_id = False
tr_type = False tr_type = False
if journal.type in ('sale','sale_refund'): if journal.type in ('sale','sale_refund'):
@ -386,8 +400,8 @@ class account_voucher(osv.osv):
line_pool.unlink(cr, uid, line_ids) line_pool.unlink(cr, uid, line_ids)
return default return default
journal = journal_pool.browse(cr, uid, journal_id) journal = journal_pool.browse(cr, uid, journal_id, context=context)
partner = partner_pool.browse(cr, uid, partner_id) partner = partner_pool.browse(cr, uid, partner_id, context=context)
account_id = False account_id = False
if journal.type in ('sale','sale_refund'): if journal.type in ('sale','sale_refund'):
account_id = partner.property_account_receivable.id account_id = partner.property_account_receivable.id
@ -416,7 +430,7 @@ class account_voucher(osv.osv):
else: else:
ids = context['move_line_ids'] ids = context['move_line_ids']
ids.reverse() 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 company_currency = journal.company_id.currency_id.id
if company_currency != currency_id and ttype == 'payment': if company_currency != currency_id and ttype == 'payment':
@ -471,7 +485,7 @@ class account_voucher(osv.osv):
return default 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 date: latest value from user input for field date
@param args: other arguments @param args: other arguments
@ -488,11 +502,12 @@ 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: if not journal_id:
return False return False
if not context: context = {}
journal_pool = self.pool.get('account.journal') 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 account_id = journal.default_credit_account_id or journal.default_debit_account_id
tax_id = False tax_id = False
if account_id and account_id.tax_ids: if account_id and account_id.tax_ids:
@ -510,18 +525,19 @@ class account_voucher(osv.osv):
self.action_move_line_create(cr, uid, ids, context=context) self.action_move_line_create(cr, uid, ids, context=context)
return True 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") wf_service = netsvc.LocalService("workflow")
for voucher_id in ids: for voucher_id in ids:
wf_service.trg_create(uid, 'account.voucher', voucher_id, cr) wf_service.trg_create(uid, 'account.voucher', voucher_id, cr)
self.write(cr, uid, ids, {'state':'draft'}) self.write(cr, uid, ids, {'state':'draft'})
return True 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') reconcile_pool = self.pool.get('account.move.reconcile')
move_pool = self.pool.get('account.move') move_pool = self.pool.get('account.move')
if not context: context = {}
for voucher in self.browse(cr, uid, ids): for voucher in self.browse(cr, uid, ids, context=context):
recs = [] recs = []
for line in voucher.move_ids: for line in voucher.move_ids:
if line.reconcile_id: if line.reconcile_id:
@ -582,7 +598,7 @@ class account_voucher(osv.osv):
currency_pool = self.pool.get('res.currency') currency_pool = self.pool.get('res.currency')
tax_obj = self.pool.get('account.tax') tax_obj = self.pool.get('account.tax')
seq_obj = self.pool.get('ir.sequence') 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: if inv.move_id:
continue continue
if inv.number: if inv.number:
@ -753,7 +769,8 @@ class account_voucher_line(osv.osv):
def _compute_balance(self, cr, uid, ids, name, args, context=None): def _compute_balance(self, cr, uid, ids, name, args, context=None):
currency_pool = self.pool.get('res.currency') currency_pool = self.pool.get('res.currency')
rs_data = {} rs_data = {}
for line in self.browse(cr, uid, ids): if not context: context = {}
for line in self.browse(cr, uid, ids, context=context):
res = {} res = {}
company_currency = line.voucher_id.journal_id.company_id.currency_id.id company_currency = line.voucher_id.journal_id.company_id.currency_id.id
voucher_currency = line.voucher_id.currency_id.id voucher_currency = line.voucher_id.currency_id.id
@ -793,7 +810,7 @@ class account_voucher_line(osv.osv):
'name': '' '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 Returns a dict that contains new values and context
@ -804,6 +821,7 @@ class account_voucher_line(osv.osv):
@return: Returns a dict which contains new values, and context @return: Returns a dict which contains new values, and context
""" """
res = {} res = {}
if not context: context = {}
move_line_pool = self.pool.get('account.move.line') move_line_pool = self.pool.get('account.move.line')
if move_line_id: if move_line_id:
move_line = move_line_pool.browse(cr, user, move_line_id, context=context) move_line = move_line_pool.browse(cr, user, move_line_id, context=context)
@ -828,6 +846,7 @@ class account_voucher_line(osv.osv):
@return: Returns a dict that contains default values for fields @return: Returns a dict that contains default values for fields
""" """
if not context: context = {}
journal_id = context.get('journal_id', False) journal_id = context.get('journal_id', False)
partner_id = context.get('partner_id', False) partner_id = context.get('partner_id', False)
journal_pool = self.pool.get('account.journal') journal_pool = self.pool.get('account.journal')
@ -835,7 +854,7 @@ class account_voucher_line(osv.osv):
values = super(account_voucher_line, self).default_get(cr, user, fields_list, context=context) 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): if (not journal_id) or ('account_id' not in fields_list):
return values return values
journal = journal_pool.browse(cr, user, journal_id) journal = journal_pool.browse(cr, user, journal_id, context=context)
account_id = False account_id = False
ttype = 'cr' ttype = 'cr'
if journal.type in ('sale', 'sale_refund'): if journal.type in ('sale', 'sale_refund'):
@ -864,7 +883,8 @@ class account_bank_statement(osv.osv):
def button_cancel(self, cr, uid, ids, context=None): def button_cancel(self, cr, uid, ids, context=None):
voucher_obj = self.pool.get('account.voucher') voucher_obj = self.pool.get('account.voucher')
for st in self.browse(cr, uid, ids, context): if not context: context = {}
for st in self.browse(cr, uid, ids, context=context):
voucher_ids = [] voucher_ids = []
for line in st.line_ids: for line in st.line_ids:
if line.voucher_id: if line.voucher_id:
@ -877,6 +897,7 @@ class account_bank_statement(osv.osv):
wf_service = netsvc.LocalService("workflow") wf_service = netsvc.LocalService("workflow")
move_line_obj = self.pool.get('account.move.line') move_line_obj = self.pool.get('account.move.line')
bank_st_line_obj = self.pool.get('account.bank.statement.line') bank_st_line_obj = self.pool.get('account.bank.statement.line')
if not context: context = {}
st_line = bank_st_line_obj.browse(cr, uid, st_line_id, context=context) st_line = bank_st_line_obj.browse(cr, uid, st_line_id, context=context)
if st_line.voucher_id: if st_line.voucher_id:
voucher_obj.write(cr, uid, [st_line.voucher_id.id], {'number': next_number}, context=context) voucher_obj.write(cr, uid, [st_line.voucher_id.id], {'number': next_number}, context=context)
@ -902,6 +923,7 @@ class account_bank_statement_line(osv.osv):
return {} return {}
res = {} res = {}
if not context: context = {}
# company_currency_id = False # company_currency_id = False
for line in self.browse(cursor, user, ids, context=context): for line in self.browse(cursor, user, ids, context=context):
# if not company_currency_id: # if not company_currency_id:
@ -923,8 +945,9 @@ class account_bank_statement_line(osv.osv):
} }
def unlink(self, cr, uid, ids, context=None): def unlink(self, cr, uid, ids, context=None):
if not context: context = {}
voucher_obj = self.pool.get('account.voucher') 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 = [] unlink_ids = []
for st_line in statement_line: for st_line in statement_line:
if st_line.voucher_id: if st_line.voucher_id:

View File

@ -27,6 +27,7 @@ class invoice(osv.osv):
def invoice_pay_customer(self, cr, uid, ids, context=None): def invoice_pay_customer(self, cr, uid, ids, context=None):
if not ids: return [] if not ids: return []
if not context: context = {}
inv = self.browse(cr, uid, ids[0], context=context) inv = self.browse(cr, uid, ids[0], context=context)
return { return {
'name':_("Pay Invoice"), 'name':_("Pay Invoice"),

View File

@ -35,7 +35,7 @@ class account_statement_from_invoice_lines(osv.osv_memory):
} }
def populate_statement(self, cr, uid, ids, context=None): def populate_statement(self, cr, uid, ids, context=None):
if not context: context = {}
statement_id = context.get('statement_id', False) statement_id = context.get('statement_id', False)
if not statement_id: if not statement_id:
return {} return {}
@ -134,7 +134,7 @@ class account_statement_from_invoice(osv.osv_memory):
} }
def search_invoices(self, cr, uid, ids, context=None): def search_invoices(self, cr, uid, ids, context=None):
if not context: context = {}
line_obj = self.pool.get('account.move.line') line_obj = self.pool.get('account.move.line')
statement_obj = self.pool.get('account.bank.statement') statement_obj = self.pool.get('account.bank.statement')
journal_obj = self.pool.get('account.journal') journal_obj = self.pool.get('account.journal')

View File

@ -41,7 +41,7 @@ class account_voucher_unreconcile(osv.osv_memory):
voucher_pool = self.pool.get('account.voucher') voucher_pool = self.pool.get('account.voucher')
reconcile_pool = self.pool.get('account.move.reconcile') reconcile_pool = self.pool.get('account.move.reconcile')
if context.get('active_id'): 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 = [] recs = []
for line in voucher.move_ids: for line in voucher.move_ids:
if line.reconcile_id: if line.reconcile_id:

View File

@ -29,6 +29,7 @@ class account_analytic_account(osv.osv):
_description = 'Analytic Account' _description = 'Analytic Account'
def _compute_level_tree(self, cr, uid, ids, child_ids, res, field_names, context=None): def _compute_level_tree(self, cr, uid, ids, child_ids, res, field_names, context=None):
if not context: context = {}
def recursive_computation(account_id, res): def recursive_computation(account_id, res):
account = self.browse(cr, uid, account_id) account = self.browse(cr, uid, account_id)
for son in account.child_ids: for son in account.child_ids:
@ -92,6 +93,7 @@ class account_analytic_account(osv.osv):
if not ids: if not ids:
return [] return []
res = [] res = []
if not context: context = {}
for account in self.browse(cr, uid, ids, context=context): for account in self.browse(cr, uid, ids, context=context):
data = [] data = []
acc = account acc = account
@ -137,6 +139,7 @@ class account_analytic_account(osv.osv):
} }
def _default_company(self, cr, uid, context=None): def _default_company(self, cr, uid, context=None):
if not context: context = {}
user = self.pool.get('res.users').browse(cr, uid, uid, context=context) user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
if user.company_id: if user.company_id:
return user.company_id.id return user.company_id.id
@ -163,6 +166,7 @@ class account_analytic_account(osv.osv):
def copy(self, cr, uid, id, default=None, context=None): def copy(self, cr, uid, id, default=None, context=None):
if not default: if not default:
default = {} default = {}
if not context: context = {}
default['code'] = False default['code'] = False
default['line_ids'] = [] default['line_ids'] = []
return super(account_analytic_account, self).copy(cr, uid, id, default, context=context) return super(account_analytic_account, self).copy(cr, uid, id, default, context=context)

View File

@ -65,10 +65,12 @@ class auction_dates(osv.osv):
name = [(r['id'], '['+r['auction1']+'] '+ r['name']) for r in reads] name = [(r['id'], '['+r['auction1']+'] '+ r['name']) for r in reads]
return name 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') lots_obj = self.pool.get('auction.lots')
result = {} result = {}
for data in self.browse(cr, uid, ids): if not context:
context={}
for data in self.browse(cr, uid, ids, context=context):
buyer_inv_ids = [] buyer_inv_ids = []
seller_inv_ids = [] seller_inv_ids = []
result[data.id] = { result[data.id] = {
@ -76,7 +78,7 @@ class auction_dates(osv.osv):
'buyer_invoice_history': seller_inv_ids, 'buyer_invoice_history': seller_inv_ids,
} }
lots_ids = lots_obj.search(cr, uid, [('auction_id','=',data.id)]) 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: if lot.ach_inv_id:
buyer_inv_ids.append(lot.ach_inv_id.id) buyer_inv_ids.append(lot.ach_inv_id.id)
if lot.sel_inv_id: if lot.sel_inv_id:

View File

@ -31,9 +31,9 @@ class report_custom(report_rml):
def __init__(self, name, table, tmpl, xsl): def __init__(self, name, table, tmpl, xsl):
report_rml.__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) 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 auction = lots[0].auction_id
xml = '''<?xml version="1.0" encoding="UTF-8"?> xml = '''<?xml version="1.0" encoding="UTF-8"?>

View File

@ -35,7 +35,7 @@ class report_custom(report_rml):
def __init__(self, name, table, tmpl, xsl): def __init__(self, name, table, tmpl, xsl):
report_rml.__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") 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']) 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'])

View File

@ -34,7 +34,7 @@ class auction_lots_send_aie(osv.osv_memory):
_name = 'auction.lots.send.aie' _name = 'auction.lots.send.aie'
_descritption = 'Send to website' _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') selection = context and context.get('selection')
if selection: if selection:
return [('','')] + selection return [('','')] + selection
@ -50,7 +50,7 @@ class auction_lots_send_aie(osv.osv_memory):
'img_send': fields.boolean('Send Image also ?'), '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. To get default values for the object.
@param self: The object pointer. @param self: The object pointer.
@ -60,6 +60,7 @@ class auction_lots_send_aie(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: A dictionary which of fields with values. @return: A dictionary which of fields with values.
""" """
if not context: context = {}
res = super(auction_lots_send_aie, self).default_get(cr, uid, fields, context=context) res = super(auction_lots_send_aie, self).default_get(cr, uid, fields, context=context)
if 'uname' in fields and context.get('uname',False): if 'uname' in fields and context.get('uname',False):
res['uname'] = context.get('uname') res['uname'] = context.get('uname')
@ -147,7 +148,8 @@ class auction_lots_send_aie(osv.osv_memory):
fname = datas[0]['name'] fname = datas[0]['name']
self._photo_bin_send(uname, passwd, ref, did, fname, bin) 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 not context: context = {}
import httplib import httplib
data_obj = self.pool.get('ir.model.data') data_obj = self.pool.get('ir.model.data')
conn = httplib.HTTPConnection('www.auction-in-europe.com') conn = httplib.HTTPConnection('www.auction-in-europe.com')
@ -174,14 +176,15 @@ class auction_lots_send_aie(osv.osv_memory):
'context': context 'context': context
} }
def _send(self, cr, uid, ids, context={}): def _send(self, cr, uid, ids, context=None):
if not context: context = {}
import pickle, thread, sql_db import pickle, thread, sql_db
cr.execute('select name,aie_categ from auction_lot_category') cr.execute('select name,aie_categ from auction_lot_category')
vals = dict(cr.fetchall()) vals = dict(cr.fetchall())
cr.close() cr.close()
service = netsvc.LocalService("object_proxy") 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 = [] lots_ids = []
datas = self.read(cr, uid, ids[0],['uname','login','lang','numerotation','dates']) datas = self.read(cr, uid, ids[0],['uname','login','lang','numerotation','dates'])
for l in lots: for l in lots:
@ -211,7 +214,8 @@ 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)) thread.start_new_thread(_photos_send, (cr.dbname, uid, datas['uname'], datas['password'],datas['dates'], lots_ids))
return {} return {}
def send_pdf(self, cr, uid, ids, context): def send_pdf(self, cr, uid, ids, context=None):
if not context: context = {}
threaded_calculation = threading.Thread(target=self._send, args=(cr, uid, ids, context)) threaded_calculation = threading.Thread(target=self._send, args=(cr, uid, ids, context))
threaded_calculation.start() threaded_calculation.start()
return {} return {}

View File

@ -32,7 +32,7 @@ class auction_lots_pay(osv.osv_memory):
_description = 'Send results to Auction-in-europe.com' _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') selection = context and context.get('selection')
if selection: if selection:
return [('','')] + selection return [('','')] + selection
@ -45,7 +45,7 @@ class auction_lots_pay(osv.osv_memory):
'dates': fields.selection(_date_get,'Auction Date'), '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. To get default values for the object.
@param self: The object pointer. @param self: The object pointer.
@ -55,6 +55,7 @@ class auction_lots_pay(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: A dictionary which of fields with values. @return: A dictionary which of fields with values.
""" """
if not context: context = {}
res = super(auction_lots_pay, self).default_get(cr, uid, fields, context=context) res = super(auction_lots_pay, self).default_get(cr, uid, fields, context=context)
if 'uname' in fields and context.get('uname',False): if 'uname' in fields and context.get('uname',False):
res['uname'] = context.get('uname') res['uname'] = context.get('uname')
@ -96,7 +97,8 @@ class auction_lots_pay(osv.osv_memory):
return val return val
return post_multipart('auction-in-europe.com', "/bin/catalog_result.cgi", (('uname',uname),('password',passwd),('did',did)),(('file',catalog),)) 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 not context: context = {}
import httplib import httplib
conn = httplib.HTTPConnection('www.auction-in-europe.com') conn = httplib.HTTPConnection('www.auction-in-europe.com')
data_obj = self.pool.get('ir.model.data') data_obj = self.pool.get('ir.model.data')
@ -124,7 +126,8 @@ class auction_lots_pay(osv.osv_memory):
'context': context 'context': context
} }
def send(self, cr, uid, ids, context): def send(self, cr, uid, ids, context=None):
if not context: context = {}
import pickle import pickle
service = netsvc.LocalService("object_proxy") service = netsvc.LocalService("object_proxy")
datas = self.read(cr, uid, ids[0],['uname','password','dates']) datas = self.read(cr, uid, ids[0],['uname','password','dates'])

View File

@ -26,7 +26,7 @@ class auction_catalog_flagey(osv.osv_memory):
_name = 'auction.catalog.flagey' _name = 'auction.catalog.flagey'
_description = '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. To get default values for the object.
@param self: The object pointer. @param self: The object pointer.
@ -36,10 +36,11 @@ class auction_catalog_flagey(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: A dictionary which of fields with values. @return: A dictionary which of fields with values.
""" """
if not context: context = {}
res = super(auction_catalog_flagey, self).default_get(cr, uid, fields, context=context) res = super(auction_catalog_flagey, self).default_get(cr, uid, fields, context=context)
return res 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 Creates view dynamically, adding fields at runtime, raises exception
at the time of initialization of view. at the time of initialization of view.
@ -52,15 +53,16 @@ class auction_catalog_flagey(osv.osv_memory):
""" """
lots_obj = self.pool.get('auction.lots') lots_obj = self.pool.get('auction.lots')
auc_dates_obj = self.pool.get('auction.dates') auc_dates_obj = self.pool.get('auction.dates')
if not context: context = {}
current_auction = auc_dates_obj.browse(cr, uid, context.get('active_ids', [])) 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_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: for ab in v_ids:
if not ab.auction_id : if not ab.auction_id :
raise osv.except_osv('Error!','No Lots belong to this Auction Date') raise osv.except_osv('Error!','No Lots belong to this Auction Date')
pass pass
def print_report(self, cr, uid, ids, context): def print_report(self, cr, uid, ids, context=None):
""" """
Prints auction catalog flagey report. Prints auction catalog flagey report.
@param self: The object pointer. @param self: The object pointer.
@ -70,6 +72,7 @@ class auction_catalog_flagey(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: Report @return: Report
""" """
if not context: context = {}
datas = {'ids': context.get('active_ids',[])} datas = {'ids': context.get('active_ids',[])}
return { return {
'type': 'ir.actions.report.xml', 'type': 'ir.actions.report.xml',

View File

@ -31,14 +31,15 @@ class auction_lots_able(osv.osv_memory):
_name = "auction.lots.able" _name = "auction.lots.able"
_description = "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. This function Update auction lots object and set taken away field true.
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks, @param uid: the current users ID for security checks,
@param ids: List of auction lots ables IDs. @param ids: List of auction lots ables IDs.
""" """
self.pool.get('auction.lots').write(cr, uid, context['active_ids'], {'ach_emp':True}) if not context: context = {}
self.pool.get('auction.lots').write(cr, uid, context.get('active_ids', []), {'ach_emp':True})
return {} return {}
auction_lots_able() auction_lots_able()

View File

@ -50,7 +50,7 @@ class auction_lots_auction_move(osv.osv_memory):
auction_lot_history_obj = self.pool.get('auction.lot.history') auction_lot_history_obj = self.pool.get('auction.lot.history')
auction_lots_obj = self.pool.get('auction.lots') auction_lots_obj = self.pool.get('auction.lots')
rec_ids = auction_lots_obj.browse(cr, uid, context.get('active_ids', [])) 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', []))): if not (current.auction_id and len(context.get('active_ids', []))):
return {} return {}

View File

@ -32,7 +32,7 @@ class wiz_auc_lots_buyer_map(osv.osv_memory):
'ach_uid': fields.many2one('res.partner','Buyer', required=True), '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. To get default values for the object.
@param self: The object pointer. @param self: The object pointer.
@ -42,14 +42,15 @@ class wiz_auc_lots_buyer_map(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: A dictionary which of fields with values. @return: A dictionary which of fields with values.
""" """
res = super(wiz_auc_lots_buyer_map,self).default_get(cr, uid, fields, context) if not context: context = {}
res = super(wiz_auc_lots_buyer_map,self).default_get(cr, uid, fields, context=context)
auction_lots_obj = self.pool.get('auction.lots') auction_lots_obj = self.pool.get('auction.lots')
lots_ids = auction_lots_obj.search(cr, uid, [('ach_uid', '=', ''), ('ach_login', '!=', '')]) 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): 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 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 return res
def _start(self, cr, uid, ids, context=None): def _start(self, cr, uid, ids, context=None):
@ -65,7 +66,7 @@ class wiz_auc_lots_buyer_map(osv.osv_memory):
if not context: if not context:
context={} context={}
lots_obj = self.pool.get('auction.lots') 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): 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.') raise osv.except_osv('Error', 'No buyer is set for this lot.')
if not rec.ach_uid and rec.ach_login: if not rec.ach_uid and rec.ach_login:
@ -86,8 +87,8 @@ class wiz_auc_lots_buyer_map(osv.osv_memory):
rec_ids = context and context.get('active_ids',[]) or [] rec_ids = context and context.get('active_ids',[]) or []
assert rec_ids, _('Active IDs not Found') assert rec_ids, _('Active IDs not Found')
lots_obj = self.pool.get('auction.lots') lots_obj = self.pool.get('auction.lots')
for current in self.browse(cr, uid, ids): for current in self.browse(cr, uid, ids, context=context):
for lots in lots_obj.browse(cr, uid, rec_ids, context): for lots in lots_obj.browse(cr, uid, rec_ids, context=context):
if lots.ach_login == current.ach_login: if lots.ach_login == current.ach_login:
lots_obj.write(cr, uid, [lots.id], {'ach_uid': current.ach_uid.id}, context=context) lots_obj.write(cr, uid, [lots.id], {'ach_uid': current.ach_uid.id}, context=context)
return {} return {}
@ -111,7 +112,7 @@ class wiz_auc_lots_buyer_map(osv.osv_memory):
lots_obj = self.pool.get('auction.lots') lots_obj = self.pool.get('auction.lots')
if record_ids: if record_ids:
try: 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: if lots.ach_uid:
res['arch'] = """ res['arch'] = """
<form title="Mapping Result"> <form title="Mapping Result">

View File

@ -44,7 +44,7 @@ class auction_lots_cancel(osv.osv):
context={} context={}
lots_obj = self.pool.get('auction.lots') lots_obj = self.pool.get('auction.lots')
invoice_obj = self.pool.get('account.invoice') 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: if lot.ach_inv_id:
supplier_refund_inv_id = invoice_obj.refund(cr, uid, [lot.ach_inv_id.id]) supplier_refund_inv_id = invoice_obj.refund(cr, uid, [lot.ach_inv_id.id])
if lot.sel_inv_id: if lot.sel_inv_id:

View File

@ -28,14 +28,15 @@ class auction_lots_enable(osv.osv_memory):
'confirm_en':fields.integer('Catalog Number') '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. This function Update auction lots object and set taken away field False.
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks, @param uid: the current users ID for security checks,
@param ids: List of auction lots enables IDs. @param ids: List of auction lots enables IDs.
""" """
self.pool.get('auction.lots').write(cr, uid, context['active_id'], {'ach_emp':False}) if not context: context = {}
self.pool.get('auction.lots').write(cr, uid, context.get('active_id',False), {'ach_emp':False})
return {} return {}
auction_lots_enable() auction_lots_enable()

View File

@ -36,7 +36,7 @@ class auction_lots_invoice(osv.osv_memory):
'number': fields.integer('Invoice Number'), '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. To get default values for the object.
@param self: The object pointer. @param self: The object pointer.
@ -46,6 +46,7 @@ class auction_lots_invoice(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: A dictionary which of fields with values. @return: A dictionary which of fields with values.
""" """
if not context: context = {}
res = super(auction_lots_invoice, self).default_get(cr, uid, fields, context=context) res = super(auction_lots_invoice, self).default_get(cr, uid, fields, context=context)
service = netsvc.LocalService("object_proxy") service = netsvc.LocalService("object_proxy")
lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', context.get('active_ids', [])) lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', context.get('active_ids', []))
@ -78,7 +79,7 @@ class auction_lots_invoice(osv.osv_memory):
#TODO: recuperer id next invoice (de la sequence)??? #TODO: recuperer id next invoice (de la sequence)???
invoice_number = False 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: if 'objects' in fields:
res.update({'objects':len(context.get('active_ids', []))}) res.update({'objects':len(context.get('active_ids', []))})
if 'amount' in fields: if 'amount' in fields:
@ -93,7 +94,7 @@ class auction_lots_invoice(osv.osv_memory):
res.update({'number':invoice_number}) res.update({'number':invoice_number})
return res return res
def print_report(self, cr, uid, ids, context={}): def print_report(self, cr, uid, ids, context=None):
""" """
Create an invoice report. Create an invoice report.
@param cr: the current row, from the database cursor. @param cr: the current row, from the database cursor.
@ -101,6 +102,7 @@ class auction_lots_invoice(osv.osv_memory):
@param ids: List of Auction lots make invoice buyers IDs @param ids: List of Auction lots make invoice buyers IDs
@return: dictionary of account invoice form. @return: dictionary of account invoice form.
""" """
if not context: context = {}
service = netsvc.LocalService("object_proxy") service = netsvc.LocalService("object_proxy")
datas = {'ids' : context.get('active_ids',[])} datas = {'ids' : context.get('active_ids',[])}
res = self.read(cr, uid, ids, ['number','ach_uid']) res = self.read(cr, uid, ids, ['number','ach_uid'])

View File

@ -54,7 +54,7 @@ class auction_lots_make_invoice(osv.osv_memory):
context={} context={}
res = super(auction_lots_make_invoice, self).default_get(cr, uid, fields, context=context) res = super(auction_lots_make_invoice, self).default_get(cr, uid, fields, context=context)
lots_obj = self.pool.get('auction.lots') 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: if 'amount' in fields:
res.update({'amount': lot.seller_price}) res.update({'amount': lot.seller_price})
if 'objects' in fields: if 'objects' in fields:
@ -75,7 +75,7 @@ class auction_lots_make_invoice(osv.osv_memory):
mod_obj = self.pool.get('ir.model.data') mod_obj = self.pool.get('ir.model.data')
result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter') result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter')
id = mod_obj.read(cr, uid, result, ['res_id']) 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 { return {
'domain': "[('id','in', ["+','.join(map(str, lots_ids))+"])]", 'domain': "[('id','in', ["+','.join(map(str, lots_ids))+"])]",
'name': 'Seller invoices', 'name': 'Seller invoices',

View File

@ -49,7 +49,7 @@ class auction_lots_make_invoice_buyer(osv.osv_memory):
context={} context={}
res = super(auction_lots_make_invoice_buyer, self).default_get(cr, uid, fields, context=context) res = super(auction_lots_make_invoice_buyer, self).default_get(cr, uid, fields, context=context)
lots_obj=self.pool.get('auction.lots') 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: if 'amount' in fields:
res.update({'amount': lot.buyer_price}) res.update({'amount': lot.buyer_price})
if 'buyer_id' in fields: 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', []))}) res.update({'objects': len(context.get('active_ids', []))})
return res 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 . Create an invoice for selected lots (IDS) to BUYER_ID .
@param cr: the current row, from the database cursor. @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') mod_obj = self.pool.get('ir.model.data')
result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter') result = mod_obj._get_id(cr, uid, 'account', 'view_account_invoice_filter')
id = mod_obj.read(cr, uid, result, ['res_id']) id = mod_obj.read(cr, uid, result, ['res_id'])
lots = order_obj.browse(cr, uid, context.get('active_ids', [])) lots = order_obj.browse(cr, uid, context.get('active_ids', []), context=context)
for current in self.browse(cr, uid, ids, context): for current in self.browse(cr, uid, ids, context=context):
invoice_number = current.number invoice_number = current.number
for lot in lots: for lot in lots:
up_auction = order_obj.write(cr, uid, [lot.id], {'ach_uid': current.buyer_id.id}) up_auction = order_obj.write(cr, uid, [lot.id], {'ach_uid': current.buyer_id.id})

View File

@ -38,7 +38,7 @@ class auction_lots_numerotate_per_lot(osv.osv_memory):
'obj_num': fields.integer('Catalog Number', required=True) '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. To get default values for the object.
@param self: The object pointer. @param self: The object pointer.
@ -48,13 +48,14 @@ class auction_lots_numerotate_per_lot(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: A dictionary which of fields with values. @return: A dictionary which of fields with values.
""" """
if not context: context = {}
res = super(auction_lots_numerotate_per_lot, self).default_get(cr, uid, fields, context=context) res = super(auction_lots_numerotate_per_lot, self).default_get(cr, uid, fields, context=context)
active_id = context.get('active_id',False) active_id = context.get('active_id',False)
active_model = context.get('active_model') active_model = context.get('active_model')
if active_id and (active_model and active_model!='auction.lots'): if active_id and (active_model and active_model!='auction.lots'):
return res return res
lots_obj = self.pool.get('auction.lots') 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): if 'bord_vnd_id' in fields and context.get('bord_vnd_id',False):
res['bord_vnd_id'] = context.get('bord_vnd_id') res['bord_vnd_id'] = context.get('bord_vnd_id')
if 'lot_num' in fields and context.get('lot_num',False): 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 res['obj_num'] = lots.obj_num
return res 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 record_ids = context and context.get('active_ids',False) or False
assert record_ids, _('Active IDs not Found') assert record_ids, _('Active IDs not Found')
data_obj = self.pool.get('ir.model.data') data_obj = self.pool.get('ir.model.data')
@ -89,7 +90,7 @@ class auction_lots_numerotate_per_lot(osv.osv_memory):
'context': context '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 record_ids = context and context.get('active_ids',False) or False
assert record_ids, _('Active IDs not Found') assert record_ids, _('Active IDs not Found')
datas = self.read(cr, uid, ids[0], ['bord_vnd_id','lot_num','obj_num']) 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 '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 record_ids = context and context.get('active_ids',False) or False
assert record_ids, _('Active IDs not Found') assert record_ids, _('Active IDs not Found')
datas = self.read(cr, uid, ids[0], ['bord_vnd_id','lot_num']) 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']) 'lot_est2', 'obj_desc'])
return lots_datas[0] 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 record_ids = context and context.get('active_ids',False) or False
assert record_ids, _('Active IDs not Found') assert record_ids, _('Active IDs not Found')
data_obj = self.pool.get('ir.model.data') 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) '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 record_ids = context and context.get('active_ids',False) or False
assert record_ids, _('Active IDs not Found') assert record_ids, _('Active IDs not Found')
datas = self.read(cr, uid, ids[0], ['number']) datas = self.read(cr, uid, ids[0], ['number'])
nbr = int(datas['number']) nbr = int(datas['number'])
lots_obj = self.pool.get('auction.lots') 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: for rec_id in rec_ids:
lots_obj.write(cr, uid, [rec_id.id], {'obj_num':nbr}) lots_obj.write(cr, uid, [rec_id.id], {'obj_num':nbr})
nbr+=1 nbr+=1

View File

@ -34,7 +34,7 @@ class auction_lots_sms_send(osv.osv_memory):
'text':fields.text('SMS Message', required=True) '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 to send sms
@ -44,18 +44,18 @@ class auction_lots_sms_send(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: number indicating the acknowledgement @return: number indicating the acknowledgement
""" """
if not context: context = {}
lot_obj = self.pool.get('auction.lots') lot_obj = self.pool.get('auction.lots')
partner_obj = self.pool.get('res.partner') partner_obj = self.pool.get('res.partner')
partner_address_obj = self.pool.get('res.partner.address') partner_address_obj = self.pool.get('res.partner.address')
for data in self.read(cr, uid, ids): for data in self.read(cr, uid, ids):
lots = lot_obj.read(cr, uid, context['active_ids'], ['obj_num','obj_price','ach_uid']) 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) res = partner_obj.read(cr, uid, [l['ach_uid'][0] for l in lots if l['ach_uid']], ['gsm'], context)
nbr = 0 nbr = 0
for r in res: for r in res:
add = partner_obj.address_get(cr, uid, [r['id']])['default'] 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 to = addr.mobile
if to: if to:
tools.smssend(data['user'], data['password'], data['app_id'], unicode(data['text'], 'utf-8').encode('latin1'), to) tools.smssend(data['user'], data['password'], data['app_id'], unicode(data['text'], 'utf-8').encode('latin1'), to)

View File

@ -52,7 +52,7 @@ class auction_pay_buy(osv.osv_memory):
context={} context={}
res = super(auction_pay_buy, self).default_get(cr, uid, fields, context=context) res = super(auction_pay_buy, self).default_get(cr, uid, fields, context=context)
auction_lots_obj= self.pool.get('auction.lots') 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: if 'amount' in fields:
res.update({'amount': lot.buyer_price}) res.update({'amount': lot.buyer_price})
if 'buyer_id' in fields: if 'buyer_id' in fields:
@ -61,7 +61,7 @@ class auction_pay_buy(osv.osv_memory):
res.update({'total': lot.buyer_price}) res.update({'total': lot.buyer_price})
return res return res
def pay_and_reconcile(self, cr, uid, ids, context): def pay_and_reconcile(self, cr, uid, ids, context=None):
""" """
Pay and Reconcile Pay and Reconcile
@param cr: the current row, from the database cursor. @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 @param context: A standard dictionary
@return: @return:
""" """
if not context: context = {}
lot_obj = self.pool.get('auction.lots') lot_obj = self.pool.get('auction.lots')
bank_statement_line_obj = self.pool.get('account.bank.statement.line') 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: if not abs(datas['total'] - (datas['amount'] + datas['amount2'] + datas['amount3'])) <0.01:
rest = datas['total'] - (datas['amount'] + datas['amount2'] + datas['amount3']) 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))) 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: for lot in lots:
if datas['buyer_id']: if datas['buyer_id']:
lot_obj.write(cr, uid, [lot.id], {'ach_uid': datas['buyer_id']}) lot_obj.write(cr, uid, [lot.id], {'ach_uid': datas['buyer_id']})

View File

@ -33,7 +33,7 @@ class auction_pay_sel(osv.osv_memory):
'period_id':fields.many2one('account.period', 'Period', required=True), '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 Pay and Reconcile
@param cr: the current row, from the database cursor. @param cr: the current row, from the database cursor.
@ -42,9 +42,10 @@ class auction_pay_sel(osv.osv_memory):
@param context: A standard dictionary @param context: A standard dictionary
@return: @return:
""" """
lot = self.pool.get('auction.lots').browse(cr, uid, context['active_id'], context) if not context: context = {}
lot = self.pool.get('auction.lots').browse(cr, uid, context['active_id'], context=context)
invoice_obj = self.pool.get('account.invoice') 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) account_id = datas.get('writeoff_acc_id', False)
period_id = datas.get('period_id', False) period_id = datas.get('period_id', False)
journal_id = datas.get('journal_id', False) journal_id = datas.get('journal_id', False)

View File

@ -25,7 +25,8 @@ class auction_payer(osv.osv_memory):
_name = "auction.payer" _name = "auction.payer"
_description = "Auction payer" _description = "Auction payer"
def payer(self, cr, uid, ids, context): def payer(self, cr, uid, ids, context=None):
if not context: context = {}
self.pool.get('auction.lots').write(cr, uid, context.get('active_ids', []), {'is_ok':True, 'state':'paid'}) self.pool.get('auction.lots').write(cr, uid, context.get('active_ids', []), {'is_ok':True, 'state':'paid'})
return {} return {}
@ -38,14 +39,15 @@ class auction_payer_sel(osv.osv_memory):
_name = "auction.payer.sel" _name = "auction.payer.sel"
_description = "Auction payment for seller" _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. This function Update auction lots object and seller paid true.
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks, @param uid: the current users ID for security checks,
@param ids: List of auction payer sels IDs. @param ids: List of auction payer sels IDs.
""" """
self.pool.get('auction.lots').write(cr, uid, context['active_ids'], {'paid_vnd':True}) if not context: context = {}
self.pool.get('auction.lots').write(cr, uid, context.get('active_ids', []), {'paid_vnd':True})
return {} return {}
auction_payer_sel() auction_payer_sel()

View File

@ -45,7 +45,7 @@ class auction_taken(osv.osv_memory):
if not context: if not context:
context={} context={}
lot_obj = self.pool.get('auction.lots') 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: for lot in current.lot_ids:
lot_obj.write(cr, uid, lot.id, {'state':'taken_away', 'ach_emp': True}) lot_obj.write(cr, uid, lot.id, {'state':'taken_away', 'ach_emp': True})
return {'lot_ids': []} return {'lot_ids': []}

View File

@ -29,7 +29,7 @@ class auction_transfer_unsold_object(osv.osv):
_name = 'auction.transfer.unsold.object' _name = 'auction.transfer.unsold.object'
_description = 'To transfer unsold objects' _description = 'To transfer unsold objects'
def _start(self, cr, uid, context): def _start(self, cr, uid, context=None):
""" """
To initialize auction_id_from To initialize auction_id_from
@param self: The object pointer. @param self: The object pointer.
@ -40,7 +40,7 @@ class auction_transfer_unsold_object(osv.osv):
@return: auction_id_from @return: auction_id_from
""" """
lots_obj = self.pool.get('auction.lots') 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 auction_from = rec and rec.auction_id.id or False
return auction_from return auction_from
@ -53,7 +53,7 @@ class auction_transfer_unsold_object(osv.osv):
'auction_id_from': _start, '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 To Transfer the unsold object
@param self: The object pointer. @param self: The object pointer.
@ -63,15 +63,16 @@ class auction_transfer_unsold_object(osv.osv):
@param context: A standard dictionary @param context: A standard dictionary
@return: @return:
""" """
if not context: context = {}
bid_line_obj = self.pool.get('auction.bid_line') bid_line_obj = self.pool.get('auction.bid_line')
lots_obj = self.pool.get('auction.lots') lots_obj = self.pool.get('auction.lots')
lot_history_obj = self.pool.get('auction.lot.history') 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) 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')]) 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}) 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, up_auction = lots_obj.write(cr, uid, [rec.id], {'auction_id': res[0].auction_id_to.id,
'obj_ret':None, 'obj_ret':None,

View File

@ -52,7 +52,7 @@ class audittrail_view_log(osv.osv_memory):
result = act_obj.read(cr, uid, [id])[0] result = act_obj.read(cr, uid, [id])[0]
#start Loop #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 not datas.get('from', None):
if datas.get('to') <> time.strftime("%Y-%m-%d %H:%M:%S"): if datas.get('to') <> time.strftime("%Y-%m-%d %H:%M:%S"):
result['domain'] = str([('timestamp', '<', datas.get('to'))]) result['domain'] = str([('timestamp', '<', datas.get('to'))])

View File

@ -35,7 +35,7 @@ class base_action_rule(osv.osv):
_name = 'base.action.rule' _name = 'base.action.rule'
_description = 'Action Rules' _description = 'Action Rules'
def _state_get(self, cr, uid, context={}): def _state_get(self, cr, uid, context=None):
""" Get State """ Get State
@param self: The object pointer @param self: The object pointer
@param cr: the current row, from the database cursor, @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 """ @param context: A standard dictionary for contextual values """
return self.state_get(cr, uid, context=context) 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 """ Get State
@param self: The object pointer @param self: The object pointer
@param cr: the current row, from the database cursor, @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 """ @param context: A standard dictionary for contextual values """
return [('', '')] return [('', '')]
def priority_get(self, cr, uid, context={}): def priority_get(self, cr, uid, context=None):
""" Get Priority """ Get Priority
@param self: The object pointer @param self: The object pointer
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@ -190,12 +190,12 @@ the rule to mark CC(mail to any other person defined in actions)."),
return True return True
def create(self, cr, uid, vals, context=None): 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) self._register_hook(cr, uid, [res_id], context=context)
return res_id return res_id
def write(self, cr, uid, ids, vals, context=None): 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) self._register_hook(cr, uid, ids, context=context)
return res return res
@ -396,7 +396,7 @@ the rule to mark CC(mail to any other person defined in actions)."),
if not scrit: if not scrit:
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) model_obj = self.pool.get(action.model_id.model)
for obj in objects: for obj in objects:
ok = self.do_check(cr, uid, action, obj, context=context) 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() empty = orm.browse_null()
rule_obj = self.pool.get('base.action.rule') 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: if rule.act_mail_body:
try: try:
rule_obj.format_mail(empty, rule.act_mail_body) rule_obj.format_mail(empty, rule.act_mail_body)

View File

@ -106,7 +106,7 @@ def _links_get(self, cr, uid, context=None):
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
@return: list of dictionary which contain object and name and id. @return: list of dictionary which contain object and name and id.
""" """
if not context: context = {}
obj = self.pool.get('res.request.link') obj = self.pool.get('res.request.link')
ids = obj.search(cr, uid, []) ids = obj.search(cr, uid, [])
res = obj.read(cr, uid, ids, ['object', 'name'], context=context) res = obj.read(cr, uid, ids, ['object', 'name'], context=context)
@ -222,7 +222,7 @@ class calendar_attendee(osv.osv):
name += ':' name += ':'
return (name or '') + (email and ('MAILTO:' + email) or '') 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 . Compute data on function fields for attendee values .
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@ -234,6 +234,7 @@ class calendar_attendee(osv.osv):
""" """
name = name[0] name = name[0]
result = {} result = {}
if not context: context = {}
for attdata in self.browse(cr, uid, ids, context=context): for attdata in self.browse(cr, uid, ids, context=context):
id = attdata.id id = attdata.id
result[id] = {} result[id] = {}
@ -300,7 +301,7 @@ class calendar_attendee(osv.osv):
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
@return: list of dictionary which contain object and name and id. @return: list of dictionary which contain object and name and id.
""" """
if not context: context = {}
obj = self.pool.get('res.request.link') obj = self.pool.get('res.request.link')
ids = obj.search(cr, uid, []) ids = obj.search(cr, uid, [])
res = obj.read(cr, uid, ids, ['object', 'name'], context=context) res = obj.read(cr, uid, ids, ['object', 'name'], context=context)
@ -314,6 +315,7 @@ class calendar_attendee(osv.osv):
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
@return: list of dictionary which contain code and name and id. @return: list of dictionary which contain code and name and id.
""" """
if not context: context = {}
obj = self.pool.get('res.lang') obj = self.pool.get('res.lang')
ids = obj.search(cr, uid, []) ids = obj.search(cr, uid, [])
res = obj.read(cr, uid, ids, ['code', 'name'], context=context) res = obj.read(cr, uid, ids, ['code', 'name'], context=context)
@ -649,7 +651,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_id = ir_obj.search(cr, uid, [('model', '=', model)])[0]
model_obj = self.pool.get(model) 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 basic_alarm = data.alarm_id
cal_alarm = data.base_calendar_alarm_id cal_alarm = data.base_calendar_alarm_id
@ -719,7 +721,7 @@ true, it will allow you to hide the event alarm information without removing it.
ir_obj = self.pool.get('ir.model') ir_obj = self.pool.get('ir.model')
model_id = ir_obj.search(cr, uid, [('model', '=', model)])[0] model_id = ir_obj.search(cr, uid, [('model', '=', model)])[0]
model_obj = self.pool.get(model) 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)]) alarm_ids = alarm_obj.search(cr, uid, [('model_id', '=', model_id), ('res_id', '=', datas.id)])
if alarm_ids: if alarm_ids:
alarm_obj.unlink(cr, uid, alarm_ids) alarm_obj.unlink(cr, uid, alarm_ids)
@ -794,7 +796,7 @@ class calendar_alarm(osv.osv):
delta = timedelta(minutes=vals['trigger_duration']) delta = timedelta(minutes=vals['trigger_duration'])
trigger_date = dtstart + (vals['trigger_occurs'] == 'after' and delta or -delta) trigger_date = dtstart + (vals['trigger_occurs'] == 'after' and delta or -delta)
vals['trigger_date'] = trigger_date 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 return res
def do_run_scheduler(self, cr, uid, automatic=False, use_new_cursor=False, \ def do_run_scheduler(self, cr, uid, automatic=False, use_new_cursor=False, \
@ -1593,6 +1595,7 @@ true, it will allow you to hide the event alarm information without removing it.
@return: True @return: True
""" """
res = False res = False
if not context: context = {}
for event_datas in self.read(cr, uid, ids, ['date', 'rrule', 'exdate'], context=context): for event_datas in self.read(cr, uid, ids, ['date', 'rrule', 'exdate'], context=context):
event_id = event_datas['id'] event_id = event_datas['id']
if isinstance(event_id, (int, long)): if isinstance(event_id, (int, long)):
@ -1685,7 +1688,7 @@ class calendar_todo(osv.osv):
_inherit = "calendar.event" _inherit = "calendar.event"
_description = "Calendar Task" _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 Get Date
@param self: The object pointer @param self: The object pointer
@ -1697,11 +1700,12 @@ class calendar_todo(osv.osv):
""" """
res = {} res = {}
if not context: context = {}
for event in self.browse(cr, uid, ids, context=context): for event in self.browse(cr, uid, ids, context=context):
res[event.id] = event.date_start res[event.id] = event.date_start
return res 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 Set Date
@param self: The object pointer @param self: The object pointer

View File

@ -74,7 +74,7 @@ send an Email to Invited Person')
model_field = context.get('attendee_field', False) model_field = context.get('attendee_field', False)
obj = self.pool.get(model) 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') att_obj = self.pool.get('calendar.attendee')
user_obj = self.pool.get('res.users') user_obj = self.pool.get('res.users')
current_user = user_obj.browse(cr, uid, uid, context=context) current_user = user_obj.browse(cr, uid, uid, context=context)

View File

@ -82,8 +82,9 @@ class base_calendar_set_exrule(osv.osv_memory):
@param fields: List of fields for default value @param fields: List of fields for default value
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
""" """
if not context: context = {}
event_obj = self.pool.get(context.get('active_model')) 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: if not event.rrule:
raise osv.except_osv(_("Warning !"), _("Please Apply Recurrency before applying Exception Rule.")) raise osv.except_osv(_("Warning !"), _("Please Apply Recurrency before applying Exception Rule."))
return False return False
@ -102,7 +103,8 @@ class base_calendar_set_exrule(osv.osv_memory):
weekstring = '' weekstring = ''
monthstring = '' monthstring = ''
yearstring = '' yearstring = ''
ex_id = base_calendar.base_calendar_id2real_id(context['active_id']) if not context: context = {}
ex_id = base_calendar.base_calendar_id2real_id(context.get('active_id', False))
model = context.get('model', False) model = context.get('model', False)
model_obj = self.pool.get(model) model_obj = self.pool.get(model)
for datas in self.read(cr, uid, ids, context=context): for datas in self.read(cr, uid, ids, context=context):

View File

@ -24,7 +24,7 @@ from osv import fields
class calendar_event_edit_all(osv.osv_memory): 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 """ Get Default value for Start Date
@param self: The object pointer @param self: The object pointer
@param cr: the current row, from the database cursor, @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']) event = model_obj.read(cr, uid, context_id, ['name', 'location', 'alarm_id'])
return event['date'] return event['date']
def _default_deadline(self, cr, uid, context={}): def _default_deadline(self, cr, uid, context=None):
""" Get Default value for End Date """ Get Default value for End Date
@param self: The object pointer @param self: The object pointer
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,

View File

@ -36,13 +36,14 @@ class res_partner_contact(osv.osv):
@fields: Get Fields @fields: Get Fields
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
@param arg: list of tuples of form [(name_of_the_field, operator, value), ...]. """ @param arg: list of tuples of form [(name_of_the_field, operator, value), ...]. """
if not context: context = {}
res = dict.fromkeys(ids, False) res = dict.fromkeys(ids, False)
res_partner_job_obj = self.pool.get('res.partner.job') res_partner_job_obj = self.pool.get('res.partner.job')
all_job_ids = res_partner_job_obj.search(cr, uid, []) 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))) 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: if contact.job_ids:
res[contact.id] = all_job_names.get(contact.job_ids[0].id, False) res[contact.id] = all_job_names.get(contact.job_ids[0].id, False)
@ -77,7 +78,7 @@ class res_partner_contact(osv.osv):
_order = "name,first_name" _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....... """ will return name and first_name.......
@param self: The object pointer @param self: The object pointer
@ -91,6 +92,7 @@ class res_partner_contact(osv.osv):
if not len(ids): if not len(ids):
return [] return []
res = [] res = []
if not context: context = {}
for contact in self.browse(cr, user, ids, context=context): for contact in self.browse(cr, user, ids, context=context):
_contact = "" _contact = ""
if contact.title: if contact.title:
@ -119,7 +121,7 @@ res_partner_contact()
class res_partner_address(osv.osv): class res_partner_address(osv.osv):
#overriding of the name_get defined in base in order to remove the old contact name #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 self: The object pointer
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@ -131,6 +133,7 @@ class res_partner_address(osv.osv):
if not len(ids): if not len(ids):
return [] return []
res = [] res = []
if not context: context = {}
for r in self.read(cr, user, ids, ['zip', 'city', 'partner_id', 'street']): for r in self.read(cr, user, ids, ['zip', 'city', 'partner_id', 'street']):
if context.get('contact_display', 'contact')=='partner' and r['partner_id']: if context.get('contact_display', 'contact')=='partner' and r['partner_id']:
res.append((r['id'], r['partner_id'][1])) res.append((r['id'], r['partner_id'][1]))
@ -235,10 +238,11 @@ class res_partner_job(osv.osv):
@address_id : ID of the Address selected, @address_id : ID of the Address selected,
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
""" """
if not context: context = {}
partner_id = False partner_id = False
if address_id: if address_id:
address = self.pool.get('res.partner.address')\ 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 partner_id = address.partner_id.id
return {'value': {'name': partner_id}} return {'value': {'name': partner_id}}

View File

@ -35,7 +35,8 @@ class base_contact_installer(osv.osv_memory):
""" """
This function is used to create contact and address from existing partner address This function is used to create contact and address from existing partner address
""" """
obj = self.pool.get("base.contact.installer").browse(cr, uid, uid) if not context: context = {}
obj = self.pool.get("base.contact.installer").browse(cr, uid, uid, context=context)
if obj.migrate: if obj.migrate:
cr.execute("""DROP TRIGGER IF EXISTS contactjob on res_partner_contact; cr.execute("""DROP TRIGGER IF EXISTS contactjob on res_partner_contact;
DROP LANGUAGE IF EXISTS plpgsql CASCADE; DROP LANGUAGE IF EXISTS plpgsql CASCADE;

View File

@ -73,23 +73,26 @@ def _format_iban(string):
class res_partner_bank(osv.osv): class res_partner_bank(osv.osv):
_inherit = "res.partner.bank" _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 #overwrite to format the iban number correctly
if not context: context = {}
if 'iban' in vals and vals['iban']: if 'iban' in vals and vals['iban']:
vals['iban'] = _format_iban(vals['iban']) vals['iban'] = _format_iban(vals['iban'])
return super(res_partner_bank, self).create(cr, uid, vals, context) 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 #overwrite to format the iban number correctly
if not context: context = {}
if 'iban' in vals and vals['iban']: if 'iban' in vals and vals['iban']:
vals['iban'] = _format_iban(vals['iban']) vals['iban'] = _format_iban(vals['iban'])
return super(res_partner_bank, self).write(cr, uid, ids, vals, context) 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 Check the IBAN number
''' '''
for bank_acc in self.browse(cr, uid, ids): if not context: context = {}
for bank_acc in self.browse(cr, uid, ids, context=context):
if not bank_acc.iban: if not bank_acc.iban:
continue continue
iban = _format_iban(bank_acc.iban) iban = _format_iban(bank_acc.iban)
@ -109,7 +112,7 @@ class res_partner_bank(osv.osv):
return False return False
return True 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): def default_iban_check(iban_cn):
return iban_cn[0] in string.ascii_lowercase and iban_cn[1] in string.ascii_lowercase return iban_cn[0] in string.ascii_lowercase and iban_cn[1] in string.ascii_lowercase
@ -123,16 +126,18 @@ class res_partner_bank(osv.osv):
def name_get(self, cr, uid, ids, context=None): def name_get(self, cr, uid, ids, context=None):
res = [] res = []
to_check_ids = [] to_check_ids = []
for id in self.browse(cr, uid, ids): if not context: context = {}
for id in self.browse(cr, uid, ids, context=context):
if id.state=='iban': if id.state=='iban':
res.append((id.id,id.iban)) res.append((id.id,id.iban))
else: else:
to_check_ids.append(id.id) 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 return res
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
#overwrite the search method in order to search not only on bank type == basic account number but also on type == iban #overwrite the search method in order to search not only on bank type == basic account number but also on type == iban
if not context: context = {}
res = super(res_partner_bank,self).search(cr, uid, args, offset, limit, order, context=context, count=count) res = super(res_partner_bank,self).search(cr, uid, args, offset, limit, order, context=context, count=count)
if filter(lambda x:x[0]=='acc_number' ,args): if filter(lambda x:x[0]=='acc_number' ,args):
#get the value of the search #get the value of the search
@ -151,6 +156,7 @@ class res_partner_bank(osv.osv):
This function returns the bank account number computed from the iban account number, thanks to the mapping_list dictionary that contains the rules associated to its country. This function returns the bank account number computed from the iban account number, thanks to the mapping_list dictionary that contains the rules associated to its country.
''' '''
res = {} res = {}
if not context: context = {}
mapping_list = { mapping_list = {
#TODO add rules for others countries #TODO add rules for others countries
'be': lambda x: x[4:], 'be': lambda x: x[4:],
@ -158,7 +164,7 @@ class res_partner_bank(osv.osv):
'ch': lambda x: x[9:], 'ch': lambda x: x[9:],
'gb': lambda x: x[14:], '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: if not record.iban:
res[record.id] = False res[record.id] = False
continue continue

View File

@ -35,8 +35,9 @@ class module(osv.osv):
'file_graph': fields.binary('Relationship Graph'), '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') obj_model = self.pool.get('ir.model')
if not context: context = {}
if level == 0: if level == 0:
return tuple() return tuple()
relation = [] relation = []
@ -86,7 +87,7 @@ class module(osv.osv):
) )
return res 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_model = self.pool.get('ir.model')
obj_mod_data = self.pool.get('ir.model.data') obj_mod_data = self.pool.get('ir.model.data')
obj_ids = [] obj_ids = []
@ -99,6 +100,7 @@ class module(osv.osv):
return obj_ids return obj_ids
def get_relation_graph(self, cr, uid, module_name, context=None): def get_relation_graph(self, cr, uid, module_name, context=None):
if not context: context = {}
object_ids = self._get_module_objects(cr, uid, module_name, context=context) object_ids = self._get_module_objects(cr, uid, module_name, context=context)
if not object_ids: if not object_ids:
return {'module_file': False} return {'module_file': False}

View File

@ -74,7 +74,7 @@ class report_graph(report.interface.report_int):
input.close() input.close()
return output.read() 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']) pdf_string = self.get_proximity_graph(cr, uid, data['id'])
return (pdf_string, 'pdf') return (pdf_string, 'pdf')

View File

@ -28,8 +28,9 @@ form_rep = '''<?xml version="1.0"?>
<label colspan="2" string="(Relationship Graphs generated)" align="0.0"/> <label colspan="2" string="(Relationship Graphs generated)" align="0.0"/>
</form>''' </form>'''
def _get_graph(self, cr, uid, datas, context={}): def _get_graph(self, cr, uid, datas, context=None):
mod_obj = pooler.get_pool(cr.dbname).get('ir.module.module') mod_obj = pooler.get_pool(cr.dbname).get('ir.module.module')
if not context: context = {}
modules = mod_obj.browse(cr, uid, datas['ids'], context=context) modules = mod_obj.browse(cr, uid, datas['ids'], context=context)
for module in modules: for module in modules:
module_data = mod_obj.get_relation_graph(cr, uid, module.name, context=context) module_data = mod_obj.get_relation_graph(cr, uid, module.name, context=context)

View File

@ -404,7 +404,7 @@ class wizard_tech_guide_rst(wizard.interface):
'name': 'modules_technical_guide_rst.tgz' 'name': 'modules_technical_guide_rst.tgz'
} }
def _get_views(self, cr, uid, module_id, context={}): def _get_views(self, cr, uid, module_id, context=None):
pool = pooler.get_pool(cr.dbname) pool = pooler.get_pool(cr.dbname)
module_module_obj = pool.get('ir.module.module') module_module_obj = pool.get('ir.module.module')
res = {} res = {}

View File

@ -28,7 +28,7 @@ from osv import osv, fields
class quality_check(wizard.interface): class quality_check(wizard.interface):
def _create_quality_check(self, cr, uid, data, context={}): def _create_quality_check(self, cr, uid, data, context=None):
pool = pooler.get_pool(cr.dbname) pool = pooler.get_pool(cr.dbname)
obj_quality = pool.get('module.quality.check') obj_quality = pool.get('module.quality.check')
objs = [] objs = []

View File

@ -40,7 +40,7 @@ fields_rep = {
'module_file': {'string': 'Save report', 'type': 'binary', 'required': True}, 'module_file': {'string': 'Save report', 'type': 'binary', 'required': True},
} }
def get_detail(self, cr, uid, datas, context={}): def get_detail(self, cr, uid, datas, context=None):
data = pooler.get_pool(cr.dbname).get('module.quality.detail').browse(cr, uid, datas['id']) data = pooler.get_pool(cr.dbname).get('module.quality.detail').browse(cr, uid, datas['id'])
if not data.detail: if not data.detail:
raise wizard.except_wizard(_('Warning'), _('No report to save!')) raise wizard.except_wizard(_('Warning'), _('No report to save!'))

View File

@ -37,7 +37,7 @@ class report_creator(osv.osv):
if context is None: if context is None:
context = {} context = {}
data_l = self.read(cr, uid, ids, ['sql_query'], context) data_l = self.read(cr, uid, ids, ['sql_query'], context=context)
final_datas = [] final_datas = []
#start Loop #start Loop
for i in data_l: for i in data_l:
@ -183,7 +183,7 @@ class report_creator(osv.osv):
} }
return result return result
def read(self, cr, user, ids, fields = None, context = None, load = '_classic_read'): def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'):
""" """
overrides orm Read method.Read List of fields for report creator. overrides orm Read method.Read List of fields for report creator.
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@ -357,13 +357,14 @@ class report_creator(osv.osv):
""" """
return self.model_set_id and 'min('+self.model_set_id+'.id)' return self.model_set_id and 'min('+self.model_set_id+'.id)'
def _sql_query_get(self, cr, uid, ids, prop, unknow_none, context, where_plus=[], limit=None, offset=None): def _sql_query_get(self, cr, uid, ids, prop, unknow_none, context=None, where_plus=[], limit=None, offset=None):
""" """
Get sql query which return on sql_query field. Get sql query which return on sql_query field.
@return: Dictionary of sql query. @return: Dictionary of sql query.
""" """
result = {} result = {}
for obj in self.browse(cr, uid, ids): if not context: context = {}
for obj in self.browse(cr, uid, ids, context=context):
fields = [] fields = []
groupby = [] groupby = []
i = 0 i = 0
@ -476,7 +477,7 @@ class report_creator(osv.osv):
return value return value
def _function_field(self, cr, uid, ids): def _function_field(self, cr, uid, ids, context=None):
""" """
constraints function which specify that constraints function which specify that
not display field which are not stored in Database. not display field which are not stored in Database.
@ -486,7 +487,8 @@ class report_creator(osv.osv):
@return: True if display field which are stored in database. @return: True if display field which are stored in database.
or false if display field which are not store in dtabase. or false if display field which are not store in dtabase.
""" """
this_objs = self.browse(cr, uid, ids) if not context: context = {}
this_objs = self.browse(cr, uid, ids, context=context)
for obj in this_objs: for obj in this_objs:
for fld in obj.field_ids: for fld in obj.field_ids:
# Allowing to use count(*) # Allowing to use count(*)
@ -497,7 +499,7 @@ class report_creator(osv.osv):
return False return False
return True return True
def _aggregation_error(self, cr, uid, ids): def _aggregation_error(self, cr, uid, ids, context=None):
""" """
constraints function which specify that constraints function which specify that
aggregate function to the non calculated field.. aggregate function to the non calculated field..
@ -507,10 +509,10 @@ class report_creator(osv.osv):
@return: True if model colume type is in integer or float. @return: True if model colume type is in integer or float.
or false model colume type is not in integer or float. or false model colume type is not in integer or float.
""" """
if not context: context = {}
aggregate_columns = ('integer', 'float') aggregate_columns = ('integer', 'float')
apply_functions = ('sum', 'min', 'max', 'avg', 'count') apply_functions = ('sum', 'min', 'max', 'avg', 'count')
this_objs = self.browse(cr, uid, ids) this_objs = self.browse(cr, uid, ids, context=context)
for obj in this_objs: for obj in this_objs:
for fld in obj.field_ids: for fld in obj.field_ids:
# Allowing to use count(*) # Allowing to use count(*)
@ -521,9 +523,10 @@ class report_creator(osv.osv):
return False return False
return True return True
def _calander_view_error(self, cr, uid, ids): def _calander_view_error(self, cr, uid, ids, context=None):
required_types = [] required_types = []
this_objs = self.browse(cr, uid, ids) if not context: context = {}
this_objs = self.browse(cr, uid, ids, context=context)
for obj in this_objs: for obj in this_objs:
if obj.view_type1 == 'calendar' or obj.view_type2 == 'calendar' or obj.view_type3 == 'calendar': if obj.view_type1 == 'calendar' or obj.view_type2 == 'calendar' or obj.view_type3 == 'calendar':
for fld in obj.field_ids: for fld in obj.field_ids:

View File

@ -42,10 +42,11 @@ class report_xml(osv.osv):
fp = open(addons.get_module_resource('base_report_designer','openerp_sxw2rml', 'normalized_odt2rml.xsl'),'rb') fp = open(addons.get_module_resource('base_report_designer','openerp_sxw2rml', 'normalized_odt2rml.xsl'),'rb')
return {'report_rml_content': str(sxw2rml(sxwval, xsl=fp.read()))} return {'report_rml_content': str(sxw2rml(sxwval, xsl=fp.read()))}
def upload_report(self, cr, uid, report_id, file_sxw, file_type, context): def upload_report(self, cr, uid, report_id, file_sxw, file_type, context=None):
''' '''
Untested function Untested function
''' '''
if not context: context = {}
pool = pooler.get_pool(cr.dbname) pool = pooler.get_pool(cr.dbname)
sxwval = StringIO(base64.decodestring(file_sxw)) sxwval = StringIO(base64.decodestring(file_sxw))
if file_type=='sxw': if file_type=='sxw':
@ -59,8 +60,9 @@ class report_xml(osv.osv):
pool.get('ir.actions.report.xml').register_all(cr) pool.get('ir.actions.report.xml').register_all(cr)
return True return True
def report_get(self, cr, uid, report_id, context={}): def report_get(self, cr, uid, report_id, context=None):
report = self.browse(cr, uid, report_id, context) if not context: context = {}
report = self.browse(cr, uid, report_id, context=context)
return { return {
'file_type' : report.report_type, 'file_type' : report.report_type,
'report_sxw_content': report.report_sxw_content and base64.encodestring(report.report_sxw_content) or False, 'report_sxw_content': report.report_sxw_content and base64.encodestring(report.report_sxw_content) or False,

View File

@ -29,8 +29,9 @@ class base_report_designer_installer(osv.osv_memory):
_name = 'base_report_designer.installer' _name = 'base_report_designer.installer'
_inherit = 'res.config.installer' _inherit = 'res.config.installer'
def default_get(self, cr, uid, fields, context={}): def default_get(self, cr, uid, fields, context=None):
data = super(base_report_designer_installer, self).default_get(cr, uid, fields, context) if not context: context = {}
data = super(base_report_designer_installer, self).default_get(cr, uid, fields, context=context)
plugin_file = open(addons.get_module_resource('base_report_designer','plugin', 'openerp_report_designer.zip'),'rb') plugin_file = open(addons.get_module_resource('base_report_designer','plugin', 'openerp_report_designer.zip'),'rb')
data['plugin_file'] = base64.encodestring(plugin_file.read()) data['plugin_file'] = base64.encodestring(plugin_file.read())
return data return data

View File

@ -38,11 +38,12 @@ class base_report_sxw(osv.osv_memory):
} }
def get_report(self, cr, uid, ids, context): def get_report(self, cr, uid, ids, context=None):
data=self.read(cr,uid,ids)[0] if not context: context = {}
data = self.read(cr,uid,ids)[0]
data_obj = self.pool.get('ir.model.data') data_obj = self.pool.get('ir.model.data')
id2 = data_obj._get_id(cr, uid, 'base_report_designer', 'view_base_report_file_sxw') id2 = data_obj._get_id(cr, uid, 'base_report_designer', 'view_base_report_file_sxw')
report = self.pool.get('ir.actions.report.xml').browse(cr, uid, data['report_id'], context) report = self.pool.get('ir.actions.report.xml').browse(cr, uid, data['report_id'], context=context)
if id2: if id2:
id2 = data_obj.browse(cr, uid, id2, context=context).res_id id2 = data_obj.browse(cr, uid, id2, context=context).res_id
return { return {
@ -74,11 +75,11 @@ class base_report_file_sxw(osv.osv_memory):
@return: A dictionary which of fields with values. @return: A dictionary which of fields with values.
""" """
if not context: context = {}
res = super(base_report_file_sxw, self).default_get(cr, uid, fields, context=context) res = super(base_report_file_sxw, self).default_get(cr, uid, fields, context=context)
report_id1 = self.pool.get('base.report.sxw').search(cr,uid,[]) report_id1 = self.pool.get('base.report.sxw').search(cr,uid,[])
data=self.pool.get('base.report.sxw').read(cr,uid,report_id1)[0] data=self.pool.get('base.report.sxw').read(cr,uid,report_id1)[0]
report = self.pool.get('ir.actions.report.xml').browse(cr, uid, data['report_id'], context) report = self.pool.get('ir.actions.report.xml').browse(cr, uid, data['report_id'], context=context)
if not context: if not context:
context={} context={}
if 'report_id' in fields: if 'report_id' in fields:
@ -92,9 +93,10 @@ class base_report_file_sxw(osv.osv_memory):
'file_sxw_upload':fields.binary('Your .SXW file',required=True) 'file_sxw_upload':fields.binary('Your .SXW file',required=True)
} }
def upload_report(self, cr, uid, ids, context): def upload_report(self, cr, uid, ids, context=None):
from base_report_designer import openerp_sxw2rml from base_report_designer import openerp_sxw2rml
import StringIO import StringIO
if not context: context = {}
data=self.read(cr,uid,ids)[0] data=self.read(cr,uid,ids)[0]
sxwval = StringIO.StringIO(base64.decodestring(data['file_sxw_upload'])) sxwval = StringIO.StringIO(base64.decodestring(data['file_sxw_upload']))
fp = tools.file_open('normalized_oo2rml.xsl',subdir='addons/base_report_designer/openerp_sxw2rml') fp = tools.file_open('normalized_oo2rml.xsl',subdir='addons/base_report_designer/openerp_sxw2rml')
@ -106,7 +108,7 @@ class base_report_file_sxw(osv.osv_memory):
cr.commit() cr.commit()
data_obj = self.pool.get('ir.model.data') data_obj = self.pool.get('ir.model.data')
id2 = data_obj._get_id(cr, uid, 'base_report_designer', 'view_base_report_file_rml') id2 = data_obj._get_id(cr, uid, 'base_report_designer', 'view_base_report_file_rml')
report = self.pool.get('ir.actions.report.xml').browse(cr, uid, data['report_id'], context) report = self.pool.get('ir.actions.report.xml').browse(cr, uid, data['report_id'], context=context)
if id2: if id2:
id2 = data_obj.browse(cr, uid, id2, context=context).res_id id2 = data_obj.browse(cr, uid, id2, context=context).res_id
return { return {
@ -135,12 +137,14 @@ class base_report_rml_save(osv.osv_memory):
@return: A dictionary which of fields with values. @return: A dictionary which of fields with values.
""" """
if not context:
context = {}
res = super(base_report_rml_save, self).default_get(cr, uid, fields, context=context) res = super(base_report_rml_save, self).default_get(cr, uid, fields, context=context)
report_id = self.pool.get('base.report.sxw').search(cr,uid,[]) report_id = self.pool.get('base.report.sxw').search(cr,uid,[])
data=self.pool.get('base.report.file.sxw').read(cr,uid,report_id)[0] data=self.pool.get('base.report.file.sxw').read(cr,uid,report_id)[0]
report = self.pool.get('ir.actions.report.xml').browse(cr, uid, data['report_id'], context) report = self.pool.get('ir.actions.report.xml').browse(cr, uid, data['report_id'], context=context)
if not context:
context={}
if 'file_rml' in fields: if 'file_rml' in fields:
res['file_rml'] = base64.encodestring(report.report_rml_content) res['file_rml'] = base64.encodestring(report.report_rml_content)
return res return res

View File

@ -42,10 +42,10 @@ class base_setup_config_choice(osv.osv_memory):
file_data = tools.file_open(path,'rb').read() file_data = tools.file_open(path,'rb').read()
return base64.encodestring(file_data) return base64.encodestring(file_data)
def get_users(self, cr, uid, context={}): def get_users(self, cr, uid, context=None):
user_obj = self.pool.get('res.users') user_obj = self.pool.get('res.users')
user_ids = user_obj.search(cr, uid, []) user_ids = user_obj.search(cr, uid, [])
users = user_obj.browse(cr, uid, user_ids) users = user_obj.browse(cr, uid, user_ids, context=context)
user_str = '\n'.join(map(lambda x: ' - %s :\n\t\tLogin : %s \n\t\tPassword : %s' % (x.name, x.login, x.password), users)) user_str = '\n'.join(map(lambda x: ' - %s :\n\t\tLogin : %s \n\t\tPassword : %s' % (x.name, x.login, x.password), users))
return _('The following users have been installed : \n')+ user_str return _('The following users have been installed : \n')+ user_str

View File

@ -65,7 +65,7 @@ class base_setup_company(osv.osv_memory):
company_id = companies.search(cr, uid, [], limit=1, order="id") company_id = companies.search(cr, uid, [], limit=1, order="id")
if not company_id or 'company_id' not in fields_list: if not company_id or 'company_id' not in fields_list:
return defaults return defaults
company = companies.browse(cr, uid, company_id[0]) company = companies.browse(cr, uid, company_id[0], context=context)
defaults['company_id'] = company.id defaults['company_id'] = company.id
if not self._show_company_data(cr, uid, context=context): if not self._show_company_data(cr, uid, context=context):

View File

@ -1,111 +1,111 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
# OpenERP, Open Source Management Solution # OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as # it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the # published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version. # License, or (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details. # GNU Affero General Public License for more details.
# #
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################## ##############################################################################
from osv import fields,osv from osv import fields,osv
import tools import tools
import re import re
import time import time
class base_synchro_server(osv.osv): class base_synchro_server(osv.osv):
'''Class to store the information regarding server''' '''Class to store the information regarding server'''
_name = "base.synchro.server" _name = "base.synchro.server"
_description = "Synchronized server" _description = "Synchronized server"
_columns = { _columns = {
'name': fields.char('Server name', size=64,required=True), 'name': fields.char('Server name', size=64,required=True),
'server_url': fields.char('Server URL', size=64,required=True), 'server_url': fields.char('Server URL', size=64,required=True),
'server_port': fields.integer('Server Port', size=64,required=True), 'server_port': fields.integer('Server Port', size=64,required=True),
'server_db': fields.char('Server Database', size=64,required=True), 'server_db': fields.char('Server Database', size=64,required=True),
'login': fields.char('User Name',size=50,required=True), 'login': fields.char('User Name',size=50,required=True),
'password': fields.char('Password',size=64,invisible=True,required=True), 'password': fields.char('Password',size=64,invisible=True,required=True),
'obj_ids' : fields.one2many('base.synchro.obj','server_id','Models',ondelete='cascade') 'obj_ids' : fields.one2many('base.synchro.obj','server_id','Models',ondelete='cascade')
} }
_defaults = { _defaults = {
'server_port': lambda *args: 8069 'server_port': lambda *args: 8069
} }
base_synchro_server() base_synchro_server()
class base_synchro_obj(osv.osv): class base_synchro_obj(osv.osv):
'''Class to store the operations done by wizard''' '''Class to store the operations done by wizard'''
_name = "base.synchro.obj" _name = "base.synchro.obj"
_description = "Register Class" _description = "Register Class"
_columns = { _columns = {
'name':fields.char('Name', size=64, select=1, required=1), 'name':fields.char('Name', size=64, select=1, required=1),
'domain':fields.char('Domain', size=64, select=1, required=1), 'domain':fields.char('Domain', size=64, select=1, required=1),
'server_id':fields.many2one('base.synchro.server','Server', ondelete='cascade', select=1, required=1), 'server_id':fields.many2one('base.synchro.server','Server', ondelete='cascade', select=1, required=1),
'model_id': fields.many2one('ir.model', 'Object to synchronize',required=True), 'model_id': fields.many2one('ir.model', 'Object to synchronize',required=True),
'action':fields.selection([('d','Download'),('u','Upload'),('b','Both')],'Synchronisation direction', required=True), 'action':fields.selection([('d','Download'),('u','Upload'),('b','Both')],'Synchronisation direction', required=True),
'sequence': fields.integer('Sequence'), 'sequence': fields.integer('Sequence'),
'active': fields.boolean('Active'), 'active': fields.boolean('Active'),
'synchronize_date':fields.datetime('Latest Synchronization', readonly=True), 'synchronize_date':fields.datetime('Latest Synchronization', readonly=True),
'line_id':fields.one2many('base.synchro.obj.line','obj_id','Ids Affected',ondelete='cascade'), 'line_id':fields.one2many('base.synchro.obj.line','obj_id','Ids Affected',ondelete='cascade'),
'avoid_ids':fields.one2many('base.synchro.obj.avoid','obj_id','Fields Not Sync.'), 'avoid_ids':fields.one2many('base.synchro.obj.avoid','obj_id','Fields Not Sync.'),
} }
_defaults = { _defaults = {
'active': lambda *args: True, 'active': lambda *args: True,
'action': lambda *args: 'd', 'action': lambda *args: 'd',
'domain': lambda *args: '[]' 'domain': lambda *args: '[]'
} }
_order = 'sequence' _order = 'sequence'
# #
# Return a list of changes: [ (date, id) ] # Return a list of changes: [ (date, id) ]
# #
def get_ids(self, cr, uid, object, dt, domain=[], context={}): def get_ids(self, cr, uid, object, dt, domain=[], context=None):
return self._get_ids(cr, uid, object, dt, domain, context) return self._get_ids(cr, uid, object, dt, domain, context=context)
def _get_ids(self, cr, uid, object, dt, domain=[], context={}): def _get_ids(self, cr, uid, object, dt, domain=[], context=None):
result = [] result = []
if dt: if dt:
domain2 = domain+[('write_date','>=',dt)] domain2 = domain+[('write_date','>=',dt)]
domain3 = domain+[('create_date','>=',dt)] domain3 = domain+[('create_date','>=',dt)]
else: else:
domain2 = domain3 = domain domain2 = domain3 = domain
ids = self.pool.get(object).search(cr, uid, domain2, context=context) ids = self.pool.get(object).search(cr, uid, domain2, context=context)
ids += self.pool.get(object).search(cr, uid, domain3, context=context) ids += self.pool.get(object).search(cr, uid, domain3, context=context)
for r in self.pool.get(object).perm_read(cr, uid, ids, context, details=False): for r in self.pool.get(object).perm_read(cr, uid, ids, context, details=False):
result.append( (r['write_date'] or r['create_date'], r['id'], context.get('action', 'd'))) result.append( (r['write_date'] or r['create_date'], r['id'], context.get('action', 'd')))
return result return result
base_synchro_obj() base_synchro_obj()
class base_synchro_obj_avoid(osv.osv): class base_synchro_obj_avoid(osv.osv):
_name = "base.synchro.obj.avoid" _name = "base.synchro.obj.avoid"
_description = "Fields to not synchronize" _description = "Fields to not synchronize"
_columns = { _columns = {
'name':fields.char('Field Name', size=64, select=1, required=1), 'name':fields.char('Field Name', size=64, select=1, required=1),
'obj_id':fields.many2one('base.synchro.obj', 'Object', required=1,ondelete='cascade'), 'obj_id':fields.many2one('base.synchro.obj', 'Object', required=1,ondelete='cascade'),
} }
base_synchro_obj_avoid() base_synchro_obj_avoid()
class base_synchro_obj_line(osv.osv): class base_synchro_obj_line(osv.osv):
'''Class to store the operations done by wizard''' '''Class to store the operations done by wizard'''
_name = "base.synchro.obj.line" _name = "base.synchro.obj.line"
_description = "Synchronized instances" _description = "Synchronized instances"
_columns = { _columns = {
'name': fields.datetime('Date', required=True), 'name': fields.datetime('Date', required=True),
'obj_id': fields.many2one('base.synchro.obj', 'Object', ondelete='cascade', select=True), 'obj_id': fields.many2one('base.synchro.obj', 'Object', ondelete='cascade', select=True),
'local_id': fields.integer('Local Id',readonly=True), 'local_id': fields.integer('Local Id',readonly=True),
'remote_id':fields.integer('Remote Id',readonly=True), 'remote_id':fields.integer('Remote Id',readonly=True),
} }
_defaults = { _defaults = {
'name': lambda *args: time.strftime('%Y-%m-%d %H:%M:%S') 'name': lambda *args: time.strftime('%Y-%m-%d %H:%M:%S')
} }
base_synchro_obj_line() base_synchro_obj_line()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -65,7 +65,9 @@ class base_synchro(osv.osv_memory):
report_create = 0 report_create = 0
report_write = 0 report_write = 0
def synchronize(self, cr, uid, server, object, context): def synchronize(self, cr, uid, server, object, context=None):
if not context:
context = {}
pool = pooler.get_pool(cr.dbname) pool = pooler.get_pool(cr.dbname)
self.meta = {} self.meta = {}
ids = [] ids = []
@ -136,7 +138,9 @@ class base_synchro(osv.osv_memory):
self.meta = {} self.meta = {}
return True return True
def get_id(self, cr, uid, object_id, id, action, context={}): def get_id(self, cr, uid, object_id, id, action, context=None):
if not context:
context = {}
pool = pooler.get_pool(cr.dbname) pool = pooler.get_pool(cr.dbname)
line_pool = pool.get('base.synchro.obj.line') line_pool = pool.get('base.synchro.obj.line')
field_src = (action=='u') and 'local_id' or 'remote_id' field_src = (action=='u') and 'local_id' or 'remote_id'
@ -147,9 +151,11 @@ class base_synchro(osv.osv_memory):
result = line_pool.read(cr, uid, rid, [field_dest], context=context)[0][field_dest] result = line_pool.read(cr, uid, rid, [field_dest], context=context)[0][field_dest]
return result return result
def relation_transform(self, cr, uid, pool_src, pool_dest, object, id, action, context={}): def relation_transform(self, cr, uid, pool_src, pool_dest, object, id, action, context=None):
if not id: if not id:
return False return False
if not context:
context = {}
pool = pooler.get_pool(cr.dbname) pool = pooler.get_pool(cr.dbname)
cr.execute('''select o.id from base_synchro_obj o left join ir_model m on (o.model_id =m.id) where cr.execute('''select o.id from base_synchro_obj o left join ir_model m on (o.model_id =m.id) where
m.model=%s and m.model=%s and
@ -181,10 +187,12 @@ class base_synchro(osv.osv_memory):
# Otherwise, use the name_search method # Otherwise, use the name_search method
# #
def data_transform(self, cr, uid, pool_src, pool_dest, object, data, action='u', context={}): def data_transform(self, cr, uid, pool_src, pool_dest, object, data, action='u', context=None):
self.meta.setdefault(pool_src, {}) self.meta.setdefault(pool_src, {})
if not context:
context = {}
if not object in self.meta[pool_src]: if not object in self.meta[pool_src]:
self.meta[pool_src][object] = pool_src.get(object).fields_get(cr, uid, context) self.meta[pool_src][object] = pool_src.get(object).fields_get(cr, uid, context=context)
fields = self.meta[pool_src][object] fields = self.meta[pool_src][object]
for f in fields: for f in fields:
@ -196,7 +204,7 @@ class base_synchro(osv.osv_memory):
del data[f] del data[f]
elif ftype == 'many2one': elif ftype == 'many2one':
if data[f]: if data[f]:
df = self.relation_transform(cr, uid, pool_src, pool_dest, fields[f]['relation'], data[f][0], action, context) df = self.relation_transform(cr, uid, pool_src, pool_dest, fields[f]['relation'], data[f][0], action, context=context)
data[f] = df data[f] = df
if not data[f]: if not data[f]:
del data[f] del data[f]
@ -212,11 +220,13 @@ class base_synchro(osv.osv_memory):
# #
def upload_download(self, cr, uid, ids, context): def upload_download(self, cr, uid, ids, context=None):
if not context:
context = {}
start_date = time.strftime('%Y-%m-%d, %Hh %Mm %Ss') start_date = time.strftime('%Y-%m-%d, %Hh %Mm %Ss')
syn_obj = self.browse(cr, uid, ids)[0] syn_obj = self.browse(cr, uid, ids, context=context)[0]
pool = pooler.get_pool(cr.dbname) pool = pooler.get_pool(cr.dbname)
server = pool.get('base.synchro.server').browse(cr, uid, ids, context)[0] server = pool.get('base.synchro.server').browse(cr, uid, ids, context=context)[0]
for object in server.obj_ids: for object in server.obj_ids:
dt = time.strftime('%Y-%m-%d %H:%M:%S') dt = time.strftime('%Y-%m-%d %H:%M:%S')
self.synchronize(cr, uid, server, object, context) self.synchronize(cr, uid, server, object, context)
@ -249,7 +259,9 @@ Exceptions:
}) })
return True return True
def upload_download_multi_thread(self, cr, uid, data, context): def upload_download_multi_thread(self, cr, uid, data, context=None):
if not context:
context = {}
threaded_synchronization = threading.Thread(target=self.upload_download, args=(cr, uid, data, context)) threaded_synchronization = threading.Thread(target=self.upload_download, args=(cr, uid, data, context))
threaded_synchronization.run() threaded_synchronization.run()
data_obj = self.pool.get('ir.model.data') data_obj = self.pool.get('ir.model.data')

View File

@ -52,12 +52,12 @@ class res_partner(osv.osv):
vat_country, vat_number = vat[:2].lower(), vat[2:].replace(' ', '') vat_country, vat_number = vat[:2].lower(), vat[2:].replace(' ', '')
return vat_country, vat_number return vat_country, vat_number
def check_vat(self, cr, uid, ids): def check_vat(self, cr, uid, ids, context=None):
''' '''
Check the VAT number depending of the country. Check the VAT number depending of the country.
http://sima-pc.com/nif.php http://sima-pc.com/nif.php
''' '''
for partner in self.browse(cr, uid, ids): for partner in self.browse(cr, uid, ids, context=context):
if not partner.vat: if not partner.vat:
continue continue
vat_country, vat_number = self._split_vat(partner.vat) vat_country, vat_number = self._split_vat(partner.vat)
@ -75,7 +75,7 @@ class res_partner(osv.osv):
'vat_subjected': fields.boolean('VAT Legal Statement', help="Check this box if the partner is subjected to the VAT. It will be used for the VAT legal statement.") 'vat_subjected': fields.boolean('VAT Legal Statement', help="Check this box if the partner is subjected to the VAT. It will be used for the VAT legal statement.")
} }
def _construct_constraint_msg(self, cr, uid, ids): def _construct_constraint_msg(self, cr, uid, ids, context=None):
def default_vat_check(cn, vn): def default_vat_check(cn, vn):
# by default, a VAT number is valid if: # by default, a VAT number is valid if:
# it starts with 2 letters # it starts with 2 letters

View File

@ -70,7 +70,7 @@ class board_board(osv.osv):
return arch return arch
def write(self, cr, uid, ids, vals, context = {}): def write(self, cr, uid, ids, vals, context=None):
""" """
Writes values in one or several fields. Writes values in one or several fields.
@ -81,10 +81,12 @@ class board_board(osv.osv):
dictionary must be with the form: {name_of_the_field: value, ...}. dictionary must be with the form: {name_of_the_field: value, ...}.
@return: True @return: True
""" """
result = super(board_board, self).write(cr, uid, ids, vals, context) if not context:
context = {}
result = super(board_board, self).write(cr, uid, ids, vals, context=context)
board = self.pool.get('board.board').browse(cr, uid, ids[0]) board = self.pool.get('board.board').browse(cr, uid, ids[0], context=context)
view = self.create_view(cr, uid, ids[0], context) view = self.create_view(cr, uid, ids[0], context=context)
id = board.view_id.id id = board.view_id.id
cr.execute("update ir_ui_view set arch=%s where id=%s", (view, id)) cr.execute("update ir_ui_view set arch=%s where id=%s", (view, id))
return result return result
@ -104,13 +106,13 @@ class board_board(osv.osv):
if not 'name' in vals: if not 'name' in vals:
return False return False
id = super(board_board, self).create(cr, user, vals, context) id = super(board_board, self).create(cr, user, vals, context=context)
view_id = self.pool.get('ir.ui.view').create(cr, user, { view_id = self.pool.get('ir.ui.view').create(cr, user, {
'name': vals['name'], 'name': vals['name'],
'model': 'board.board', 'model': 'board.board',
'priority': 16, 'priority': 16,
'type': 'form', 'type': 'form',
'arch': self.create_view(cr, user, id, context), 'arch': self.create_view(cr, user, id, context=context),
}) })
super(board_board, self).write(cr, user, [id], {'view_id': view_id}, context) super(board_board, self).write(cr, user, [id], {'view_id': view_id}, context)
@ -135,7 +137,7 @@ class board_board(osv.osv):
[('user_id', '=', user), ('ref_id' ,'=', view_id)]) [('user_id', '=', user), ('ref_id' ,'=', view_id)])
if vids: if vids:
view_id = vids[0] view_id = vids[0]
arch = self.pool.get('ir.ui.view.custom').browse(cr, user, view_id) arch = self.pool.get('ir.ui.view.custom').browse(cr, user, view_id, context=context)
res['arch'] = arch.arch res['arch'] = arch.arch
res['toolbar'] = {'print': [], 'action': [], 'relate': []} res['toolbar'] = {'print': [], 'action': [], 'relate': []}
@ -193,13 +195,13 @@ class board_note_type(osv.osv):
board_note_type() board_note_type()
def _type_get(self, cr, uid, context={}): def _type_get(self, cr, uid, context=None):
""" """
Get by default Note type. Get by default Note type.
""" """
obj = self.pool.get('board.note.type') obj = self.pool.get('board.note.type')
ids = obj.search(cr, uid, []) ids = obj.search(cr, uid, [])
res = obj.read(cr, uid, ids, ['name'], context) res = obj.read(cr, uid, ids, ['name'], context=context)
res = [(r['name'], r['name']) for r in res] res = [(r['name'], r['name']) for r in res]
return res return res

View File

@ -40,7 +40,7 @@ class board_menu_create(osv.osv_memory):
""" """
data = context and context.get('active_id', False) or False data = context and context.get('active_id', False) or False
if data: if data:
board = self.pool.get('board.board').browse(cr, uid, data) board = self.pool.get('board.board').browse(cr, uid, data, context=context)
if not board.line_ids: if not board.line_ids:
raise osv.except_osv(_('User Error!'), raise osv.except_osv(_('User Error!'),
_('Please Insert Dashboard View(s) !')) _('Please Insert Dashboard View(s) !'))
@ -60,7 +60,7 @@ class board_menu_create(osv.osv_memory):
context_id = context and context.get('active_id', False) or False context_id = context and context.get('active_id', False) or False
if context_id: if context_id:
board = self.pool.get('board.board').browse(cr, uid, context_id) board = self.pool.get('board.board').browse(cr, uid, context_id, context=context)
action_id = self.pool.get('ir.actions.act_window').create(cr, uid, { action_id = self.pool.get('ir.actions.act_window').create(cr, uid, {
'name': board.name, 'name': board.name,
'view_type': 'form', 'view_type': 'form',

View File

@ -160,7 +160,7 @@ def get_attribute_mapping(cr, uid, calname, context=None):
type_id = type_obj.search(cr, uid, domain) type_id = type_obj.search(cr, uid, domain)
fids = field_obj.search(cr, uid, [('type_id', '=', type_id[0])]) fids = field_obj.search(cr, uid, [('type_id', '=', type_id[0])])
res = {} res = {}
for field in field_obj.browse(cr, uid, fids): for field in field_obj.browse(cr, uid, fids, context=context):
attr = field.name.name attr = field.name.name
res[attr] = {} res[attr] = {}
res[attr]['field'] = field.field_id.name res[attr]['field'] = field.field_id.name

View File

@ -35,6 +35,8 @@ class calendar_collection(osv.osv):
} }
def _get_root_calendar_directory(self, cr, uid, context=None): def _get_root_calendar_directory(self, cr, uid, context=None):
if not context:
context = {}
objid = self.pool.get('ir.model.data') objid = self.pool.get('ir.model.data')
try: try:
mid = objid._get_id(cr, uid, 'document', 'dir_calendars') mid = objid._get_id(cr, uid, 'document', 'dir_calendars')
@ -50,6 +52,8 @@ class calendar_collection(osv.osv):
return False return False
def get_node_class(self, cr, uid, ids, dbro=None, dynamic=False, context=None): def get_node_class(self, cr, uid, ids, dbro=None, dynamic=False, context=None):
if not context:
context = {}
if dbro is None: if dbro is None:
dbro = self.browse(cr, uid, ids, context=context) dbro = self.browse(cr, uid, ids, context=context)
@ -70,6 +74,8 @@ class calendar_collection(osv.osv):
return False return False
def get_schedule_inbox_URL(self, cr, uid, ids, context=None): def get_schedule_inbox_URL(self, cr, uid, ids, context=None):
if not context:
context = {}
calendar_obj = self.pool.get('basic.calendar') calendar_obj = self.pool.get('basic.calendar')
calendar_ids = calendar_obj.search(cr, uid, [ calendar_ids = calendar_obj.search(cr, uid, [

View File

@ -46,27 +46,31 @@ AVAILABLE_PRIORITIES = [
class crm_case(object): class crm_case(object):
"""A simple python class to be used for common functions """ """A simple python class to be used for common functions """
def _get_default_partner_address(self, cr, uid, context): def _get_default_partner_address(self, cr, uid, context=None):
"""Gives id of default address for current user """Gives id of default address for current user
@param self: The object pointer @param self: The object pointer
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks, @param uid: the current users ID for security checks,
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
""" """
if not context:
context = {}
if not context.get('portal', False): if not context.get('portal', False):
return False return False
return self.pool.get('res.users').browse(cr, uid, uid, context).address_id.id return self.pool.get('res.users').browse(cr, uid, uid, context).address_id.id
def _get_default_partner(self, cr, uid, context): def _get_default_partner(self, cr, uid, context=None):
"""Gives id of partner for current user """Gives id of partner for current user
@param self: The object pointer @param self: The object pointer
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks, @param uid: the current users ID for security checks,
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
""" """
if not context:
context = {}
if not context.get('portal', False): if not context.get('portal', False):
return False return False
user = self.pool.get('res.users').browse(cr, uid, uid, context) user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
if not user.address_id: if not user.address_id:
return False return False
return user.address_id.partner_id.id return user.address_id.partner_id.id
@ -100,7 +104,7 @@ class crm_case(object):
}) })
return super(osv.osv, self).copy(cr, uid, id, default, context=context) return super(osv.osv, self).copy(cr, uid, id, default, context=context)
def _get_default_email(self, cr, uid, context): def _get_default_email(self, cr, uid, context=None):
"""Gives default email address for current user """Gives default email address for current user
@param self: The object pointer @param self: The object pointer
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@ -109,29 +113,31 @@ class crm_case(object):
""" """
if not context.get('portal', False): if not context.get('portal', False):
return False return False
user = self.pool.get('res.users').browse(cr, uid, uid, context) user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
if not user.address_id: if not user.address_id:
return False return False
return user.address_id.email return user.address_id.email
def _get_default_user(self, cr, uid, context): def _get_default_user(self, cr, uid, context=None):
"""Gives current user id """Gives current user id
@param self: The object pointer @param self: The object pointer
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks, @param uid: the current users ID for security checks,
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
""" """
if context.get('portal', False): if context and context.get('portal', False):
return False return False
return uid return uid
def _get_section(self, cr, uid, context): def _get_section(self, cr, uid, context=None):
"""Gives section id for current User """Gives section id for current User
@param self: The object pointer @param self: The object pointer
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks, @param uid: the current users ID for security checks,
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
""" """
if not context:
context = {}
user = self.pool.get('res.users').browse(cr, uid, uid, context=context) user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
return user.context_section_id.id or False return user.context_section_id.id or False
@ -147,7 +153,7 @@ class crm_case(object):
context = {} context = {}
stage_pool = self.pool.get('crm.case.stage') stage_pool = self.pool.get('crm.case.stage')
model = self._name model = self._name
for case in self.browse(cr, uid, ids, context): for case in self.browse(cr, uid, ids, context=context):
next_stage = False next_stage = False
data = {} data = {}
domain = [('object_id.model', '=', model)] domain = [('object_id.model', '=', model)]
@ -181,7 +187,7 @@ class crm_case(object):
context = {} context = {}
stage_pool = self.pool.get('crm.case.stage') stage_pool = self.pool.get('crm.case.stage')
model = self._name model = self._name
for case in self.browse(cr, uid, ids, context): for case in self.browse(cr, uid, ids, context=context):
prev_stage = False prev_stage = False
data = {} data = {}
domain = [('object_id.model', '=', model)] domain = [('object_id.model', '=', model)]
@ -236,7 +242,7 @@ class crm_case(object):
address = self.pool.get('res.partner.address').browse(cr, uid, add) address = self.pool.get('res.partner.address').browse(cr, uid, add)
return {'value': {'email_from': address.email, 'phone': address.phone}} return {'value': {'email_from': address.email, 'phone': address.phone}}
def _history(self, cr, uid, cases, keyword, history=False, subject=None, email=False, details=None, email_from=False, message_id=False, attach=[], context={}): def _history(self, cr, uid, cases, keyword, history=False, subject=None, email=False, details=None, email_from=False, message_id=False, attach=[], context=None):
mailgate_pool = self.pool.get('mailgate.thread') mailgate_pool = self.pool.get('mailgate.thread')
return mailgate_pool.history(cr, uid, cases, keyword, history=history,\ return mailgate_pool.history(cr, uid, cases, keyword, history=history,\
subject=subject, email=email, \ subject=subject, email=email, \
@ -356,7 +362,7 @@ class crm_case(object):
self._action(cr, uid, cases, 'draft') self._action(cr, uid, cases, 'draft')
return True return True
def remind_partner(self, cr, uid, ids, context={}, attach=False): def remind_partner(self, cr, uid, ids, context=None, attach=False):
""" """
@param self: The object pointer @param self: The object pointer
@ -369,7 +375,7 @@ class crm_case(object):
return self.remind_user(cr, uid, ids, context, attach, return self.remind_user(cr, uid, ids, context, attach,
destination=False) destination=False)
def remind_user(self, cr, uid, ids, context={}, attach=False,destination=True): def remind_user(self, cr, uid, ids, context=None, attach=False,destination=True):
""" """
@param self: The object pointer @param self: The object pointer
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@ -378,7 +384,9 @@ class crm_case(object):
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
""" """
for case in self.browse(cr, uid, ids): if not context:
context = {}
for case in self.browse(cr, uid, ids, context=context):
if not case.section_id.reply_to: if not case.section_id.reply_to:
raise osv.except_osv(_('Error!'), ("Reply To is not specified in the sales team")) raise osv.except_osv(_('Error!'), ("Reply To is not specified in the sales team"))
if not case.email_from: if not case.email_from:
@ -420,7 +428,7 @@ class crm_case(object):
self._history(cr, uid, [case], _('Send'), history=True, subject=subject, email=dest, details=body, email_from=src) self._history(cr, uid, [case], _('Send'), history=True, subject=subject, email=dest, details=body, email_from=src)
return True return True
def _check(self, cr, uid, ids=False, context={}): def _check(self, cr, uid, ids=False, context=None):
""" """
Function called by the scheduler to process cases for date actions Function called by the scheduler to process cases for date actions
Only works on not done and cancelled cases Only works on not done and cancelled cases
@ -438,10 +446,10 @@ class crm_case(object):
time.strftime('%Y-%m-%d %H:%M:%S'))) time.strftime('%Y-%m-%d %H:%M:%S')))
ids2 = map(lambda x: x[0], cr.fetchall() or []) ids2 = map(lambda x: x[0], cr.fetchall() or [])
cases = self.browse(cr, uid, ids2, context) cases = self.browse(cr, uid, ids2, context=context)
return self._action(cr, uid, cases, False, context=context) return self._action(cr, uid, cases, False, context=context)
def _action(self, cr, uid, cases, state_to, scrit=None, context={}): def _action(self, cr, uid, cases, state_to, scrit=None, context=None):
if not context: if not context:
context = {} context = {}
context['state_to'] = state_to context['state_to'] = state_to
@ -461,6 +469,8 @@ class crm_case(object):
""" Get a list of emails of the people following this thread """ Get a list of emails of the people following this thread
""" """
res = {} res = {}
if not context:
context = {}
for case in self.browse(cr, uid, ids, context=context): for case in self.browse(cr, uid, ids, context=context):
l=[] l=[]
if case.email_cc: if case.email_cc:
@ -515,8 +525,8 @@ class crm_case_section(osv.osv):
_description = "Sales Teams" _description = "Sales Teams"
_order = "complete_name" _order = "complete_name"
def get_full_name(self, cr, uid, ids, field_name, arg, context={}): def get_full_name(self, cr, uid, ids, field_name, arg, context=None):
return dict(self.name_get(cr, uid, ids, context)) return dict(self.name_get(cr, uid, ids, context=context))
_columns = { _columns = {
'name': fields.char('Sales Team', size=64, required=True, translate=True), 'name': fields.char('Sales Team', size=64, required=True, translate=True),
@ -546,7 +556,7 @@ class crm_case_section(osv.osv):
('code_uniq', 'unique (code)', 'The code of the sales team must be unique !') ('code_uniq', 'unique (code)', 'The code of the sales team must be unique !')
] ]
def _check_recursion(self, cr, uid, ids): def _check_recursion(self, cr, uid, ids, context=None):
""" """
Checks for recursion level for sales team Checks for recursion level for sales team

View File

@ -50,7 +50,9 @@ this if you want the rule to send an email to the partner."),
} }
def email_send(self, cr, uid, obj, emails, body, emailfrom=tools.config.get('email_from', False), context={}): def email_send(self, cr, uid, obj, emails, body, emailfrom=tools.config.get('email_from', False), context=None):
if not context:
context = {}
body = self.format_mail(obj, body) body = self.format_mail(obj, body)
if not emailfrom: if not emailfrom:
if hasattr(obj, 'user_id') and obj.user_id and obj.user_id.address_id and obj.user_id.address_id.email: if hasattr(obj, 'user_id') and obj.user_id and obj.user_id.address_id and obj.user_id.address_id.email:
@ -67,11 +69,13 @@ this if you want the rule to send an email to the partner."),
_("No E-Mail ID Found for your Company address!")) _("No E-Mail ID Found for your Company address!"))
return tools.email_send(emailfrom, emails, name, body, reply_to=reply_to, openobject_id=str(obj.id)) return tools.email_send(emailfrom, emails, name, body, reply_to=reply_to, openobject_id=str(obj.id))
def do_check(self, cr, uid, action, obj, context={}): def do_check(self, cr, uid, action, obj, context=None):
""" @param self: The object pointer """ @param self: The object pointer
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks, @param uid: the current users ID for security checks,
@param context: A standard dictionary for contextual values""" @param context: A standard dictionary for contextual values"""
if not context:
context = {}
ok = super(base_action_rule, self).do_check(cr, uid, action, obj, context=context) ok = super(base_action_rule, self).do_check(cr, uid, action, obj, context=context)
if hasattr(obj, 'section_id'): if hasattr(obj, 'section_id'):
@ -102,11 +106,13 @@ this if you want the rule to send an email to the partner."),
ok = ok and res_count ok = ok and res_count
return ok return ok
def do_action(self, cr, uid, action, model_obj, obj, context={}): def do_action(self, cr, uid, action, model_obj, obj, context=None):
""" @param self: The object pointer """ @param self: The object pointer
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks, @param uid: the current users ID for security checks,
@param context: A standard dictionary for contextual values """ @param context: A standard dictionary for contextual values """
if not context:
context = {}
res = super(base_action_rule, self).do_action(cr, uid, action, model_obj, obj, context=context) res = super(base_action_rule, self).do_action(cr, uid, action, model_obj, obj, context=context)
write = {} write = {}
@ -138,20 +144,24 @@ this if you want the rule to send an email to the partner."),
return True return True
def state_get(self, cr, uid, context={}): def state_get(self, cr, uid, context=None):
"""Gets available states for crm """Gets available states for crm
@param self: The object pointer @param self: The object pointer
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks, @param uid: the current users ID for security checks,
@param context: A standard dictionary for contextual values """ @param context: A standard dictionary for contextual values """
if not context:
context = {}
res = super(base_action_rule, self).state_get(cr, uid, context=context) res = super(base_action_rule, self).state_get(cr, uid, context=context)
return res + crm.AVAILABLE_STATES return res + crm.AVAILABLE_STATES
def priority_get(self, cr, uid, context={}): def priority_get(self, cr, uid, context=None):
"""@param self: The object pointer """@param self: The object pointer
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks, @param uid: the current users ID for security checks,
@param context: A standard dictionary for contextual values """ @param context: A standard dictionary for contextual values """
if not context:
context = {}
res = super(base_action_rule, self).priority_get(cr, uid, context=context) res = super(base_action_rule, self).priority_get(cr, uid, context=context)
return res + crm.AVAILABLE_PRIORITIES return res + crm.AVAILABLE_PRIORITIES

View File

@ -40,6 +40,8 @@ class crm_installer(osv.osv_memory):
} }
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
if not context:
context = {}
res = super(crm_installer, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False) res = super(crm_installer, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False)
#Checking sale module is installed or not #Checking sale module is installed or not
cr.execute("SELECT * from ir_module_module where state='installed' and name = 'sale'") cr.execute("SELECT * from ir_module_module where state='installed' and name = 'sale'")

View File

@ -41,7 +41,7 @@ class crm_lead(crm_case, osv.osv):
_description = "Lead" _description = "Lead"
_order = "date_action, priority, id desc" _order = "date_action, priority, id desc"
_inherit = ['mailgate.thread','res.partner.address'] _inherit = ['mailgate.thread','res.partner.address']
def _compute_day(self, cr, uid, ids, fields, args, context={}): def _compute_day(self, cr, uid, ids, fields, args, context=None):
""" """
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks, @param uid: the current users ID for security checks,
@ -53,7 +53,9 @@ class crm_lead(crm_case, osv.osv):
res_obj = self.pool.get('resource.resource') res_obj = self.pool.get('resource.resource')
res = {} res = {}
for lead in self.browse(cr, uid, ids , context): if not context:
context = {}
for lead in self.browse(cr, uid, ids, context=context):
for field in fields: for field in fields:
res[lead.id] = {} res[lead.id] = {}
duration = 0 duration = 0
@ -311,7 +313,7 @@ class crm_lead(crm_case, osv.osv):
self.log(cr, uid, case.id, message) self.log(cr, uid, case.id, message)
return stage return stage
def message_new(self, cr, uid, msg, context): def message_new(self, cr, uid, msg, context=None):
""" """
Automatically calls when new email message arrives Automatically calls when new email message arrives
@ -319,7 +321,8 @@ class crm_lead(crm_case, osv.osv):
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks @param uid: the current users ID for security checks
""" """
if not context:
context = {}
mailgate_pool = self.pool.get('email.server.tools') mailgate_pool = self.pool.get('email.server.tools')
subject = msg.get('subject') subject = msg.get('subject')
@ -356,14 +359,15 @@ class crm_lead(crm_case, osv.osv):
return res return res
def message_update(self, cr, uid, ids, vals={}, msg="", default_act='pending', context={}): def message_update(self, cr, uid, ids, vals={}, msg="", default_act='pending', context=None):
""" """
@param self: The object pointer @param self: The object pointer
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks, @param uid: the current users ID for security checks,
@param ids: List of update mails IDs @param ids: List of update mails IDs
""" """
if not context:
context = {}
if isinstance(ids, (str, int, long)): if isinstance(ids, (str, int, long)):
ids = [ids] ids = [ids]

View File

@ -145,7 +145,7 @@ class calendar_attendee(osv.osv):
_inherit = 'calendar.attendee' _inherit = 'calendar.attendee'
_description = 'Calendar Attendee' _description = 'Calendar Attendee'
def _compute_data(self, cr, uid, ids, name, arg, context): def _compute_data(self, cr, uid, ids, name, arg, context=None):
""" """
@param self: The object pointer @param self: The object pointer
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@ -154,7 +154,9 @@ class calendar_attendee(osv.osv):
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
""" """
name = name[0] name = name[0]
result = super(calendar_attendee, self)._compute_data(cr, uid, ids, name, arg, context) if not context:
context = {}
result = super(calendar_attendee, self)._compute_data(cr, uid, ids, name, arg, context=context)
for attdata in self.browse(cr, uid, ids, context=context): for attdata in self.browse(cr, uid, ids, context=context):
id = attdata.id id = attdata.id
@ -181,7 +183,7 @@ class res_users(osv.osv):
def create(self, cr, uid, data, context=None): def create(self, cr, uid, data, context=None):
if context is None: if context is None:
context = {} context = {}
user_id = super(res_users, self).create(cr, uid, data, context) user_id = super(res_users, self).create(cr, uid, data, context=context)
data_obj = self.pool.get('ir.model.data') data_obj = self.pool.get('ir.model.data')
try: try:
data_id = data_obj._get_id(cr, uid, 'crm', 'ir_ui_view_sc_calendar0') data_id = data_obj._get_id(cr, uid, 'crm', 'ir_ui_view_sc_calendar0')

View File

@ -135,7 +135,7 @@ class crm_opportunity(osv.osv):
self.write(cr, uid, ids, {'date_open': time.strftime('%Y-%m-%d %H:%M:%S')}) self.write(cr, uid, ids, {'date_open': time.strftime('%Y-%m-%d %H:%M:%S')})
return res return res
def onchange_stage_id(self, cr, uid, ids, stage_id, context={}): def onchange_stage_id(self, cr, uid, ids, stage_id, context=None):
""" @param self: The object pointer """ @param self: The object pointer
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@ -144,8 +144,11 @@ class crm_opportunity(osv.osv):
@stage_id: change state id on run time """ @stage_id: change state id on run time """
if not stage_id: if not stage_id:
return {'value':{}} return {'value':{}}
if not context:
context = {}
stage = self.pool.get('crm.case.stage').browse(cr, uid, stage_id, context) stage = self.pool.get('crm.case.stage').browse(cr, uid, stage_id, context=context)
if not stage.on_change: if not stage.on_change:
return {'value':{}} return {'value':{}}
@ -168,7 +171,9 @@ class crm_opportunity(osv.osv):
@return : Dictionary value for created Meeting view @return : Dictionary value for created Meeting view
""" """
value = {} value = {}
for opp in self.browse(cr, uid, ids): if not context:
context = {}
for opp in self.browse(cr, uid, ids, context=context):
data_obj = self.pool.get('ir.model.data') data_obj = self.pool.get('ir.model.data')
# Get meeting views # Get meeting views

View File

@ -157,7 +157,9 @@ class crm_phonecall(crm_case, osv.osv):
@return : Dictionary value for created Meeting view @return : Dictionary value for created Meeting view
""" """
value = {} value = {}
for phonecall in self.browse(cr, uid, ids): if not context:
context = {}
for phonecall in self.browse(cr, uid, ids, context=context):
data_obj = self.pool.get('ir.model.data') data_obj = self.pool.get('ir.model.data')
# Get meeting views # Get meeting views

View File

@ -52,7 +52,7 @@ class report_custom(report_int):
""" Create Custom Report """ """ Create Custom Report """
def create(self, cr, uid, ids, datas, context={}): def create(self, cr, uid, ids, datas, context=None):
""" @param cr: the current row, from the database cursor, """ @param cr: the current row, from the database cursor,
@param uid: the current users ID for security checks, @param uid: the current users ID for security checks,

View File

@ -122,9 +122,11 @@ class crm_lead2opportunity(osv.osv_memory):
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
""" """
if not context:
context = {}
lead_obj = self.pool.get('crm.lead') lead_obj = self.pool.get('crm.lead')
for lead in lead_obj.browse(cr, uid, context.get('active_ids', [])): for lead in lead_obj.browse(cr, uid, context.get('active_ids', []), context=context):
if lead.state in ['done', 'cancel']: if lead.state in ['done', 'cancel']:
raise osv.except_osv(_("Warning !"), _("Closed/Cancelled \ raise osv.except_osv(_("Warning !"), _("Closed/Cancelled \
Leads Could not convert into Opportunity")) Leads Could not convert into Opportunity"))
@ -178,7 +180,7 @@ class crm_lead2opportunity_partner(osv.osv_memory):
if not context: if not context:
context = {} context = {}
partner_ids = self._create_partner(cr, uid, ids, context) partner_ids = self._create_partner(cr, uid, ids, context=context)
value = {} value = {}
data_obj = self.pool.get('ir.model.data') data_obj = self.pool.get('ir.model.data')
data_id = data_obj._get_id(cr, uid, 'crm', 'view_crm_lead2opportunity_action') data_id = data_obj._get_id(cr, uid, 'crm', 'view_crm_lead2opportunity_action')
@ -212,6 +214,8 @@ class crm_lead2opportunity_partner(osv.osv_memory):
@return : Dictionary value for Opportunity form @return : Dictionary value for Opportunity form
""" """
value = {} value = {}
if not context:
context = {}
data_obj = self.pool.get('ir.model.data') data_obj = self.pool.get('ir.model.data')
data_id = data_obj._get_id(cr, uid, 'crm', 'view_crm_lead2opportunity_create') data_id = data_obj._get_id(cr, uid, 'crm', 'view_crm_lead2opportunity_create')
view_id = False view_id = False
@ -243,9 +247,11 @@ class crm_lead2opportunity_partner(osv.osv_memory):
@param context: A standard dictionary for contextual values @param context: A standard dictionary for contextual values
""" """
if not context:
context = {}
lead_obj = self.pool.get('crm.lead') lead_obj = self.pool.get('crm.lead')
for lead in lead_obj.browse(cr, uid, context.get('active_ids', [])): for lead in lead_obj.browse(cr, uid, context.get('active_ids', []), context=context):
if lead.state in ['done', 'cancel']: if lead.state in ['done', 'cancel']:
raise osv.except_osv(_("Warning !"), _("Closed/Cancelled \ raise osv.except_osv(_("Warning !"), _("Closed/Cancelled \
Leads Could not convert into Opportunity")) Leads Could not convert into Opportunity"))
@ -276,6 +282,8 @@ class crm_lead2opportunity_action(osv.osv_memory):
@return : Dictionary value for Opportunity form @return : Dictionary value for Opportunity form
""" """
value = {} value = {}
if not context:
context = {}
data_obj = self.pool.get('ir.model.data') data_obj = self.pool.get('ir.model.data')
view_id = False view_id = False
for this in self.browse(cr, uid, ids, context=context): for this in self.browse(cr, uid, ids, context=context):

View File

@ -174,8 +174,8 @@ class crm_lead2partner(osv.osv_memory):
contact_id = False contact_id = False
rec_ids = context and context.get('active_ids', []) rec_ids = context and context.get('active_ids', [])
for data in self.browse(cr, uid, ids): for data in self.browse(cr, uid, ids, context=context):
for lead in lead_obj.browse(cr, uid, rec_ids): for lead in lead_obj.browse(cr, uid, rec_ids, context=context):
if data.action == 'create': if data.action == 'create':
partner_id = partner_obj.create(cr, uid, { partner_id = partner_obj.create(cr, uid, {
'name': lead.partner_name or lead.contact_name or lead.name, 'name': lead.partner_name or lead.contact_name or lead.name,
@ -229,7 +229,7 @@ class crm_lead2partner(osv.osv_memory):
if not context: if not context:
context = {} context = {}
partner_ids = self._create_partner(cr, uid, ids, context) partner_ids = self._create_partner(cr, uid, ids, context=context)
mod_obj = self.pool.get('ir.model.data') mod_obj = self.pool.get('ir.model.data')
result = mod_obj._get_id(cr, uid, 'base', 'view_res_partner_filter') result = mod_obj._get_id(cr, uid, 'base', 'view_res_partner_filter')
res = mod_obj.read(cr, uid, result, ['res_id']) res = mod_obj.read(cr, uid, result, ['res_id'])

View File

@ -57,7 +57,7 @@ class crm_partner2opportunity(osv.osv_memory):
res.update({'partner_id': data and data[0] or False}) res.update({'partner_id': data and data[0] or False})
return res return res
def make_opportunity(self, cr, uid, ids, context): def make_opportunity(self, cr, uid, ids, context=None):
""" """
@param self: The object pointer @param self: The object pointer
@param cr: the current row, from the database cursor, @param cr: the current row, from the database cursor,
@ -67,7 +67,7 @@ class crm_partner2opportunity(osv.osv_memory):
data = context and context.get('active_ids', []) or [] data = context and context.get('active_ids', []) or []
make_opportunity = self.pool.get('crm.partner2opportunity') make_opportunity = self.pool.get('crm.partner2opportunity')
for make_opportunity_obj in make_opportunity.browse(cr,uid,ids): for make_opportunity_obj in make_opportunity.browse(cr, uid, ids, context=context):
data_obj = self.pool.get('ir.model.data') data_obj = self.pool.get('ir.model.data')
result = data_obj._get_id(cr, uid, 'crm', 'view_crm_case_opportunities_filter') result = data_obj._get_id(cr, uid, 'crm', 'view_crm_case_opportunities_filter')
res = data_obj.read(cr, uid, result, ['res_id']) res = data_obj.read(cr, uid, result, ['res_id'])

View File

@ -31,7 +31,9 @@ import pooler
class phonecall2meeting(wizard.interface): class phonecall2meeting(wizard.interface):
def _makeMeeting(self, cr, uid, data, context): def _makeMeeting(self, cr, uid, data, context=None):
if not context:
context = {}
pool = pooler.get_pool(cr.dbname) pool = pooler.get_pool(cr.dbname)
phonecall_case_obj = pool.get('crm.phonecall') phonecall_case_obj = pool.get('crm.phonecall')
data_obj = pool.get('ir.model.data') data_obj = pool.get('ir.model.data')

View File

@ -138,8 +138,8 @@ class crm_phonecall2partner(osv.osv_memory):
rec_ids = context and context.get('active_ids', []) rec_ids = context and context.get('active_ids', [])
for data in self.browse(cr, uid, ids): for data in self.browse(cr, uid, ids, context=context):
for phonecall in phonecall_obj.browse(cr, uid, rec_ids): for phonecall in phonecall_obj.browse(cr, uid, rec_ids, context=context):
if data.action == 'create': if data.action == 'create':
partner_id = partner_obj.create(cr, uid, { partner_id = partner_obj.create(cr, uid, {
'name': phonecall.name or phonecall.name, 'name': phonecall.name or phonecall.name,
@ -181,7 +181,7 @@ class crm_phonecall2partner(osv.osv_memory):
if not context: if not context:
context = {} context = {}
partner_ids = self._create_partner(cr, uid, ids, context) partner_ids = self._create_partner(cr, uid, ids, context=context)
mod_obj = self.pool.get('ir.model.data') mod_obj = self.pool.get('ir.model.data')
result = mod_obj._get_id(cr, uid, 'base', 'view_res_partner_filter') result = mod_obj._get_id(cr, uid, 'base', 'view_res_partner_filter')
res = mod_obj.read(cr, uid, result, ['res_id']) res = mod_obj.read(cr, uid, result, ['res_id'])

View File

@ -181,7 +181,7 @@ class crm_send_new_email(osv.osv_memory):
user_obj = self.pool.get('res.users') user_obj = self.pool.get('res.users')
user_mail_from = user_obj._get_email_from(cr, uid, [uid], context=context)[uid] user_mail_from = user_obj._get_email_from(cr, uid, [uid], context=context)[uid]
for case in mod_obj.browse(cr, uid, res_id): for case in mod_obj.browse(cr, uid, res_id, context=context):
if 'email_to' in fields: if 'email_to' in fields:
res.update({'email_to': case.email_from and tools.ustr(case.email_from) or ''}) res.update({'email_to': case.email_from and tools.ustr(case.email_from) or ''})
if 'email_from' in fields: if 'email_from' in fields:

View File

@ -24,7 +24,9 @@ import wizard
import pooler import pooler
import time import time
def _open_history_event(self, cr, uid, data, context): def _open_history_event(self, cr, uid, data, context=None):
if not context:
context = {}
pool = pooler.get_pool(cr.dbname) pool = pooler.get_pool(cr.dbname)
data_obj = pool.get('ir.model.data') data_obj = pool.get('ir.model.data')
result = data_obj._get_id(cr, uid, 'crm', 'view_crm_case_filter') result = data_obj._get_id(cr, uid, 'crm', 'view_crm_case_filter')
@ -35,7 +37,7 @@ def _open_history_event(self, cr, uid, data, context):
res = '' res = ''
if data.get('model',False) and data.get('ids',False): if data.get('model',False) and data.get('ids',False):
model_obj = pooler.get_pool(cr.dbname).get(data['model']) model_obj = pooler.get_pool(cr.dbname).get(data['model'])
res = model_obj.browse(cr,uid,data['ids']) res = model_obj.browse(cr, uid, data['ids'], context=context)
if len(res): if len(res):
res = res[0].name res = res[0].name
return { return {

Some files were not shown because too many files have changed in this diff Show More