diff --git a/addons/account/account.py b/addons/account/account.py index e30912aa187..f8215606313 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -20,6 +20,7 @@ ############################################################################## import time +from operator import itemgetter import netsvc from osv import fields, osv @@ -33,6 +34,25 @@ from dateutil.relativedelta import relativedelta from tools import config +def check_cycle(self, cr, uid, ids): + """ climbs the ``self._table.parent_id`` chains for 100 levels or + until it can't find any more parent(s) + + Returns true if it runs out of parents (no cycle), false if + it can recurse 100 times without ending all chains + """ + level = 100 + while len(ids): + cr.execute('SELECT DISTINCT parent_id '\ + 'FROM '+self._table+' '\ + 'WHERE id IN %s '\ + 'AND parent_id IS NOT NULL',(tuple(ids),)) + ids = map(itemgetter(0), cr.fetchall()) + if not level: + return False + level -= 1 + return True + class account_payment_term(osv.osv): _name = "account.payment.term" _description = "Payment Term" @@ -170,6 +190,7 @@ class account_account(osv.osv): _name = "account.account" _description = "Account" _parent_store = True + logger = netsvc.Logger() def _get_children_and_consol(self, cr, uid, ids, context={}): ids2=[] @@ -228,66 +249,88 @@ class account_account(osv.osv): if ids3: ids3 = self._get_children_and_consol(cr, uid, ids3, context) return ids2 + ids3 - - def __compute(self, cr, uid, ids, field_names, arg, context={}, query=''): - #compute the balance/debit/credit accordingly to the value of field_name for the given account ids - mapping = { - 'balance': "COALESCE(SUM(l.debit),0) - COALESCE(SUM(l.credit), 0) as balance ", - 'debit': "COALESCE(SUM(l.debit), 0) as debit ", - 'credit': "COALESCE(SUM(l.credit), 0) as credit " - } - #get all the necessary accounts - ids2 = self._get_children_and_consol(cr, uid, ids, context) - #compute for each account the balance/debit/credit from the move lines - accounts = {} - if ids2: - aml_query = self.pool.get('account.move.line')._query_get(cr, uid, context=context) - - wheres = [""] - if query.strip(): - wheres.append(query.strip()) - if aml_query.strip(): - wheres.append(aml_query.strip()) - query = " AND ".join(wheres) - - cr.execute("SELECT l.account_id as id, " +\ - ' , '.join(map(lambda x: mapping[x], field_names)) + - "FROM " \ - "account_move_line l " \ - "WHERE " \ - "l.account_id =ANY(%s) " \ - + query + - " GROUP BY l.account_id",(ids2,)) - - for res in cr.dictfetchall(): - accounts[res['id']] = res - - - # consolidate accounts with direct children - ids2.reverse() - brs = list(self.browse(cr, uid, ids2, context=context)) - sums = {} - while brs: - current = brs[0] - can_compute = True - for child in current.child_id: - if child.id not in sums: - can_compute = False - try: - brs.insert(0, brs.pop(brs.index(child))) - except ValueError: - brs.insert(0, child) - if can_compute: - brs.pop(0) - for fn in field_names: - sums.setdefault(current.id, {})[fn] = accounts.get(current.id, {}).get(fn, 0.0) - if current.child_id: - sums[current.id][fn] += sum(sums[child.id][fn] for child in current.child_id) - res = {} - null_result = dict((fn, 0.0) for fn in field_names) - for id in ids: - res[id] = sums.get(id, null_result) - return res + + def __compute(self, cr, uid, ids, field_names, arg=None, context=None, + query='', query_params=()): + """ compute the balance, debit and/or credit for the provided + account ids + Arguments: + `ids`: account ids + `field_names`: the fields to compute (a list of any of + 'balance', 'debit' and 'credit') + `arg`: unused fields.function stuff + `query`: additional query filter (as a string) + `query_params`: parameters for the provided query string + (__compute will handle their escaping) as a + tuple + """ + mapping = { + 'balance': "COALESCE(SUM(l.debit),0) " \ + "- COALESCE(SUM(l.credit), 0) as balance", + 'debit': "COALESCE(SUM(l.debit), 0) as debit", + 'credit': "COALESCE(SUM(l.credit), 0) as credit" + } + #get all the necessary accounts + children_and_consolidated = self._get_children_and_consol(cr, uid, ids, context=context) + #compute for each account the balance/debit/credit from the move lines + accounts = {} + if children_and_consolidated: + aml_query = self.pool.get('account.move.line')._query_get(cr, uid, context=context) + + wheres = [""] + if query.strip(): + wheres.append(query.strip()) + if aml_query.strip(): + wheres.append(aml_query.strip()) + filters = " AND ".join(wheres) + self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG, + 'Filters: %s'%filters) + # IN might not work ideally in case there are too many + # children_and_consolidated, in that case join on a + # values() e.g.: + # SELECT l.account_id as id FROM account_move_line l + # INNER JOIN (VALUES (id1), (id2), (id3), ...) AS tmp (id) + # ON l.account_id = tmp.id + # or make _get_children_and_consol return a query and join on that + request = ("SELECT l.account_id as id, " +\ + ' , '.join(map(mapping.__getitem__, field_names)) + + " FROM account_move_line l" \ + " WHERE l.account_id IN %s " \ + + filters + + " GROUP BY l.account_id") + params = (tuple(children_and_consolidated),) + query_params + cr.execute(request, params) + self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG, + 'Status: %s'%cr.statusmessage) + + for res in cr.dictfetchall(): + accounts[res['id']] = res + + # consolidate accounts with direct children + children_and_consolidated.reverse() + brs = list(self.browse(cr, uid, children_and_consolidated, context=context)) + sums = {} + while brs: + current = brs[0] + can_compute = True + for child in current.child_id: + if child.id not in sums: + can_compute = False + try: + brs.insert(0, brs.pop(brs.index(child))) + except ValueError: + brs.insert(0, child) + if can_compute: + brs.pop(0) + for fn in field_names: + sums.setdefault(current.id, {})[fn] = accounts.get(current.id, {}).get(fn, 0.0) + if current.child_id: + sums[current.id][fn] += sum(sums[child.id][fn] for child in current.child_id) + res = {} + null_result = dict((fn, 0.0) for fn in field_names) + for id in ids: + res[id] = sums.get(id, null_result) + return res def _get_company_currency(self, cr, uid, ids, field_name, arg, context={}): result = {} @@ -392,8 +435,10 @@ class account_account(osv.osv): if (obj_self in obj_self.child_consol_ids) or (p_id and (p_id is obj_self.id)): return False while(ids): - cr.execute('select distinct child_id from account_account_consol_rel where parent_id =ANY(%s)',(ids,)) - child_ids = filter(None, map(lambda x: x[0], cr.fetchall())) + cr.execute('SELECT DISTINCT child_id '\ + 'FROM account_account_consol_rel '\ + 'WHERE parent_id IN %s', (tuple(ids),)) + child_ids = map(itemgetter(0), cr.fetchall()) c_ids = child_ids if (p_id and (p_id in c_ids)) or (obj_self.id in c_ids): return False @@ -883,7 +928,10 @@ class account_move(osv.osv): def _amount_compute(self, cr, uid, ids, name, args, context, where =''): if not ids: return {} - cr.execute('select move_id,sum(debit) from account_move_line where move_id =ANY(%s) group by move_id',(ids,)) + cr.execute( 'SELECT move_id, SUM(debit) '\ + 'FROM account_move_line '\ + 'WHERE move_id IN %s '\ + 'GROUP BY move_id', (tuple(ids),)) result = dict(cr.fetchall()) for id in ids: result.setdefault(id, 0.0) @@ -982,7 +1030,10 @@ class account_move(osv.osv): if new_name: self.write(cr, uid, [move.id], {'name':new_name}) - cr.execute('update account_move set state=%s where id =ANY(%s) ',('posted',ids,)) + cr.execute('UPDATE account_move '\ + 'SET state=%s '\ + 'WHERE id IN %s', + ('posted', tuple(ids),)) else: raise osv.except_osv(_('Integrity Error !'), _('You can not validate a non-balanced entry !\nMake sure you have configured Payment Term properly !\nIt should contain atleast one Payment Term Line with type "Balance" !')) return True @@ -995,7 +1046,9 @@ class account_move(osv.osv): if not line.journal_id.update_posted: raise osv.except_osv(_('Error !'), _('You can not modify a posted entry of this journal !\nYou should set the journal to allow cancelling entries if you want to do that.')) if len(ids): - cr.execute('update account_move set state=%s where id =ANY(%s)',('draft',ids,)) + cr.execute('UPDATE account_move '\ + 'SET state=%s '\ + 'WHERE id IN %s', ('draft', tuple(ids),)) return True def write(self, cr, uid, ids, vals, context={}): @@ -1114,7 +1167,10 @@ class account_move(osv.osv): else: line_id2 = 0 - cr.execute('select sum('+mode+') from account_move_line where move_id=%s and id<>%s', (move.id, line_id2)) + cr.execute('SELECT SUM(%s) '\ + 'FROM account_move_line '\ + 'WHERE move_id=%s AND id<>%s', + (mode, move.id, line_id2)) result = cr.fetchone()[0] or 0.0 cr.execute('update account_move_line set '+mode2+'=%s where id=%s', (result, line_id)) return True @@ -1268,24 +1324,26 @@ class account_tax_code(osv.osv): This code is used for some tax declarations. """ - def _sum(self, cr, uid, ids, name, args, context, where =''): - ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) + def _sum(self, cr, uid, ids, name, args, context,where ='', where_params=()): + parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) if context.get('based_on', 'invoices') == 'payments': cr.execute('SELECT line.tax_code_id, sum(line.tax_amount) \ FROM account_move_line AS line, \ account_move AS move \ LEFT JOIN account_invoice invoice ON \ (invoice.move_id = move.id) \ - WHERE line.tax_code_id =ANY(%s) '+where+' \ + WHERE line.tax_code_id IN %s '+where+' \ AND move.id = line.move_id \ AND ((invoice.state = \'paid\') \ OR (invoice.id IS NULL)) \ - GROUP BY line.tax_code_id',(ids2,)) + GROUP BY line.tax_code_id', + (parent_ids,)+where_params) else: cr.execute('SELECT line.tax_code_id, sum(line.tax_amount) \ FROM account_move_line AS line \ - WHERE line.tax_code_id =ANY(%s) '+where+' \ - GROUP BY line.tax_code_id',(ids2,)) + WHERE line.tax_code_id IN %s '+where+' \ + GROUP BY line.tax_code_id', + (parent_ids,)+where_params) res=dict(cr.fetchall()) for record in self.browse(cr, uid, ids, context): def _rec_get(record): @@ -1302,12 +1360,14 @@ class account_tax_code(osv.osv): else: fiscalyear_id = self.pool.get('account.fiscalyear').find(cr, uid, exception=False) where = '' + where_params = () if fiscalyear_id: pids = map(lambda x: str(x.id), self.pool.get('account.fiscalyear').browse(cr, uid, fiscalyear_id).period_ids) if pids: - where = ' and period_id in (' + (','.join(pids))+')' + where = ' and period_id IN %s' + where_params = (tuple(pids),) return self._sum(cr, uid, ids, name, args, context, - where=where) + where=where, where_params=where_params) def _sum_period(self, cr, uid, ids, name, args, context): if 'period_id' in context and context['period_id']: @@ -1318,7 +1378,7 @@ class account_tax_code(osv.osv): return dict.fromkeys(ids, 0.0) period_id = period_id[0] return self._sum(cr, uid, ids, name, args, context, - where=' and line.period_id='+str(period_id)) + where=' and line.period_id=%s', where_params=(period_id,)) _name = 'account.tax.code' _description = 'Tax Code' @@ -1366,24 +1426,15 @@ class account_tax_code(osv.osv): 'sign': lambda *args: 1.0, 'notprintable': lambda *a: False, } - def _check_recursion(self, cr, uid, ids): - level = 100 - while len(ids): - cr.execute('select distinct parent_id from account_tax_code where id =ANY(%s)',(ids,)) - ids = filter(None, map(lambda x:x[0], cr.fetchall())) - if not level: - return False - level -= 1 - return True - - + def copy(self, cr, uid, id, default=None, context=None): if default is None: default = {} default = default.copy() default.update({'line_ids': []}) return super(account_tax_code, self).copy(cr, uid, id, default, context) - + + _check_recursion = check_cycle _constraints = [ (_check_recursion, 'Error ! You can not create recursive accounts.', ['parent_id']) ] @@ -1731,7 +1782,7 @@ class account_model(osv.osv): 'ref': fields.char('Reference', size=64), 'journal_id': fields.many2one('account.journal', 'Journal', required=True), 'lines_id': fields.one2many('account.model.line', 'model_id', 'Model Entries'), - 'legend' :fields.text('Legend',readonly=True,size=100), + 'legend' :fields.text('Legend', readonly=True, size=100), } _defaults = { @@ -1741,7 +1792,7 @@ class account_model(osv.osv): move_ids = [] for model in self.browse(cr, uid, ids, context): context.update({'date':datas['date']}) - period_id = self.pool.get('account.period').find(cr, uid, dt=context.get('date',False)) + period_id = self.pool.get('account.period').find(cr, uid, dt=context.get('date', False)) if not period_id: raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !')) period_id = period_id[0] @@ -1943,9 +1994,9 @@ class account_account_template(osv.osv): 'reconcile': fields.boolean('Allow Reconciliation', help="Check this option if you want the user to reconcile entries in this account."), 'shortcut': fields.char('Shortcut', size=12), 'note': fields.text('Note'), - 'parent_id': fields.many2one('account.account.template','Parent Account Template', ondelete='cascade'), - 'child_parent_ids':fields.one2many('account.account.template','parent_id','Children'), - 'tax_ids': fields.many2many('account.tax.template', 'account_account_template_tax_rel','account_id','tax_id', 'Default Taxes'), + 'parent_id': fields.many2one('account.account.template', 'Parent Account Template', ondelete='cascade'), + 'child_parent_ids':fields.one2many('account.account.template', 'parent_id', 'Children'), + 'tax_ids': fields.many2many('account.tax.template', 'account_account_template_tax_rel', 'account_id', 'tax_id', 'Default Taxes'), 'nocreate': fields.boolean('Optional create', help="If checked, the new chart of accounts will not contain this by default."), } @@ -1955,16 +2006,7 @@ class account_account_template(osv.osv): 'nocreate': lambda *a: False, } - def _check_recursion(self, cr, uid, ids): - level = 100 - while len(ids): - cr.execute('select parent_id from account_account_template where id =ANY(%s)',(ids,)) - ids = filter(None, map(lambda x:x[0], cr.fetchall())) - if not level: - return False - level -= 1 - return True - + _check_recursion = check_cycle _constraints = [ (_check_recursion, 'Error ! You can not create recursive account templates.', ['parent_id']) ] @@ -1994,14 +2036,14 @@ class account_add_tmpl_wizard(osv.osv_memory): acc_obj=self.pool.get('account.account') tmpl_obj=self.pool.get('account.account.template') #print "Searching for ",context - tids=tmpl_obj.read(cr, uid, [context['tmpl_ids']],['parent_id']) + tids=tmpl_obj.read(cr, uid, [context['tmpl_ids']], ['parent_id']) if not tids or not tids[0]['parent_id']: return False - ptids = tmpl_obj.read(cr, uid, [tids[0]['parent_id'][0]],['code']) + ptids = tmpl_obj.read(cr, uid, [tids[0]['parent_id'][0]], ['code']) res = None if not ptids or not ptids[0]['code']: raise osv.except_osv(_('Error !'), _('Cannot locate parent code for template account!')) - res = acc_obj.search(cr,uid,[('code','=',ptids[0]['code'])]) + res = acc_obj.search(cr, uid, [('code','=',ptids[0]['code'])]) return res and res[0] or False @@ -2015,9 +2057,9 @@ class account_add_tmpl_wizard(osv.osv_memory): def action_create(self,cr,uid,ids,context=None): acc_obj=self.pool.get('account.account') tmpl_obj=self.pool.get('account.account.template') - data= self.read(cr,uid,ids) - company_id = acc_obj.read(cr,uid,[data[0]['cparent_id']],['company_id'])[0]['company_id'][0] - account_template = tmpl_obj.browse(cr,uid,context['tmpl_ids']) + data= self.read(cr, uid, ids) + company_id = acc_obj.read(cr, uid, [data[0]['cparent_id']], ['company_id'])[0]['company_id'][0] + account_template = tmpl_obj.browse(cr, uid, context['tmpl_ids']) #tax_ids = [] #for tax in account_template.tax_ids: # tax_ids.append(tax_template_ref[tax.id]) @@ -2036,10 +2078,10 @@ class account_add_tmpl_wizard(osv.osv_memory): 'company_id': company_id, } # print "Creating:", vals - new_account = acc_obj.create(cr,uid,vals) + new_account = acc_obj.create(cr, uid, vals) return {'type':'state', 'state': 'end' } - def action_cancel(self,cr,uid,ids,context=None): + def action_cancel(self, cr, uid, ids, context=None): return { 'type': 'state', 'state': 'end' } account_add_tmpl_wizard() @@ -2074,16 +2116,7 @@ class account_tax_code_template(osv.osv): return [(x['id'], (x['code'] and x['code'] + ' - ' or '') + x['name']) \ for x in reads] - def _check_recursion(self, cr, uid, ids): - level = 100 - while len(ids): - cr.execute('select distinct parent_id from account_tax_code_template where id =ANY(%s)',(ids,)) - ids = filter(None, map(lambda x:x[0], cr.fetchall())) - if not level: - return False - level -= 1 - return True - + _check_recursion = check_cycle _constraints = [ (_check_recursion, 'Error ! You can not create recursive Tax Codes.', ['parent_id']) ] @@ -2246,11 +2279,11 @@ class wizard_multi_charts_accounts(osv.osv_memory): _inherit = 'res.config' _columns = { - 'company_id':fields.many2one('res.company','Company',required=True), - 'chart_template_id': fields.many2one('account.chart.template','Chart Template',required=True), - 'bank_accounts_id': fields.one2many('account.bank.accounts.wizard', 'bank_account_id', 'Bank Accounts',required=True), - 'code_digits':fields.integer('# of Digits',required=True,help="No. of Digits to use for account code"), - 'seq_journal':fields.boolean('Separated Journal Sequences',help="Check this box if you want to use a different sequence for each created journal. Otherwise, all will use the same sequence."), + 'company_id':fields.many2one('res.company', 'Company', required=True), + 'chart_template_id': fields.many2one('account.chart.template', 'Chart Template', required=True), + 'bank_accounts_id': fields.one2many('account.bank.accounts.wizard', 'bank_account_id', 'Bank Accounts', required=True), + 'code_digits':fields.integer('# of Digits', required=True, help="No. of Digits to use for account code"), + 'seq_journal':fields.boolean('Separated Journal Sequences', help="Check this box if you want to use a different sequence for each created journal. Otherwise, all will use the same sequence."), } def _get_chart(self, cr, uid, context={}): @@ -2259,14 +2292,14 @@ class wizard_multi_charts_accounts(osv.osv_memory): return ids[0] return False _defaults = { - 'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr,uid,[uid],c)[0].company_id.id, + 'company_id': lambda self, cr, uid, c: self.pool.get('res.users').browse(cr, uid, [uid], c)[0].company_id.id, 'chart_template_id': _get_chart, 'code_digits': lambda *a:6, 'seq_journal': True } def execute(self, cr, uid, ids, context=None): - 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_tax = self.pool.get('account.tax') obj_journal = self.pool.get('account.journal') @@ -2298,7 +2331,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'company_id': company_id, 'sign': tax_code_template.sign, } - new_tax_code = self.pool.get('account.tax.code').create(cr,uid,vals) + new_tax_code = self.pool.get('account.tax.code').create(cr, uid, vals) #recording the new tax code to do the mapping tax_code_template_ref[tax_code_template.id] = new_tax_code @@ -2331,7 +2364,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'company_id': company_id, 'type_tax_use': tax.type_tax_use } - new_tax = obj_acc_tax.create(cr,uid,vals_tax) + new_tax = obj_acc_tax.create(cr, uid, vals_tax) #as the accounts have not been created yet, we have to wait before filling these fields todo_dict[new_tax] = { 'account_collected_id': tax.account_collected_id and tax.account_collected_id.id or False, @@ -2369,7 +2402,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): 'tax_ids': [(6,0,tax_ids)], 'company_id': company_id, } - new_account = obj_acc.create(cr,uid,vals) + new_account = obj_acc.create(cr, uid, vals) acc_template_ref[account_template.id] = new_account #reactivate the parent_store functionnality on account_account self.pool._init = False @@ -2385,11 +2418,11 @@ class wizard_multi_charts_accounts(osv.osv_memory): # Creating Journals vals_journal={} view_id = self.pool.get('account.journal.view').search(cr,uid,[('name','=','Journal View')])[0] - seq_id = obj_sequence.search(cr,uid,[('name','=','Account Journal')])[0] + seq_id = obj_sequence.search(cr, uid, [('name','=','Account Journal')])[0] if obj_multi.seq_journal: - seq_id_sale = obj_sequence.search(cr,uid,[('name','=','Sale Journal')])[0] - seq_id_purchase = obj_sequence.search(cr,uid,[('name','=','Purchase Journal')])[0] + seq_id_sale = obj_sequence.search(cr, uid, [('name','=','Sale Journal')])[0] + seq_id_purchase = obj_sequence.search(cr, uid, [('name','=','Purchase Journal')])[0] else: seq_id_sale = seq_id seq_id_purchase = seq_id @@ -2421,8 +2454,8 @@ class wizard_multi_charts_accounts(osv.osv_memory): obj_journal.create(cr,uid,vals_journal) # Bank Journals - view_id_cash = self.pool.get('account.journal.view').search(cr,uid,[('name','=','Cash Journal View')])[0] - view_id_cur = self.pool.get('account.journal.view').search(cr,uid,[('name','=','Multi-Currency Cash Journal View')])[0] + view_id_cash = self.pool.get('account.journal.view').search(cr, uid, [('name','=','Cash Journal View')])[0] + view_id_cur = self.pool.get('account.journal.view').search(cr, uid, [('name','=','Multi-Currency Cash Journal View')])[0] ref_acc_bank = obj_multi.chart_template_id.bank_account_view_id current_num = 1 @@ -2500,7 +2533,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): #create the property property_obj.create(cr, uid, vals) - fp_ids = obj_fiscal_position_template.search(cr, uid,[('chart_template_id', '=', obj_multi.chart_template_id.id)]) + fp_ids = obj_fiscal_position_template.search(cr, uid, [('chart_template_id', '=', obj_multi.chart_template_id.id)]) if fp_ids: for position in obj_fiscal_position_template.browse(cr, uid, fp_ids): diff --git a/addons/account/account_analytic_line.py b/addons/account/account_analytic_line.py index d02dec33af0..2cd1b4d17bd 100644 --- a/addons/account/account_analytic_line.py +++ b/addons/account/account_analytic_line.py @@ -92,9 +92,9 @@ class account_analytic_line(osv.osv): company_id=company_obj._company_default_get(cr, uid, 'account.analytic.line', context) # Compute based on pricetype - pricetype=self.pool.get('product.price.type').browse(cr,uid,company_obj.browse(cr,uid,company_id).property_valuation_price_type.id) + pricetype=self.pool.get('product.price.type').browse(cr, uid, company_obj.browse(cr,uid,company_id).property_valuation_price_type.id) # Take the company currency as the reference one - context['currency_id']=company_obj.browse(cr,uid,company_id).currency_id.id + context['currency_id']=company_obj.browse(cr, uid, company_id).currency_id.id amount_unit=prod.price_get(pricetype.field, context)[prod.id] amount=amount_unit*unit_amount or 1.0 return {'value': { diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 81b6e3157a1..6de3dabaa28 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -32,7 +32,7 @@ class account_bank_statement(osv.osv): mod_obj = self.pool.get('ir.model.data') if context is None: context = {} - model_data_ids = mod_obj.search(cr,uid,[('model','=','ir.ui.view'),('name','=','view_account_statement_from_invoice')], context=context) + model_data_ids = mod_obj.search(cr, uid, [('model','=','ir.ui.view'),('name','=','view_account_statement_from_invoice')], context=context) resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id'] context.update({'statement_id': ids[0]}) return { diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 7350596c4e3..47f2a71b8f6 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -66,9 +66,9 @@ class account_move_line(osv.osv): #the query have to be build with no reference to periods but thanks to the creation date if context.get('periods',False): #if one or more period are given, use them - fiscalperiod_ids = fiscalperiod_obj.search(cr,uid,[('id','in',context['periods'])]) + fiscalperiod_ids = fiscalperiod_obj.search(cr, uid, [('id','in',context['periods'])]) else: - fiscalperiod_ids = self.pool.get('account.period').search(cr,uid,[('fiscalyear_id','in',fiscalyear_ids)]) + fiscalperiod_ids = self.pool.get('account.period').search(cr, uid, [('fiscalyear_id','in',fiscalyear_ids)]) @@ -87,7 +87,7 @@ class account_move_line(osv.osv): #add to 'res' a new clause containing the creation date criterion count = 1 res += " AND (" - periods = self.pool.get('account.period').read(cr,uid,p_ids,['date_start','date_stop']) + periods = self.pool.get('account.period').read(cr, uid, p_ids, ['date_start','date_stop']) for period in periods: if count != 1: res += " OR " @@ -150,7 +150,7 @@ class account_move_line(osv.osv): for item in i[2]: data[item]=i[2][item] if context['journal']: - journal_obj=self.pool.get('account.journal').browse(cr,uid,context['journal']) + journal_obj=self.pool.get('account.journal').browse(cr, uid, context['journal']) if journal_obj.type == 'purchase': if total_new>0: account = journal_obj.default_credit_account_id @@ -298,9 +298,10 @@ class account_move_line(osv.osv): for line_id in ids: res[line_id] = False cursor.execute('SELECT l.id, i.id ' \ - 'FROM account_move_line l, account_invoice i ' \ - 'WHERE l.move_id = i.move_id ' \ - 'AND l.id =ANY(%s)',(ids,)) + 'FROM account_move_line l, account_invoice i ' \ + 'WHERE l.move_id = i.move_id ' \ + 'AND l.id IN %s', + (tuple(ids),)) invoice_ids = [] for line_id, invoice_id in cursor.fetchall(): res[line_id] = invoice_id @@ -333,7 +334,7 @@ class account_move_line(osv.osv): return [] where = ' and '.join(map(lambda x: '(abs(sum(debit-credit))'+x[1]+str(x[2])+')',args)) cursor.execute('select id, sum(debit-credit) from account_move_line \ - group by id,debit,credit having '+where) + group by id, debit, credit having '+where) res = cursor.fetchall() if not len(res): return [('id', '=', '0')] @@ -433,8 +434,8 @@ class account_move_line(osv.osv): 'account_tax_id':fields.many2one('account.tax', 'Tax'), 'analytic_account_id' : fields.many2one('account.analytic.account', 'Analytic Account'), #TODO: remove this - 'amount_taxed':fields.float("Taxed Amount",digits_compute=dp.get_precision('Account')), - 'company_id': fields.related('account_id','company_id',type='many2one',relation='res.company',string='Company',store=True) + 'amount_taxed':fields.float("Taxed Amount", digits_compute=dp.get_precision('Account')), + 'company_id': fields.related('account_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True) } @@ -469,7 +470,7 @@ class account_move_line(osv.osv): 'currency_id': _get_currency, 'journal_id': lambda self, cr, uid, c: c.get('journal_id', False), 'period_id': lambda self, cr, uid, c: c.get('period_id', False), - 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.move.line', context=c) + 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.move.line', context=c) } _order = "date desc,id desc" _sql_constraints = [ @@ -620,10 +621,11 @@ class account_move_line(osv.osv): else: date = time.strftime('%Y-%m-%d') - cr.execute('SELECT account_id, reconcile_id \ - FROM account_move_line \ - WHERE id =ANY(%s) \ - GROUP BY account_id,reconcile_id',(ids,)) + cr.execute('SELECT account_id, reconcile_id '\ + 'FROM account_move_line '\ + 'WHERE id IN %s '\ + 'GROUP BY account_id,reconcile_id', + (tuple(ids),)) r = cr.fetchall() #TODO: move this check to a constraint in the account_move_reconcile object if (len(r) != 1) and not context.get('fy_closing', False): @@ -811,9 +813,9 @@ class account_move_line(osv.osv): else: journal_id = context['journal_id'] period_id = context['period_id'] - journal = self.pool.get('account.journal').browse(cr,uid,[journal_id])[0] + journal = self.pool.get('account.journal').browse(cr, uid, [journal_id])[0] if journal.allow_date: - period = self.pool.get('account.period').browse(cr,uid,[period_id])[0] + period = self.pool.get('account.period').browse(cr, uid, [period_id])[0] if not time.strptime(vals['date'],'%Y-%m-%d')>=time.strptime(period.date_start,'%Y-%m-%d') or not time.strptime(vals['date'],'%Y-%m-%d')<=time.strptime(period.date_stop,'%Y-%m-%d'): raise osv.except_osv(_('Error'),_('The date of your Ledger Posting is not in the defined period !')) else: diff --git a/addons/account/installer.py b/addons/account/installer.py index 44eb081d7be..6dce5aa95bb 100644 --- a/addons/account/installer.py +++ b/addons/account/installer.py @@ -99,7 +99,7 @@ class account_installer(osv.osv_memory): mod_obj = self.pool.get('ir.model.data') result = mod_obj._get_id(cr, uid, 'account', 'configurable_chart_template') id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id'] - obj_multi = self.pool.get('account.chart.template').browse(cr,uid, id) + obj_multi = self.pool.get('account.chart.template').browse(cr, uid, id) obj_acc = self.pool.get('account.account') obj_acc_tax = self.pool.get('account.tax') @@ -108,7 +108,7 @@ class account_installer(osv.osv_memory): obj_acc_template = self.pool.get('account.account.template') obj_fiscal_position_template = self.pool.get('account.fiscal.position.template') obj_fiscal_position = self.pool.get('account.fiscal.position') - company_id = self.pool.get('res.users').browse(cr,uid,[uid],context)[0].company_id + company_id = self.pool.get('res.users').browse(cr, uid, [uid], context)[0].company_id seq_journal = True # Creating Account @@ -133,7 +133,7 @@ class account_installer(osv.osv_memory): 'company_id': company_id.id, 'sign': tax_code_template.sign, } - new_tax_code = self.pool.get('account.tax.code').create(cr,uid,vals) + new_tax_code = self.pool.get('account.tax.code').create(cr, uid, vals) #recording the new tax code to do the mapping tax_code_template_ref[tax_code_template.id] = new_tax_code @@ -166,7 +166,7 @@ class account_installer(osv.osv_memory): 'company_id': company_id.id, 'type_tax_use': tax.type_tax_use } - new_tax = obj_acc_tax.create(cr,uid,vals_tax) + new_tax = obj_acc_tax.create(cr, uid, vals_tax) #as the accounts have not been created yet, we have to wait before filling these fields todo_dict[new_tax] = { 'account_collected_id': tax.account_collected_id and tax.account_collected_id.id or False, @@ -204,7 +204,7 @@ class account_installer(osv.osv_memory): 'tax_ids': [(6,0,tax_ids)], 'company_id': company_id.id, } - new_account = obj_acc.create(cr,uid,vals) + new_account = obj_acc.create(cr, uid, vals) acc_template_ref[account_template.id] = new_account if account_template.name == 'Bank Current Account': view_id_cash = self.pool.get('account.journal.view').search(cr,uid,[('name','=','Cash Journal View')])[0] @@ -328,8 +328,8 @@ class account_installer(osv.osv_memory): obj_journal.create(cr,uid,vals_journal) # Bank Journals - view_id_cash = self.pool.get('account.journal.view').search(cr,uid,[('name','=','Cash Journal View')])[0] - view_id_cur = self.pool.get('account.journal.view').search(cr,uid,[('name','=','Multi-Currency Cash Journal View')])[0] + view_id_cash = self.pool.get('account.journal.view').search(cr, uid, [('name','=','Cash Journal View')])[0] + view_id_cur = self.pool.get('account.journal.view').search(cr, uid, [('name','=','Multi-Currency Cash Journal View')])[0] ref_acc_bank = obj_multi.bank_account_view_id @@ -426,7 +426,7 @@ class account_installer(osv.osv_memory): 'sign': 1, 'parent_id':sal_tax_parent_id } - new_tax_code = self.pool.get('account.tax.code').create(cr,uid,vals_tax_code) + new_tax_code = self.pool.get('account.tax.code').create(cr, uid, vals_tax_code) sales_tax = obj_tax.create(cr, uid, {'name':'VAT%s%%'%(s_tax*100), 'description':'VAT%s%%'%(s_tax*100), @@ -445,7 +445,7 @@ class account_installer(osv.osv_memory): 'sign': 1, 'parent_id':pur_tax_parent_id } - new_tax_code = self.pool.get('account.tax.code').create(cr,uid,vals_tax_code) + new_tax_code = self.pool.get('account.tax.code').create(cr, uid, vals_tax_code) purchase_tax = obj_tax.create(cr, uid, {'name':'VAT%s%%'%(p_tax*100), 'description':'VAT%s%%'%(p_tax*100), @@ -457,7 +457,7 @@ class account_installer(osv.osv_memory): tax_val.update({'supplier_taxes_id':[(6,0,[purchase_tax])]}) default_tax.append(('supplier_taxes_id',purchase_tax)) if len(tax_val): - product_ids = obj_product.search(cr,uid, []) + product_ids = obj_product.search(cr, uid, []) for product in obj_product.browse(cr, uid, product_ids): obj_product.write(cr, uid, product.id, tax_val) for name, value in default_tax: diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 5ef80d40560..662a114e40d 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -20,6 +20,7 @@ ############################################################################## import time +from operator import itemgetter import decimal_precision as dp import netsvc @@ -31,7 +32,7 @@ from tools.translate import _ class account_invoice(osv.osv): def _amount_all(self, cr, uid, ids, name, args, context=None): res = {} - for invoice in self.browse(cr,uid,ids, context=context): + for invoice in self.browse(cr, uid, ids, context=context): res[invoice.id] = { 'amount_untaxed': 0.0, 'amount_tax': 0.0, @@ -111,12 +112,12 @@ class account_invoice(osv.osv): context_unreconciled.update({'date':lines.date}) # If amount currency setted, compute for debit and credit in company currency if lines.amount_currency < 0: - credit_tmp=abs(cur_obj.compute(cr, uid, lines.currency_id.id, inv.company_id.currency_id.id, lines.amount_currency, round=False,context=context_unreconciled)) + credit_tmp=abs(cur_obj.compute(cr, uid, lines.currency_id.id, inv.company_id.currency_id.id, lines.amount_currency, round=False, context=context_unreconciled)) elif lines.amount_currency > 0: - debit_tmp=abs(cur_obj.compute(cr, uid, lines.currency_id.id, inv.company_id.currency_id.id, lines.amount_currency, round=False,context=context_unreconciled)) + debit_tmp=abs(cur_obj.compute(cr, uid, lines.currency_id.id, inv.company_id.currency_id.id, lines.amount_currency, round=False, context=context_unreconciled)) # Then, recomput into invoice currency to avoid rounding trouble ! - debit += cur_obj.compute(cr, uid, inv.company_id.currency_id.id, inv.currency_id.id, debit_tmp, round=False,context=context) - credit += cur_obj.compute(cr, uid, inv.company_id.currency_id.id, inv.currency_id.id, credit_tmp, round=False,context=context) + debit += cur_obj.compute(cr, uid, inv.company_id.currency_id.id, inv.currency_id.id, debit_tmp, round=False, context=context) + credit += cur_obj.compute(cr, uid, inv.company_id.currency_id.id, inv.currency_id.id, credit_tmp, round=False, context=context) else: debit+=debit_tmp credit+=credit_tmp @@ -130,19 +131,19 @@ class account_invoice(osv.osv): amount = debit-credit result = inv.amount_total - amount # Use is_zero function to avoid rounding trouble => should be fixed into ORM - res[inv.id] = not self.pool.get('res.currency').is_zero(cr, uid, inv.company_id.currency_id,result) and result or 0.0 + res[inv.id] = not self.pool.get('res.currency').is_zero(cr, uid, inv.company_id.currency_id, result) and result or 0.0 return res def _get_lines(self, cr, uid, ids, name, arg, context=None): res = {} for id in ids: - move_lines = self.move_line_id_payment_get(cr,uid,[id]) + move_lines = self.move_line_id_payment_get(cr, uid, [id]) if not move_lines: res[id] = [] continue res[id] = [] - data_lines = self.pool.get('account.move.line').browse(cr,uid,move_lines) + data_lines = self.pool.get('account.move.line').browse(cr, uid, move_lines) partial_ids = []# Keeps the track of ids where partial payments are done with payment terms for line in data_lines: ids_line = [] @@ -218,7 +219,7 @@ class account_invoice(osv.osv): _order = "number" _log_create = True _columns = { - 'name': fields.char('Description', size=64, select=True,readonly=True, states={'draft':[('readonly',False)]}), + 'name': fields.char('Description', size=64, select=True, readonly=True, states={'draft':[('readonly',False)]}), 'origin': fields.char('Source Document', size=64, help="Reference of the document that produced this invoice."), 'type': fields.selection([ ('out_invoice','Customer Invoice'), @@ -246,8 +247,8 @@ class account_invoice(osv.osv): \n* The \'Open\' state is used when user create invoice,a invoice number is generated.Its in open state till user does not pay invoice. \ \n* The \'Done\' state is set automatically when invoice is paid.\ \n* The \'Cancelled\' state is used when user cancel invoice.'), - 'date_invoice': fields.date('Date Invoiced', states={'open':[('readonly',True)],'close':[('readonly',True)]}, help="Keep empty to use the current date"), - 'date_due': fields.date('Due Date', states={'open':[('readonly',True)],'close':[('readonly',True)]}, + 'date_invoice': fields.date('Date Invoiced', states={'open':[('readonly',True)], 'close':[('readonly',True)]}, help="Keep empty to use the current date"), + 'date_due': fields.date('Due Date', states={'open':[('readonly',True)], 'close':[('readonly',True)]}, help="If you use payment terms, the due date will be computed automatically at the generation "\ "of accounting entries. If you keep the payment term and the due date empty, it means direct payment. The payment term may compute several due dates, for example 50% now, 50% in one month."), 'partner_id': fields.many2one('res.partner', 'Partner', change_default=True, readonly=True, required=True, states={'draft':[('readonly',False)]}), @@ -264,7 +265,7 @@ class account_invoice(osv.osv): 'tax_line': fields.one2many('account.invoice.tax', 'invoice_id', 'Tax Lines', readonly=True, states={'draft':[('readonly',False)]}), 'move_id': fields.many2one('account.move', 'Invoice Movement', readonly=True, help="Links to the automatically generated Ledger Postings."), - 'amount_untaxed': fields.function(_amount_all, method=True, digits_compute=dp.get_precision('Account'),string='Untaxed', + 'amount_untaxed': fields.function(_amount_all, method=True, digits_compute=dp.get_precision('Account'), string='Untaxed', store={ 'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line'], 20), 'account.invoice.tax': (_get_invoice_tax, None, 20), @@ -286,7 +287,7 @@ class account_invoice(osv.osv): }, multi='all'), 'currency_id': fields.many2one('res.currency', 'Currency', required=True, readonly=True, states={'draft':[('readonly',False)]}), - 'journal_id': fields.many2one('account.journal', 'Journal', required=True,readonly=True, states={'draft':[('readonly',False)]}), + 'journal_id': fields.many2one('account.journal', 'Journal', required=True, readonly=True, states={'draft':[('readonly',False)]}), 'company_id': fields.many2one('res.company', 'Company', required=True, change_default=True), 'check_total': fields.float('Total', digits_compute=dp.get_precision('Account'), states={'open':[('readonly',True)],'close':[('readonly',True)]}), 'reconciled': fields.function(_reconciled, method=True, string='Paid/Reconciled', type='boolean', @@ -297,8 +298,8 @@ class account_invoice(osv.osv): }, help="The Ledger Postings of the invoice have been reconciled with Ledger Postings of the payment(s)."), 'partner_bank': fields.many2one('res.partner.bank', 'Bank Account', help='The bank account to pay to or to be paid from'), - 'move_lines':fields.function(_get_lines , method=True,type='many2many' , relation='account.move.line',string='Entry Lines'), - 'residual': fields.function(_amount_residual, method=True, digits_compute=dp.get_precision('Account'),string='Residual', + 'move_lines':fields.function(_get_lines , method=True, type='many2many', relation='account.move.line', string='Entry Lines'), + 'residual': fields.function(_amount_residual, method=True, digits_compute=dp.get_precision('Account'), string='Residual', store={ 'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line'], 50), 'account.invoice.tax': (_get_invoice_tax, None, 50), @@ -321,7 +322,7 @@ class account_invoice(osv.osv): 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'account.invoice', context=c), 'reference_type': lambda *a: 'none', 'check_total': lambda *a: 0.0, - 'user_id': lambda s,cr,u,c: u, + 'user_id': lambda s, cr, u, c: u, } def create(self, cr, uid, vals, context={}): @@ -338,7 +339,7 @@ class account_invoice(osv.osv): def confirm_paid(self, cr, uid, ids, context=None): self.write(cr, uid, ids, {'state':'paid'}, context=context) - for (id,name) in self.name_get(cr, uid, ids): + for (id, name) in self.name_get(cr, uid, ids): message = _('Document ') + " '" + name + "' "+ _("has been paid.") self.log(cr, uid, id, message) return True @@ -389,8 +390,8 @@ class account_invoice(osv.osv): if not rec_res_id and not pay_res_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company, Please Create account.')) - rec_obj_acc=self.pool.get('account.account').browse(cr,uid,[rec_res_id]) - pay_obj_acc=self.pool.get('account.account').browse(cr,uid,[pay_res_id]) + rec_obj_acc=self.pool.get('account.account').browse(cr, uid, [rec_res_id]) + pay_obj_acc=self.pool.get('account.account').browse(cr, uid, [pay_res_id]) p.property_account_receivable = rec_obj_acc[0] p.property_account_payable = pay_obj_acc[0] @@ -418,7 +419,7 @@ class account_invoice(osv.osv): if payment_term != partner_payment_term: if partner_payment_term: to_update = self.onchange_payment_term_date_invoice( - cr,uid,ids,partner_payment_term,date_invoice) + cr, uid, ids, partner_payment_term, date_invoice) result['value'].update(to_update['value']) else: result['value']['date_due'] = False @@ -470,14 +471,14 @@ class account_invoice(osv.osv): partner_obj = self.pool.get('res.partner').browse(cr,uid,part_id) if partner_obj.property_account_payable and partner_obj.property_account_receivable: if partner_obj.property_account_payable.company_id.id != company_id and partner_obj.property_account_receivable.company_id.id != company_id: - rec_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) - pay_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_payable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) + rec_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) + pay_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_payable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) if not rec_pro_id: - rec_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_receivable'),('company_id','=',company_id)]) + rec_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_receivable'),('company_id','=',company_id)]) if not pay_pro_id: - pay_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_payable'),('company_id','=',company_id)]) - rec_line_data = self.pool.get('ir.property').read(cr,uid,rec_pro_id,['name','value','res_id']) - pay_line_data = self.pool.get('ir.property').read(cr,uid,pay_pro_id,['name','value','res_id']) + pay_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_payable'),('company_id','=',company_id)]) + rec_line_data = self.pool.get('ir.property').read(cr, uid, rec_pro_id, ['name','value','res_id']) + pay_line_data = self.pool.get('ir.property').read(cr, uid, pay_pro_id, ['name','value','res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False if not rec_res_id and not rec_res_id: @@ -494,15 +495,15 @@ class account_invoice(osv.osv): for line in inv_obj[0].invoice_line: if line.account_id: if line.account_id.company_id.id != company_id: - result_id = self.pool.get('account.account').search(cr,uid,[('name','=',line.account_id.name),('company_id','=',company_id)]) + result_id = self.pool.get('account.account').search(cr, uid, [('name','=',line.account_id.name),('company_id','=',company_id)]) if not result_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company in invoice line account, Please Create account.')) - r_id = self.pool.get('account.invoice.line').write(cr,uid,[line.id],{'account_id': result_id[0]}) + r_id = self.pool.get('account.invoice.line').write(cr, uid, [line.id], {'account_id': result_id[0]}) else: if invoice_line: for inv_line in invoice_line: - obj_l = self.pool.get('account.account').browse(cr,uid,inv_line[2]['account_id']) + obj_l = self.pool.get('account.account').browse(cr, uid, inv_line[2]['account_id']) if obj_l.company_id.id != company_id: raise osv.except_osv(_('Configration Error !'), _('invoice line account company is not match with invoice company.')) @@ -565,12 +566,13 @@ class account_invoice(osv.osv): def move_line_id_payment_get(self, cr, uid, ids, *args): res = [] if not ids: return res - cr.execute('select \ - l.id \ - from account_move_line l \ - left join account_invoice i on (i.move_id=l.move_id) \ - where i.id in ('+','.join(map(str,map(int, ids)))+') and l.account_id=i.account_id') - res = map(lambda x: x[0], cr.fetchall()) + cr.execute('SELECT l.id '\ + 'FROM account_move_line l '\ + 'LEFT JOIN account_invoice i ON (i.move_id=l.move_id) '\ + 'WHERE i.id IN %s '\ + 'AND l.account_id=i.account_id', + (tuple(ids),)) + res = map(itemgetter(0), cr.fetchall()) return res def copy(self, cr, uid, id, default=None, context=None): @@ -600,7 +602,7 @@ class account_invoice(osv.osv): ait_obj = self.pool.get('account.invoice.tax') for id in ids: cr.execute("DELETE FROM account_invoice_tax WHERE invoice_id=%s", (id,)) - partner = self.browse(cr, uid, id,context=context).partner_id + partner = self.browse(cr, uid, id, context=context).partner_id if partner.lang: context.update({'lang': partner.lang}) for taxe in ait_obj.compute(cr, uid, id, context=context).values(): @@ -850,7 +852,7 @@ class account_invoice(osv.osv): move = {'ref': inv.number, 'line_id': line, 'journal_id': journal_id, 'date': date} period_id=inv.period_id and inv.period_id.id or False if not period_id: - period_ids= self.pool.get('account.period').search(cr,uid,[('date_start','<=',inv.date_invoice or time.strftime('%Y-%m-%d')),('date_stop','>=',inv.date_invoice or time.strftime('%Y-%m-%d'))]) + period_ids= self.pool.get('account.period').search(cr, uid, [('date_start','<=',inv.date_invoice or time.strftime('%Y-%m-%d')),('date_stop','>=',inv.date_invoice or time.strftime('%Y-%m-%d'))]) if len(period_ids): period_id=period_ids[0] if period_id: @@ -889,8 +891,9 @@ class account_invoice(osv.osv): def action_number(self, cr, uid, ids, *args): cr.execute('SELECT id, type, number, move_id, reference ' \ - 'FROM account_invoice ' \ - 'WHERE id IN ('+','.join(map(str, ids))+')') + 'FROM account_invoice ' \ + 'WHERE id IN %s', + (tuple(ids),)) obj_inv = self.browse(cr, uid, ids)[0] for (id, invtype, number, move_id, reference) in cr.fetchall(): if not number: @@ -937,7 +940,7 @@ class account_invoice(osv.osv): raise osv.except_osv(_('Error !'), _('You cannot cancel the Invoice which is Partially Paid! You need to unreconcile concerned payment entries!')) self.write(cr, uid, ids, {'state':'cancel', 'move_id':False}) - self._log_event(cr, uid, ids,-1.0, 'Cancel Invoice') + self._log_event(cr, uid, ids, -1.0, 'Cancel Invoice') return True ################### @@ -1113,7 +1116,9 @@ class account_invoice(osv.osv): move_ids = [move_id,] if invoice.move_id: move_ids.append(invoice.move_id.id) - cr.execute('SELECT id FROM account_move_line WHERE move_id = ANY(%s)',(move_ids,)) + cr.execute('SELECT id FROM account_move_line '\ + 'WHERE move_id IN %s', + ((move_id, invoice.move_id.id),)) lines = line.browse(cr, uid, map(lambda x: x[0], cr.fetchall()) ) for l in lines+invoice.payment_ids: if l.account_id.id==src_account_id: @@ -1130,7 +1135,7 @@ class account_invoice(osv.osv): account_invoice() class account_invoice_line(osv.osv): - def _amount_line(self, cr, uid, ids, prop, unknow_none,unknow_dict): + def _amount_line(self, cr, uid, ids, prop, unknow_none, unknow_dict): res = {} tax_obj = self.pool.get('account.tax') cur_obj = self.pool.get('res.currency') @@ -1215,12 +1220,12 @@ class account_invoice_line(osv.osv): res = self.pool.get('product.product').browse(cr, uid, product, context=context) if company_id: - in_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_income'),('res_id','=','product.template,'+str(res.product_tmpl_id.id)+''),('company_id','=',company_id)]) + in_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_income'),('res_id','=','product.template,'+str(res.product_tmpl_id.id)+''),('company_id','=',company_id)]) if not in_pro_id: - in_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_income_categ'),('res_id','=','product.template,'+str(res.categ_id.id)+''),('company_id','=',company_id)]) - exp_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_expense'),('res_id','=','product.template,'+str(res.product_tmpl_id.id)+''),('company_id','=',company_id)]) + in_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_income_categ'),('res_id','=','product.template,'+str(res.categ_id.id)+''),('company_id','=',company_id)]) + exp_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_expense'),('res_id','=','product.template,'+str(res.product_tmpl_id.id)+''),('company_id','=',company_id)]) if not exp_pro_id: - exp_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_expense_categ'),('res_id','=','product.template,'+str(res.categ_id.id)+''),('company_id','=',company_id)]) + exp_pro_id = self.pool.get('ir.property').search(cr, uid, [('name','=','property_account_expense_categ'),('res_id','=','product.template,'+str(res.categ_id.id)+''),('company_id','=',company_id)]) if not in_pro_id: in_acc = res.product_tmpl_id.property_account_income @@ -1230,7 +1235,7 @@ class account_invoice_line(osv.osv): else: app_acc_in = in_acc_cate else: - app_acc_in = self.pool.get('account.account').browse(cr,uid,in_pro_id)[0] + app_acc_in = self.pool.get('account.account').browse(cr, uid, in_pro_id)[0] if not exp_pro_id: ex_acc = res.product_tmpl_id.property_account_expense ex_acc_cate = res.categ_id.property_account_expense_categ @@ -1239,7 +1244,7 @@ class account_invoice_line(osv.osv): else: app_acc_exp = ex_acc_cate else: - app_acc_exp = self.pool.get('account.account').browse(cr,uid,exp_pro_id)[0] + app_acc_exp = self.pool.get('account.account').browse(cr, uid, exp_pro_id)[0] if not in_pro_id and not exp_pro_id: in_acc = res.product_tmpl_id.property_account_income in_acc_cate = res.categ_id.property_account_income_categ @@ -1255,13 +1260,13 @@ class account_invoice_line(osv.osv): # app_acc_in = self.pool.get('account.account').browse(cr,uid,in_pro_id)[0] # app_acc_exp = self.pool.get('account.account').browse(cr,uid,exp_pro_id)[0] if app_acc_in.company_id.id != company_id and app_acc_exp.company_id.id != company_id: - in_res_id=self.pool.get('account.account').search(cr,uid,[('name','=',app_acc_in.name),('company_id','=',company_id)]) - exp_res_id=self.pool.get('account.account').search(cr,uid,[('name','=',app_acc_exp.name),('company_id','=',company_id)]) + in_res_id=self.pool.get('account.account').search(cr, uid, [('name','=',app_acc_in.name),('company_id','=',company_id)]) + exp_res_id=self.pool.get('account.account').search(cr, uid, [('name','=',app_acc_exp.name),('company_id','=',company_id)]) if not in_res_id and not exp_res_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company, Please Create account.')) - in_obj_acc=self.pool.get('account.account').browse(cr,uid,in_res_id) - exp_obj_acc=self.pool.get('account.account').browse(cr,uid,exp_res_id) + in_obj_acc=self.pool.get('account.account').browse(cr, uid, in_res_id) + exp_obj_acc=self.pool.get('account.account').browse(cr, uid, exp_res_id) if in_acc or ex_acc: res.product_tmpl_id.property_account_income = in_obj_acc[0] res.product_tmpl_id.property_account_expense = exp_obj_acc[0] @@ -1285,10 +1290,10 @@ class account_invoice_line(osv.osv): taxep=None tax_obj = self.pool.get('account.tax') if type in ('out_invoice', 'out_refund'): - taxes = res.taxes_id and res.taxes_id or (a and self.pool.get('account.account').browse(cr, uid,a).tax_ids or False) + taxes = res.taxes_id and res.taxes_id or (a and self.pool.get('account.account').browse(cr, uid, a).tax_ids or False) tax_id = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, taxes) else: - taxes = res.supplier_taxes_id and res.supplier_taxes_id or (a and self.pool.get('account.account').browse(cr, uid,a).tax_ids or False) + taxes = res.supplier_taxes_id and res.supplier_taxes_id or (a and self.pool.get('account.account').browse(cr, uid, a).tax_ids or False) tax_id = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, taxes) if type in ('in_invoice', 'in_refund'): to_update = self.product_id_change_unit_price_inv(cr, uid, tax_id, price_unit or res.standard_price, qty, address_invoice_id, product, partner_id, context=context) @@ -1409,25 +1414,25 @@ class account_invoice_tax(osv.osv): 'base_amount': fields.float('Base Code Amount', digits_compute=dp.get_precision('Account')), 'tax_code_id': fields.many2one('account.tax.code', 'Tax Code', help="The tax basis of the tax declaration."), 'tax_amount': fields.float('Tax Code Amount', digits_compute=dp.get_precision('Account')), - 'company_id': fields.related('account_id','company_id',type='many2one',relation='res.company',string='Company',store=True), + 'company_id': fields.related('account_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True), } - def base_change(self, cr, uid, ids, base,currency_id=False,company_id=False,date_invoice=False): + def base_change(self, cr, uid, ids, base, currency_id=False, company_id=False, date_invoice=False): cur_obj = self.pool.get('res.currency') company_obj = self.pool.get('res.company') company_currency=False if company_id: - company_currency = company_obj.read(cr,uid,[company_id],['currency_id'])[0]['currency_id'][0] + company_currency = company_obj.read(cr, uid, [company_id], ['currency_id'])[0]['currency_id'][0] if currency_id and company_currency: base = cur_obj.compute(cr, uid, currency_id, company_currency, base, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False) return {'value': {'base_amount':base}} - def amount_change(self, cr, uid, ids, amount,currency_id=False,company_id=False,date_invoice=False): + def amount_change(self, cr, uid, ids, amount, currency_id=False, company_id=False, date_invoice=False): cur_obj = self.pool.get('res.currency') company_obj = self.pool.get('res.company') company_currency=False if company_id: - company_currency = company_obj.read(cr,uid,[company_id],['currency_id'])[0]['currency_id'][0] + company_currency = company_obj.read(cr, uid, [company_id], ['currency_id'])[0]['currency_id'][0] if currency_id and company_currency: amount = cur_obj.compute(cr, uid, currency_id, company_currency, amount, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False) return {'value': {'tax_amount':amount}} diff --git a/addons/account/partner.py b/addons/account/partner.py index 2497aaa447c..3a5d7a5ab7e 100644 --- a/addons/account/partner.py +++ b/addons/account/partner.py @@ -18,6 +18,7 @@ # along with this program. If not, see . # ############################################################################## +from operator import itemgetter from osv import fields, osv import ir @@ -88,22 +89,19 @@ class res_partner(osv.osv): _name = 'res.partner' _inherit = 'res.partner' _description = 'Partner' + def _credit_debit_get(self, cr, uid, ids, field_names, arg, context): - query = self.pool.get('account.move.line')._query_get(cr, 1, context=context) - cr.execute("""select - l.partner_id, a.type, sum(l.debit-l.credit) - from - account_move_line l - left join - account_account a on (l.account_id=a.id) - where - a.type =ANY(%s) and - l.partner_id =ANY(%s) and - l.reconcile_id is null and - """+query+""" - group by - l.partner_id, a.type - """,(['receivable','payable'],ids,)) + query = self.pool.get('account.move.line')._query_get(cr, uid, context=context) + cr.execute("""SELECT l.partner_id, a.type, SUM(l.debit-l.credit) + FROM account_move_line l + LEFT JOIN account_account a ON (l.account_id=a.id) + WHERE a.type IN ('receivable','payable') + AND l.partner_id IN %s + AND l.reconcile_id IS NULL + AND """ + query + """ + GROUP BY l.partner_id, a.type + """, + (tuple(ids),)) tinvert = { 'credit': 'receivable', 'debit': 'payable' @@ -116,28 +114,34 @@ class res_partner(osv.osv): if val is None: val=0 res[pid][maps[type]] = (type=='receivable') and val or -val return res - - def _credit_search(self, cr, uid, obj, name, args, context): + + def _asset_difference_search(self, cr, uid, obj, name, type, args, context=None): if not len(args): return [] - where = ' and '.join(map(lambda x: '(sum(debit-credit)'+x[1]+str(x[2])+')',args)) - query = self.pool.get('account.move.line')._query_get(cr, uid, context={}) - cr.execute(('select partner_id from account_move_line l where account_id in (select id from account_account where type=%s and active) and reconcile_id is null and '+query+' and partner_id is not null group by partner_id having '+where), ('receivable',) ) + having_values = tuple(map(itemgetter(2), args)) + where = ' AND '.join( + map(lambda x: '(SUM(debit-credit) %(operator)s %%s)' % { + 'operator':x[1]},args)) + query = self.pool.get('account.move.line')._query_get(cr, uid, context=context) + cr.execute(('SELECT partner_id FROM account_move_line l '\ + 'WHERE account_id IN '\ + '(SELECT id FROM account_account '\ + 'WHERE type=%s AND active) '\ + 'AND reconcile_id IS NULL '\ + 'AND '+query+' '\ + 'AND partner_id IS NOT NULL '\ + 'GROUP BY partner_id HAVING '+where), + (type,) + having_values) res = cr.fetchall() if not len(res): return [('id','=','0')] - return [('id','in',map(lambda x:x[0], res))] + return [('id','in',map(itemgetter(0), res))] + + def _credit_search(self, cr, uid, obj, name, args, context): + return self._asset_difference_search(cr, uid, obj, name, 'receivable', args, context=context) def _debit_search(self, cr, uid, obj, name, args, context): - if not len(args): - return [] - query = self.pool.get('account.move.line')._query_get(cr, uid, context={}) - where = ' and '.join(map(lambda x: '(sum(debit-credit)'+x[1]+str(x[2])+')',args)) - cr.execute(('select partner_id from account_move_line l where account_id in (select id from account_account where type=%s and active) and reconcile_id is null and '+query+' and partner_id is not null group by partner_id having '+where), ('payable',) ) - res = cr.fetchall() - if not len(res): - return [('id','=','0')] - return [('id','in',map(lambda x:x[0], res))] + return self._asset_difference_search(cr, uid, obj, name, 'payable', args, context=context) _columns = { 'credit': fields.function(_credit_debit_get, diff --git a/addons/account/project/project.py b/addons/account/project/project.py index a844d6dec2e..39e3cd5e959 100644 --- a/addons/account/project/project.py +++ b/addons/account/project/project.py @@ -46,7 +46,7 @@ class account_journal(osv.osv): _inherit="account.journal" _columns = { - 'analytic_journal_id':fields.many2one('account.analytic.journal','Analytic Journal'), + 'analytic_journal_id':fields.many2one('account.analytic.journal', 'Analytic Journal'), } account_journal() diff --git a/addons/account/project/report/analytic_balance.py b/addons/account/project/report/analytic_balance.py index f7b909ae452..8815369375e 100644 --- a/addons/account/project/report/analytic_balance.py +++ b/addons/account/project/report/analytic_balance.py @@ -32,15 +32,9 @@ class account_analytic_balance(report_sxw.rml_parse): 'get_objects': self._get_objects, 'lines_g': self._lines_g, 'move_sum': self._move_sum, -# 'move_sum_debit': self._move_sum_debit, -# 'move_sum_credit': self._move_sum_credit, 'sum_all': self._sum_all, -# 'sum_debit': self._sum_debit, -# 'sum_credit': self._sum_credit, 'sum_balance': self._sum_balance, -# 'sum_quantity': self._sum_quantity, 'move_sum_balance': self._move_sum_balance, -# 'move_sum_quantity': self._move_sum_quantity, }) self.acc_ids = [] self.read_data = [] @@ -81,10 +75,10 @@ class account_analytic_balance(report_sxw.rml_parse): sum(aal.amount) AS balance, sum(aal.unit_amount) AS quantity \ FROM account_analytic_line AS aal, account_account AS aa \ WHERE (aal.general_account_id=aa.id) \ - AND (aal.account_id in (" + ','.join(map(str, ids)) + "))\ + AND (aal.account_id IN aal.account_id IN %s)\ AND (date>=%s) AND (date<=%s) AND aa.active \ GROUP BY aal.general_account_id, aa.name, aa.code, aal.code \ - ORDER BY aal.code", (date1, date2)) + ORDER BY aal.code", (tuple(ids), date1, date2)) res = self.cr.dictfetchall() for r in res: @@ -107,62 +101,26 @@ class account_analytic_balance(report_sxw.rml_parse): self.acc_data_dict[account_id] = ids else: ids = self.acc_data_dict[account_id] - + + query_params = (tuple(ids), date1, date2) if option == "credit" : self.cr.execute("SELECT -sum(amount) FROM account_analytic_line \ - WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount<0", - (ids,date1, date2)) + WHERE account_id IN %s AND date>=%s AND date<=%s AND amount<0",query_params) elif option == "debit" : self.cr.execute("SELECT sum(amount) FROM account_analytic_line \ - WHERE account_id =ANY(%s)\ - AND date>=%s AND date<=%s AND amount>0", - (ids,date1, date2)) + WHERE account_id IN %s\ + AND date>=%s AND date<=%s AND amount>0",query_params) elif option == "quantity" : self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line \ - WHERE account_id =ANY(%s)\ - AND date>=%s AND date<=%s", - (ids,date1, date2)) + WHERE account_id IN %s\ + AND date>=%s AND date<=%s",query_params) return self.cr.fetchone()[0] or 0.0 - -# def _move_sum_debit(self, account_id, date1, date2): -# account_analytic_obj = self.pool.get('account.analytic.account') -# ids = account_analytic_obj.search(self.cr, self.uid, -# [('parent_id', 'child_of', [account_id])]) -# self.cr.execute("SELECT sum(amount) \ -# FROM account_analytic_line \ -# WHERE account_id in ("+ ','.join(map(str, ids)) +") \ -# AND date>=%s AND date<=%s AND amount>0", -# (date1, date2)) -# return self.cr.fetchone()[0] or 0.0 -# -# def _move_sum_credit(self, account_id, date1, date2): -# account_analytic_obj = self.pool.get('account.analytic.account') -# ids = account_analytic_obj.search(self.cr, self.uid, -# [('parent_id', 'child_of', [account_id])]) -# self.cr.execute("SELECT -sum(amount) \ -# FROM account_analytic_line \ -# WHERE account_id in ("+ ','.join(map(str, ids)) +") \ -# AND date>=%s AND date<=%s AND amount<0", -# (date1, date2)) -# return self.cr.fetchone()[0] or 0.0 -# def _move_sum_balance(self, account_id, date1, date2): debit = self._move_sum(account_id, date1, date2, 'debit') credit = self._move_sum(account_id, date1, date2, 'credit') return (debit-credit) -# def _move_sum_quantity(self, account_id, date1, date2): -# account_analytic_obj = self.pool.get('account.analytic.account') -# ids = account_analytic_obj.search(self.cr, self.uid, -# [('parent_id', 'child_of', [account_id])]) -# self.cr.execute("SELECT sum(unit_amount) \ -# FROM account_analytic_line \ -# WHERE account_id in ("+ ','.join(map(str, ids)) +") \ -# AND date>=%s AND date<=%s", -# (date1, date2)) -# return self.cr.fetchone()[0] or 0.0 - def _sum_all(self, accounts, date1, date2, option): ids = map(lambda x: x['id'], accounts) if not len(ids): @@ -174,68 +132,25 @@ class account_analytic_balance(report_sxw.rml_parse): self.acc_sum_list = ids2 else: ids2 = self.acc_sum_list + query_params = (tuple(ids2), date1, date2) if option == "debit" : self.cr.execute("SELECT sum(amount) FROM account_analytic_line \ - WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount>0", - (ids,date1, date2,)) + WHERE account_id IN %s AND date>=%s AND date<=%s AND amount>0",query_params) elif option == "credit" : self.cr.execute("SELECT -sum(amount) FROM account_analytic_line \ - WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount<0", - (ids,date1, date2,)) + WHERE account_id IN %s AND date>=%s AND date<=%s AND amount<0",query_params) elif option == "quantity" : self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line \ - WHERE account_id =ANY(%s)AND date>=%s AND date<=%s", - (ids,date1, date2,)) + WHERE account_id IN %s AND date>=%s AND date<=%s",query_params) return self.cr.fetchone()[0] or 0.0 -# def _sum_debit(self, accounts, date1, date2): -# ids = map(lambda x: x['id'], accounts) -# if not len(ids): -# return 0.0 -# account_analytic_obj = self.pool.get('account.analytic.account') -# ids2 = account_analytic_obj.search(self.cr, self.uid, -# [('parent_id', 'child_of', ids)]) -# self.cr.execute("SELECT sum(amount) \ -# FROM account_analytic_line \ -# WHERE account_id IN ("+','.join(map(str, ids2))+") \ -# AND date>=%s AND date<=%s AND amount>0", -# (date1, date2)) -# return self.cr.fetchone()[0] or 0.0 -# -# def _sum_credit(self, accounts, date1, date2): -# ids = map(lambda x: x['id'], accounts) -# if not len(ids): -# return 0.0 -# ids = map(lambda x: x['id'], accounts) -# account_analytic_obj = self.pool.get('account.analytic.account') -# ids2 = account_analytic_obj.search(self.cr, self.uid, -# [('parent_id', 'child_of', ids)]) -# self.cr.execute("SELECT -sum(amount) \ -# FROM account_analytic_line \ -# WHERE account_id IN ("+','.join(map(str, ids2))+") \ -# AND date>=%s AND date<=%s AND amount<0", -# (date1, date2)) -# return self.cr.fetchone()[0] or 0.0 def _sum_balance(self, accounts, date1, date2): debit = self._sum_all(accounts, date1, date2, 'debit') or 0.0 credit = self._sum_all(accounts, date1, date2, 'credit') or 0.0 return (debit-credit) -# def _sum_quantity(self, accounts, date1, date2): -# ids = map(lambda x: x['id'], accounts) -# if not len(ids): -# return 0.0 -# account_analytic_obj = self.pool.get('account.analytic.account') -# ids2 = account_analytic_obj.search(self.cr, self.uid, -# [('parent_id', 'child_of', ids)]) -# self.cr.execute("SELECT sum(unit_amount) \ -# FROM account_analytic_line \ -# WHERE account_id IN ("+','.join(map(str, ids2))+") \ -# AND date>=%s AND date<=%s", -# (date1, date2)) -# return self.cr.fetchone()[0] or 0.0 report_sxw.report_sxw('report.account.analytic.account.balance', 'account.analytic.account', 'addons/account/project/report/analytic_balance.rml', diff --git a/addons/account/project/report/analytic_check.py b/addons/account/project/report/analytic_check.py index 458827d8bf3..3075a7821bb 100644 --- a/addons/account/project/report/analytic_check.py +++ b/addons/account/project/report/analytic_check.py @@ -77,41 +77,6 @@ class account_analytic_analytic_check(report_sxw.rml_parse): return res -# def _lines_p(self, date1, date2): -# res = [] -# acc_obj = self.pool.get('account.account') -# for a in acc_obj.read(self.cr, self.uid, self.ids, ['name', 'code','sign']): -# self.cr.execute("SELECT sum(debit), sum(credit) \ -# FROM account_move_line \ -# WHERE date>=%s AND date<=%s AND state<>'draft' AND account_id = %s", (date1, date2, a['id'])) -# (gd, gc) = self.cr.fetchone() -# gd = gd or 0.0 -# gc = gc or 0.0 -# -# self.cr.execute("SELECT abs(sum(amount)) AS balance \ -# FROM account_analytic_line \ -# WHERE date>=%s AND date<=%s AND amount*%s>0 AND general_account_id = %s", (date1, date2, a['sign'], a['id'])) -# (ad,) = self.cr.fetchone() -# ad = ad or 0.0 -# self.cr.execute("SELECT abs(sum(amount)) AS balance \ -# FROM account_analytic_line \ -# WHERE date>=%s AND date<=%s AND amount*%s<0 AND general_account_id = %s", (date1, date2, a['sign'], a['id'])) -# (ac,) = self.cr.fetchone() -# ac = ac or 0.0 -# -# res.append({'code': a['code'], 'name': a['name'], -# 'gen_debit': gd, -# 'gen_credit': gc, -# 'ana_debit': ad, -# 'ana_credit': ac, -# 'delta_debit': gd - ad, -# 'delta_credit': gc - ac,}) -# self.sum_gen_deb += gd -# self.sum_gen_cred += gc -# self.sum_ana_deb += ad -# self.sum_ana_cred += ac -# return res - def _gen_deb(self, date1, date2): return self.sum_gen_deb diff --git a/addons/account/project/report/cost_ledger.py b/addons/account/project/report/cost_ledger.py index 9163cd8e0d4..4317831998c 100644 --- a/addons/account/project/report/cost_ledger.py +++ b/addons/account/project/report/cost_ledger.py @@ -93,15 +93,14 @@ class account_analytic_cost_ledger(report_sxw.rml_parse): ids = map(lambda x: x.id, accounts) if not len(ids): return 0.0 - self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount>0", (ids, date1, date2,)) + self.cr.execute("SELECT sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount>0", (tuple(ids), date1, date2,)) return self.cr.fetchone()[0] or 0.0 def _sum_credit(self, accounts, date1, date2): ids = map(lambda x: x.id, accounts) if not len(ids): return 0.0 - ids = map(lambda x: x.id, accounts) - self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount<0", (ids,date1, date2,)) + self.cr.execute("SELECT -sum(amount) FROM account_analytic_line WHERE account_id IN %s AND date>=%s AND date<=%s AND amount<0", (tuple(ids),date1, date2,)) return self.cr.fetchone()[0] or 0.0 def _sum_balance(self, accounts, date1, date2): diff --git a/addons/account/project/report/inverted_analytic_balance.py b/addons/account/project/report/inverted_analytic_balance.py index 37f469d4ef8..f313a9c55db 100644 --- a/addons/account/project/report/inverted_analytic_balance.py +++ b/addons/account/project/report/inverted_analytic_balance.py @@ -38,12 +38,17 @@ class account_inverted_analytic_balance(report_sxw.rml_parse): def _lines_g(self, accounts, date1, date2): ids = map(lambda x: x.id, accounts) - self.cr.execute("SELECT aa.name AS name, aa.code AS code, sum(aal.amount) AS balance, sum(aal.unit_amount) AS quantity, aa.id AS id \ + self.cr.execute("SELECT aa.name AS name, aa.code AS code, " + "sum(aal.amount) AS balance, " + "sum(aal.unit_amount) AS quantity, aa.id AS id \ FROM account_analytic_line AS aal, account_account AS aa \ - WHERE (aal.general_account_id=aa.id) AND (aal.account_id =ANY(%s)) AND (date>=%s) AND (date<=%s) AND aa.active \ - GROUP BY aal.general_account_id, aa.name, aa.code, aal.code, aa.id ORDER BY aal.code", (ids,date1,date2,)) + WHERE (aal.general_account_id=aa.id) " + "AND (aal.account_id IN %s) " + "AND (date>=%s) AND (date<=%s) AND aa.active \ + GROUP BY aal.general_account_id, aa.name, aa.code, aal.code, aa.id " + "ORDER BY aal.code", + (tuple(ids), date1, date2)) res = self.cr.dictfetchall() - for r in res: if r['balance'] > 0: r['debit'] = r['balance'] @@ -58,10 +63,17 @@ class account_inverted_analytic_balance(report_sxw.rml_parse): def _lines_a(self, accounts, general_account_id, date1, date2): ids = map(lambda x: x.id, accounts) - self.cr.execute("SELECT sum(aal.amount) AS balance, sum(aal.unit_amount) AS quantity, aaa.code AS code, aaa.name AS name, account_id \ - FROM account_analytic_line AS aal, account_analytic_account AS aaa \ - WHERE aal.account_id=aaa.id AND aal.account_id =ANY(%s) AND aal.general_account_id=%s AND aal.date>=%s AND aal.date<=%s \ - GROUP BY aal.account_id, general_account_id, aaa.code, aaa.name ORDER BY aal.account_id", (ids,general_account_id, date1, date2,)) + self.cr.execute("SELECT sum(aal.amount) AS balance, " + "sum(aal.unit_amount) AS quantity, " + "aaa.code AS code, aaa.name AS name, account_id \ + FROM account_analytic_line AS aal, " + "account_analytic_account AS aaa \ + WHERE aal.account_id=aaa.id AND aal.account_id IN %s " + "AND aal.general_account_id=%s AND aal.date>=%s " + "AND aal.date<=%s \ + GROUP BY aal.account_id, general_account_id, aaa.code, aaa.name " + "ORDER BY aal.account_id", + (tuple(ids), general_account_id, date1, date2)) res = self.cr.dictfetchall() aaa_obj = self.pool.get('account.analytic.account') @@ -86,14 +98,14 @@ class account_inverted_analytic_balance(report_sxw.rml_parse): ids = map(lambda x: x.id, accounts) self.cr.execute("SELECT sum(amount) \ FROM account_analytic_line \ - WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount>0", (ids,date1, date2,)) + WHERE account_id IN %s AND date>=%s AND date<=%s AND amount>0", (tuple(ids),date1, date2,)) return self.cr.fetchone()[0] or 0.0 def _sum_credit(self, accounts, date1, date2): ids = map(lambda x: x.id, accounts) self.cr.execute("SELECT -sum(amount) \ FROM account_analytic_line \ - WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount<0", (ids,date1, date2,)) + WHERE account_id IN %s AND date>=%s AND date<=%s AND amount<0", (tuple(ids),date1, date2,)) return self.cr.fetchone()[0] or 0.0 def _sum_balance(self, accounts, date1, date2): @@ -105,7 +117,7 @@ class account_inverted_analytic_balance(report_sxw.rml_parse): ids = map(lambda x: x.id, accounts) self.cr.execute("SELECT sum(unit_amount) \ FROM account_analytic_line \ - WHERE account_id =ANY(%s) AND date>=%s AND date<=%s", (ids,date1, date2,)) + WHERE account_id IN %s AND date>=%s AND date<=%s", (tuple(ids),date1, date2,)) return self.cr.fetchone()[0] or 0.0 report_sxw.report_sxw('report.account.analytic.account.inverted.balance', 'account.analytic.account', 'addons/account/project/report/inverted_analytic_balance.rml',parser=account_inverted_analytic_balance, header=False) diff --git a/addons/account/project/report/quantity_cost_ledger.py b/addons/account/project/report/quantity_cost_ledger.py index 12bea390eba..37b09827c51 100644 --- a/addons/account/project/report/quantity_cost_ledger.py +++ b/addons/account/project/report/quantity_cost_ledger.py @@ -52,9 +52,9 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse): WHERE (aal.account_id=%s) AND (aal.date>=%s) \ AND (aal.date<=%s) AND (aal.general_account_id=aa.id) \ AND aa.active \ - AND (aal.journal_id =ANY(%s) ) \ + AND (aal.journal_id IN %s ) \ GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code", - (account_id, date1, date2,journal_ids)) + (account_id, date1, date2, tuple(journal_ids))) res = self.cr.dictfetchall() return res @@ -79,9 +79,9 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse): account_analytic_journal AS aaj \ WHERE (aal.general_account_id=%s) AND (aal.account_id=%s) \ AND (aal.date>=%s) AND (aal.date<=%s) \ - AND (aal.journal_id=aaj.id) AND (aaj.id =ANY(%s)) \ + AND (aal.journal_id=aaj.id) AND (aaj.id IN %s) \ ORDER BY aal.date, aaj.code, aal.code", - (general_account_id, account_id, date1, date2,journal_ids,)) + (general_account_id, account_id, date1, date2,tuple(journal_ids))) res = self.cr.dictfetchall() return res @@ -96,8 +96,8 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse): self.cr.execute("SELECT sum(unit_amount) \ FROM account_analytic_line \ WHERE account_id = %s AND date >= %s AND date <= %s \ - AND journal_id =ANY(%s)", - (account_id, date1, date2,journal_ids,)) + AND journal_id IN %s", + (account_id, date1, date2, tuple(journal_ids),)) return self.cr.fetchone()[0] or 0.0 def _sum_quantity(self, accounts, date1, date2, journals): @@ -107,14 +107,14 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse): if not journals: self.cr.execute("SELECT sum(unit_amount) \ FROM account_analytic_line \ - WHERE account_id =ANY(%s) AND date>=%s AND date<=%s", - (ids, date1, date2,)) + WHERE account_id IN %s AND date>=%s AND date<=%s", + (tuple(ids), date1, date2,)) else: journal_ids = journals self.cr.execute("SELECT sum(unit_amount) \ FROM account_analytic_line \ - WHERE account_id =ANY(%s) AND date >= %s AND date <= %s \ - AND journal_id =ANY(%s)",(ids, date1, date2, journal_ids)) + WHERE account_id IN %s AND date >= %s AND date <= %s \ + AND journal_id IN %s",(tuple(ids), date1, date2, tuple(journal_ids))) return self.cr.fetchone()[0] or 0.0 report_sxw.report_sxw('report.account.analytic.account.quantity_cost_ledger', diff --git a/addons/account/project/wizard/account_analytic_cost_ledger_for_journal_report.py b/addons/account/project/wizard/account_analytic_cost_ledger_for_journal_report.py index 73dd38533c4..122fbd41a12 100644 --- a/addons/account/project/wizard/account_analytic_cost_ledger_for_journal_report.py +++ b/addons/account/project/wizard/account_analytic_cost_ledger_for_journal_report.py @@ -29,7 +29,7 @@ class account_analytic_cost_ledger_journal_report(osv.osv_memory): _columns = { 'date1': fields.date('Start of period', required=True), 'date2': fields.date('End of period', required=True), - 'journal': fields.many2many('account.analytic.journal', 'ledger_journal_rel','ledger_id', 'Journal_id','Journals'), + 'journal': fields.many2many('account.analytic.journal', 'ledger_journal_rel', 'ledger_id', 'Journal_id', 'Journals'), } _defaults = { diff --git a/addons/account/report/account_account_report.py b/addons/account/report/account_account_report.py index 55e5d7030c7..b396521e45c 100644 --- a/addons/account/report/account_account_report.py +++ b/addons/account/report/account_account_report.py @@ -38,8 +38,8 @@ class account_account_report(osv.osv): ('closed', 'Closed'), ], 'Internal Type', readonly=True), 'company_id': fields.many2one('res.company', 'Company', required=True), - 'currency_mode': fields.selection([('current', 'At Date'), ('average', 'Average Rate')], 'Outgoing Currencies Rate',readonly=True), - 'user_type': fields.many2one('account.account.type', 'Account Type',readonly=True), + 'currency_mode': fields.selection([('current', 'At Date'), ('average', 'Average Rate')], 'Outgoing Currencies Rate', readonly=True), + 'user_type': fields.many2one('account.account.type', 'Account Type', readonly=True), 'quantity': fields.float('Quantity', readonly=True), 'amount_total': fields.float('Total Amount', readonly=True), 'credit': fields.float('Credit', readonly=True), diff --git a/addons/account/report/account_analytic_report.py b/addons/account/report/account_analytic_report.py index 87912b4a3ef..a740076ad09 100644 --- a/addons/account/report/account_analytic_report.py +++ b/addons/account/report/account_analytic_report.py @@ -28,21 +28,21 @@ class analytic_report(osv.osv): _auto = False _columns = { 'date_start': fields.date('Date Start', readonly=True), - 'date_end': fields.date('Date End',readonly=True), + 'date_end': fields.date('Date End', readonly=True), 'name' : fields.char('Analytic Account', size=128, readonly=True), - 'partner_id' : fields.many2one('res.partner', 'Associated Partner',readonly=True), + 'partner_id' : fields.many2one('res.partner', 'Associated Partner', readonly=True), 'journal_id' : fields.many2one('account.analytic.journal', 'Analytic Journal', readonly=True), 'parent_id': fields.many2one('account.analytic.account', 'Parent Analytic Account', readonly=True), - 'user_id' : fields.many2one('res.users', 'Account Manager',readonly=True), - 'product_id' : fields.many2one('product.product', 'Product',readonly=True), - 'total_quantity': fields.float('# Total Quantity',readonly=True), - 'debit' : fields.float('Debit',readonly=True), - 'credit' : fields.float('Credit',readonly=True), - 'balance' : fields.float('Balance',readonly=True), + 'user_id' : fields.many2one('res.users', 'Account Manager', readonly=True), + 'product_id' : fields.many2one('product.product', 'Product', readonly=True), + 'total_quantity': fields.float('# Total Quantity', readonly=True), + 'debit' : fields.float('Debit', readonly=True), + 'credit' : fields.float('Credit', readonly=True), + 'balance' : fields.float('Balance', readonly=True), 'year': fields.char('Year', size=4, readonly=True), 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), ('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'), - ('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True), + ('10','October'), ('11','November'), ('12','December')], 'Month', readonly=True), 'day': fields.char('Day', size=128, readonly=True), 'nbr':fields.integer('# of Lines', readonly=True), 'company_id': fields.many2one('res.company', 'Company', readonly=True), diff --git a/addons/account/report/account_balance.py b/addons/account/report/account_balance.py index 78683b5120b..93a09db9edf 100644 --- a/addons/account/report/account_balance.py +++ b/addons/account/report/account_balance.py @@ -68,14 +68,14 @@ class account_balance(report_sxw.rml_parse): result='' if form.has_key('periods') and form['periods']: period_ids = form['periods'] - per_ids = self.pool.get('account.period').browse(self.cr,self.uid,form['periods']) + per_ids = self.pool.get('account.period').browse(self.cr, self.uid, form['periods']) for r in per_ids: if r == per_ids[len(per_ids)-1]: result+=r.name+". " else: result+=r.name+", " else: - fy_obj = self.pool.get('account.fiscalyear').browse(self.cr,self.uid,form['fiscalyear']) + fy_obj = self.pool.get('account.fiscalyear').browse(self.cr, self.uid, form['fiscalyear']) res = fy_obj.period_ids len_res = len(res) for r in res: @@ -118,7 +118,7 @@ class account_balance(report_sxw.rml_parse): child_ids = self.pool.get('account.account')._get_children_and_consol(self.cr, self.uid, ids, ctx) if child_ids: ids = child_ids - accounts = self.pool.get('account.account').read(self.cr, self.uid, ids,['type','code','name','debit','credit','balance','parent_id'], ctx) + accounts = self.pool.get('account.account').read(self.cr, self.uid, ids, ['type','code','name','debit','credit','balance','parent_id'], ctx) for account in accounts: if account['id'] in done: continue diff --git a/addons/account/report/account_balance_landscape.py b/addons/account/report/account_balance_landscape.py index a2677e46c27..02d69ba8b19 100644 --- a/addons/account/report/account_balance_landscape.py +++ b/addons/account/report/account_balance_landscape.py @@ -351,7 +351,7 @@ class account_balance_landscape(rml_parse.rml_parse): if perc==1: if form['select_account']!=False: - ref_ac=self.pool.get('account.account').browse(self.cr, self.uid,form['select_account'],ctx.copy()) + ref_ac=self.pool.get('account.account').browse(self.cr, self.uid, form['select_account'], ctx.copy()) if ref_ac.balance<>0.00: ref_bal=ref_ac.balance else: @@ -365,7 +365,7 @@ class account_balance_landscape(rml_parse.rml_parse): total_for_perc=[] # if perc==1: self.done_total=1 - self.total_for_perc=self.linesForTotal(form,ids={},doneAccount={},level=1) + self.total_for_perc=self.linesForTotal(form, ids={}, doneAccount={}, level=1) self.done_total=0 for t1 in range(0,len(form['fiscalyear'])): @@ -376,13 +376,13 @@ class account_balance_landscape(rml_parse.rml_parse): # self.result_total = {} for temp in range(0,len(form['fiscalyear'])): - fy=self.pool.get('account.fiscalyear').name_get(self.cr,self.uid,form['fiscalyear'][temp]) + fy=self.pool.get('account.fiscalyear').name_get(self.cr, self.uid, form['fiscalyear'][temp]) years["year"+str(temp)]=fy[0][1][12:16] return [years] - def linesForTotal(self,form,ids={},doneAccount={},level=1): + def linesForTotal(self, form, ids={}, doneAccount={}, level=1): if self.done_total==1: self.done_total==1 else: @@ -443,7 +443,7 @@ class account_balance_landscape(rml_parse.rml_parse): ids2 = [(x.code,x.id) for x in entry[0].child_id] ids2.sort() - result_total_parent = self.linesForTotal(form, [x[1] for x in ids2],doneAccount,level+1) + result_total_parent = self.linesForTotal(form, [x[1] for x in ids2], doneAccount, level+1) return [self.result_total] @@ -462,7 +462,7 @@ class account_balance_landscape(rml_parse.rml_parse): ctx['periods'] = form['periods'] ctx['period_manner']=form['period_manner'] ctx['state'] = form['context'].get('state','all') - tmp1 = self.pool.get('account.account').browse(self.cr, self.uid, ids,ctx.copy()) + tmp1 = self.pool.get('account.account').browse(self.cr, self.uid, ids, ctx.copy()) if len(tmp1): accounts.append(tmp1) @@ -598,12 +598,12 @@ class account_balance_landscape(rml_parse.rml_parse): return result - def get_years(self,form): + def get_years(self, form): result =[] res={} - for temp in range(0,len(form['fiscalyear'])): + for temp in range(0, len(form['fiscalyear'])): res={} - fy=self.pool.get('account.fiscalyear').name_get(self.cr,self.uid,form['fiscalyear'][temp]) + fy=self.pool.get('account.fiscalyear').name_get(self.cr, self.uid, form['fiscalyear'][temp]) res['year']=fy[0][1] res['last_str']=temp @@ -611,7 +611,7 @@ class account_balance_landscape(rml_parse.rml_parse): self.linesForYear(form) return result - def get_lines(self,year_dict,form): + def get_lines(self, year_dict, form): final_result = [] line_l =[] res = {} @@ -643,7 +643,7 @@ class account_balance_landscape(rml_parse.rml_parse): final_result.append(res) return final_result - def cal_total(self,year_dict): + def cal_total(self, year_dict): total_l = self.result_total if total_l: for k,v in total_l.items(): diff --git a/addons/account/report/account_entries_report.py b/addons/account/report/account_entries_report.py index 85ba8a058f7..2c22db01e53 100644 --- a/addons/account/report/account_entries_report.py +++ b/addons/account/report/account_entries_report.py @@ -33,18 +33,18 @@ class account_entries_report(osv.osv): 'date_maturity': fields.date('Date Maturity', readonly=True), 'nbr':fields.integer('# of Entries', readonly=True), 'nbl':fields.integer('# of Lines', readonly=True), - 'amount': fields.float('Amount',readonly=True), + 'amount': fields.float('Amount', readonly=True), 'year': fields.char('Year', size=4, readonly=True), 'day': fields.char('Day', size=128, readonly=True), 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), ('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'), - ('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True), - 'ref': fields.char('Reference', size=64,readonly=True), + ('10','October'), ('11','November'), ('12','December')], 'Month', readonly=True), + 'ref': fields.char('Reference', size=64, readonly=True), 'period_id': fields.many2one('account.period', 'Period', readonly=True), 'account_id': fields.many2one('account.account', 'Account', readonly=True), 'journal_id': fields.many2one('account.journal', 'Journal', readonly=True), 'product_id': fields.many2one('product.product', 'Product', readonly=True), - 'state': fields.selection([('draft','Draft'), ('posted','Posted')], 'State',readonly=True, + 'state': fields.selection([('draft','Draft'), ('posted','Posted')], 'State', readonly=True, help='When new account move is created the state will be \'Draft\'. When all the payments are done it will be in \'Posted\' state.'), 'state_2': fields.selection([('draft','Draft'), ('valid','Valid')], 'State of Move Line', readonly=True, help='When new move line is created the state will be \'Draft\'.\n* When all the payments are done it will be in \'Valid\' state.'), diff --git a/addons/account/report/account_invoice_report.py b/addons/account/report/account_invoice_report.py index 1fb90a86bec..43c8344f110 100644 --- a/addons/account/report/account_invoice_report.py +++ b/addons/account/report/account_invoice_report.py @@ -33,16 +33,16 @@ class account_invoice_report(osv.osv): 'day': fields.char('Day', size=128, readonly=True), 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), ('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'), - ('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True), + ('10','October'), ('11','November'), ('12','December')], 'Month', readonly=True), 'product_id':fields.many2one('product.product', 'Product', readonly=True), 'product_qty':fields.float('Qty', readonly=True), 'uom_name': fields.char('Default UoM', size=128, readonly=True), - 'payment_term': fields.many2one('account.payment.term', 'Payment Term',readonly=True), - 'period_id': fields.many2one('account.period', 'Force Period', domain=[('state','<>','done')],readonly=True), - 'fiscal_position': fields.many2one('account.fiscal.position', 'Fiscal Position',readonly=True), + 'payment_term': fields.many2one('account.payment.term', 'Payment Term', readonly=True), + 'period_id': fields.many2one('account.period', 'Force Period', domain=[('state','<>','done')], readonly=True), + 'fiscal_position': fields.many2one('account.fiscal.position', 'Fiscal Position', readonly=True), 'currency_id': fields.many2one('res.currency', 'Currency', readonly=True), 'categ_id': fields.many2one('product.category','Category of Product', readonly=True), - 'journal_id': fields.many2one('account.journal', 'Journal',readonly=True), + 'journal_id': fields.many2one('account.journal', 'Journal', readonly=True), 'partner_id':fields.many2one('res.partner', 'Partner', readonly=True), 'company_id':fields.many2one('res.company', 'Company', readonly=True), 'user_id':fields.many2one('res.users', 'Salesman', readonly=True), diff --git a/addons/account/report/account_report.py b/addons/account/report/account_report.py index e2c05616c3f..5a62c1ea337 100644 --- a/addons/account/report/account_report.py +++ b/addons/account/report/account_report.py @@ -207,15 +207,15 @@ class report_account_type_sales(osv.osv): _description = "Report of the Sales by Account Type" _auto = False _columns = { - 'name': fields.char('Year',size=64,required=False, readonly=True), - 'period_id': fields.many2one('account.period', 'Force Period',readonly=True), - 'product_id': fields.many2one('product.product', 'Product',readonly=True), + 'name': fields.char('Year', size=64, required=False, readonly=True), + 'period_id': fields.many2one('account.period', 'Force Period', readonly=True), + 'product_id': fields.many2one('product.product', 'Product', readonly=True), 'quantity': fields.float('Quantity', readonly=True), 'user_type': fields.many2one('account.account.type', 'Account Type', readonly=True), 'amount_total': fields.float('Total', readonly=True), 'currency_id': fields.many2one('res.currency', 'Currency', readonly=True), 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), ('05','May'), ('06','June'), - ('07','July'), ('08','August'), ('09','September'), ('10','October'), ('11','November'), ('12','December')],'Month',readonly=True), + ('07','July'), ('08','August'), ('09','September'), ('10','October'), ('11','November'), ('12','December')], 'Month', readonly=True), } _order = 'name desc,amount_total desc' @@ -249,15 +249,15 @@ class report_account_sales(osv.osv): _description = "Report of the Sales by Account" _auto = False _columns = { - 'name': fields.char('Year',size=64,required=False, readonly=True), - 'period_id': fields.many2one('account.period', 'Force Period',readonly=True), - 'product_id': fields.many2one('product.product', 'Product',readonly=True), + 'name': fields.char('Year', size=64, required=False, readonly=True), + 'period_id': fields.many2one('account.period', 'Force Period', readonly=True), + 'product_id': fields.many2one('product.product', 'Product', readonly=True), 'quantity': fields.float('Quantity', readonly=True), 'account_id': fields.many2one('account.account', 'Account', readonly=True), 'amount_total': fields.float('Total', readonly=True), 'currency_id': fields.many2one('res.currency', 'Currency', readonly=True), 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), ('05','May'), ('06','June'), - ('07','July'), ('08','August'), ('09','September'), ('10','October'), ('11','November'), ('12','December')],'Month',readonly=True), + ('07','July'), ('08','August'), ('09','September'), ('10','October'), ('11','November'), ('12','December')], 'Month', readonly=True), } _order = 'name desc,amount_total desc' diff --git a/addons/account/report/aged_trial_balance.py b/addons/account/report/aged_trial_balance.py index 26e24031c3a..43db65f25c9 100644 --- a/addons/account/report/aged_trial_balance.py +++ b/addons/account/report/aged_trial_balance.py @@ -80,13 +80,13 @@ class aged_trial_report(rml_parse.rml_parse): self.cr.execute("""SELECT partner_id, SUM(debit-credit) FROM account_move_line AS line, account_account WHERE (line.account_id = account_account.id) - AND (account_account.type =ANY(%s)) - AND (partner_id =ANY (%s)) + AND (account_account.type IN %s) + AND (partner_id IN %s) AND ((reconcile_id IS NULL) OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) AND (account_account.company_id = %s) AND account_account.active - GROUP BY partner_id""" , (self.ACCOUNT_TYPE, partner_ids,form['date1'],form['company_id'],)) + GROUP BY partner_id""" , (tuple(self.ACCOUNT_TYPE), tuple(partner_ids),form['date1'],form['company_id'],)) t = self.cr.fetchall() for i in t: totals[i[0]] = i[1] @@ -97,14 +97,14 @@ class aged_trial_report(rml_parse.rml_parse): self.cr.execute("""SELECT partner_id, SUM(debit-credit) FROM account_move_line AS line, account_account WHERE (line.account_id=account_account.id) - AND (account_account.type =ANY (%s)) + AND (account_account.type IN %s) AND (COALESCE(date_maturity,date) < %s) - AND (partner_id =ANY (%s)) + AND (partner_id IN %s) AND ((reconcile_id IS NULL) OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) AND (account_account.company_id = %s) AND account_account.active - GROUP BY partner_id""", (self.ACCOUNT_TYPE, form['date1'], partner_ids,form['date1'], form['company_id'],)) + GROUP BY partner_id""", (tuple(self.ACCOUNT_TYPE), form['date1'], tuple(partner_ids),form['date1'], form['company_id'],)) t = self.cr.fetchall() for i in t: future_past[i[0]] = i[1] @@ -112,14 +112,14 @@ class aged_trial_report(rml_parse.rml_parse): self.cr.execute("""SELECT partner_id, SUM(debit-credit) FROM account_move_line AS line, account_account WHERE (line.account_id=account_account.id) - AND (account_account.type =ANY (%s)) + AND (account_account.type IN %s) AND (COALESCE(date_maturity,date) > %s) - AND (partner_id =ANY (%s)) + AND (partner_id IN %s) AND ((reconcile_id IS NULL) OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) AND (account_account.company_id = %s) AND account_account.active - GROUP BY partner_id""" , (self.ACCOUNT_TYPE, form['date1'], partner_ids, form['date1'], form['company_id'],)) + GROUP BY partner_id""" , (tuple(self.ACCOUNT_TYPE), form['date1'], tuple(partner_ids), form['date1'], form['company_id'],)) t = self.cr.fetchall() for i in t: future_past[i[0]] = i[1] @@ -131,14 +131,14 @@ class aged_trial_report(rml_parse.rml_parse): self.cr.execute("""SELECT partner_id, SUM(debit-credit) FROM account_move_line AS line, account_account WHERE (line.account_id=account_account.id) - AND (account_account.type =ANY (%s)) + AND (account_account.type IN %s) AND (COALESCE(date_maturity,date) BETWEEN %s AND %s) - AND (partner_id =ANY (%s)) + AND (partner_id IN %s) AND ((reconcile_id IS NULL) OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) AND (account_account.company_id = %s) AND account_account.active - GROUP BY partner_id""" , (self.ACCOUNT_TYPE, form[str(i)]['start'], form[str(i)]['stop'],partner_ids ,form['date1'] ,form['company_id'],)) + GROUP BY partner_id""" , (tuple(self.ACCOUNT_TYPE), form[str(i)]['start'], form[str(i)]['stop'], tuple(partner_ids) ,form['date1'] ,form['company_id'],)) t = self.cr.fetchall() d = {} diff --git a/addons/account/report/central_journal.py b/addons/account/report/central_journal.py index 36c61b877ff..d76f6ccf07b 100644 --- a/addons/account/report/central_journal.py +++ b/addons/account/report/central_journal.py @@ -40,7 +40,7 @@ class journal_print(report_sxw.rml_parse): ids_final = [] for journal in journal_id: for period in period_id: - ids_journal_period = self.pool.get('account.journal.period').search(self.cr,self.uid, [('journal_id','=',journal),('period_id','=',period)]) + ids_journal_period = self.pool.get('account.journal.period').search(self.cr, self.uid, [('journal_id','=',journal),('period_id','=',period)]) if ids_journal_period: self.cr.execute('select a.code, a.name, sum(debit) as debit, sum(credit) as credit from account_move_line l left join account_account a on (l.account_id=a.id) where l.period_id=%s and l.journal_id=%s and l.state<>\'draft\' group by a.id, a.code, a.name, l.journal_id, l.period_id', (period, journal)) res = self.cr.dictfetchall() diff --git a/addons/account/report/compare_account_balance.py b/addons/account/report/compare_account_balance.py index 28054377834..13fb90fdb5f 100644 --- a/addons/account/report/compare_account_balance.py +++ b/addons/account/report/compare_account_balance.py @@ -320,7 +320,7 @@ class account_balance(report_sxw.rml_parse): # return super(account_balance,self).repeatIn(lst, name, nodes_parent=False) #end - def linesForYear(self,form): + def linesForYear(self, form): temp=0 years={} @@ -351,7 +351,7 @@ class account_balance(report_sxw.rml_parse): if perc==1: if form['select_account']!=False: - ref_ac=self.pool.get('account.account').browse(self.cr, self.uid,form['select_account'],ctx.copy()) + ref_ac=self.pool.get('account.account').browse(self.cr, self.uid, form['select_account'], ctx.copy()) if ref_ac.balance<>0.00: ref_bal=ref_ac.balance else: @@ -365,7 +365,7 @@ class account_balance(report_sxw.rml_parse): total_for_perc=[] # if perc==1: self.done_total=1 - self.total_for_perc=self.linesForTotal(form,ids={},doneAccount={},level=1) + self.total_for_perc=self.linesForTotal(form, ids={}, doneAccount={}, level=1) self.done_total=0 for t1 in range(0,len(form['fiscalyear'])): @@ -376,13 +376,13 @@ class account_balance(report_sxw.rml_parse): # self.result_total = {} for temp in range(0,len(form['fiscalyear'])): - fy=self.pool.get('account.fiscalyear').name_get(self.cr,self.uid,form['fiscalyear'][temp]) + fy=self.pool.get('account.fiscalyear').name_get(self.cr, self.uid, form['fiscalyear'][temp]) years["year"+str(temp)]=fy[0][1][12:16] return [years] - def linesForTotal(self,form,ids={},doneAccount={},level=1): + def linesForTotal(self, form, ids={}, doneAccount={}, level=1): if self.done_total==1: self.done_total==1 else: @@ -440,7 +440,7 @@ class account_balance(report_sxw.rml_parse): ids2 = [(x.code,x.id) for x in entry[0].child_id] ids2.sort() - result_total_parent = self.linesForTotal(form, [x[1] for x in ids2],doneAccount,level+1) + result_total_parent = self.linesForTotal(form, [x[1] for x in ids2], doneAccount, level+1) return [self.result_total] @@ -459,7 +459,7 @@ class account_balance(report_sxw.rml_parse): ctx['periods'] = form['periods'] ctx['period_manner']=form['period_manner'] ctx['state'] = form['context'].get('state','all') - tmp1 = self.pool.get('account.account').browse(self.cr, self.uid, ids,ctx.copy()) + tmp1 = self.pool.get('account.account').browse(self.cr, self.uid, ids, ctx.copy()) if len(tmp1): accounts.append(tmp1) @@ -594,12 +594,12 @@ class account_balance(report_sxw.rml_parse): return result - def get_years(self,form): + def get_years(self, form): result =[] res={} for temp in range(0,len(form['fiscalyear'])): res={} - fy=self.pool.get('account.fiscalyear').name_get(self.cr,self.uid,form['fiscalyear'][temp]) + fy=self.pool.get('account.fiscalyear').name_get(self.cr, self.uid, form['fiscalyear'][temp]) res['year']=fy[0][1] res['last_str']=temp @@ -607,7 +607,7 @@ class account_balance(report_sxw.rml_parse): self.linesForYear(form) return result - def get_lines(self,year_dict,form): + def get_lines(self, year_dict, form): final_result = [] line_l =[] res = {} @@ -639,7 +639,7 @@ class account_balance(report_sxw.rml_parse): final_result.append(res) return final_result - def cal_total(self,year_dict): + def cal_total(self, year_dict): total_l = self.result_total if total_l: for k,v in total_l.items(): diff --git a/addons/account/report/general_journal.py b/addons/account/report/general_journal.py index 112ce970694..631930ce3a7 100644 --- a/addons/account/report/general_journal.py +++ b/addons/account/report/general_journal.py @@ -18,7 +18,7 @@ # along with this program. If not, see . # ############################################################################## - +from operator import itemgetter import pooler import time from report import report_sxw @@ -41,10 +41,12 @@ class journal_print(report_sxw.rml_parse): def set_context(self, objects, data, ids, report_type = None): super(journal_print, self).set_context(objects, data, ids, report_type) - self.cr.execute('select period_id, journal_id from account_journal_period where id =ANY(%s)',(ids,)) + self.cr.execute('SELECT period_id, journal_id ' + 'FROM account_journal_period ' + 'WHERE id IN %s', + (tuple(ids),)) res = self.cr.fetchall() - self.period_ids = map(lambda x:x[0],res) - self.journal_ids = map(lambda x:x[1],res) + self.period_ids, self.journal_ids = zip(*res) # returns a list of period objs def periods(self, journal_period_objs): @@ -63,7 +65,7 @@ class journal_print(report_sxw.rml_parse): ids_final = [] for journal in journal_id: for period in period_id: - ids_journal_period = self.pool.get('account.journal.period').search(self.cr,self.uid, [('journal_id','=',journal),('period_id','=',period)]) + ids_journal_period = self.pool.get('account.journal.period').search(self.cr, self.uid, [('journal_id','=',journal),('period_id','=',period)]) if ids_journal_period: ids_final.append(ids_journal_period[0]) data_jour_period = self.pool.get('account.journal.period').browse(self.cr, self.uid, ids_final) @@ -74,7 +76,14 @@ class journal_print(report_sxw.rml_parse): periods.append(data.period_id.id) for period in periods: period_data = self.pool.get('account.period').browse(self.cr, self.uid, period) - self.cr.execute('select j.code, j.name, sum(l.debit) as debit, sum(l.credit) as credit from account_move_line l left join account_journal j on (l.journal_id=j.id) where period_id=%s and journal_id =ANY(%s) and l.state<>\'draft\' group by j.id, j.code, j.name', (period,journal_id,)) + self.cr.execute( + 'SELECT j.code, j.name, ' + 'SUM(l.debit) AS debit, SUM(l.credit) AS credit ' + 'FROM account_move_line l ' + 'LEFT JOIN account_journal j ON (l.journal_id=j.id) ' + 'WHERE period_id=%s AND journal_id IN %s ' + 'AND l.state<>\'draft\' ' + 'GROUP BY j.id, j.code, j.name', (period, tuple(journal_id))) res = self.cr.dictfetchall() res[0].update({'period_name':period_data.name}) res[0].update({'pid':period}) @@ -82,45 +91,60 @@ class journal_print(report_sxw.rml_parse): return lines_data if not self.journal_ids: return [] - self.cr.execute('select j.code, j.name, sum(l.debit) as debit, sum(l.credit) as credit from account_move_line l left join account_journal j on (l.journal_id=j.id) where period_id=%s and journal_id =ANY(%s) and l.state<>\'draft\' group by j.id, j.code, j.name', (period_id,self.journal_ids,)) + + self.cr.execute('SELECT j.code, j.name, ' + 'SUM(l.debit) AS debit, SUM(l.credit) AS credit ' + 'FROM account_move_line l ' + 'LEFT JOIN account_journal j ON (l.journal_id=j.id) ' + 'WHERE period_id=%s AND journal_id IN %s ' + 'AND l.state<>\'draft\' ' + 'GROUP BY j.id, j.code, j.name', + (period_id, tuple(self.journal_ids))) res = self.cr.dictfetchall() return res - def _sum_debit_period(self, period_id,journal_id=None): - if type(journal_id)==type([]): - self.cr.execute('select sum(debit) from account_move_line where period_id=%s and journal_id =ANY(%s) and state<>\'draft\'', (period_id,journal_id,)) - return self.cr.fetchone()[0] or 0.0 - if not self.journal_ids: + def _sum_debit_period(self, period_id, journal_id=None): + journals = journal_id or self.journal_ids + if not journals: return 0.0 - self.cr.execute('select sum(debit) from account_move_line where period_id=%s and journal_id =ANY(%s) and state<>\'draft\'', (period_id,self.journal_ids,)) - + self.cr.execute('SELECT SUM(debit) FROM account_move_line ' + 'WHERE period_id=%s AND journal_id IN %s ' + 'AND state<>\'draft\'', + (period_id, tuple(journals))) return self.cr.fetchone()[0] or 0.0 - def _sum_credit_period(self, period_id,journal_id=None): - if type(journal_id)==type([]): - self.cr.execute('select sum(credit) from account_move_line where period_id=%s and journal_id =ANY(%s) and state<>\'draft\'', (period_id,journal_id,)) - return self.cr.fetchone()[0] or 0.0 - if not self.journal_ids: + def _sum_credit_period(self, period_id, journal_id=None): + journals = journal_id or self.journal_ids + if not journals: return 0.0 - self.cr.execute('select sum(credit) from account_move_line where period_id=%s and journal_id =ANY(%s) and state<>\'draft\'', (period_id,self.journal_ids,)) + self.cr.execute('SELECT SUM(credit) FROM account_move_line ' + 'WHERE period_id=%s AND journal_id IN %s ' + 'AND state<>\'draft\'', + (period_id, tuple(journals))) return self.cr.fetchone()[0] or 0.0 - def _sum_debit(self,period_id=None,journal_id=None): - if type(period_id)==type([]): - self.cr.execute('select sum(debit) from account_move_line where period_id =ANY(%s) and journal_id =ANY(%s) and state<>\'draft\'',(period_id,journal_id,)) - return self.cr.fetchone()[0] or 0.0 - if not self.journal_ids or not self.period_ids: + def _sum_debit(self, period_id=None, journal_id=None): + journals = journal_id or self.journal_ids + periods = period_id or self.period_ids + if not (journals and periods): return 0.0 - self.cr.execute('select sum(debit) from account_move_line where period_id =ANY(%s) and journal_id =ANY(%s) and state<>\'draft\'',(self.period_ids,self.journal_ids,)) + self.cr.execute('SELECT SUM(debit) FROM account_move_line ' + 'WHERE period_id IN %s ' + 'AND journal_id IN %s ' + 'AND state<>\'draft\'', + (tuple(periods), tuple(journals))) return self.cr.fetchone()[0] or 0.0 - def _sum_credit(self,period_id=None,journal_id=None): - if type(period_id)==type([]): - self.cr.execute('select sum(credit) from account_move_line where period_id =ANY(%s) and journal_id =ANY(%s) and state<>\'draft\'',(period_id,journal_id,)) - return self.cr.fetchone()[0] or 0.0 - if not self.journal_ids or not self.period_ids: + def _sum_credit(self, period_id=None, journal_id=None): + periods = period_id or self.period_ids + journals = journal_id or self.journal_ids + if not (periods and journals): return 0.0 - self.cr.execute('select sum(credit) from account_move_line where period_id =ANY(%s) and journal_id =ANY(%s) and state<>\'draft\'',(self.period_ids,self.journal_ids,)) + self.cr.execute('SELECT SUM(credit) FROM account_move_line ' + 'WHERE period_id IN %s ' + 'AND journal_id IN %s ' + 'AND state<>\'draft\'', + (tuple(periods), tuple(journals))) return self.cr.fetchone()[0] or 0.0 report_sxw.report_sxw('report.account.general.journal', 'account.journal.period', 'addons/account/report/general_journal.rml', parser=journal_print) report_sxw.report_sxw('report.account.general.journal.wiz', 'account.journal.period', 'addons/account/report/wizard_general_journal.rml', parser=journal_print, header=False) diff --git a/addons/account/report/general_ledger.py b/addons/account/report/general_ledger.py index e2c24fe96d2..32186c269f9 100644 --- a/addons/account/report/general_ledger.py +++ b/addons/account/report/general_ledger.py @@ -70,7 +70,7 @@ class general_ledger(rml_parse.rml_parse): }) self.context = context - def get_min_date(self,form): + def get_min_date(self, form): ## Get max born from account_fiscal year # @@ -87,14 +87,15 @@ class general_ledger(rml_parse.rml_parse): #periods = form['periods'][0][2] if not periods: sql = """ - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = """ + str(form['fiscalyear']) + """ + Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = %s """ + sqlargs = (form['fiscalyear'],) else: - periods_id = ','.join(map(str, periods)) sql = """ - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id in ( """ + periods_id + """) + Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id in %s """ - self.cr.execute(sql) + sqlargs = (tuple(periods),) + self.cr.execute(sql, sqlargs) res = self.cr.dictfetchall() borne_min = res[0]['start_date'] borne_max = res[0]['stop_date'] @@ -105,15 +106,22 @@ class general_ledger(rml_parse.rml_parse): periods = form['periods'] #periods = form['periods'][0][2] if not periods: - sql = """ - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.fiscalyear_id = """ + str(form['fiscalyear']) + """ - """ + sql = """ + SELECT MIN(p.date_start) AS start_date, + MAX(p.date_stop) AS stop_date + FROM account_period AS p + WHERE p.fiscalyear_id = %s + """ + sqlargs = (form['fiscalyear'],) else: - periods_id = ','.join(map(str, periods)) sql = """ - Select min(p.date_start) as start_date,max(p.date_stop) as stop_date from account_period as p where p.id in ( """ + periods_id + """) + SELECT MIN(p.date_start) AS start_date, + MAX(p.date_stop) AS stop_date + FROM account_period AS p + WHERE p.id IN %s """ - self.cr.execute(sql) + sqlargs = (tuple(periods),) + self.cr.execute(sql, sqlargs) res = self.cr.dictfetchall() period_min = res[0]['start_date'] period_max = res[0]['stop_date'] @@ -150,7 +158,7 @@ class general_ledger(rml_parse.rml_parse): ## We will make the test for period or date ## We will now make the test # - ctx['state'] = form['context'].get('state','all') + ctx['state'] = form['context'].get('state', 'all') if form.has_key('fiscalyear'): ctx['fiscalyear'] = form['fiscalyear'] ctx['periods'] = form['periods'] @@ -165,10 +173,10 @@ class general_ledger(rml_parse.rml_parse): if account and account.child_consol_ids: # add ids of consolidated childs also of selected account ctx['consolidate_childs'] = True ctx['account_id'] = account.id - ids_acc = self.pool.get('account.account').search(self.cr, self.uid,[('parent_id', 'child_of', [account.id])], context=ctx) + ids_acc = self.pool.get('account.account').search(self.cr, self.uid, [('parent_id', 'child_of', [account.id])], context=ctx) for child_id in ids_acc: child_account = self.pool.get('account.account').browse(self.cr, self.uid, child_id) - sold_account = self._sum_solde_account(child_account,form) + sold_account = self._sum_solde_account(child_account, form) self.sold_accounts[child_account.id] = sold_account if form['display_account'] == 'bal_mouvement': if child_account.type != 'view' \ @@ -196,8 +204,12 @@ class general_ledger(rml_parse.rml_parse): else: ## We will now compute solde initiaux for move in res: - SOLDEINIT = "SELECT sum(l.debit) AS sum_debit, sum(l.credit) AS sum_credit FROM account_move_line l WHERE l.account_id = " + str(move.id) + " AND l.date < '" + self.borne_date['max_date'] + "'" + " AND l.date > '" + self.borne_date['min_date'] + "'" - self.cr.execute(SOLDEINIT) + SOLDEINIT = "SELECT SUM(l.debit) AS sum_debit,"\ + " SUM(l.credit) AS sum_credit "\ + "FROM account_move_line l "\ + "WHERE l.account_id = %s "\ + "AND l.date < %s AND l.date > %s" + self.cr.execute(SOLDEINIT, (move.id, self.borne_date['max_date'], self.borne_date['min_date'])) resultat = self.cr.dictfetchall() if resultat[0] : if resultat[0]['sum_debit'] == None: @@ -263,7 +275,7 @@ class general_ledger(rml_parse.rml_parse): for l in res: l['move']=l['move_name'] if l['invoice_id']: - l['ref'] = '%s: %s'%(inv_types[l['invoice_type']],l['invoice_number']) + l['ref'] = '%s: %s'%(inv_types[l['invoice_type']], l['invoice_number']) l['partner'] = l['partner_name'] or '' account_sum = l['debit'] - l ['credit'] #c = time.strptime(l['date'],"%Y-%m-%d") @@ -296,7 +308,7 @@ class general_ledger(rml_parse.rml_parse): self.cr.execute("SELECT sum(credit) "\ "FROM account_move_line l "\ - "WHERE l.account_id = %s AND %s "%(account.id,self.query)) + "WHERE l.account_id = %s AND %s "%(account.id, self.query)) ## Add solde init to the result # sum_credit = self.cr.fetchone()[0] or 0.0 @@ -310,7 +322,7 @@ class general_ledger(rml_parse.rml_parse): def _sum_solde_account(self, account, form): self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\ "FROM account_move_line l "\ - "WHERE l.account_id = %s AND %s"%(account.id,self.query)) + "WHERE l.account_id = %s AND %s"%(account.id, self.query)) sum_solde = self.cr.fetchone()[0] or 0.0 if form.get('soldeinit', False): sum_solde += account.init_debit - account.init_credit @@ -322,7 +334,8 @@ class general_ledger(rml_parse.rml_parse): return 0.0 self.cr.execute("SELECT sum(debit) "\ "FROM account_move_line l "\ - "WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query) + "WHERE l.account_id IN %s AND "+self.query, + (tuple(self.child_ids),)) sum_debit = self.cr.fetchone()[0] or 0.0 return sum_debit @@ -331,7 +344,8 @@ class general_ledger(rml_parse.rml_parse): return 0.0 self.cr.execute("SELECT sum(credit) "\ "FROM account_move_line l "\ - "WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query) + "WHERE l.account_id IN %s AND "+self.query, + (tuple(self.child_ids),)) ## Add solde init to the result # sum_credit = self.cr.fetchone()[0] or 0.0 @@ -342,7 +356,8 @@ class general_ledger(rml_parse.rml_parse): return 0.0 self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\ "FROM account_move_line l "\ - "WHERE l.account_id in ("+','.join(map(str, self.child_ids))+") AND "+self.query) + "WHERE l.account_id IN %s AND "+self.query, + (tuple(self.child_ids),)) sum_solde = self.cr.fetchone()[0] or 0.0 return sum_solde diff --git a/addons/account/report/overdue.py b/addons/account/report/overdue.py index d25432bde24..b7ffaf8816f 100644 --- a/addons/account/report/overdue.py +++ b/addons/account/report/overdue.py @@ -51,7 +51,7 @@ class Overdue(report_sxw.rml_parse): 'country_id' : False, } if adr_id: - result = res_partner_address.read(self.cr, self.uid, [adr_id],context=self.context.copy()) + result = res_partner_address.read(self.cr, self.uid, [adr_id], context=self.context.copy()) result[0]['country_id'] = result[0]['country_id'] and result[0]['country_id'][1] or False return result diff --git a/addons/account/report/partner_balance.py b/addons/account/report/partner_balance.py index f296475cb3f..142375aedb5 100644 --- a/addons/account/report/partner_balance.py +++ b/addons/account/report/partner_balance.py @@ -29,7 +29,6 @@ class partner_balance(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(partner_balance, self).__init__(cr, uid, name, context=context) self.date_lst = [] - self.date_lst_string = '' self.account_ids = '' self.localcontext.update( { 'time': time, @@ -49,7 +48,7 @@ class partner_balance(report_sxw.rml_parse): # # Date Management # - def date_range(self,start,end): + def date_range(self, start, end): if not start or not end: return [] start = datetime.date.fromtimestamp(time.mktime(time.strptime(start,"%Y-%m-%d"))) @@ -63,7 +62,7 @@ class partner_balance(report_sxw.rml_parse): full_str_date.append(str(date)) return full_str_date - def transform_period_into_date_array(self,data): + def transform_period_into_date_array(self, data): ## Get All Period Date # # If we have no period we will take all perdio in the FiscalYear. @@ -74,17 +73,17 @@ class partner_balance(report_sxw.rml_parse): date_array = [] for period_id in periods_id: period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id) - date_array = date_array + self.date_range(period_obj.date_start,period_obj.date_stop) + date_array = date_array + self.date_range(period_obj.date_start, period_obj.date_stop) self.date_lst = date_array self.date_lst.sort() - def transform_date_into_date_array(self,data): - return_array = self.date_range(data['form']['date1'],data['form']['date2']) + def transform_date_into_date_array(self, data): + return_array = self.date_range(data['form']['date1'], data['form']['date2']) self.date_lst = return_array self.date_lst.sort() - def transform_both_into_date_array(self,data): + def transform_both_into_date_array(self, data): final_date_array = [] date_start_date = data['form']['date1'] date_stop_date = data['form']['date2'] @@ -96,7 +95,7 @@ class partner_balance(report_sxw.rml_parse): if periods_id: for period_id in periods_id: period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id) - date_array = date_array + self.date_range(period_obj.date_start,period_obj.date_stop) + date_array = date_array + self.date_range(period_obj.date_start, period_obj.date_stop) period_start_date = date_array[0] period_stop_date = date_array[-1] @@ -110,15 +109,15 @@ class partner_balance(report_sxw.rml_parse): else : stop_date = date_stop_date - final_date_array = final_date_array + self.date_range(start_date,stop_date) + final_date_array = final_date_array + self.date_range(start_date, stop_date) self.date_lst = final_date_array self.date_lst.sort() else : - final_date_array = final_date_array + self.date_range(date_start_date,date_stop_date) + final_date_array = final_date_array + self.date_range(date_start_date, date_stop_date) self.date_lst = final_date_array self.date_lst.sort() - def transform_none_into_date_array(self,data): + def transform_none_into_date_array(self, data): sql = "SELECT min(date) as start_date from account_move_line" self.cr.execute(sql) @@ -130,12 +129,12 @@ class partner_balance(report_sxw.rml_parse): array = [] - array = array + self.date_range(start_date,stop_date) + array = array + self.date_range(start_date, stop_date) self.date_lst = array self.date_lst.sort() - def comma_me(self,amount): + def comma_me(self, amount): if type(amount) is float : amount = str('%.2f'%amount) else : @@ -166,28 +165,24 @@ class partner_balance(report_sxw.rml_parse): self.transform_both_into_date_array(data) - ## - self.date_lst_string ='' - if self.date_lst: - self.date_lst_string = '\'' + '\',\''.join(map(str, self.date_lst)) + '\'' ## Compute Code account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') # if (data['form']['result_selection'] == 'customer' ): - self.ACCOUNT_TYPE = ['receivable'] + self.ACCOUNT_TYPE = ('receivable',) elif (data['form']['result_selection'] == 'supplier'): - self.ACCOUNT_TYPE = ['payable'] + self.ACCOUNT_TYPE = ('payable',) else: - self.ACCOUNT_TYPE = ['payable','receivable'] + self.ACCOUNT_TYPE = ('payable','receivable') # self.cr.execute("SELECT a.id " \ "FROM account_account a " \ "LEFT JOIN account_account_type t " \ "ON (a.type = t.code) " \ "WHERE a.company_id = %s " \ - "AND a.type =ANY(%s) "\ - "AND a.active", (data['form']['company_id'],self.ACCOUNT_TYPE,)) + "AND a.type IN %s " \ + "AND a.active", (data['form']['company_id'], self.ACCOUNT_TYPE)) self.account_ids = [a for (a,) in self.cr.fetchall()] super(partner_balance, self).set_context(objects, data, ids, report_type) @@ -197,7 +192,7 @@ class partner_balance(report_sxw.rml_parse): account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') full_account = [] result_tmp = 0.0 - if self.date_lst_string: + if self.date_lst: self.cr.execute( "SELECT p.ref,l.account_id,ac.name as account_name,ac.code as code ,p.name, sum(debit) as debit, sum(credit) as credit, " \ "CASE WHEN sum(debit) > sum(credit) " \ @@ -211,16 +206,17 @@ class partner_balance(report_sxw.rml_parse): "(SELECT sum(debit-credit) " \ "FROM account_move_line l " \ "WHERE partner_id = p.id " \ - "AND l.date IN (" + self.date_lst_string + ") " \ + "AND l.date IN %s " \ "AND blocked = TRUE " \ ") AS enlitige " \ "FROM account_move_line l LEFT JOIN res_partner p ON (l.partner_id=p.id) " \ "JOIN account_account ac ON (l.account_id = ac.id)" \ - "WHERE ac.type =ANY(%s) " - "AND l.date IN (" + self.date_lst_string + ") " \ - "AND ac.company_id = %s" \ + "WHERE ac.type IN %s " \ + "AND l.date IN %s " \ + "AND ac.company_id = %s " \ "GROUP BY p.id, p.ref, p.name,l.account_id,ac.name,ac.code " \ - "ORDER BY l.account_id,p.name",(self.ACCOUNT_TYPE,data['form']['company_id'],)) + "ORDER BY l.account_id,p.name", + (tuple(self.date_lst), self.ACCOUNT_TYPE, tuple(self.date_lst), data['form']['company_id'])) res = self.cr.dictfetchall() for r in res: full_account.append(r) @@ -228,7 +224,7 @@ class partner_balance(report_sxw.rml_parse): ## We will now compute Total return self._add_subtotal(full_account) - def _add_subtotal(self,cleanarray): + def _add_subtotal(self, cleanarray): i=0 completearray = [] tot_debit = 0.0 @@ -347,75 +343,79 @@ class partner_balance(report_sxw.rml_parse): return completearray - def _sum_debit(self,data): + def _sum_debit(self, data): if not self.ids: return 0.0 account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') result_tmp = 0.0 temp_res = 0.0 - if self.date_lst_string: + if self.date_lst: self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line AS l " \ - "WHERE l.account_id =ANY(%s)" \ - "AND l.date IN (" + self.date_lst_string + ")" ,(self.account_ids,)) + "WHERE l.account_id IN %s" \ + "AND l.date IN %s", + (tuple(self.account_ids), tuple(self.date_lst))) temp_res = float(self.cr.fetchone()[0] or 0.0) result_tmp = result_tmp + temp_res return result_tmp - def _sum_credit(self,data): + def _sum_credit(self, data): if not self.ids: return 0.0 account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') result_tmp = 0.0 temp_res = 0.0 - if self.date_lst_string: + if self.date_lst: self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line AS l " \ - "WHERE l.account_id =ANY(%s)" \ - "AND l.date IN (" + self.date_lst_string + ")" ,(self.account_ids,)) + "WHERE l.account_id IN %s" \ + "AND l.date IN %s", + (tuple(self.account_ids), tuple(self.date_lst),)) temp_res = float(self.cr.fetchone()[0] or 0.0) result_tmp = result_tmp + temp_res return result_tmp - def _sum_litige(self,data): + def _sum_litige(self, data): if not self.ids: return 0.0 account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') result_tmp = 0.0 temp_res = 0.0 - if self.date_lst_string: + if self.date_lst: self.cr.execute( "SELECT sum(debit-credit) " \ "FROM account_move_line AS l " \ - "WHERE l.account_id =ANY(%s)" \ - "AND l.date IN (" + self.date_lst_string + ")"\ - "AND l.blocked=TRUE " ,(self.account_ids,)) + "WHERE l.account_id IN %s" \ + "AND l.date IN %s " \ + "AND l.blocked=TRUE ", + (tuple(self.account_ids), tuple(self.date_lst),)) temp_res = float(self.cr.fetchone()[0] or 0.0) result_tmp = result_tmp + temp_res return result_tmp - def _sum_sdebit(self,data): + def _sum_sdebit(self, data): if not self.ids: return 0.0 account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') result_tmp = 0.0 a = 0.0 - if self.date_lst_string: + if self.date_lst: self.cr.execute( "SELECT CASE WHEN sum(debit) > sum(credit) " \ "THEN sum(debit) - sum(credit) " \ "ELSE 0 " \ "END " \ "FROM account_move_line AS l " \ - "WHERE l.account_id =ANY(%s)" \ - "AND l.date IN (" + self.date_lst_string + ")" \ - "GROUP BY l.partner_id",(self.account_ids,)) + "WHERE l.account_id IN %s" \ + "AND l.date IN %s " \ + "GROUP BY l.partner_id", + (tuple(self.account_ids), tuple(self.date_lst),)) a = self.cr.fetchone()[0] if self.cr.fetchone() != None: @@ -425,7 +425,7 @@ class partner_balance(report_sxw.rml_parse): return result_tmp - def _sum_scredit(self,data): + def _sum_scredit(self, data): if not self.ids: return 0.0 @@ -433,16 +433,17 @@ class partner_balance(report_sxw.rml_parse): result_tmp = 0.0 a = 0.0 - if self.date_lst_string: + if self.date_lst: self.cr.execute( "SELECT CASE WHEN sum(debit) < sum(credit) " \ "THEN sum(credit) - sum(debit) " \ "ELSE 0 " \ "END " \ "FROM account_move_line AS l " \ - "WHERE l.account_id =ANY(%s)" \ - "AND l.date IN (" + self.date_lst_string + ")" \ - "GROUP BY l.partner_id",(self.account_ids,)) + "WHERE l.account_id IN %s" \ + "AND l.date IN %s " \ + "GROUP BY l.partner_id", + (tuple(self.account_ids), tuple(self.date_lst),)) a = self.cr.fetchone()[0] or 0.0 if self.cr.fetchone() != None: @@ -453,11 +454,11 @@ class partner_balance(report_sxw.rml_parse): return result_tmp - def _solde_balance_debit(self,data): + def _solde_balance_debit(self, data): debit, credit = self._sum_debit(data), self._sum_credit(data) return debit > credit and debit - credit - def _solde_balance_credit(self,data): + def _solde_balance_credit(self, data): debit, credit = self._sum_debit(data), self._sum_credit(data) return credit > debit and credit - debit diff --git a/addons/account/report/tax_report.py b/addons/account/report/tax_report.py index daa010a0453..2075b1f139b 100644 --- a/addons/account/report/tax_report.py +++ b/addons/account/report/tax_report.py @@ -28,7 +28,6 @@ from report import report_sxw class tax_report(rml_parse.rml_parse): _name = 'report.account.vat.declaration' def __init__(self, cr, uid, name, context={}): - print "tax______init", name, context super(tax_report, self).__init__(cr, uid, name, context=context) self.localcontext.update({ 'time': time, @@ -86,9 +85,10 @@ class tax_report(rml_parse.rml_parse): def _get_period(self, period_id, context={}): return self.pool.get('account.period').browse(self.cr, self.uid, period_id, context=context).name - def _get_general(self, tax_code_id,period_list ,company_id, based_on, context={}): + def _get_general(self, tax_code_id, period_list ,company_id, based_on, context={}): res=[] obj_account = self.pool.get('account.account') + periods_ids = tuple(period_list) if based_on == 'payments': self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \ SUM(line.debit) AS debit, \ @@ -107,11 +107,11 @@ class tax_report(rml_parse.rml_parse): AND line.account_id = account.id \ AND account.company_id = %s \ AND move.id = line.move_id \ - AND line.period_id =ANY(%s) \ + AND line.period_id IN %s \ AND ((invoice.state = %s) \ OR (invoice.id IS NULL)) \ GROUP BY account.id,account.name,account.code', ('draft', tax_code_id, - company_id, period_list, 'paid',)) + company_id, periods_ids, 'paid',)) else : self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \ @@ -127,10 +127,10 @@ class tax_report(rml_parse.rml_parse): AND line.tax_code_id = %s \ AND line.account_id = account.id \ AND account.company_id = %s \ - AND line.period_id =ANY(%s)\ + AND line.period_id IN %s\ AND account.active \ GROUP BY account.id,account.name,account.code', ('draft', tax_code_id, - company_id, period_list,)) + company_id, periods_ids,)) res = self.cr.dictfetchall() #AND line.period_id IN ('+ period_sql_list +') \ diff --git a/addons/account/report/third_party_ledger.py b/addons/account/report/third_party_ledger.py index c10fcb33313..07e3dc39b18 100644 --- a/addons/account/report/third_party_ledger.py +++ b/addons/account/report/third_party_ledger.py @@ -42,7 +42,7 @@ class third_party_ledger(rml_parse.rml_parse): 'get_currency': self._get_currency, 'comma_me' : self.comma_me, }) - def date_range(self,start,end): + def date_range(self, start, end): if not start or not end: return [] start = datetime.date.fromtimestamp(time.mktime(time.strptime(start,"%Y-%m-%d"))) @@ -57,7 +57,7 @@ class third_party_ledger(rml_parse.rml_parse): return full_str_date # - def transform_period_into_date_array(self,data): + def transform_period_into_date_array(self, data): ## Get All Period Date if not data['form']['periods']: periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',data['form']['fiscalyear'])]) @@ -66,12 +66,12 @@ class third_party_ledger(rml_parse.rml_parse): date_array = [] for period_id in periods_id: period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id) - date_array = date_array + self.date_range(period_obj.date_start,period_obj.date_stop) + date_array = date_array + self.date_range(period_obj.date_start, period_obj.date_stop) self.date_lst = date_array self.date_lst.sort() def transform_date_into_date_array(self,data): - return_array = self.date_range(data['form']['date1'],data['form']['date2']) + return_array = self.date_range(data['form']['date1'], data['form']['date2']) self.date_lst = return_array self.date_lst.sort() @@ -84,7 +84,7 @@ class third_party_ledger(rml_parse.rml_parse): date_array = [] for period_id in periods_id: period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id) - date_array = date_array + self.date_range(period_obj.date_start,period_obj.date_stop) + date_array = date_array + self.date_range(period_obj.date_start, period_obj.date_stop) period_start_date = date_array[0] date_start_date = data['form']['date1'] @@ -105,7 +105,7 @@ class third_party_ledger(rml_parse.rml_parse): self.date_lst = final_date_array self.date_lst.sort() - def transform_none_into_date_array(self,data): + def transform_none_into_date_array(self, data): sql = "SELECT min(date) as start_date from account_move_line" self.cr.execute(sql) start_date = self.cr.fetchone()[0] @@ -118,7 +118,7 @@ class third_party_ledger(rml_parse.rml_parse): self.date_lst.sort() - def comma_me(self,amount): + def comma_me(self, amount): if type(amount) is float : amount = str('%.2f'%amount) else : @@ -143,7 +143,7 @@ class third_party_ledger(rml_parse.rml_parse): ## Si on imprime depuis les partenaires if ids: #PARTNER_REQUEST = "AND line.partner_id IN (" + ','.join(map(str, ids)) + ")" - PARTNER_REQUEST = "AND line.partner_id =ANY(%s)" %ids + PARTNER_REQUEST = "AND line.partner_id IN %s",(tuple(ids),) # Transformation des date # # @@ -179,8 +179,8 @@ class third_party_ledger(rml_parse.rml_parse): "LEFT JOIN account_account_type t " \ "ON (a.type=t.code) " \ "WHERE a.company_id = %s " \ - 'AND a.type =ANY(%s)' \ - "AND a.active", (data['form']['company_id'],self.ACCOUNT_TYPE,)) + 'AND a.type IN %s' \ + "AND a.active", (data['form']['company_id'],tuple(self.ACCOUNT_TYPE))) self.account_ids = [a for (a,) in self.cr.fetchall()] account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') @@ -196,11 +196,11 @@ class third_party_ledger(rml_parse.rml_parse): "AND line.date >= %s " \ "AND line.date <= %s " \ "AND line.reconcile_id IS NULL " \ - "AND line.account_id =ANY(%s)" \ + "AND line.account_id IN %s" \ " " + PARTNER_REQUEST + " " \ "AND account.company_id = %s " \ "AND account.active " , - (self.date_lst[0],self.date_lst[len(self.date_lst)-1],self.account_ids,data['form']['company_id'],)) + (self.date_lst[0],self.date_lst[len(self.date_lst)-1],tuple(self.account_ids),data['form']['company_id'],)) # else: # # self.cr.execute( @@ -261,11 +261,11 @@ class third_party_ledger(rml_parse.rml_parse): "LEFT JOIN account_journal j " \ "ON (l.journal_id = j.id) " \ "WHERE l.partner_id = %s " \ - "AND l.account_id =ANY(%s)"\ + "AND l.account_id IN %s"\ "AND l.date IN (" + self.date_lst_string + ")" " " + RECONCILE_TAG + " "\ "ORDER BY l.id", - (partner.id,self.account_ids,)) + (partner.id, tuple(self.account_ids),)) res = self.cr.dictfetchall() sum = 0.0 for r in res: @@ -275,7 +275,7 @@ class third_party_ledger(rml_parse.rml_parse): return full_account - def _sum_debit_partner(self, partner,data): + def _sum_debit_partner(self, partner, data): account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') result_tmp = 0.0 @@ -288,10 +288,10 @@ class third_party_ledger(rml_parse.rml_parse): "SELECT sum(debit) " \ "FROM account_move_line " \ "WHERE partner_id = %s " \ - "AND account_id =ANY(%s)" \ + "AND account_id IN %s" \ "AND reconcile_id IS NULL " \ "AND date < %s " , - (partner.id, self.account_ids,self.date_lst[0],)) + (partner.id, tuple(self.account_ids), self.date_lst[0],)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 @@ -303,10 +303,10 @@ class third_party_ledger(rml_parse.rml_parse): "SELECT sum(debit) " \ "FROM account_move_line " \ "WHERE partner_id = %s " \ - "AND account_id =ANY(%s)" \ + "AND account_id IN %s" \ " " + RECONCILE_TAG + " " \ "AND date IN (" + self.date_lst_string + ")" , - (partner.id,self.account_ids,)) + (partner.id,tuple(self.account_ids),)) contemp = self.cr.fetchone() if contemp != None: @@ -315,7 +315,7 @@ class third_party_ledger(rml_parse.rml_parse): result_tmp = result_tmp + 0.0 return result_tmp - def _sum_credit_partner(self, partner,data): + def _sum_credit_partner(self, partner, data): account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') result_tmp = 0.0 if data['form']['reconcil'] : @@ -327,10 +327,10 @@ class third_party_ledger(rml_parse.rml_parse): "SELECT sum(credit) " \ "FROM account_move_line " \ "WHERE partner_id=%s " \ - "AND account_id =ANY(%s)" \ + "AND account_id IN %s" \ "AND reconcile_id IS NULL " \ "AND date < %s " , - (partner.id,self.account_ids,self.date_lst[0],)) + (partner.id, tuple(self.account_ids), self.date_lst[0],)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 @@ -342,10 +342,10 @@ class third_party_ledger(rml_parse.rml_parse): "SELECT sum(credit) " \ "FROM account_move_line " \ "WHERE partner_id=%s " \ - "AND account_id =ANY(%s)" \ + "AND account_id IN %s" \ " " + RECONCILE_TAG + " " \ "AND date IN (" + self.date_lst_string + ")", - (partner.id,self.account_ids,)) + (partner.id, tuple(self.account_ids),)) contemp = self.cr.fetchone() if contemp != None: @@ -354,7 +354,7 @@ class third_party_ledger(rml_parse.rml_parse): result_tmp = result_tmp + 0.0 return result_tmp - def _sum_debit(self,data): + def _sum_debit(self, data): if not self.ids: return 0.0 account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') @@ -367,11 +367,11 @@ class third_party_ledger(rml_parse.rml_parse): self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line " \ - "WHERE partner_id =ANY(%s)" \ - "AND account_id =ANY(%s)" \ + "WHERE partner_id IN %s" \ + "AND account_id IN %s" \ "AND reconcile_id IS NULL " \ "AND date < %s " , - (self.partner_ids,self.account_ids,self.date_lst[0],)) + (tuple(self.partner_ids), tuple(self.account_ids), self.date_lst[0],)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 @@ -382,10 +382,10 @@ class third_party_ledger(rml_parse.rml_parse): self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line " \ - "WHERE partner_id =ANY(%s)" \ - "AND account_id =ANY(%s)" \ + "WHERE partner_id IN %s" \ + "AND account_id IN %s" \ " " + RECONCILE_TAG + " " \ - "AND date IN (" + self.date_lst_string + ")",(self.partner_ids,self.account_ids,)) + "AND date IN (" + self.date_lst_string + ")",(tuple(self.partner_ids), tuple(self.account_ids),)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 @@ -395,7 +395,7 @@ class third_party_ledger(rml_parse.rml_parse): return result_tmp - def _sum_credit(self,data): + def _sum_credit(self, data): if not self.ids: return 0.0 account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') @@ -408,11 +408,11 @@ class third_party_ledger(rml_parse.rml_parse): self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line " \ - "WHERE partner_id =ANY(%s)" \ - "AND account_id =ANY(%s)" \ + "WHERE partner_id IN %s" \ + "AND account_id IN %s" \ "AND reconcile_id IS NULL " \ "AND date < %s " , - (self.partner_ids,self.account_ids,self.date_lst[0],)) + (tuple(self.partner_ids), tuple(self.account_ids), self.date_lst[0],)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 @@ -423,10 +423,10 @@ class third_party_ledger(rml_parse.rml_parse): self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line " \ - "WHERE partner_id =ANY(%s)" \ - "AND account_id =ANY(%s)" \ + "WHERE partner_id IN %s" \ + "AND account_id IN %s" \ " " + RECONCILE_TAG + " " \ - "AND date IN (" + self.date_lst_string + ")",(self.partner_ids,self.account_ids,)) + "AND date IN (" + self.date_lst_string + ")",(tuple(self.partner_ids), tuple(self.account_ids),)) contemp = self.cr.fetchone() if contemp != None: result_tmp = contemp[0] or 0.0 diff --git a/addons/account/report/voucher_print.py b/addons/account/report/voucher_print.py index 1eefd995df7..829f0f7e397 100755 --- a/addons/account/report/voucher_print.py +++ b/addons/account/report/voucher_print.py @@ -36,10 +36,10 @@ class report_voucher_move(report_sxw.rml_parse): }) self.user=uid - def convert(self,amount): - user_id = self.pool.get('res.users').browse(self.cr, self.user,[self.user])[0] + def convert(self, amount): + user_id = self.pool.get('res.users').browse(self.cr, self.user, [self.user])[0] cur = user_id.company_id.currency_id.name - amt_en = amount_to_text_en.amount_to_text(amount,'en',cur); + amt_en = amount_to_text_en.amount_to_text(amount, 'en', cur); return amt_en def debit(self, move_ids): diff --git a/addons/account/wizard/account_automatic_reconcile.py b/addons/account/wizard/account_automatic_reconcile.py index a1798ae9cbf..1cf74a342a7 100644 --- a/addons/account/wizard/account_automatic_reconcile.py +++ b/addons/account/wizard/account_automatic_reconcile.py @@ -214,7 +214,7 @@ class account_automatic_reconcile(osv.osv_memory): # add the number of transactions for partners who have only one # unreconciled transactions to the unreconciled count - partner_filter = partner_ids and 'AND partner_id not in (%s)' % ','.join(map(str, filter(None, partner_ids))) or '' + partner_filter = partner_ids and 'AND partner_id NOT IN %s',(tuple(partner_ids),) or '' cr.execute( "SELECT count(*) " \ "FROM account_move_line " \ diff --git a/addons/account/wizard/account_balance_report.py b/addons/account/wizard/account_balance_report.py index b131ff3123a..5d02f9fa972 100644 --- a/addons/account/wizard/account_balance_report.py +++ b/addons/account/wizard/account_balance_report.py @@ -117,7 +117,7 @@ class account_balance_report(osv.osv_memory): context = {} sql = """ SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """ - cr.execute(sql,(data['form']['date_from'],)) + cr.execute(sql, (data['form']['date_from'],)) res = cr.dictfetchall() if res: diff --git a/addons/account/wizard/account_chart.py b/addons/account/wizard/account_chart.py index af3f0c26511..440dbd407ec 100644 --- a/addons/account/wizard/account_chart.py +++ b/addons/account/wizard/account_chart.py @@ -53,12 +53,12 @@ class account_chart(osv.osv_memory): act_obj = self.pool.get('ir.actions.act_window') data = self.read(cr, uid, ids, [], context=context)[0] result = mod_obj._get_id(cr, uid, 'account', 'action_account_tree') - id = mod_obj.read(cr, uid, [result], ['res_id'],context=context)[0]['res_id'] + id = mod_obj.read(cr, uid, [result], ['res_id'], context=context)[0]['res_id'] result = act_obj.read(cr, uid, [id], context=context)[0] result['context'] = str({'fiscalyear': data['fiscalyear'], \ 'state': data['target_move']}) if data['fiscalyear']: - result['name'] += ':' + self.pool.get('account.fiscalyear').read(cr, uid, [data['fiscalyear']],context=context)[0]['code'] + result['name'] += ':' + self.pool.get('account.fiscalyear').read(cr, uid, [data['fiscalyear']], context=context)[0]['code'] return result _defaults = { diff --git a/addons/account/wizard/account_fiscalyear_close.py b/addons/account/wizard/account_fiscalyear_close.py index c71c85ea4a3..56b6410e3a2 100644 --- a/addons/account/wizard/account_fiscalyear_close.py +++ b/addons/account/wizard/account_fiscalyear_close.py @@ -160,10 +160,10 @@ class account_fiscalyear_close(osv.osv_memory): 'WHERE b.account_id = %s ' \ 'AND b.reconcile_id is NOT NULL ' \ 'AND a.reconcile_id = b.reconcile_id ' \ - 'AND b.period_id =ANY(%s)'\ - 'AND a.period_id =ANY(%s)' \ + 'AND b.period_id IN %s'\ + 'AND a.period_id IN %s' \ 'ORDER BY id ' \ - 'LIMIT %s OFFSET %s', (account.id,period_ids,periods_fy2,limit, offset)) + 'LIMIT %s OFFSET %s', (account.id,tuple(period_ids),tuple(periods_fy2),limit, offset)) result = cr.dictfetchall() if not result: break diff --git a/addons/account/wizard/account_fiscalyear_close_state.py b/addons/account/wizard/account_fiscalyear_close_state.py index f42857eb13c..403abbcbe12 100644 --- a/addons/account/wizard/account_fiscalyear_close_state.py +++ b/addons/account/wizard/account_fiscalyear_close_state.py @@ -43,7 +43,7 @@ class account_fiscalyear_close_state(osv.osv_memory): @param ids: List of Account fiscalyear close state’s IDs """ - for data in self.read(cr, uid, ids,context=context): + for data in self.read(cr, uid, ids, context=context): if not data['sure']: raise osv.except_osv(_('UserError'), _('Closing of states \ cancelled, please check the box !')) diff --git a/addons/account/wizard/account_general_ledger_report.py b/addons/account/wizard/account_general_ledger_report.py index 9809f4aad89..ad5e74786b0 100644 --- a/addons/account/wizard/account_general_ledger_report.py +++ b/addons/account/wizard/account_general_ledger_report.py @@ -96,7 +96,7 @@ class account_general_ledger_report(osv.osv_memory): context = {} sql = """ SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """ - cr.execute(sql,(data['form']['date_from'],)) + cr.execute(sql, (data['form']['date_from'],)) res = cr.dictfetchall() if res: if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']): diff --git a/addons/account/wizard/account_invoice_refund.py b/addons/account/wizard/account_invoice_refund.py index 9396209ccc6..41baac36f89 100644 --- a/addons/account/wizard/account_invoice_refund.py +++ b/addons/account/wizard/account_invoice_refund.py @@ -61,7 +61,7 @@ class account_invoice_refund(osv.osv_memory): date = False period = False description = False - for inv in inv_obj.browse(cr, uid, context['active_ids'],context=context): + for inv in inv_obj.browse(cr, uid, context['active_ids'], context=context): if inv.state in ['draft', 'proforma2', 'cancel']: raise osv.except_osv(_('Error !'), _('Can not %s draft/proforma/cancel invoice.') % (mode)) if form['period'] : @@ -81,7 +81,7 @@ class account_invoice_refund(osv.osv_memory): from account_period where date(%s) between date_start AND date_stop \ and company_id = %s limit 1 """, - (date, self.pool.get('res.users').browse(cr, uid, uid,context=context).company_id.id,)) + (date, self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id,)) else: cr.execute("""SELECT id from account_period where date(%s) @@ -102,7 +102,7 @@ class account_invoice_refund(osv.osv_memory): _('No Period found on Invoice!')) refund_id = inv_obj.refund(cr, uid, [inv.id], date, period, description) - refund = inv_obj.browse(cr, uid, refund_id[0],context=context) + refund = inv_obj.browse(cr, uid, refund_id[0], context=context) inv_obj.write(cr, uid, [refund.id], {'date_due': date, 'check_total': inv.check_total}) inv_obj.button_compute(cr, uid, refund_id) @@ -118,7 +118,7 @@ class account_invoice_refund(osv.osv_memory): reconcile_obj.unlink(cr, uid, line.reconcile_id.id) wf_service.trg_validate(uid, 'account.invoice', \ refund.id, 'invoice_open', cr) - refund = inv_obj.browse(cr, uid, refund_id[0],context=context) + refund = inv_obj.browse(cr, uid, refund_id[0], context=context) for tmpline in refund.move_id.line_id : if tmpline.account_id.id == inv.account_id.id : to_reconcile_ids[tmpline.account_id.id].append(tmpline.id) @@ -136,13 +136,13 @@ class account_invoice_refund(osv.osv_memory): 'partner_insite', 'partner_contact', 'partner_ref', 'payment_term', 'account_id', 'currency_id', 'invoice_line', 'tax_line', - 'journal_id', 'period_id'],context=context) + 'journal_id', 'period_id'], context=context) invoice = invoice[0] del invoice['id'] - invoice_lines = self.pool.get('account.invoice.line').read(cr, uid, invoice['invoice_line'],context=context) + invoice_lines = self.pool.get('account.invoice.line').read(cr, uid, invoice['invoice_line'], context=context) invoice_lines = inv_obj._refund_cleanup_lines(cr, uid, invoice_lines) tax_lines = self.pool.get('account.invoice.tax').read( - cr, uid, invoice['tax_line'],context=context) + cr, uid, invoice['tax_line'], context=context) tax_lines = inv_obj._refund_cleanup_lines(cr, uid, tax_lines) invoice.update({ @@ -176,8 +176,8 @@ class account_invoice_refund(osv.osv_memory): else: xml_id = 'action_invoice_tree4' result = mod_obj._get_id(cr, uid, 'account', xml_id) - id = mod_obj.read(cr, uid, result, ['res_id'],context=context)['res_id'] - result = act_obj.read(cr, uid, id,context=context) + id = mod_obj.read(cr, uid, result, ['res_id'], context=context)['res_id'] + result = act_obj.read(cr, uid, id, context=context) result['res_id'] = created_inv return result diff --git a/addons/account/wizard/account_move_bank_reconcile.py b/addons/account/wizard/account_move_bank_reconcile.py index c339ed18831..b103f0c55e7 100644 --- a/addons/account/wizard/account_move_bank_reconcile.py +++ b/addons/account/wizard/account_move_bank_reconcile.py @@ -40,7 +40,7 @@ class account_move_bank_reconcile(osv.osv_memory): @param ids: account move bank reconcile’s ID or list of IDs @return: dictionary of Open account move line on given journal_id. """ - 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 \ from account_journal where id=%s', (data['journal_id'],)) account_id = cr.fetchone()[0] diff --git a/addons/account/wizard/account_open_closed_fiscalyear.py b/addons/account/wizard/account_open_closed_fiscalyear.py index 552e630125d..381c4c44aae 100644 --- a/addons/account/wizard/account_open_closed_fiscalyear.py +++ b/addons/account/wizard/account_open_closed_fiscalyear.py @@ -35,18 +35,9 @@ class account_open_closed_fiscalyear(osv.osv_memory): if not data_fyear.end_journal_period_id: raise osv.except_osv(_('Error'), _('No journal for ending writing has been defined for the fiscal year')) period_journal = data_fyear.end_journal_period_id - ids_move = self.pool.get('account.move').search(cr,uid,[('journal_id','=',period_journal.journal_id.id),('period_id','=',period_journal.period_id.id)]) + ids_move = self.pool.get('account.move').search(cr, uid, [('journal_id','=',period_journal.journal_id.id),('period_id','=',period_journal.period_id.id)]) if ids_move: - cr.execute('delete from account_move where id =ANY(%s)',(ids_move,)) - #cr.execute('UPDATE account_journal_period ' \ - # 'SET state = %s ' \ - # 'WHERE period_id IN (SELECT id FROM account_period WHERE fiscalyear_id = %s)', - # ('draft',data_fyear)) - #cr.execute('UPDATE account_period SET state = %s ' \ - # 'WHERE fiscalyear_id = %s', ('draft',data_fyear)) - #cr.execute('UPDATE account_fiscalyear ' \ - # 'SET state = %s, end_journal_period_id = null '\ - # 'WHERE id = %s', ('draft',data_fyear)) + cr.execute('delete from account_move where id IN %s', (tuple(ids_move),)) return {} account_open_closed_fiscalyear() diff --git a/addons/account/wizard/account_partner_balance_report.py b/addons/account/wizard/account_partner_balance_report.py index 0c330ed6d1e..c6d82128256 100644 --- a/addons/account/wizard/account_partner_balance_report.py +++ b/addons/account/wizard/account_partner_balance_report.py @@ -72,7 +72,6 @@ class account_partner_balance(osv.osv_memory): 'model': 'res.partner', 'form': self.read(cr, uid, ids, [])[0], } - if data['form']['state'] == 'bydate' : return self._check_date(cr, uid, data, context) if data['form']['state'] == 'byperiod': @@ -89,7 +88,7 @@ class account_partner_balance(osv.osv_memory): def _check_date(self, cr, uid, data, context): sql = """ SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """ - cr.execute(sql,(data['form']['date1'],)) + cr.execute(sql, (data['form']['date1'],)) res = cr.dictfetchall() if res: if (data['form']['date2'] > res[0]['date_stop'] or data['form']['date2'] < res[0]['date_start']): diff --git a/addons/account/wizard/account_pay_invoice.py b/addons/account/wizard/account_pay_invoice.py index a3a57536a67..2d59c556ba0 100644 --- a/addons/account/wizard/account_pay_invoice.py +++ b/addons/account/wizard/account_pay_invoice.py @@ -142,7 +142,7 @@ class account_invoice_pay(osv.osv_memory): cur_obj = self.pool.get('res.currency') if context is None: context = {} - data = self.read(cr, uid, ids,context=context)[0] + data = self.read(cr, uid, ids, context=context)[0] writeoff_account_id = False writeoff_journal_id = False comment = False diff --git a/addons/account/wizard/account_reconcile.py b/addons/account/wizard/account_reconcile.py index be0ebc40677..9ace53cc6fa 100644 --- a/addons/account/wizard/account_reconcile.py +++ b/addons/account/wizard/account_reconcile.py @@ -45,9 +45,9 @@ class account_move_line_reconcile(osv.osv_memory): _description = 'Account move line reconcile' _columns = { 'trans_nbr': fields.integer('# of Transaction', readonly=True), - 'credit': fields.float('Credit amount',readonly=True), - 'debit': fields.float('Debit amount',readonly=True), - 'writeoff': fields.float('Write-Off amount',readonly=True), + 'credit': fields.float('Credit amount', readonly=True), + 'debit': fields.float('Debit amount', readonly=True), + 'writeoff': fields.float('Write-Off amount', readonly=True), } def default_get(self, cr, uid, fields, context=None): diff --git a/addons/account/wizard/account_statement_from_invoice.py b/addons/account/wizard/account_statement_from_invoice.py index 097d11c1b83..00462e8fb26 100644 --- a/addons/account/wizard/account_statement_from_invoice.py +++ b/addons/account/wizard/account_statement_from_invoice.py @@ -41,7 +41,7 @@ class account_statement_from_invoice_lines(osv.osv_memory): currency_obj = self.pool.get('res.currency') statement_reconcile_obj = self.pool.get('account.bank.statement.reconcile') - data = self.read(cr, uid, ids,context=context)[0] + data = self.read(cr, uid, ids, context=context)[0] line_ids = data['line_ids'] line_date = time.strftime('%Y-%m-%d') @@ -98,8 +98,8 @@ class account_statement_from_invoice(osv.osv_memory): _description = "Entries by Statement from Invoices" _columns = { 'date': fields.date('Date payment',required=True), - 'journal_ids': fields.many2many('account.journal','account_journal_relation','account_id','journal_id','Journal'), - 'line_ids': fields.many2many('account.move.line','account_move_line_relation','move_id','line_id','Invoices'), + 'journal_ids': fields.many2many('account.journal', 'account_journal_relation', 'account_id', 'journal_id', 'Journal'), + 'line_ids': fields.many2many('account.move.line', 'account_move_line_relation', 'move_id', 'line_id', 'Invoices'), } _defaults = { 'date':lambda *a: time.strftime('%Y-%m-%d'), @@ -113,7 +113,7 @@ class account_statement_from_invoice(osv.osv_memory): mod_obj = self.pool.get('ir.model.data') statement_id = 'statement_id' in context and context['statement_id'] - data = self.read(cr, uid, ids,context=context)[0] + data = self.read(cr, uid, ids, context=context)[0] statement = statement_obj.browse(cr, uid, statement_id, context=context) args_move_line = [] repeated_move_line_ids = [] @@ -126,7 +126,7 @@ class account_statement_from_invoice(osv.osv_memory): args_move_line.append(('partner_id','=',st_line.partner_id.id)) args_move_line.append(('account_id','=',st_line.account_id.id)) - move_line_id = line_obj.search(cr, uid, args_move_line,context=context) + move_line_id = line_obj.search(cr, uid, args_move_line, context=context) if move_line_id: repeated_move_line_ids += move_line_id diff --git a/addons/account/wizard/account_third_party_ledger.py b/addons/account/wizard/account_third_party_ledger.py index 7a6514e17c2..daff801f3bd 100644 --- a/addons/account/wizard/account_third_party_ledger.py +++ b/addons/account/wizard/account_third_party_ledger.py @@ -112,7 +112,7 @@ class account_partner_ledger(osv.osv_memory): context = {} sql = """ SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """ - cr.execute(sql,(data['form']['date1'],)) + cr.execute(sql, (data['form']['date1'],)) res = cr.dictfetchall() if res: if (data['form']['date2'] > res[0]['date_stop'] or data['form']['date2'] < res[0]['date_start']): diff --git a/addons/account/wizard/account_use_model.py b/addons/account/wizard/account_use_model.py index 28a892a398b..04647dc4a26 100644 --- a/addons/account/wizard/account_use_model.py +++ b/addons/account/wizard/account_use_model.py @@ -29,7 +29,7 @@ class account_use_model(osv.osv_memory): _name = 'account.use.model' _description = 'Use model' _columns = { - 'model': fields.many2many('account.model', 'account_use_model_relation','account_id','model_id','Account Model'), + 'model': fields.many2many('account.model', 'account_use_model_relation', 'account_id', 'model_id', 'Account Model'), } def create_entries(self, cr, uid, ids, context=None): @@ -41,12 +41,12 @@ class account_use_model(osv.osv_memory): if context is None: context = {} - data = self.read(cr, uid, ids,context=context)[0] + data = self.read(cr, uid, ids, context=context)[0] record_id = context and context.get('model_line', False) or False if record_id: - data_model = account_model_obj.browse(cr,uid,data['model']) + data_model = account_model_obj.browse(cr, uid, data['model']) else: - data_model = account_model_obj.browse(cr,uid,context['active_ids']) + data_model = account_model_obj.browse(cr, uid, context['active_ids']) move_ids = [] for model in data_model: period_id = account_period_obj.find(cr, uid, context=context) diff --git a/addons/account_analytic_analysis/account_analytic_analysis.py b/addons/account_analytic_analysis/account_analytic_analysis.py index 742ef74cc84..dc2ada7aea9 100644 --- a/addons/account_analytic_analysis/account_analytic_analysis.py +++ b/addons/account_analytic_analysis/account_analytic_analysis.py @@ -32,31 +32,29 @@ class account_analytic_account(osv.osv): def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context={}): res = {} - ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) - if ids2: - acc_set = ",".join(map(str, ids2)) + parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) + if parent_ids: cr.execute("select account_analytic_line.account_id, COALESCE(sum(amount_currency),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ - where account_analytic_line.account_id =ANY(%s) \ + where account_analytic_line.account_id IN %s \ and account_analytic_journal.type = 'sale' \ - group by account_analytic_line.account_id" ,(ids2,)) + group by account_analytic_line.account_id" ,(parent_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) - return self._compute_currency_for_level_tree(cr, uid, ids, ids2, res, acc_set, context) + return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context) def _ca_to_invoice_calc(self, cr, uid, ids, name, arg, context={}): res = {} res2 = {} - ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) - if ids2: + parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) + if parent_ids: # Amount uninvoiced hours to invoice at sale price # Warning # This computation doesn't take care of pricelist ! # Just consider list_price - acc_set = ",".join(map(str, ids2)) cr.execute("""SELECT account_analytic_account.id, \ COALESCE(sum (product_template.list_price * \ account_analytic_line.unit_amount * \ @@ -73,11 +71,11 @@ class account_analytic_account(osv.osv): on account_analytic_account.id = account_analytic_line.account_id \ JOIN hr_timesheet_invoice_factor \ on hr_timesheet_invoice_factor.id = account_analytic_account.to_invoice \ - WHERE account_analytic_account.id =ANY(%s) \ + WHERE account_analytic_account.id IN %s \ AND account_analytic_line.invoice_id is null \ AND account_analytic_line.to_invoice IS NOT NULL \ and account_analytic_journal.type in ('purchase','general') \ - GROUP BY account_analytic_account.id;""",(ids2,)) + GROUP BY account_analytic_account.id;""",(parent_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) @@ -96,17 +94,17 @@ class account_analytic_account(osv.osv): def _hours_qtt_non_invoiced_calc (self, cr, uid, ids, name, arg, context={}): res = {} - ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) - if ids2: + parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) + if parent_ids: cr.execute("select account_analytic_line.account_id, COALESCE(sum(unit_amount),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ - where account_analytic_line.account_id =ANY(%s) \ + where account_analytic_line.account_id IN %s \ and account_analytic_journal.type='general' \ and invoice_id is null \ AND to_invoice IS NOT NULL \ - GROUP BY account_analytic_line.account_id;",(ids2,)) + GROUP BY account_analytic_line.account_id;",(parent_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) for obj_id in ids: @@ -121,15 +119,15 @@ class account_analytic_account(osv.osv): def _hours_quantity_calc(self, cr, uid, ids, name, arg, context={}): res = {} - ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) - if ids2: + parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) + if parent_ids: cr.execute("select account_analytic_line.account_id,COALESCE(SUM(unit_amount),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ - where account_analytic_line.account_id =ANY(%s) \ + where account_analytic_line.account_id IN %s \ and account_analytic_journal.type='general' \ - GROUP BY account_analytic_line.account_id",(ids2,)) + GROUP BY account_analytic_line.account_id",(parent_ids,)) ff = cr.fetchall() for account_id, sum in ff: res[account_id] = round(sum,2) @@ -145,30 +143,29 @@ class account_analytic_account(osv.osv): def _total_cost_calc(self, cr, uid, ids, name, arg, context={}): res = {} - ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) - if ids2: - acc_set = ",".join(map(str, ids2)) + parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) + if parent_ids: cr.execute("""select account_analytic_line.account_id,COALESCE(sum(amount_currency),0.0) \ from account_analytic_line \ join account_analytic_journal \ on account_analytic_line.journal_id = account_analytic_journal.id \ - where account_analytic_line.account_id =ANY(%s) \ + where account_analytic_line.account_id IN %s \ and amount<0 \ - GROUP BY account_analytic_line.account_id""",(ids2,)) + GROUP BY account_analytic_line.account_id""",(parent_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = round(sum,2) - return self._compute_currency_for_level_tree(cr, uid, ids, ids2, res, acc_set, context) + return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context) # TODO Take care of pricelist and purchase ! def _ca_theorical_calc(self, cr, uid, ids, name, arg, context={}): res = {} res2 = {} - ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) + parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) # Warning # This computation doesn't take care of pricelist ! # Just consider list_price - if ids2: + if parent_ids: cr.execute("""select account_analytic_line.account_id as account_id, \ COALESCE(sum((account_analytic_line.unit_amount * pt.list_price) \ - (account_analytic_line.unit_amount * pt.list_price \ @@ -184,10 +181,10 @@ class account_analytic_account(osv.osv): on (a.id=account_analytic_line.account_id) \ join hr_timesheet_invoice_factor hr \ on (hr.id=a.to_invoice) \ - where account_analytic_line.account_id =ANY(%s) \ + where account_analytic_line.account_id IN %s \ and a.to_invoice IS NOT NULL \ - and account_analytic_journal.type in ('purchase','general') - GROUP BY account_analytic_line.account_id""",(ids2,)) + and account_analytic_journal.type IN ('purchase','general') + GROUP BY account_analytic_line.account_id""",(parent_ids,)) for account_id, sum in cr.fetchall(): res2[account_id] = round(sum,2) @@ -207,13 +204,13 @@ class account_analytic_account(osv.osv): def _last_worked_date_calc (self, cr, uid, ids, name, arg, context={}): res = {} - ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) - if ids2: + parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) + if parent_ids: cr.execute("select account_analytic_line.account_id, max(date) \ from account_analytic_line \ - where account_id =ANY(%s) \ + where account_id IN %s \ and invoice_id is null \ - GROUP BY account_analytic_line.account_id" ,(ids2,)) + GROUP BY account_analytic_line.account_id" ,(parent_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = sum for obj_id in ids: @@ -228,16 +225,16 @@ class account_analytic_account(osv.osv): def _last_invoice_date_calc (self, cr, uid, ids, name, arg, context={}): res = {} - ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) - if ids2: + parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) + if parent_ids: cr.execute ("select account_analytic_line.account_id, \ date(max(account_invoice.date_invoice)) \ from account_analytic_line \ join account_invoice \ on account_analytic_line.invoice_id = account_invoice.id \ - where account_analytic_line.account_id =ANY(%s) \ + where account_analytic_line.account_id IN %s \ and account_analytic_line.invoice_id is not null \ - GROUP BY account_analytic_line.account_id",(ids2,)) + GROUP BY account_analytic_line.account_id",(parent_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = sum for obj_id in ids: @@ -252,13 +249,13 @@ class account_analytic_account(osv.osv): def _last_worked_invoiced_date_calc (self, cr, uid, ids, name, arg, context={}): res = {} - ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) - if ids2: + parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) + if parent_ids: cr.execute("select account_analytic_line.account_id, max(date) \ from account_analytic_line \ - where account_id =ANY(%s) \ + where account_id IN %s \ and invoice_id is not null \ - GROUP BY account_analytic_line.account_id;",(ids2,)) + GROUP BY account_analytic_line.account_id;",(parent_ids,)) for account_id, sum in cr.fetchall(): res[account_id] = sum for obj_id in ids: @@ -346,10 +343,10 @@ class account_analytic_account(osv.osv): def _month(self, cr, uid, ids, name, arg, context=None): res = {} for id in ids: - ids2 = self.search(cr, uid, [('parent_id', 'child_of', [id])]) - if ids2: + parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) + if parent_ids: cr.execute('SELECT DISTINCT(month_id) FROM account_analytic_analysis_summary_month ' \ - 'WHERE account_id =ANY(%s) AND unit_amount <> 0.0',(ids2,)) + 'WHERE account_id IN %s AND unit_amount <> 0.0',(parent_ids,)) res[id] = [int(id * 1000000 + int(x[0])) for x in cr.fetchall()] else: res[id] = [] @@ -360,10 +357,10 @@ class account_analytic_account(osv.osv): cr.execute('SELECT MAX(id) FROM res_users') max_user = cr.fetchone()[0] for id in ids: - ids2 = self.search(cr, uid, [('parent_id', 'child_of', [id])]) - if ids2: + parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) + if parent_ids: cr.execute('SELECT DISTINCT("user") FROM account_analytic_analysis_summary_user ' \ - 'WHERE account_id =ANY(%s) AND unit_amount <> 0.0',(ids2,)) + 'WHERE account_id IN %s AND unit_amount <> 0.0',(parent_ids,)) res[id] = [int((id * max_user) + x[0]) for x in cr.fetchall()] else: res[id] = [] @@ -405,12 +402,12 @@ class account_analytic_account_summary_user(osv.osv): max_user = cr.fetchone()[0] account_ids = [int(str(x/max_user - (x%max_user == 0 and 1 or 0))) for x in ids] user_ids = [int(str(x-((x/max_user - (x%max_user == 0 and 1 or 0)) *max_user))) for x in ids] - account_ids2 = account_obj.search(cr, uid, [('parent_id', 'child_of', account_ids)]) - if account_ids2: + parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', account_ids)])) + if parent_ids: cr.execute('SELECT id, unit_amount ' \ 'FROM account_analytic_analysis_summary_user ' \ - 'WHERE account_id =ANY(%s) ' \ - 'AND "user" =ANY(%s)',(account_ids2, user_ids,)) + 'WHERE account_id IN %s ' \ + 'AND "user" IN %s',(parent_ids, user_ids,)) for sum_id, unit_amount in cr.fetchall(): res[sum_id] = unit_amount for obj_id in ids: @@ -488,9 +485,9 @@ class account_analytic_account_summary_user(osv.osv): for i in range(0, len(ids), cr.IN_MAX): sub_ids = ids[i:i+cr.IN_MAX] if d1: - cr.execute('select %s from \"%s\" where id in (%s) ' \ - 'and account_id in (%s) ' \ - 'and "user" in (%s) and %s order by %s' % \ + cr.execute('select %s from \"%s\" where id IN (%s) ' \ + 'and account_id IN (%s) ' \ + 'and "user" IN (%s) and %s order by %s' % \ (','.join(fields_pre2 + ['id']), self._table, ','.join([str(x) for x in sub_ids]), ','.join([str(x/max_user - (x%max_user == 0 and 1 or 0)) for x in sub_ids]), @@ -500,9 +497,9 @@ class account_analytic_account_summary_user(osv.osv): raise except_orm(_('AccessError'), _('You try to bypass an access rule (Document type: %s).') % self._description) else: - cr.execute('select %s from \"%s\" where id in (%s) ' \ - 'and account_id in (%s) ' \ - 'and "user" in (%s) order by %s' % \ + cr.execute('select %s from \"%s\" where id IN (%s) ' \ + 'and account_id IN (%s) ' \ + 'and "user" IN (%s) order by %s' % \ (','.join(fields_pre2 + ['id']), self._table, ','.join([str(x) for x in sub_ids]), ','.join([str(x/max_user - (x%max_user == 0 and 1 or 0)) for x in sub_ids]), @@ -570,12 +567,12 @@ class account_analytic_account_summary_month(osv.osv): account_obj = self.pool.get('account.analytic.account') account_ids = [int(str(int(x))[:-6]) for x in ids] month_ids = [int(str(int(x))[-6:]) for x in ids] - account_ids2 = account_obj.search(cr, uid, [('parent_id', 'child_of', account_ids)]) - if account_ids2: + parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', account_ids)])) + if parent_ids: cr.execute('SELECT id, unit_amount ' \ 'FROM account_analytic_analysis_summary_month ' \ - 'WHERE account_id =ANY(%s) ' \ - 'AND month_id =ANY(%s) ',(account_ids2, month_ids,)) + 'WHERE account_id IN %s ' \ + 'AND month_id IN %s ',(parent_ids, month_ids,)) for sum_id, unit_amount in cr.fetchall(): res[sum_id] = unit_amount for obj_id in ids: @@ -664,9 +661,9 @@ class account_analytic_account_summary_month(osv.osv): for i in range(0, len(ids), cr.IN_MAX): sub_ids = ids[i:i+cr.IN_MAX] if d1: - cr.execute('select %s from \"%s\" where id in (%s) ' \ - 'and account_id in (%s) ' \ - 'and month_id in (%s) and %s order by %s' % \ + cr.execute('select %s from \"%s\" where id IN (%s) ' \ + 'and account_id IN (%s) ' \ + 'and month_id IN (%s) and %s order by %s' % \ (','.join(fields_pre2 + ['id']), self._table, ','.join([str(x) for x in sub_ids]), ','.join([str(x)[:-6] for x in sub_ids]), @@ -676,9 +673,9 @@ class account_analytic_account_summary_month(osv.osv): raise except_orm(_('AccessError'), _('You try to bypass an access rule (Document type: %s).') % self._description) else: - cr.execute('select %s from \"%s\" where id in (%s) ' \ - 'and account_id in (%s) ' \ - 'and month_id in (%s) order by %s' % \ + cr.execute('select %s from \"%s\" where id IN (%s) ' \ + 'and account_id IN (%s) ' \ + 'and month_id IN (%s) order by %s' % \ (','.join(fields_pre2 + ['id']), self._table, ','.join([str(x) for x in sub_ids]), ','.join([str(x)[:-6] for x in sub_ids]), diff --git a/addons/account_analytic_plans/account_analytic_plans.py b/addons/account_analytic_plans/account_analytic_plans.py index db441d0931f..00fa4cf0f44 100644 --- a/addons/account_analytic_plans/account_analytic_plans.py +++ b/addons/account_analytic_plans/account_analytic_plans.py @@ -83,16 +83,16 @@ class account_analytic_plan_instance(osv.osv): _name='account.analytic.plan.instance' _description = 'Analytic Plan Instance' _columns={ - 'name':fields.char('Analytic Distribution',size=64), - 'code':fields.char('Distribution Code',size=16), + 'name':fields.char('Analytic Distribution', size=64), + 'code':fields.char('Distribution Code', size=16), 'journal_id': fields.many2one('account.analytic.journal', 'Analytic Journal' ), - 'account_ids':fields.one2many('account.analytic.plan.instance.line','plan_id','Account Id'), - 'account1_ids':one2many_mod2('account.analytic.plan.instance.line','plan_id','Account1 Id'), - 'account2_ids':one2many_mod2('account.analytic.plan.instance.line','plan_id','Account2 Id'), - 'account3_ids':one2many_mod2('account.analytic.plan.instance.line','plan_id','Account3 Id'), - 'account4_ids':one2many_mod2('account.analytic.plan.instance.line','plan_id','Account4 Id'), - 'account5_ids':one2many_mod2('account.analytic.plan.instance.line','plan_id','Account5 Id'), - 'account6_ids':one2many_mod2('account.analytic.plan.instance.line','plan_id','Account6 Id'), + 'account_ids':fields.one2many('account.analytic.plan.instance.line', 'plan_id', 'Account Id'), + 'account1_ids':one2many_mod2('account.analytic.plan.instance.line', 'plan_id', 'Account1 Id'), + 'account2_ids':one2many_mod2('account.analytic.plan.instance.line', 'plan_id', 'Account2 Id'), + 'account3_ids':one2many_mod2('account.analytic.plan.instance.line', 'plan_id', 'Account3 Id'), + 'account4_ids':one2many_mod2('account.analytic.plan.instance.line', 'plan_id', 'Account4 Id'), + 'account5_ids':one2many_mod2('account.analytic.plan.instance.line', 'plan_id', 'Account5 Id'), + 'account6_ids':one2many_mod2('account.analytic.plan.instance.line', 'plan_id', 'Account6 Id'), 'plan_id':fields.many2one('account.analytic.plan', "Model's Plan"), } @@ -184,21 +184,21 @@ class account_analytic_plan_instance(osv.osv): def create(self, cr, uid, vals, context=None): if context and 'journal_id' in context: - journal= self.pool.get('account.journal').browse(cr,uid,context['journal_id']) + journal= self.pool.get('account.journal').browse(cr, uid, context['journal_id']) pids = self.pool.get('account.analytic.plan.instance').search(cr, uid, [('name','=',vals['name']),('code','=',vals['code']),('plan_id','<>',False)]) if pids: raise osv.except_osv(_('Error'), _('A model having this name and code already exists !')) - res = self.pool.get('account.analytic.plan.line').search(cr,uid,[('plan_id','=',journal.plan_id.id)]) + res = self.pool.get('account.analytic.plan.line').search(cr, uid, [('plan_id','=',journal.plan_id.id)]) for i in res: total_per_plan = 0 - item = self.pool.get('account.analytic.plan.line').browse(cr,uid,i) + item = self.pool.get('account.analytic.plan.line').browse(cr, uid, i) temp_list=['account1_ids','account2_ids','account3_ids','account4_ids','account5_ids','account6_ids'] for l in temp_list: if vals.has_key(l): for tempo in vals[l]: - if self.pool.get('account.analytic.account').search(cr,uid,[('parent_id','child_of',[item.root_analytic_id.id]),('id','=',tempo[2]['analytic_account_id'])]): + if self.pool.get('account.analytic.account').search(cr, uid, [('parent_id','child_of',[item.root_analytic_id.id]),('id','=',tempo[2]['analytic_account_id'])]): total_per_plan += tempo[2]['rate'] if total_per_plan < item.min_required or total_per_plan > item.max_required: raise osv.except_osv(_('Value Error') ,_('The Total Should be Between %s and %s') % (str(item.min_required), str(item.max_required))) @@ -206,13 +206,13 @@ class account_analytic_plan_instance(osv.osv): return super(account_analytic_plan_instance, self).create(cr, uid, vals, context) def write(self, cr, uid, ids, vals, context={}, check=True, update_check=True): - this = self.browse(cr,uid,ids[0]) + this = self.browse(cr, uid, ids[0]) if this.plan_id and not vals.has_key('plan_id'): #this instance is a model, so we have to create a new plan instance instead of modifying it #copy the existing model temp_id = self.copy(cr, uid, this.id, None, context) #get the list of the invoice line that were linked to the model - list = self.pool.get('account.invoice.line').search(cr,uid,[('analytics_id','=',this.id)]) + list = self.pool.get('account.invoice.line').search(cr, uid, [('analytics_id','=',this.id)]) #make them link to the copy self.pool.get('account.invoice.line').write(cr, uid, list, {'analytics_id':temp_id}, context) @@ -230,8 +230,8 @@ class account_analytic_plan_instance_line(osv.osv): _name='account.analytic.plan.instance.line' _description = 'Analytic Instance Line' _columns={ - 'plan_id':fields.many2one('account.analytic.plan.instance','Plan Id'), - 'analytic_account_id':fields.many2one('account.analytic.account','Analytic Account', required=True), + 'plan_id':fields.many2one('account.analytic.plan.instance', 'Plan Id'), + 'analytic_account_id':fields.many2one('account.analytic.account', 'Analytic Account', required=True), 'rate':fields.float('Rate (%)', required=True), } _defaults = { @@ -252,7 +252,7 @@ class account_journal(osv.osv): _inherit='account.journal' _name='account.journal' _columns = { - 'plan_id':fields.many2one('account.analytic.plan','Analytic Plans'), + 'plan_id':fields.many2one('account.analytic.plan', 'Analytic Plans'), } account_journal() @@ -260,7 +260,7 @@ class account_invoice_line(osv.osv): _inherit='account.invoice.line' _name='account.invoice.line' _columns = { - 'analytics_id':fields.many2one('account.analytic.plan.instance','Analytic Distribution'), + 'analytics_id':fields.many2one('account.analytic.plan.instance', 'Analytic Distribution'), } def create(self, cr, uid, vals, context=None): @@ -286,7 +286,7 @@ class account_move_line(osv.osv): _inherit='account.move.line' _name='account.move.line' _columns = { - 'analytics_id':fields.many2one('account.analytic.plan.instance','Analytic Distribution'), + 'analytics_id':fields.many2one('account.analytic.plan.instance', 'Analytic Distribution'), } def _default_get_move_form_hook(self, cursor, user, data): @@ -355,7 +355,7 @@ class account_invoice(osv.osv): ref = inv.reference else: ref = self._convert_ref(cr, uid, inv.number) - obj_move_line=self.pool.get('account.analytic.plan.instance').browse(cr,uid,il['analytics_id']) + obj_move_line=self.pool.get('account.analytic.plan.instance').browse(cr, uid, il['analytics_id']) amount_calc=cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, il['price'], context={'date': inv.date_invoice}) * sign qty=il['quantity'] il['analytic_lines']=[] diff --git a/addons/account_analytic_plans/wizard/analytic_plan_create_model.py b/addons/account_analytic_plans/wizard/analytic_plan_create_model.py index aafaf986b51..dc108d1700a 100644 --- a/addons/account_analytic_plans/wizard/analytic_plan_create_model.py +++ b/addons/account_analytic_plans/wizard/analytic_plan_create_model.py @@ -37,7 +37,7 @@ class analytic_plan_create_model(osv.osv_memory): raise osv.except_osv(_('Error'), _('No analytic plan defined !')) plan_obj.write(cr, uid, [context['active_id']], {'plan_id':pids[0]}) - model_data_ids = mod_obj.search(cr,uid,[('model', '=', 'ir.ui.view'),('name', '=', 'view_analytic_plan_create_model')], context=context) + model_data_ids = mod_obj.search(cr, uid, [('model', '=', 'ir.ui.view'),('name', '=', 'view_analytic_plan_create_model')], context=context) resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id'] return { 'name': _('Distribution Model Saved'), diff --git a/addons/account_anglo_saxon/invoice.py b/addons/account_anglo_saxon/invoice.py index 7c1ecbab758..4c3b9b81dcc 100644 --- a/addons/account_anglo_saxon/invoice.py +++ b/addons/account_anglo_saxon/invoice.py @@ -157,17 +157,17 @@ class account_invoice(osv.osv): def _refund_cleanup_lines(self, cr, uid, lines): for line in lines: inv_id = line['invoice_id'] - inv_obj = self.browse(cr,uid,inv_id[0]) + inv_obj = self.browse(cr, uid, inv_id[0]) if inv_obj.type == 'in_invoice': if line.get('product_id',False): - product_obj = self.pool.get('product.product').browse(cr,uid,line['product_id'][0]) + product_obj = self.pool.get('product.product').browse(cr, uid, line['product_id'][0]) oa = product_obj.product_tmpl_id.property_stock_account_output and product_obj.product_tmpl_id.property_stock_account_output.id if not oa: oa = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id if oa: fpos = inv_obj.fiscal_position or False a = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, oa) - account_data = self.pool.get('account.account').read(cr,uid,[a],['name'])[0] + account_data = self.pool.get('account.account').read(cr, uid, [a], ['name'])[0] line.update({'account_id': (account_data['id'],account_data['name'])}) res = super(account_invoice,self)._refund_cleanup_lines(cr, uid, lines) return res diff --git a/addons/account_budget/crossovered_budget.py b/addons/account_budget/crossovered_budget.py index 0e2ef2a363d..187d4999c0a 100644 --- a/addons/account_budget/crossovered_budget.py +++ b/addons/account_budget/crossovered_budget.py @@ -72,7 +72,7 @@ class account_budget_post_dotation(osv.osv): res={} for line in self.browse(cr, uid, ids): if line.period_id: - obj_period=self.pool.get('account.period').browse(cr, uid,line.period_id.id) + obj_period=self.pool.get('account.period').browse(cr, uid, line.period_id.id) total_days=strToDate(obj_period.date_stop) - strToDate(obj_period.date_start) budget_id=line.post_id and line.post_id.id or False @@ -84,7 +84,7 @@ class account_budget_post_dotation(osv.osv): tot_planned=0.00 for record in res1: - obj_lines = self.pool.get('crossovered.budget.lines').browse(cr, uid,record[0]) + obj_lines = self.pool.get('crossovered.budget.lines').browse(cr, uid, record[0]) count_days = min(strToDate(obj_period.date_stop),strToDate(obj_lines.date_to)) - max(strToDate(obj_period.date_start), strToDate(obj_lines.date_from)) days_in_period = count_days.days +1 count_days = strToDate(obj_lines.date_to) - strToDate(obj_lines.date_from) @@ -102,7 +102,7 @@ class account_budget_post_dotation(osv.osv): 'post_id': fields.many2one('account.budget.post', 'Item', select=True), 'period_id': fields.many2one('account.period', 'Period'), 'amount': fields.float('Amount', digits=(16,2)), - 'tot_planned':fields.function(_tot_planned,method=True, string='Total Planned Amount',type='float',store=True), + 'tot_planned':fields.function(_tot_planned, method=True, string='Total Planned Amount', type='float', store=True), } account_budget_post_dotation() @@ -114,12 +114,12 @@ class crossovered_budget(osv.osv): _columns = { 'name': fields.char('Name', size=50, required=True,states={'done':[('readonly',True)]}), 'code': fields.char('Code', size=20, required=True,states={'done':[('readonly',True)]}), - 'creating_user_id': fields.many2one('res.users','Responsible User'), - 'validating_user_id': fields.many2one('res.users','Validate User', readonly=True), - 'date_from': fields.date('Start Date',required=True,states={'done':[('readonly',True)]}), - 'date_to': fields.date('End Date',required=True,states={'done':[('readonly',True)]}), + 'creating_user_id': fields.many2one('res.users', 'Responsible User'), + 'validating_user_id': fields.many2one('res.users', 'Validate User', readonly=True), + 'date_from': fields.date('Start Date', required=True, states={'done':[('readonly',True)]}), + 'date_to': fields.date('End Date', required=True, states={'done':[('readonly',True)]}), 'state' : fields.selection([('draft','Draft'),('confirm','Confirmed'),('validate','Validated'),('done','Done'),('cancel', 'Cancelled')], 'Status', select=True, required=True, readonly=True), - 'crossovered_budget_line': fields.one2many('crossovered.budget.lines', 'crossovered_budget_id', 'Budget Lines',states={'done':[('readonly',True)]} ), + 'crossovered_budget_line': fields.one2many('crossovered.budget.lines', 'crossovered_budget_id', 'Budget Lines', states={'done':[('readonly',True)]} ), } _defaults = { @@ -186,10 +186,10 @@ class crossovered_budget_lines(osv.osv): res[line.id] = result return res - def _prac(self, cr, uid, ids,name,args,context): + def _prac(self, cr, uid, ids, name, args, context): res={} for line in self.browse(cr, uid, ids): - 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 @@ -223,14 +223,14 @@ class crossovered_budget_lines(osv.osv): res[line.id]=theo_amt return res - def _theo(self, cr, uid, ids,name,args,context): + def _theo(self, cr, uid, ids, name, args, context): res={} for line in self.browse(cr, uid, ids): - 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 - def _perc(self, cr, uid, ids,name,args,context): + def _perc(self, cr, uid, ids, name, args, context): res = {} for line in self.browse(cr, uid, ids): if line.theoritical_amount<>0.00: @@ -244,13 +244,13 @@ class crossovered_budget_lines(osv.osv): 'crossovered_budget_id': fields.many2one('crossovered.budget', 'Budget', ondelete='cascade', select=True, required=True), 'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account',required=True), 'general_budget_id': fields.many2one('account.budget.post', 'Budgetary Position',required=True), - 'date_from': fields.date('Start Date',required=True), - 'date_to': fields.date('End Date',required=True), + 'date_from': fields.date('Start Date', required=True), + 'date_to': fields.date('End Date', required=True), 'paid_date': fields.date('Paid Date'), - 'planned_amount':fields.float('Planned Amount',required=True,digits=(16,2)), - 'practical_amount':fields.function(_prac,method=True, string='Practical Amount',type='float',digits=(16,2)), - 'theoritical_amount':fields.function(_theo,method=True, string='Theoritical Amount',type='float',digits=(16,2)), - 'percentage':fields.function(_perc,method=True, string='Percentage',type='float'), + 'planned_amount':fields.float('Planned Amount', required=True, digits=(16,2)), + 'practical_amount':fields.function(_prac, method=True, string='Practical Amount', type='float', digits=(16,2)), + 'theoritical_amount':fields.function(_theo, method=True, string='Theoritical Amount', type='float', digits=(16,2)), + 'percentage':fields.function(_perc, method=True, string='Percentage', type='float'), } crossovered_budget_lines() diff --git a/addons/account_budget/report/crossovered_budget_report.py b/addons/account_budget/report/crossovered_budget_report.py index 54be05e8d72..6622ce81156 100644 --- a/addons/account_budget/report/crossovered_budget_report.py +++ b/addons/account_budget/report/crossovered_budget_report.py @@ -36,7 +36,7 @@ class budget_report(report_sxw.rml_parse): }) self.context=context - def funct(self,object,form,ids={}, done=None, level=1): + def funct(self, object, form, ids={}, done=None, level=1): if not ids: ids = self.ids @@ -78,7 +78,7 @@ class budget_report(report_sxw.rml_parse): context={'wizard_date_from':d_from,'wizard_date_to':d_to} for i in range(0,len(an_ids)): - analytic_name=self.pool.get('account.analytic.account').browse(self.cr, self.uid,[an_ids[i][0]]) + analytic_name=self.pool.get('account.analytic.account').browse(self.cr, self.uid, [an_ids[i][0]]) res={ 'b_id':'-1', @@ -94,7 +94,7 @@ class budget_report(report_sxw.rml_parse): line_ids = c_b_lines_obj.search(self.cr, self.uid, [('id', 'in', budget_ids),('analytic_account_id','=',an_ids[i][0])]) - line_id = c_b_lines_obj.browse(self.cr,self.uid,line_ids) + line_id = c_b_lines_obj.browse(self.cr, self.uid, line_ids) tot_theo=tot_pln=tot_prac=tot_perc=0.00 done_budget=[] @@ -194,7 +194,7 @@ class budget_report(report_sxw.rml_parse): tot['perc']=float(tot['prac'] /tot['theo'])*100 return result - def funct_total(self,form): + def funct_total(self, form): result=[] res={} diff --git a/addons/account_budget/wizard/account_budget_report.py b/addons/account_budget/wizard/account_budget_report.py index 8ebb0f7368b..9fe2e0c5977 100644 --- a/addons/account_budget/wizard/account_budget_report.py +++ b/addons/account_budget/wizard/account_budget_report.py @@ -47,7 +47,7 @@ class account_budget_report(osv.osv_memory): 'form': data } - data_model = self.pool.get(datas['model']).browse(cr,uid,context['active_id']) + data_model = self.pool.get(datas['model']).browse(cr, uid, context['active_id']) if not data_model.dotation_ids: raise osv.except_osv(_('Insufficient Data!'),_('No Depreciation or Master Budget Expenses Found on Budget %s!') % data_model.name) diff --git a/addons/account_budget/wizard/account_budget_spread.py b/addons/account_budget/wizard/account_budget_spread.py index f8a627ce070..b5ab413a862 100644 --- a/addons/account_budget/wizard/account_budget_spread.py +++ b/addons/account_budget/wizard/account_budget_spread.py @@ -27,7 +27,7 @@ class account_budget_spread(osv.osv_memory): _name = 'account.budget.spread' _description = 'Account Budget spread ' _columns = { - 'fiscalyear': fields.many2one('account.fiscalyear','Fiscal Year', required=True), + 'fiscalyear': fields.many2one('account.fiscalyear', 'Fiscal Year', required=True), 'amount': fields.float('Amount', digits_compute=dp.get_precision('Account')), } diff --git a/addons/account_coda/coda.py b/addons/account_coda/coda.py index f37b563c245..26c216583a3 100644 --- a/addons/account_coda/coda.py +++ b/addons/account_coda/coda.py @@ -29,8 +29,8 @@ class account_coda(osv.osv): 'name': fields.binary('Coda file', readonly=True), 'statement_ids': fields.one2many('account.bank.statement','coda_id','Generated Bank Statement', readonly=True), 'note': fields.text('Import log', readonly=True), - 'journal_id': fields.many2one('account.journal','Bank Journal', readonly=True,select=True), - 'date': fields.date('Import Date', readonly=True,select=True), + 'journal_id': fields.many2one('account.journal','Bank Journal', readonly=True, select=True), + 'date': fields.date('Import Date', readonly=True, select=True), 'user_id': fields.many2one('res.users','User', readonly=True, select=True), } _defaults = { diff --git a/addons/account_coda/wizard/coda_import.py b/addons/account_coda/wizard/coda_import.py index 5e1ffa365e8..e6f6d32aaa1 100644 --- a/addons/account_coda/wizard/coda_import.py +++ b/addons/account_coda/wizard/coda_import.py @@ -121,7 +121,7 @@ def _coda_parsing(self, cr, uid, data, context): bank_statement_lines = {} bank_statement['date'] = str2date(line[5:11]) bank_statement['journal_id']=data['form']['journal_id'] - period_id = pool.get('account.period').search(cr,uid,[('date_start','<=',time.strftime('%Y-%m-%d',time.strptime(bank_statement['date'],"%y/%m/%d"))),('date_stop','>=',time.strftime('%Y-%m-%d',time.strptime(bank_statement['date'],"%y/%m/%d")))]) + period_id = pool.get('account.period').search(cr, uid, [('date_start','<=',time.strftime('%Y-%m-%d',time.strptime(bank_statement['date'],"%y/%m/%d"))),('date_stop','>=',time.strftime('%Y-%m-%d',time.strptime(bank_statement['date'],"%y/%m/%d")))]) bank_statement['period_id'] = period_id[0] bank_statement['state']='draft' elif line[0] == '1': @@ -176,10 +176,10 @@ def _coda_parsing(self, cr, uid, data, context): st_line_partner_acc = str(line[10:47]).strip() cntry_number=line[10:47].strip() contry_name=line[47:125].strip() - bank_ids = pool.get('res.partner.bank').search(cr,uid,[('acc_number','=',st_line_partner_acc)]) + bank_ids = pool.get('res.partner.bank').search(cr, uid, [('acc_number','=',st_line_partner_acc)]) bank_statement_lines[st_line_name].update({'cntry_number': cntry_number, 'contry_name': contry_name}) if bank_ids: - bank = pool.get('res.partner.bank').browse(cr,uid,bank_ids[0],context) + bank = pool.get('res.partner.bank').browse(cr, uid, bank_ids[0], context) if line and bank.partner_id: bank_statement_lines[st_line_name].update({'partner_id': bank.partner_id.id}) if bank_statement_lines[st_line_name]['amount'] < 0 : @@ -274,7 +274,7 @@ def _coda_parsing(self, cr, uid, data, context): err_log += '\n\nNumber of statements : '+ str(len(bkst_list)) err_log += '\nNumber of error :'+ str(nb_err) +'\n' - pool.get('account.coda').create(cr, uid,{ + pool.get('account.coda').create(cr, uid, { 'name':codafile, 'statement_ids': [(6, 0, bkst_list,)], 'note':str_log1+str_not+std_log+err_log, diff --git a/addons/account_followup/wizard/account_followup_print.py b/addons/account_followup/wizard/account_followup_print.py index 14111575748..3ba9301a365 100644 --- a/addons/account_followup/wizard/account_followup_print.py +++ b/addons/account_followup/wizard/account_followup_print.py @@ -178,7 +178,7 @@ class account_followup_print_all(osv.osv_memory): msg_unsent = '' count = 0 data_user = user_obj.browse(cr, uid, uid) - move_lines = line_obj.browse(cr,uid,data['partner_ids'][0][2]) + move_lines = line_obj.browse(cr, uid, data['partner_ids'][0][2]) partners = [] dict_lines = {} for line in move_lines: @@ -186,7 +186,7 @@ class account_followup_print_all(osv.osv_memory): dict_lines[line.name.id] =line for partner in partners: ids_lines = move_obj.search(cr,uid,[('partner_id','=',partner.id),('reconcile_id','=',False),('account_id.type','in',['receivable'])]) - data_lines = move_obj.browse(cr,uid,ids_lines) + data_lines = move_obj.browse(cr, uid, ids_lines) followup_data = dict_lines[partner.id] dest = False if partner.address: diff --git a/addons/account_invoice_layout/account_invoice_layout.py b/addons/account_invoice_layout/account_invoice_layout.py index fda547f3c68..c4a4f64efbe 100644 --- a/addons/account_invoice_layout/account_invoice_layout.py +++ b/addons/account_invoice_layout/account_invoice_layout.py @@ -26,8 +26,8 @@ class notify_message(osv.osv): _name = 'notify.message' _description = 'Notify By Messages' _columns = { - 'name' : fields.char('Title',size=64,required=True), - 'msg' : fields.text('Special Message',size=125,required=True,help='This notification will appear at the bottom of the Invoices when printed.',translate=True) + 'name' : fields.char('Title', size=64, required=True), + 'msg' : fields.text('Special Message', size=125, required=True, help='This notification will appear at the bottom of the Invoices when printed.', translate=True) } notify_message() diff --git a/addons/account_invoice_layout/report/report_account_invoice_layout.py b/addons/account_invoice_layout/report/report_account_invoice_layout.py index 6f8070306e5..b2c1f37fb2b 100644 --- a/addons/account_invoice_layout/report/report_account_invoice_layout.py +++ b/addons/account_invoice_layout/report/report_account_invoice_layout.py @@ -43,7 +43,7 @@ class account_invoice_1(report_sxw.rml_parse): ids = self.pool.get('account.invoice.line').search(self.cr, self.uid, [('invoice_id', '=', invoice.id)]) ids.sort() for id in range(0,len(ids)): - info = self.pool.get('account.invoice.line').browse(self.cr, self.uid,ids[id], self.context.copy()) + info = self.pool.get('account.invoice.line').browse(self.cr, self.uid, ids[id], self.context.copy()) list_in_seq[info]=info.sequence i=1 j=0 @@ -80,7 +80,7 @@ class account_invoice_1(report_sxw.rml_parse): if entry.uos_id.id==False: res['uos']='' else: - uos_name = self.pool.get('product.uom').read(self.cr,self.uid,entry.uos_id.id,['name'],self.context.copy()) + uos_name = self.pool.get('product.uom').read(self.cr, self.uid, entry.uos_id.id, ['name'], self.context.copy()) res['uos'] = uos_name['name'] else: diff --git a/addons/account_invoice_layout/report/special_message_invoice.py b/addons/account_invoice_layout/report/special_message_invoice.py index eb9a5859753..fdda2e65278 100644 --- a/addons/account_invoice_layout/report/special_message_invoice.py +++ b/addons/account_invoice_layout/report/special_message_invoice.py @@ -89,7 +89,7 @@ class account_invoice_with_message(report_sxw.rml_parse): if entry.uos_id.id==False: res['uos']='' else: - uos_name = self.pool.get('product.uom').read(self.cr,self.uid,entry.uos_id.id,['name'],self.context.copy()) + uos_name = self.pool.get('product.uom').read(self.cr, self.uid, entry.uos_id.id, ['name'], self.context.copy()) res['uos']=uos_name['name'] else: diff --git a/addons/account_payment/account_move_line.py b/addons/account_payment/account_move_line.py index 07fbcbbb237..27455183afd 100644 --- a/addons/account_payment/account_move_line.py +++ b/addons/account_payment/account_move_line.py @@ -18,7 +18,7 @@ # along with this program. If not, see . # ############################################################################## - +from operator import itemgetter from osv import fields, osv from tools.translate import _ @@ -42,7 +42,7 @@ class account_move_line(osv.osv): WHERE move_line_id = ml.id AND po.state != 'cancel') as amount FROM account_move_line ml - WHERE id =ANY(%s)""" ,(ids,)) + WHERE id IN %s""", (tuple(ids),)) r=dict(cr.fetchall()) return r @@ -58,8 +58,10 @@ class account_move_line(osv.osv): END - coalesce(sum(pl.amount_currency), 0) FROM payment_line pl INNER JOIN payment_order po ON (pl.order_id = po.id) - WHERE move_line_id = l.id AND po.state != 'cancel')''' \ - + x[1] + str(x[2])+' ',args)) + WHERE move_line_id = l.id + AND po.state != 'cancel' + ) %(operator)s %%s ''' % {'operator': x[1]}, args)) + sql_args = tuple(map(itemgetter(2), args)) cr.execute(('''select id from account_move_line l @@ -68,7 +70,7 @@ class account_move_line(osv.osv): where type=%s and active) and reconcile_id is null and credit > 0 - and ''' + where + ' and ' + query), ('payable',) ) + and ''' + where + ' and ' + query), ('payable',)+sql_args ) res = cr.fetchall() if not len(res): diff --git a/addons/account_payment/payment.py b/addons/account_payment/payment.py index 8e300f7072a..4a18c91c107 100644 --- a/addons/account_payment/payment.py +++ b/addons/account_payment/payment.py @@ -30,11 +30,11 @@ class payment_type(osv.osv): _name= 'payment.type' _description= 'Payment Type' _columns= { - 'name': fields.char('Name', size=64, required=True,help='Payment Type'), - 'code': fields.char('Code', size=64, required=True,help='Specifies the Code for Payment Type'), + 'name': fields.char('Name', size=64, required=True, help='Payment Type'), + 'code': fields.char('Code', size=64, required=True, help='Specifies the Code for Payment Type'), 'suitable_bank_types': fields.many2many('res.partner.bank.type', 'bank_type_payment_type_rel', - 'pay_type_id','bank_type_id', + 'pay_type_id', 'bank_type_id', 'Suitable bank types') } @@ -45,15 +45,15 @@ class payment_mode(osv.osv): _name= 'payment.mode' _description= 'Payment Mode' _columns= { - 'name': fields.char('Name', size=64, required=True,help='Mode of Payment'), + 'name': fields.char('Name', size=64, required=True, help='Mode of Payment'), 'bank_id': fields.many2one('res.partner.bank', "Bank account", required=True,help='Bank Account for the Payment Mode'), 'journal': fields.many2one('account.journal', 'Journal', required=True, - domain=[('type', '=', 'cash')],help='Cash Journal for the Payment Mode'), - 'type': fields.many2one('payment.type','Payment type',required=True,help='Select the Payment Type for the Payment Mode.'), + domain=[('type', '=', 'cash')], help='Cash Journal for the Payment Mode'), + 'type': fields.many2one('payment.type', 'Payment type', required=True, help='Select the Payment Type for the Payment Mode.'), } - def suitable_bank_types(self,cr,uid,payment_code=None,context={}): + def suitable_bank_types(self, cr, uid, payment_code=None, context={}): """Return the codes of the bank type that are suitable for the given payment type code""" if not payment_code: @@ -66,7 +66,6 @@ class payment_mode(osv.osv): where pm.id = %s """, [payment_code]) return [x[0] for x in cr.fetchall()] - payment_mode() @@ -102,10 +101,10 @@ class payment_order(osv.osv): ('cancel','Cancelled'), ('done','Done')], 'State', select=True, help='When an order is placed the state is \'Draft\'.\n Once the bank is confirmed the state is set to \'Confirmed\'.\n Then the order is paid the state is \'Done\'.'), - 'line_ids': fields.one2many('payment.line','order_id','Payment lines',states={'done':[('readonly',True)]}), + 'line_ids': fields.one2many('payment.line', 'order_id', 'Payment lines', states={'done':[('readonly',True)]}), 'total': fields.function(_total, string="Total", method=True, type='float'), - 'user_id': fields.many2one('res.users','User', required=True, states={'done':[('readonly',True)]}), + 'user_id': fields.many2one('res.users', 'User', required=True, states={'done':[('readonly',True)]}), 'date_prefered': fields.selection([ ('now', 'Directly'), ('due', 'Due date'), @@ -131,10 +130,10 @@ class payment_order(osv.osv): return True def action_open(self, cr, uid, ids, *args): - for order in self.read(cr,uid,ids,['reference']): + for order in self.read(cr, uid, ids, ['reference']): if not order['reference']: reference = self.pool.get('ir.sequence').get(cr, uid, 'payment.order') - self.write(cr,uid,order['id'],{'reference':reference}) + self.write(cr, uid, order['id'],{'reference':reference}) return True def set_done(self, cr, uid, id, *args): @@ -151,19 +150,9 @@ class payment_line(osv.osv): _name = 'payment.line' _description = 'Payment Line' - #~ def partner_payable(self, cr, uid, ids, name, args, context={}): - #~ if not ids: return {} - #~ partners= self.read(cr, uid, ids, ['partner_id'], context) - #~ partners= dict(map(lambda x: (x['id'], x['partner_id'][0]), partners)) - #~ debit = self.pool.get('res.partner')._debit_get(cr, uid, - #~ partners.values(), name, args, context) - #~ for i in partners: - #~ partners[i] = debit[partners[i]] - #~ return partners def translate(self, orig): return { -# "to_pay": "credit", "due_date": "date_maturity", "reference": "ref"}.get(orig, orig) @@ -180,7 +169,7 @@ class payment_line(osv.osv): st=ads.street and ads.street or '' st1=ads.street2 and ads.street2 or '' if 'zip_id' in ads: - zip_city= ads.zip_id and self.pool.get('res.partner.zip').name_get(cr,uid,[ads.zip_id.id])[0][1] or '' + zip_city= ads.zip_id and self.pool.get('res.partner.zip').name_get(cr, uid, [ads.zip_id.id])[0][1] or '' else: zip=ads.zip and ads.zip or '' city= ads.city and ads.city or '' @@ -206,7 +195,7 @@ class payment_line(osv.osv): st=ads.street and ads.street or '' st1=ads.street2 and ads.street2 or '' if 'zip_id' in ads: - zip_city= ads.zip_id and self.pool.get('res.partner.zip').name_get(cr,uid,[ads.zip_id.id])[0][1] or '' + zip_city= ads.zip_id and self.pool.get('res.partner.zip').name_get(cr, uid, [ads.zip_id.id])[0][1] or '' else: zip=ads.zip and ads.zip or '' city= ads.city and ads.city or '' @@ -225,14 +214,14 @@ class payment_line(osv.osv): from account_move_line ml inner join payment_line pl on (ml.id = pl.move_line_id) - where pl.id =ANY(%s)""", - (self.translate(name),ids,)) + where pl.id IN %%s"""% self.translate(name), + (tuple(ids),)) res = dict(cr.fetchall()) if name == 'partner_id': partner_name = {} - for p_id, p_name in partner_obj.name_get(cr,uid, - filter(lambda x:x and x != 0,res.values()),context=context): + for p_id, p_name in partner_obj.name_get(cr, uid, + filter(lambda x:x and x != 0,res.values()), context=context): partner_name[p_id] = p_name for id in ids: @@ -245,61 +234,6 @@ class payment_line(osv.osv): res.setdefault(id, (False, "")) return res -# def _currency(self, cursor, user, ids, name, args, context=None): -# if not ids: -# return {} -# res = {} -# -# currency_obj = self.pool.get('res.currency') -# account_obj = self.pool.get('account.account') -# cursor.execute('''SELECT pl.id, ml.currency_id, ml.account_id -# FROM account_move_line ml -# INNER JOIN payment_line pl -# ON (ml.id = pl.move_line_id) -# WHERE pl.id in (''' + ','.join([str(x) for x in ids]) + ')') -# -# res2 = {} -# account_ids = [] -# for payment_line_id, currency_id, account_id in cursor.fetchall(): -# res2[payment_line_id] = [currency_id, account_id] -# account_ids.append(account_id) -# -# account2currency_id = {} -# for account in account_obj.browse(cursor, user, account_ids, -# context=context): -# account2currency_id[account.id] = account.company_currency_id.id -# -# for payment_line_id in ids: -# if res2[payment_line_id][0]: -# res[payment_line_id] = res2[payment_line_id][0] -# else: -# res[payment_line_id] = \ -# account2currency_id[res2[payment_line_id][1]] -# -# currency_names = {} -# for currency_id, name in currency_obj.name_get(cursor, user, res.values(), -# context=context): -# currency_names[currency_id] = name -# for payment_line_id in ids: -# res[payment_line_id] = (res[payment_line_id], -# currency_names[res[payment_line_id]]) -# return res -# -# def _to_pay_currency(self, cursor, user, ids, name , args, context=None): -# if not ids: -# return {} -# -# cursor.execute('''SELECT pl.id, -# CASE WHEN ml.amount_currency < 0 -# THEN - ml.amount_currency -# ELSE ml.credit -# END -# FROM account_move_line ml -# INNER JOIN payment_line pl -# ON (ml.id = pl.move_line_id) -# WHERE pl.id in (''' + ','.join([str(x) for x in ids]) + ')') -# return dict(cursor.fetchall()) - def _amount(self, cursor, user, ids, name, args, context=None): if not ids: return {} @@ -335,15 +269,6 @@ class payment_line(osv.osv): else: return self.pool.get('res.currency').search(cr, uid, [('rate','=',1.0)])[0] -# def select_move_lines(*a): -# print a -# return [] - -# def create(self, cr, uid, vals, context): -# print "created!!!" -# vals['company_currency'] = self._get_currency(cr, uid, context) -# return super(payment_line, self).create(cr, uid, vals, context) - def _get_ml_inv_ref(self, cr, uid, ids, *a): res={} for id in self.browse(cr, uid, ids): @@ -373,42 +298,28 @@ class payment_line(osv.osv): _columns = { 'name': fields.char('Your Reference', size=64, required=True), - 'communication': fields.char('Communication', size=64, required=True,help="Used as the message between ordering customer and current company. Depicts 'What do you want to say to the recipient about this order ?'"), - 'communication2': fields.char('Communication 2', size=64,help='The successor message of Communication.'), - 'move_line_id': fields.many2one('account.move.line','Entry line', domain=[('reconcile_id','=', False), ('account_id.type', '=','payable')],help='This Entry Line will be referred for the information of the ordering customer.'), + 'communication': fields.char('Communication', size=64, required=True, help="Used as the message between ordering customer and current company. Depicts 'What do you want to say to the recipient about this order ?'"), + 'communication2': fields.char('Communication 2', size=64, help='The successor message of Communication.'), + 'move_line_id': fields.many2one('account.move.line', 'Entry line', domain=[('reconcile_id','=', False), ('account_id.type', '=','payable')], help='This Entry Line will be referred for the information of the ordering customer.'), 'amount_currency': fields.float('Amount in Partner Currency', digits=(16,2), required=True, help='Payment amount in the partner currency'), -# 'to_pay_currency': fields.function(_to_pay_currency, string='To Pay', -# method=True, type='float', -# help='Amount to pay in the partner currency'), -# 'currency': fields.function(_currency, string='Currency', -# method=True, type='many2one', obj='res.currency'), - 'currency': fields.many2one('res.currency','Partner Currency',required=True), - 'company_currency': fields.many2one('res.currency','Company Currency',readonly=True), + 'currency': fields.many2one('res.currency','Partner Currency', required=True), + 'company_currency': fields.many2one('res.currency', 'Company Currency', readonly=True), 'bank_id': fields.many2one('res.partner.bank', 'Destination Bank account'), 'order_id': fields.many2one('payment.order', 'Order', required=True, ondelete='cascade', select=True), - 'partner_id': fields.many2one('res.partner', string="Partner",required=True,help='The Ordering Customer'), + 'partner_id': fields.many2one('res.partner', string="Partner", required=True, help='The Ordering Customer'), 'amount': fields.function(_amount, string='Amount in Company Currency', method=True, type='float', help='Payment amount in the company currency'), -# 'to_pay': fields.function(select_by_name, string="To Pay", method=True, -# type='float', help='Amount to pay in the company currency'), -# 'due_date': fields.function(select_by_name, string="Due date", -# method=True, type='date'), 'ml_date_created': fields.function(_get_ml_created_date, string="Effective Date", - method=True, type='date',help="Invoice Effective Date"), -# 'reference': fields.function(select_by_name, string="Ref", method=True, -# type='char'), + method=True, type='date', help="Invoice Effective Date"), 'ml_maturity_date': fields.function(_get_ml_maturity_date, method=True, type='date', string='Maturity Date'), 'ml_inv_ref': fields.function(_get_ml_inv_ref, method=True, type='many2one', relation='account.invoice', string='Invoice Ref.'), - 'info_owner': fields.function(info_owner, string="Owner Account", method=True, type="text",help='Address of the Main Partner'), - 'info_partner': fields.function(info_partner, string="Destination Account", method=True, type="text",help='Address of the Ordering Customer.'), -# 'partner_payable': fields.function(partner_payable, string="Partner payable", method=True, type='float'), -# 'value_date': fields.function(_value_date, string='Value Date', -# method=True, type='date'), - 'date': fields.date('Payment Date',help="If no payment date is specified, the bank will treat this payment line directly"), - 'create_date': fields.datetime('Created' ,readonly=True), + 'info_owner': fields.function(info_owner, string="Owner Account", method=True, type="text", help='Address of the Main Partner'), + 'info_partner': fields.function(info_partner, string="Destination Account", method=True, type="text", help='Address of the Ordering Customer.'), + 'date': fields.date('Payment Date', help="If no payment date is specified, the bank will treat this payment line directly"), + 'create_date': fields.datetime('Created' , readonly=True), 'state': fields.selection([('normal','Free'), ('structured','Structured')], 'Communication Type', required=True) } _defaults = { @@ -422,13 +333,13 @@ class payment_line(osv.osv): ('name_uniq', 'UNIQUE(name)', 'The payment line name must be unique!'), ] - def onchange_move_line(self,cr,uid,ids,move_line_id,payment_type,date_prefered,date_planned,currency=False,company_currency=False,context=None): + def onchange_move_line(self, cr, uid, ids, move_line_id, payment_type, date_prefered, date_planned, currency=False, company_currency=False, context=None): data={} data['amount_currency']=data['communication']=data['partner_id']=data['reference']=data['date_created']=data['bank_id']=data['amount']=False if move_line_id: - line = self.pool.get('account.move.line').browse(cr,uid,move_line_id) + line = self.pool.get('account.move.line').browse(cr, uid, move_line_id) data['amount_currency']=line.amount_to_pay res = self.onchange_amount(cr, uid, ids, data['amount_currency'], currency, @@ -444,7 +355,7 @@ class payment_line(osv.osv): data['currency'] = temp # calling onchange of partner and updating data dictionary - temp_dict=self.onchange_partner(cr,uid,ids,line.partner_id.id,payment_type) + temp_dict=self.onchange_partner(cr, uid, ids, line.partner_id.id, payment_type) data.update(temp_dict['value']) data['reference']=line.ref @@ -470,12 +381,12 @@ class payment_line(osv.osv): res['amount'] = company_amount return {'value': res} - 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['info_partner']=data['bank_id']=False if partner_id: - part_obj=self.pool.get('res.partner').browse(cr,uid,partner_id) + part_obj=self.pool.get('res.partner').browse(cr, uid, partner_id) partner=part_obj.name or '' if part_obj.address: @@ -485,7 +396,7 @@ class payment_line(osv.osv): st1=ads.street2 and ads.street2 or '' if 'zip_id' in ads: - zip_city= ads.zip_id and self.pool.get('res.partner.zip').name_get(cr,uid,[ads.zip_id.id])[0][1] or '' + zip_city= ads.zip_id and self.pool.get('res.partner.zip').name_get(cr, uid, [ads.zip_id.id])[0][1] or '' else: zip=ads.zip and ads.zip or '' city= ads.city and ads.city or '' diff --git a/addons/account_report/account.py b/addons/account_report/account.py index a3f92676111..784d95daa79 100644 --- a/addons/account_report/account.py +++ b/addons/account_report/account.py @@ -61,7 +61,7 @@ class account_report(osv.osv): if key==0: return obj.find(cr, uid, exception=False) else: - obj_key=obj.browse(cr,uid,obj.find(cr, uid, exception=False)) + obj_key=obj.browse(cr, uid, obj.find(cr, uid, exception=False)) if isinstance(obj_key,list): obj_key=obj_key[0] key_ids=obj.search(cr,uid,[('date_stop','<',obj_key.date_start)]) @@ -69,8 +69,8 @@ class account_report(osv.osv): return False return key_ids[key] - def _calc_credit(code,year=0): - context['fiscalyear']=_calc_context(year,obj_fy) + def _calc_credit(code, year=0): + context['fiscalyear']=_calc_context(year, obj_fy) if not context['fiscalyear']: del context['fiscalyear'] acc = self.pool.get('account.account') @@ -78,7 +78,7 @@ class account_report(osv.osv): return reduce(lambda y,x=0: x.credit+y, acc.browse(cr, uid, acc_id, context),0.0) def _calc_debit(code,year=0): - context['fiscalyear']=_calc_context(year,obj_fy) + context['fiscalyear']=_calc_context(year, obj_fy) if not context['fiscalyear']: del context['fiscalyear'] acc = self.pool.get('account.account') @@ -86,7 +86,7 @@ class account_report(osv.osv): return reduce(lambda y,x=0: x.debit+y, acc.browse(cr, uid, acc_id, context),0.0) def _calc_balance(code,year=0): - context['fiscalyear']=_calc_context(year,obj_fy) + context['fiscalyear']=_calc_context(year, obj_fy) if not context['fiscalyear']: del context['fiscalyear'] acc = self.pool.get('account.account') @@ -102,7 +102,7 @@ class account_report(osv.osv): return reduce(lambda y,x=0: x.amount+y, acc.browse(cr, uid, acc_id, context),0.0) def _calc_tax_code(code,period=0): - context['period_id']=_calc_context(period,obj_period) + context['period_id']=_calc_context(period, obj_period) if not context['period_id']: return 0.00 context['period_id']=context['period_id'][0] @@ -145,7 +145,7 @@ class account_report(osv.osv): def onchange_parent_id(self, cr, uid, ids, parent_id): v={} if parent_id: - acc=self.pool.get('account.report.report').browse(cr,uid,parent_id) + acc=self.pool.get('account.report.report').browse(cr, uid, parent_id) v['type']=acc.type # if int(acc.style) < 6: # v['style'] = str(int(acc.style)+1) @@ -163,8 +163,8 @@ class account_report(osv.osv): ('other','Others')], 'Type', required=True), 'expression': fields.char('Expression', size=240, required=True), - 'badness_limit' :fields.float('Badness Indicator Limit', digits=(16,2),help='This Value sets the limit of badness.'), - 'goodness_limit' :fields.float('Goodness Indicator Limit', digits=(16,2),help='This Value sets the limit of goodness.'), + 'badness_limit' :fields.float('Badness Indicator Limit', digits=(16,2), help='This Value sets the limit of badness.'), + 'goodness_limit' :fields.float('Goodness Indicator Limit', digits=(16,2), help='This Value sets the limit of goodness.'), 'parent_id': fields.many2one('account.report.report', 'Parent'), 'child_ids': fields.one2many('account.report.report', 'parent_id', 'Children'), 'note': fields.text('Note'), @@ -180,8 +180,8 @@ class account_report(osv.osv): ('very good', 'Very Good') ], string='Status'), - 'disp_tree':fields.boolean('Display Tree',help='When the indicators are printed, if one indicator is set with this field to True, then it will display one more graphs with all its children in tree'), - 'disp_graph':fields.boolean('Display As Graph',help='If the field is set to True, information will be printed as a Graph, otherwise as an array.'), + 'disp_tree':fields.boolean('Display Tree', help='When the indicators are printed, if one indicator is set with this field to True, then it will display one more graphs with all its children in tree'), + 'disp_graph':fields.boolean('Display As Graph', help='If the field is set to True, information will be printed as a Graph, otherwise as an array.'), # 'style': fields.selection(_style, 'Style', required=True), # 'color_font' : fields.selection(_color, 'Font Color', help="Font Color for the report"), # 'color_back' : fields.selection(_color, 'Back Color') @@ -215,12 +215,12 @@ account_report() class account_report_history(osv.osv): def _calc_value(self, cr, uid, ids, name, args, context): - acc_report_id=self.read(cr,uid,ids,['tmp','period_id']) + acc_report_id=self.read(cr, uid, ids, ['tmp','period_id']) tmp_ids={} for a in acc_report_id: - period_val=pooler.get_pool(cr.dbname).get('account.period').read(cr,uid,[a['period_id'][0]])[0] - period_id=pooler.get_pool(cr.dbname).get('account.period').search(cr,uid,[('date_start','<=',period_val['date_start']),('fiscalyear_id','=',period_val['fiscalyear_id'][0])]) - tmp_ids[a['id']] = pooler.get_pool(cr.dbname).get('account.report.report').read(cr,uid,[a['tmp']],context={'periods':period_id})[0]['amount'] + period_val=pooler.get_pool(cr.dbname).get('account.period').read(cr, uid, [a['period_id'][0]])[0] + period_id=pooler.get_pool(cr.dbname).get('account.period').search(cr, uid, [('date_start','<=',period_val['date_start']),('fiscalyear_id','=',period_val['fiscalyear_id'][0])]) + tmp_ids[a['id']] = pooler.get_pool(cr.dbname).get('account.report.report').read(cr, uid, [a['tmp']], context={'periods':period_id})[0]['amount'] return tmp_ids _name = "account.report.history" diff --git a/addons/account_reporting/account.py b/addons/account_reporting/account.py index 0b4a16b0dd8..c8b3273491a 100644 --- a/addons/account_reporting/account.py +++ b/addons/account_reporting/account.py @@ -76,7 +76,7 @@ class account_report_bs(osv.osv): def onchange_parent_id(self, cr, uid, ids, parent_id): v={} if parent_id: - acc=self.pool.get('account.report.report').browse(cr,uid,parent_id) + acc=self.pool.get('account.report.report').browse(cr, uid, parent_id) v['type']=acc.type if int(acc.style) < 6: v['style'] = str(int(acc.style)+1) diff --git a/addons/account_tax_include/account_tax_include.py b/addons/account_tax_include/account_tax_include.py index d84a21afff7..5cb58619a76 100644 --- a/addons/account_tax_include/account_tax_include.py +++ b/addons/account_tax_include/account_tax_include.py @@ -126,9 +126,9 @@ class account_invoice_line(osv.osv): _columns = { 'price_subtotal': fields.function(_amount_line2, method=True, string='Subtotal w/o tax', multi='amount', - store={'account.invoice':(_get_invoice,['price_type'],10), 'account.invoice.line': (lambda self,cr,uid,ids,c={}: ids, None,10)}), + store={'account.invoice':(_get_invoice,['price_type'],10), 'account.invoice.line': (lambda self, cr, uid, ids, c={}: ids, None,10)}), 'price_subtotal_incl': fields.function(_amount_line2, method=True, string='Subtotal', multi='amount', - store={'account.invoice':(_get_invoice,['price_type'],10), 'account.invoice.line': (lambda self,cr,uid,ids,c={}: ids, None,10)}), + store={'account.invoice':(_get_invoice,['price_type'],10), 'account.invoice.line': (lambda self, cr, uid, ids, c={}: ids, None,10)}), } _defaults = { diff --git a/addons/account_voucher/report/report_voucher.py b/addons/account_voucher/report/report_voucher.py index 5a84969c52f..1524f972e6a 100644 --- a/addons/account_voucher/report/report_voucher.py +++ b/addons/account_voucher/report/report_voucher.py @@ -34,8 +34,8 @@ class report_voucher(report_sxw.rml_parse): 'get_ref' : self._get_ref }) - def convert(self,amount, cur): - amt_en = amount_to_text_en.amount_to_text(amount,'en',cur); + def convert(self, amount, cur): + amt_en = amount_to_text_en.amount_to_text(amount, 'en', cur); return amt_en def debit(self, move_ids): diff --git a/addons/account_voucher/report/report_voucher_amount.py b/addons/account_voucher/report/report_voucher_amount.py index 7c0cfffe317..2cb113ae4ed 100644 --- a/addons/account_voucher/report/report_voucher_amount.py +++ b/addons/account_voucher/report/report_voucher_amount.py @@ -31,8 +31,8 @@ class report_voucher_amount(report_sxw.rml_parse): 'convert':self.convert }) - def convert(self,amount, cur): - amt_en = amount_to_text_en.amount_to_text(amount,'en',cur); + def convert(self, amount, cur): + amt_en = amount_to_text_en.amount_to_text(amount, 'en', cur); return amt_en diff --git a/addons/account_voucher/voucher.py b/addons/account_voucher/voucher.py index f7ff9ad9ef1..69a5aba09e0 100644 --- a/addons/account_voucher/voucher.py +++ b/addons/account_voucher/voucher.py @@ -212,7 +212,7 @@ class account_voucher(osv.osv): self.write(cr, uid, ids, {'state':'posted'}) return True - def cancel_voucher(self,cr,uid,ids,context={}): + def cancel_voucher(self, cr, uid, ids, context={}): self.action_cancel(cr, uid, ids) self.write(cr, uid, ids, {'state':'cancel'}) return True @@ -406,7 +406,7 @@ class account_voucher(osv.osv): 'general_account_id':line.account_id.id, 'ref':ref } - self.pool.get('account.analytic.line').create(cr,uid,an_line) + self.pool.get('account.analytic.line').create(cr, uid, an_line) self.write(cr, uid, [inv.id], {'move_id': move_id}) obj=self.pool.get('account.move').browse(cr, uid, move_id) @@ -440,7 +440,7 @@ class account_voucher(osv.osv): def action_number(self, cr, uid, ids, *args): cr.execute('SELECT id, type, number, move_id, reference ' \ 'FROM account_voucher ' \ - 'WHERE id =ANY(%s)',(ids,)) + 'WHERE id IN %s',(tuple(ids),)) for (id, invtype, number, move_id, reference) in cr.fetchall(): if not number: number = self.pool.get('ir.sequence').get(cr, uid, invtype) @@ -568,7 +568,7 @@ class account_voucher_line(osv.osv): 'value' : {'account_id' : account_id.id, 'type' : ttype, 'amount':balance} } - def onchange_amount(self, cr, uid, ids,partner_id,amount, type,type1): + def onchange_amount(self, cr, uid, ids, partner_id, amount, type, type1): if not amount: return {'value' : {}} if partner_id: @@ -630,7 +630,7 @@ class account_voucher_line(osv.osv): 'value' : { 'type' : type , 'amount':amount} } - def onchange_type(self, cr, uid, ids,partner_id,amount,type,type1): + def onchange_type(self, cr, uid, ids, partner_id, amount, type, type1): if partner_id: obj = self.pool.get('res.partner') if type1 in ('rec_voucher','bank_rec_voucher', 'journal_voucher'): diff --git a/addons/account_voucher_payment/account_voucher_payment.py b/addons/account_voucher_payment/account_voucher_payment.py index 1cd1da98208..fc879b40092 100755 --- a/addons/account_voucher_payment/account_voucher_payment.py +++ b/addons/account_voucher_payment/account_voucher_payment.py @@ -33,7 +33,7 @@ account_move_line() class account_voucher(osv.osv): _inherit = 'account.voucher' _columns = { - 'voucher_line_ids':fields.one2many('account.voucher.line','voucher_id','Voucher Lines', readonly=False, states={'proforma':[('readonly',True)]}), + 'voucher_line_ids':fields.one2many('account.voucher.line', 'voucher_id', 'Voucher Lines', readonly=False, states={'proforma':[('readonly',True)]}), } def action_move_line_create(self, cr, uid, ids, *args): @@ -192,7 +192,7 @@ class account_voucher(osv.osv): 'general_account_id':line.account_id.id, 'ref':ref } - self.pool.get('account.analytic.line').create(cr,uid,an_line) + self.pool.get('account.analytic.line').create(cr, uid, an_line) if mline_ids: self.pool.get('account.move.line').reconcile_partial(cr, uid, mline_ids, 'manual', context={}) self.write(cr, uid, [inv.id], {'move_id': move_id}) diff --git a/addons/analytic/project.py b/addons/analytic/project.py index a3425c3925b..f52dd23caa0 100644 --- a/addons/analytic/project.py +++ b/addons/analytic/project.py @@ -33,10 +33,10 @@ class account_analytic_account(osv.osv): _name = 'account.analytic.account' _description = 'Analytic Account' - def _compute_currency_for_level_tree(self, cr, uid, ids, ids2, res, acc_set, context={}): + def _compute_currency_for_level_tree(self, cr, uid, ids, ids2, res, context={}): # Handle multi-currency on each level of analytic account # This is a refactoring of _balance_calc computation - cr.execute("SELECT a.id, r.currency_id FROM account_analytic_account a INNER JOIN res_company r ON (a.company_id = r.id) where a.id in (%s)" % acc_set) + cr.execute("SELECT a.id, r.currency_id FROM account_analytic_account a INNER JOIN res_company r ON (a.company_id = r.id) where a.id IN %s" , (tuple(ids2),)) currency= dict(cr.fetchall()) res_currency= self.pool.get('res.currency') for id in ids: @@ -50,24 +50,22 @@ class account_analytic_account(osv.osv): else: res[id] += res.get(child, 0.0) - cur_obj = res_currency.browse(cr,uid,currency.values(),context) + cur_obj = res_currency.browse(cr, uid, currency.values(), context) cur_obj = dict([(o.id, o) for o in cur_obj]) for id in ids: if id in ids2: - res[id] = res_currency.round(cr,uid,cur_obj[currency[id]],res.get(id,0.0)) + res[id] = res_currency.round(cr, uid, cur_obj[currency[id]], res.get(id,0.0)) return dict([(i, res[i]) for i in ids ]) def _credit_calc(self, cr, uid, ids, name, arg, context={}): res = {} - ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) - acc_set = ",".join(map(str, ids2)) - + parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) for i in ids: res.setdefault(i,0.0) - if not ids2: + if not parent_ids: return res where_date = '' @@ -75,19 +73,17 @@ class account_analytic_account(osv.osv): where_date += " AND l.date >= '" + context['from_date'] + "'" if context.get('to_date',False): where_date += " AND l.date <= '" + context['to_date'] + "'" - cr.execute("SELECT a.id, COALESCE(SUM(l.amount_currency),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE l.amount_currency<0 and a.id =ANY(%s) GROUP BY a.id",(ids2,)) + cr.execute("SELECT a.id, COALESCE(SUM(l.amount_currency),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE l.amount_currency<0 and a.id IN %s GROUP BY a.id",(tuple(parent_ids),)) r = dict(cr.fetchall()) - return self._compute_currency_for_level_tree(cr, uid, ids, ids2, r, acc_set, context) + return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, r, context) def _debit_calc(self, cr, uid, ids, name, arg, context={}): res = {} - ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) - acc_set = ",".join(map(str, ids2)) - + parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) for i in ids: res.setdefault(i,0.0) - if not ids2: + if not parent_ids: return res where_date = '' @@ -95,19 +91,17 @@ class account_analytic_account(osv.osv): where_date += " AND l.date >= '" + context['from_date'] + "'" if context.get('to_date',False): where_date += " AND l.date <= '" + context['to_date'] + "'" - cr.execute("SELECT a.id, COALESCE(SUM(l.amount_currency),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE l.amount_currency>0 and a.id =ANY(%s) GROUP BY a.id" ,(ids2,)) + cr.execute("SELECT a.id, COALESCE(SUM(l.amount_currency),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE l.amount_currency>0 and a.id IN %s GROUP BY a.id" ,(tuple(parent_ids),)) r= dict(cr.fetchall()) - return self._compute_currency_for_level_tree(cr, uid, ids, ids2, r, acc_set, context) + return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, r, context) def _balance_calc(self, cr, uid, ids, name, arg, context={}): res = {} - ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) - acc_set = ",".join(map(str, ids2)) - + parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) for i in ids: res.setdefault(i,0.0) - if not ids2: + if not parent_ids: return res where_date = '' @@ -115,23 +109,22 @@ class account_analytic_account(osv.osv): where_date += " AND l.date >= '" + context['from_date'] + "'" if context.get('to_date',False): where_date += " AND l.date <= '" + context['to_date'] + "'" - cr.execute("SELECT a.id, COALESCE(SUM(l.amount_currency),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE a.id =ANY(%s) GROUP BY a.id",(ids2,)) + cr.execute("SELECT a.id, COALESCE(SUM(l.amount_currency),0) FROM account_analytic_account a LEFT JOIN account_analytic_line l ON (a.id=l.account_id "+where_date+") WHERE a.id IN %s GROUP BY a.id",(tuple(parent_ids),)) for account_id, sum in cr.fetchall(): res[account_id] = sum - return self._compute_currency_for_level_tree(cr, uid, ids, ids2, res, acc_set, context) + return self._compute_currency_for_level_tree(cr, uid, ids, parent_ids, res, context) def _quantity_calc(self, cr, uid, ids, name, arg, context={}): #XXX must convert into one uom res = {} - ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)]) - acc_set = ",".join(map(str, ids2)) + parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)])) for i in ids: res.setdefault(i,0.0) - if not ids2: + if not parent_ids: return res where_date = '' @@ -143,13 +136,13 @@ class account_analytic_account(osv.osv): cr.execute('SELECT a.id, COALESCE(SUM(l.unit_amount), 0) \ FROM account_analytic_account a \ LEFT JOIN account_analytic_line l ON (a.id = l.account_id ' + where_date + ') \ - WHERE a.id =ANY(%s) GROUP BY a.id',(ids2,)) + WHERE a.id IN %s GROUP BY a.id',(tuple(parent_ids),)) for account_id, sum in cr.fetchall(): res[account_id] = sum for id in ids: - if id not in ids2: + if id not in parent_ids: continue for child in self.search(cr, uid, [('parent_id', 'child_of', [id])]): if child != id: @@ -223,9 +216,9 @@ class account_analytic_account(osv.osv): 'type' : lambda *a : 'normal', 'company_id': _default_company, 'state' : lambda *a : 'open', - 'user_id' : lambda self,cr,uid,ctx : uid, - 'partner_id': lambda self,cr, uid, ctx: ctx.get('partner_id', False), - 'contact_id': lambda self,cr, uid, ctx: ctx.get('contact_id', False), + 'user_id' : lambda self, cr, uid, ctx : uid, + 'partner_id': lambda self, cr, uid, ctx: ctx.get('partner_id', False), + 'contact_id': lambda self, cr, uid, ctx: ctx.get('contact_id', False), 'date_start': lambda *a: time.strftime('%Y-%m-%d') } @@ -330,13 +323,13 @@ class account_analytic_line(osv.osv): 'currency_id': fields.function(_get_account_currency, method=True, type='many2one', relation='res.currency', string='Account currency', store={ 'account.analytic.account': (_get_account_line, ['company_id'], 50), - 'account.analytic.line': (lambda self,cr,uid,ids,c={}: ids, ['amount','unit_amount'],10), + 'account.analytic.line': (lambda self, cr, uid, ids, c={}: ids, ['amount','unit_amount'],10), }, help="The related account currency if not equal to the company one."), 'amount_currency': fields.function(_amount_currency, method=True, digits_compute= dp.get_precision('Account'), string='Amount currency', store={ 'account.analytic.account': (_get_account_line, ['company_id'], 50), - 'account.analytic.line': (lambda self,cr,uid,ids,c={}: ids, ['amount','unit_amount'],10), + 'account.analytic.line': (lambda self, cr, uid, ids, c={}: ids, ['amount','unit_amount'],10), }, help="The amount expressed in the related account currency if not equal to the company one."), diff --git a/addons/analytic_journal_billing_rate/analytic_journal_billing_rate.py b/addons/analytic_journal_billing_rate/analytic_journal_billing_rate.py index 060cc389fe6..609d1cad7d9 100644 --- a/addons/analytic_journal_billing_rate/analytic_journal_billing_rate.py +++ b/addons/analytic_journal_billing_rate/analytic_journal_billing_rate.py @@ -27,8 +27,8 @@ class analytic_journal_rate_grid(osv.osv): _name="analytic_journal_rate_grid" _description= "Relation table between journals and billing rates" _columns={ - 'journal_id': fields.many2one('account.analytic.journal', 'Analytic Journal',required=True,), - 'account_id': fields.many2one("account.analytic.account", "Analytic Account",required=True,), + 'journal_id': fields.many2one('account.analytic.journal', 'Analytic Journal', required=True,), + 'account_id': fields.many2one("account.analytic.account", "Analytic Account", required=True,), 'rate_id': fields.many2one("hr_timesheet_invoice.factor", "Invoicing Rate",), } @@ -67,14 +67,14 @@ class hr_analytic_timesheet(osv.osv): #get the old values from super and add the value from the new relation analytic_journal_rate_grid r = self.pool.get('analytic_journal_rate_grid').browse(cr, uid, temp)[0] res.setdefault('value',{}) - res['value']= super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids,account_id,user_id, unit_amount)['value'] + res['value']= super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids, account_id, user_id, unit_amount)['value'] if r.rate_id.id: res['value']['to_invoice'] = r.rate_id.id return res - def on_change_journal_id(self, cr, uid, ids,journal_id, account_id): + def on_change_journal_id(self, cr, uid, ids, journal_id, account_id): res = {} if not (journal_id and account_id): return res diff --git a/addons/analytic_user_function/analytic_user_function.py b/addons/analytic_user_function/analytic_user_function.py index fe238d373be..2f5152faea6 100644 --- a/addons/analytic_user_function/analytic_user_function.py +++ b/addons/analytic_user_function/analytic_user_function.py @@ -28,9 +28,9 @@ class analytic_user_funct_grid(osv.osv): _name="analytic_user_funct_grid" _description= "Relation table between users and products on a analytic account" _columns={ - 'user_id': fields.many2one("res.users","User",required=True,), - 'product_id': fields.many2one("product.product","Product",required=True,), - 'account_id': fields.many2one("account.analytic.account", "Analytic Account",required=True,), + 'user_id': fields.many2one("res.users", "User", required=True,), + 'product_id': fields.many2one("product.product", "Product", required=True,), + 'account_id': fields.many2one("account.analytic.account", "Analytic Account", required=True,), } analytic_user_funct_grid() @@ -53,15 +53,15 @@ class hr_analytic_timesheet(osv.osv): # Look in account, if no value for the user => look in parent until there is no more parent to look # Take the first found... if nothing found => return False - def _get_related_user_account_recursiv(self,cr,uid,user_id,account_id): + def _get_related_user_account_recursiv(self, cr, uid, user_id, account_id): temp=self.pool.get('analytic_user_funct_grid').search(cr, uid, [('user_id', '=', user_id),('account_id', '=', account_id) ]) - account=self.pool.get('account.analytic.account').browse(cr,uid,account_id) + account=self.pool.get('account.analytic.account').browse(cr, uid, account_id) if temp: return temp else: if account.parent_id: - return self._get_related_user_account_recursiv(cr,uid,user_id,account.parent_id.id) + return self._get_related_user_account_recursiv(cr, uid, user_id, account.parent_id.id) else: return False @@ -74,19 +74,19 @@ class hr_analytic_timesheet(osv.osv): return res if not (user_id): - return super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids,account_id) + return super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids, account_id) #get the browse record related to user_id and account_id - temp = self._get_related_user_account_recursiv(cr,uid,user_id,account_id) + temp = self._get_related_user_account_recursiv(cr, uid, user_id, account_id) # temp = self.pool.get('analytic_user_funct_grid').search(cr, uid, [('user_id', '=', user_id),('account_id', '=', account_id) ]) if not temp: #if there isn't any record for this user_id and account_id - return super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids,account_id) + return super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids, account_id) else: #get the old values from super and add the value from the new relation analytic_user_funct_grid r = self.pool.get('analytic_user_funct_grid').browse(cr, uid, temp)[0] res.setdefault('value',{}) - res['value']= super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids,account_id)['value'] + res['value']= super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids, account_id)['value'] res['value']['product_id'] = r.product_id.id res['value']['product_uom_id'] = r.product_id.product_tmpl_id.uom_id.id @@ -108,19 +108,19 @@ class hr_analytic_timesheet(osv.osv): res ['value']['general_account_id']= a return res - def on_change_user_id(self, cr, uid, ids,user_id, account_id, unit_amount=0): + def on_change_user_id(self, cr, uid, ids, user_id, account_id, unit_amount=0): res = {} if not (user_id): #avoid a useless call to super return res #get the old values from super - res = super(hr_analytic_timesheet, self).on_change_user_id(cr, uid, ids,user_id) + res = super(hr_analytic_timesheet, self).on_change_user_id(cr, uid, ids, user_id) if account_id: #get the browse record related to user_id and account_id # temp = self.pool.get('analytic_user_funct_grid').search(cr, uid, [('user_id', '=', user_id),('account_id', '=', account_id) ]) - temp = self._get_related_user_account_recursiv(cr,uid,user_id,account_id) + temp = self._get_related_user_account_recursiv(cr, uid, user_id, account_id) if temp: #add the value from the new relation analytic_user_funct_grid r = self.pool.get('analytic_user_funct_grid').browse(cr, uid, temp)[0] diff --git a/addons/auction/auction.py b/addons/auction/auction.py index b7a379cd387..e7c6198579a 100644 --- a/addons/auction/auction.py +++ b/addons/auction/auction.py @@ -34,7 +34,7 @@ class auction_artists(osv.osv): _columns = { 'name': fields.char('Artist/Author Name', size=64, required=True), 'pseudo': fields.char('Pseudo', size=64), - 'birth_death_dates':fields.char('Birth / Death dates',size=64), + 'birth_death_dates':fields.char('Birth / Death dates', size=64), 'biography': fields.text('Biography'), } auction_artists() @@ -45,7 +45,7 @@ auction_artists() class auction_dates(osv.osv): _name = "auction.dates" - def _adjudication_get(self, cr, uid, ids, prop, unknow_none,unknow_dict): + def _adjudication_get(self, cr, uid, ids, prop, unknow_none, unknow_dict): tmp={} for id in ids: tmp[id]=0.0 @@ -97,15 +97,21 @@ class auction_dates(osv.osv): # objects vendus mais non factures #TODO: convert this query to tiny API lots_obj = self.pool.get('auction.lots') - cr.execute('select count(*) as c from auction_lots where auction_id =ANY(%s) and state=%s and obj_price>0', (ids,'draft',)) + cr.execute('select count(*) as c from auction_lots where auction_id IN %s and state=%s and obj_price>0', (tuple(ids),'draft',)) + cr.execute('SELECT COUNT(*) AS c ' + 'FROM auction_lots ' + 'WHERE auction_id IN %s ' + 'AND state=%s AND obj_price>0', (tuple(ids), 'draft')) nbr = cr.fetchone()[0] ach_uids = {} - cr.execute('select id from auction_lots where auction_id =ANY(%s) and state=%s and obj_price>0', (ids,'draft',)) + cr.execute('SELECT id FROM auction_lots ' + 'WHERE auction_id IN %s ' + 'AND state=%s AND obj_price>0', (tuple(ids), 'draft')) r = lots_obj.lots_invoice(cr, uid, [x[0] for x in cr.fetchall()],{},None) - cr.execute('select id from auction_lots where auction_id =ANY(%s) and obj_price>0',(ids,)) + cr.execute('select id from auction_lots where auction_id IN %s and obj_price>0',(tuple(ids),)) ids2 = [x[0] for x in cr.fetchall()] # for auction in auction_ids: - c = lots_obj.seller_trans_create(cr, uid, ids2,{}) + c = lots_obj.seller_trans_create(cr, uid, ids2, {}) self.write(cr, uid, ids, {'state':'closed'}) #close the auction return True auction_dates() @@ -115,7 +121,9 @@ auction_dates() # Deposits #---------------------------------------------------------- def _inv_uniq(cr, ids): - cr.execute('select name from auction_deposit where id =ANY(%s)',(ids,)) + cr.execute('SELECT id FROM auction_lots ' + 'WHERE auction_id IN %s ' + 'AND obj_price>0', (tuple(ids),)) for datas in cr.fetchall(): cr.execute('select count(*) from auction_deposit where name=%s', (datas[0],)) if cr.fetchone()[0]>1: @@ -231,7 +239,9 @@ def _type_get(self, cr, uid,ids): # Lots #---------------------------------------------------------- def _inv_constraint(cr, ids): - cr.execute('select id, bord_vnd_id, lot_num from auction_lots where id =ANY(%s)', (ids,)) + cr.execute('SELECT id, bord_vnd_id, lot_num FROM auction_lots ' + 'WHERE id IN %s', + (tuple(ids),)) for datas in cr.fetchall(): cr.execute('select count(*) from auction_lots where bord_vnd_id=%s and lot_num=%s', (datas[1],datas[2])) if cr.fetchone()[0]>1: diff --git a/addons/auction/report/artists_lots.py b/addons/auction/report/artists_lots.py index 652a5d9801d..981440dac53 100644 --- a/addons/auction/report/artists_lots.py +++ b/addons/auction/report/artists_lots.py @@ -26,9 +26,9 @@ class report_artistlot(report_int): def __init__(self, name): report_int.__init__(self, name) - def create(self,cr, uid, ids, datas, context): + def create(self, cr, uid, ids, datas, context): service = netsvc.LocalService("object_proxy") - lots = service.execute(cr.dbname,uid, 'auction.lots', 'read', ids, ['artist_id']) + lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', ids, ['artist_id']) artists = [] for lot in lots: if lot['artist_id'] and lot['artist_id'] not in artists: @@ -40,7 +40,7 @@ class report_artistlot(report_int): datas['ids'] = artists self._obj_report = netsvc.LocalService('report.report.auction.artists') - return self._obj_report.create(cr,uid, artists, datas, context) + return self._obj_report.create(cr, uid, artists, datas, context) def result(self): return self._obj_report.result() diff --git a/addons/auction/report/auction_invoice.py b/addons/auction/report/auction_invoice.py index b8c508237a5..40ca8498756 100644 --- a/addons/auction/report/auction_invoice.py +++ b/addons/auction/report/auction_invoice.py @@ -27,7 +27,7 @@ class auction_invoice(report_int): report_int.__init__(self, name) def create(self,cr, uid, ids, datas, context): - lots = self.pool.get('auction.lots').read(cr,uid, ids, ['ach_inv_id'], context=context) + lots = self.pool.get('auction.lots').read(cr, uid, ids, ['ach_inv_id'], context=context) invoices = {} for l in lots: @@ -40,7 +40,7 @@ class auction_invoice(report_int): datas['ids'] = new_ids self._obj_invoice = netsvc.LocalService('report.account.invoice') - return self._obj_invoice.create(cr,uid, new_ids, datas, context) + return self._obj_invoice.create(cr, uid, new_ids, datas, context) def result(self): return self._obj_invoice.result() diff --git a/addons/auction/report/auction_objects.py b/addons/auction/report/auction_objects.py index b3f632bb27e..a83a75a873e 100644 --- a/addons/auction/report/auction_objects.py +++ b/addons/auction/report/auction_objects.py @@ -28,19 +28,8 @@ class auction_objects(report_sxw.rml_parse): super(auction_objects, self).__init__(cr, uid, name, context=context) self.localcontext.update({ 'time': time, - #'lines': self.lines - #'get_data' : self.get_data }) -# def lines(self, auction_id): -# -# cr.execute('select ad.name from auction_dates ad, a1uction_lots al where ad.id=al.%d group by ad.name',(auction_id)) -# return self.cr.fetchone()[0] -# def get_data(self, auction_id): -# res = self.pool.get('auction.bid.lines').read(self.cr,self.uid,[lot_id]) -# return True - - report_sxw.report_sxw('report.auction.objects', 'auction.lots', 'addons/auction/report/auction_objects.rml', parser=auction_objects) diff --git a/addons/auction/report/auction_total_rml.py b/addons/auction/report/auction_total_rml.py index 0e207db62bc..576ed47a84d 100644 --- a/addons/auction/report/auction_total_rml.py +++ b/addons/auction/report/auction_total_rml.py @@ -54,62 +54,65 @@ class auction_total_rml(report_sxw.rml_parse): for lot_id in objects: auc_lot_ids.append(lot_id.id) self.total_obj=auc_lot_ids - self.cr.execute('select auction_id from auction_lots where id =ANY(%s) group by auction_id',(auc_lot_ids,)) + self.cr.execute('SELECT auction_id FROM auction_lots ' + 'WHERE id IN %s ' + 'GROUP BY auction_id', + (tuple(auc_lot_ids),)) auc_date_ids = self.cr.fetchall() auct_dat=[] for ad_id in auc_date_ids: - auc_dates_fields = self.pool.get('auction.dates').read(self.cr,self.uid,ad_id[0],['name','auction1','id']) + auc_dates_fields = self.pool.get('auction.dates').read(self.cr, self.uid, ad_id[0], ['name','auction1','id']) auct_dat.append(auc_dates_fields) return auct_dat def sum_taxes(self,auction_id): - self.cr.execute("select count(1) from auction_lots where id =ANY(%s) and auction_id=%s group by auction_id ", (self.total_obj,auction_id,)) + self.cr.execute("select count(1) from auction_lots where id IN %s and auction_id=%s group by auction_id ", (tuple(self.total_obj),auction_id,)) res = self.cr.fetchone() return res[0] def sold_item(self, object_id): - self.cr.execute("select count(1) from auction_lots where id =ANY(%s) and auction_id=%s and state in ('unsold') ", (self.total_obj,object_id,)) + self.cr.execute("select count(1) from auction_lots where id IN %s and auction_id=%s and state IN ('unsold') ", (tuple(self.total_obj),object_id,)) res = self.cr.fetchone() return str(res[0]) def sum_buyer(self, auction_id): - self.cr.execute("select count(*) from auction_lots where id =ANY(%s) and auction_id=%s and (ach_uid is not null or ach_login is not null) ", (self.total_obj,auction_id,)) + self.cr.execute("select count(*) from auction_lots where id IN %s and auction_id=%s and (ach_uid is not null or ach_login is not null) ", (tuple(self.total_obj),auction_id,)) res = self.cr.fetchone() return str(res[0]) def sum_seller(self, auction_id): - self.cr.execute("select count(distinct bord_vnd_id) from auction_lots where id =ANY(%s) and auction_id=%s AND bord_vnd_id is not null ", (self.total_obj,auction_id,)) + self.cr.execute("select count(distinct bord_vnd_id) from auction_lots where id IN %s and auction_id=%s AND bord_vnd_id is not null ", (tuple(self.total_obj),auction_id,)) res = self.cr.fetchone() return res[0] def sum_adj(self, auction_id): - self.cr.execute("select sum(obj_price) from auction_lots where id =ANY(%s) and auction_id=%s ", (self.total_obj,auction_id,)) + self.cr.execute("select sum(obj_price) from auction_lots where id IN %s and auction_id=%s ", (tuple(self.total_obj),auction_id,)) res = self.cr.fetchone() return str(res[0]) def count_take(self, auction_id): - self.cr.execute("select count(*) from auction_lots where id =ANY(%s) and auction_id=%s and ach_emp='True' ", (self.total_obj,auction_id,)) + self.cr.execute("select count(*) from auction_lots where id IN %s and auction_id=%s and ach_emp='True' ", (tuple(self.total_obj),auction_id,)) res = self.cr.fetchone() return str(res[0]) def chek_paid(self, auction_id): - self.cr.execute("select count(1) from auction_lots where id =ANY(%s) and auction_id=%s and ((paid_ach='T') or (is_ok='T')) ", (self.total_obj,auction_id,)) + self.cr.execute("select count(1) from auction_lots where id IN %s and auction_id=%s and ((paid_ach='T') or (is_ok='T')) ", (tuple(self.total_obj),auction_id,)) res = self.cr.fetchone() return str(res[0]) def check_paid_seller(self,auction_id): - self.cr.execute("select sum(seller_price) from auction_lots where id =ANY(%s) and auction_id=%s and paid_vnd != 'T' ", (self.total_obj,auction_id,)) + self.cr.execute("select sum(seller_price) from auction_lots where id IN %s and auction_id=%s and paid_vnd != 'T' ", (tuple(self.total_obj),auction_id,)) res = self.cr.fetchone() return str(res[0]) or 0.0 def sum_credit(self,auction_id): - self.cr.execute("select sum(buyer_price) from auction_lots where id =ANY(%s) and auction_id=%s", (self.total_obj,auction_id,)) + self.cr.execute("select sum(buyer_price) from auction_lots where id IN %s and auction_id=%s", (tuple(self.total_obj),auction_id,)) res = self.cr.fetchone() return str(res[0]) def sum_debit_buyer(self,auction_id): - self.cr.execute("select sum(buyer_price) from auction_lots where id =ANY(%s) and auction_id=%s", (self.total_obj,auction_id,)) + self.cr.execute("select sum(buyer_price) from auction_lots where id IN %s and auction_id=%s", (tuple(self.total_obj),auction_id,)) res = self.cr.fetchone() return str(res[0] or 0) @@ -121,27 +124,27 @@ class auction_total_rml(report_sxw.rml_parse): def sum_credit_seller(self, object_id): - self.cr.execute("select sum(seller_price) from auction_lots where id =ANY(%s) and auction_id=%s", (self.total_obj,object_id,)) + self.cr.execute("select sum(seller_price) from auction_lots where id IN %s and auction_id=%s", (tuple(self.total_obj),object_id,)) res = self.cr.fetchone() return str(res[0] or 0) def sum_minadj(self, auction_id): - self.cr.execute('select sum(lot_est1) from auction_lots where id =ANY(%s) and auction_id=%s', (self.total_obj,auction_id,)) + self.cr.execute('select sum(lot_est1) from auction_lots where id IN %s and auction_id=%s', (tuple(self.total_obj),auction_id,)) res = self.cr.fetchone() return str(res[0]) or 0 def sum_maxadj(self, auction_id): - self.cr.execute('select sum(lot_est2) from auction_lots where id =ANY(%s) and auction_id=%s', (self.total_obj,auction_id,)) + self.cr.execute('select sum(lot_est2) from auction_lots where id IN %s and auction_id=%s', (tuple(self.total_obj),auction_id,)) res = self.cr.fetchone() return str(res[0]) or 0 def sum_buyer_paid(self, auction_id): - self.cr.execute("select count(*) from auction_lots where id =ANY(%s) and auction_id=%s and state = 'paid' ", (self.total_obj,auction_id,)) + self.cr.execute("select count(*) from auction_lots where id IN %s and auction_id=%s and state = 'paid' ", (tuple(self.total_obj),auction_id,)) res = self.cr.fetchone() return str(res[0]) def count_comm(self, auction_id): - self.cr.execute("select count(*) from auction_lots where id =ANY(%s) and auction_id=%s and obj_comm is not null ", (self.total_obj,auction_id,)) + self.cr.execute("select count(*) from auction_lots where id IN %s and auction_id=%s and obj_comm is not null ", (tuple(self.total_obj),auction_id,)) res = self.cr.fetchone() return str(res[0]) diff --git a/addons/auction/report/buyer_form_report.py b/addons/auction/report/buyer_form_report.py index 2284ff78a16..5dfe5fecca6 100644 --- a/addons/auction/report/buyer_form_report.py +++ b/addons/auction/report/buyer_form_report.py @@ -44,7 +44,7 @@ class buyer_form_report(report_sxw.rml_parse): taxes.append(lot.author_right) if lot.auction_id: taxes += lot.auction_id.buyer_costs - tax=self.pool.get('account.tax').compute(self.cr,self.uid,taxes,lot.obj_price,1) + tax=self.pool.get('account.tax').compute(self.cr, self.uid, taxes, lot.obj_price, 1) for t in tax: amount+=t['amount'] return amount @@ -55,7 +55,7 @@ class buyer_form_report(report_sxw.rml_parse): for object in objects: partner = ret_dict.get(object.ach_uid.id,False) if not partner: - ret_dict[object.ach_uid.id] = {'partner' : object.ach_uid or False,'lots':[object]} + ret_dict[object.ach_uid.id] = {'partner' : object.ach_uid or False, 'lots':[object]} else: lots = partner.get('lots') lots.append(object) diff --git a/addons/auction/report/buyer_list.py b/addons/auction/report/buyer_list.py index 06430efdc85..dde5c6ede04 100644 --- a/addons/auction/report/buyer_list.py +++ b/addons/auction/report/buyer_list.py @@ -43,22 +43,23 @@ class buyer_list(report_sxw.rml_parse): 'sum_lots':self.sum_lots }) - def lines_lots_from_auction(self,objects): + def lines_lots_from_auction(self, objects): auc_lot_ids = [] for lot_id in objects: auc_lot_ids.append(lot_id.id) self.auc_lot_ids=auc_lot_ids - self.cr.execute('select auction_id from auction_lots where id =ANY(%s) group by auction_id',(auc_lot_ids,)) + self.cr.execute('SELECT auction_id FROM auction_lots WHERE id IN %s GROUP BY auction_id', + (tuple(auc_lot_ids),)) auc_date_ids = self.cr.fetchall() auct_dat=[] for ad_id in auc_date_ids: - auc_dates_fields = self.pool.get('auction.dates').read(self.cr,self.uid,ad_id[0],['name']) + auc_dates_fields = self.pool.get('auction.dates').read(self.cr, self.uid, ad_id[0], ['name']) self.cr.execute('select * from auction_buyer_taxes_rel abr,auction_dates ad where ad.id=abr.auction_id and ad.id=%s', (ad_id[0],)) res=self.cr.fetchall() total=0 for r in res: - buyer_rel_field = self.pool.get('account.tax').read(self.cr,self.uid,r[1],['amount']) + buyer_rel_field = self.pool.get('account.tax').read(self.cr, self.uid, r[1], ['amount']) total = total + buyer_rel_field['amount'] auc_dates_fields['amount']=total auct_dat.append(auc_dates_fields) @@ -67,15 +68,18 @@ class buyer_list(report_sxw.rml_parse): def lines_lots_auct_lot(self,obj): auc_lot_ids = [] - auc_date_ids = self.pool.get('auction.dates').search(self.cr,self.uid,([('name','like',obj['name'])])) + auc_date_ids = self.pool.get('auction.dates').search(self.cr, self.uid, ([('name','like',obj['name'])])) -# self.cr.execute('select ach_uid,count(1) as no_lot, sum(obj_price) as adj_price, sum(buyer_price)-sum(obj_price) as buyer_cost ,sum(buyer_price) as to_pay from auction_lots where id in ('+','.join(map(str,self.auc_lot_ids))+') and auction_id=%s and ach_uid is not null group by ach_uid ', (auc_date_ids[0],)) - self.cr.execute('select ach_login as ach_uid,count(1) as no_lot, sum(obj_price) as adj_price, sum(buyer_price)-sum(obj_price) as buyer_cost ,sum(buyer_price) as to_pay from auction_lots where id =ANY(%s) and auction_id=%s and ach_login is not null group by ach_login order by ach_login', (self.auc_lot_ids,auc_date_ids[0],)) + self.cr.execute('SELECT ach_login AS ach_uid, COUNT(1) AS no_lot, '\ + 'SUM(obj_price) AS adj_price, '\ + 'SUM(buyer_price)-SUM(obj_price) AS buyer_cost, '\ + 'SUM(buyer_price) AS to_pay '\ + 'FROM auction_lots WHERE id IN %s '\ + 'AND auction_id=%s AND ach_login IS NOT NULL '\ + 'GROUP BY ach_login ORDER BY ach_login', + (tuple(self.auc_lot_ids), auc_date_ids[0],)) res = self.cr.dictfetchall() for r in res: -# if r['ach_uid']: -# tnm=self.pool.get('res.partner').read(self.cr,self.uid,[r['ach_uid']],['name'])# -# r.__setitem__('ach_uid',tnm[0]['name']) self.sum_adj_price_val = self.sum_adj_price_val + r['adj_price'] self.sum_buyer_obj_price_val = self.sum_buyer_obj_price_val + r['buyer_cost'] self.sum_buyer_price_val = self.sum_buyer_price_val + r['to_pay'] diff --git a/addons/auction/report/catalog2.py b/addons/auction/report/catalog2.py index 3eb993c55ce..b84bab5b9fd 100644 --- a/addons/auction/report/catalog2.py +++ b/addons/auction/report/catalog2.py @@ -69,7 +69,7 @@ class auction_catalog(report_rml): temp=self.post_process_xml_data(cr, uid, xml, context) return temp - def catalog_xml(self,cr,uid,ids,data,context,cwid="0"): + def catalog_xml(self, cr, uid, ids, data, context, cwid="0"): impl = minidom.getDOMImplementation() doc = impl.createDocument(None, "report", None) @@ -84,10 +84,10 @@ class auction_catalog(report_rml): tab_no_photo=[] for id in ids: lot_ids=pooler.get_pool(cr.dbname).get('auction.lots').search(cr, uid, [('auction_id', '=', id)]) - ab=pooler.get_pool(cr.dbname).get('auction.lots').read(cr,uid,lot_ids,['auction_id','name','lot_num','lot_est1','lot_est2'],context) + ab=pooler.get_pool(cr.dbname).get('auction.lots').read(cr, uid, lot_ids, ['auction_id','name','lot_num','lot_est1','lot_est2'], context) auction_dates_ids = [x["auction_id"][0] for x in ab] - res=pooler.get_pool(cr.dbname).get('auction.dates').read(cr,uid,ids,['name','auction1','auction2'],context) + res=pooler.get_pool(cr.dbname).get('auction.dates').read(cr, uid, ids, ['name','auction1','auction2'], context) # name emelment key = 'name' categ = doc.createElement(key) @@ -126,7 +126,7 @@ class auction_catalog(report_rml): for test in ab: if test.has_key('auction_id'): auction_ids.append(test['auction_id'][0]) - cr.execute('select * from auction_lots where auction_id =ANY(%s)',(auction_ids,)) + cr.execute('select * from auction_lots where auction_id IN %s',(tuple(auction_ids),)) res = cr.dictfetchall() for cat in res: product =doc.createElement('product') diff --git a/addons/auction/report/lots_list.py b/addons/auction/report/lots_list.py index e56c7cd7866..e21df216c64 100644 --- a/addons/auction/report/lots_list.py +++ b/addons/auction/report/lots_list.py @@ -31,7 +31,7 @@ class lots_list(report_sxw.rml_parse): 'bid_line' : self.bid_line }) def bid_line(self, lot_id): - res = self.pool.get('auction.bid.lines').read(self.cr,self.uid,[lot_id]) + res = self.pool.get('auction.bid.lines').read(self.cr, self.uid, [lot_id]) return True report_sxw.report_sxw('report.lots.list', 'auction.lots', 'addons/auction/report/lots_list.rml', parser=lots_list) diff --git a/addons/auction/report/seller_address.py b/addons/auction/report/seller_address.py index cd33f690ea5..315533e99f4 100644 --- a/addons/auction/report/seller_address.py +++ b/addons/auction/report/seller_address.py @@ -26,9 +26,9 @@ class auction_seller(report_int): def __init__(self, name): report_int.__init__(self, name) - def create(self,cr, uid, ids, datas, context): + def create(self, cr, uid, ids, datas, context): service = netsvc.LocalService("object_proxy") - lots = service.execute(cr.dbname,uid, 'auction.lots', 'read', ids, ['bord_vnd_id']) + lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', ids, ['bord_vnd_id']) bords = {} for l in lots: @@ -37,7 +37,7 @@ class auction_seller(report_int): new_ids = bords.keys() parts = {} - partners = service.execute(cr.dbname,uid, 'auction.deposit', 'read', new_ids, ['partner_id']) + partners = service.execute(cr.dbname, uid, 'auction.deposit', 'read', new_ids, ['partner_id']) for l in partners: if l['partner_id']: parts[l['partner_id'][0]]=True @@ -48,7 +48,7 @@ class auction_seller(report_int): datas['ids'] = new_ids self._obj_invoice = netsvc.LocalService('report.res.partner.address') - return self._obj_invoice.create(cr,uid, new_ids, datas, context) + return self._obj_invoice.create(cr, uid, new_ids, datas, context) def result(self): return self._obj_invoice.result() diff --git a/addons/auction/report/seller_form_report.py b/addons/auction/report/seller_form_report.py index cc476558df9..7e8af752796 100644 --- a/addons/auction/report/seller_form_report.py +++ b/addons/auction/report/seller_form_report.py @@ -28,7 +28,7 @@ from osv import osv class seller_form_report(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(seller_form_report, self).__init__(cr, uid, name, context=context) - lot=self.pool.get('auction.lots').browse(cr,uid,uid) + lot=self.pool.get('auction.lots').browse(cr, uid, uid) #address=lot.bord_vnd_id.address_get(self.cr,self.uid,[partner.id]) # partner=lot.bord_vnd_id.partner_id # address=partner.address and partner.address[0] or "" @@ -53,7 +53,7 @@ class seller_form_report(report_sxw.rml_parse): taxes.append(lot.bord_vnd_id.tax_id) elif lot.auction_id and lot.auction_id.seller_costs: taxes += lot.auction_id.seller_costs - tax=self.pool.get('account.tax').compute(self.cr,self.uid,taxes,lot.obj_price,1) + tax=self.pool.get('account.tax').compute(self.cr, self.uid, taxes, lot.obj_price, 1) for t in tax: amount+=t['amount'] return amount diff --git a/addons/auction/report/total.py b/addons/auction/report/total.py index 135e495e4b6..0d87709cbee 100644 --- a/addons/auction/report/total.py +++ b/addons/auction/report/total.py @@ -35,14 +35,14 @@ class report_custom(report_rml): def __init__(self, name, table, tmpl, xsl): report_rml.__init__(self, name, table, tmpl, xsl) - def create_xml(self,cr, uid, ids, datas, context={}): + def create_xml(self, cr, uid, ids, datas, context={}): service = netsvc.LocalService("object_proxy") # start_time = time.clock() # lots = service.execute(cr.dbname,uid, 'auction.lots', 'read', ids, ['obj_price','ach_pay_id','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']) - auction = service.execute(cr.dbname,uid, 'auction.dates', 'read', [lots[0]['auction_id'][0]])[0] + 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']) + auction = service.execute(cr.dbname, uid, 'auction.dates', 'read', [lots[0]['auction_id'][0]])[0] # mid_time = time.clock() @@ -96,7 +96,7 @@ class report_custom(report_rml): # mid_time3 = time.clock() debit = adj - costs = service.execute(cr.dbname,uid, 'auction.lots', 'compute_seller_costs', ids) + costs = service.execute(cr.dbname, uid, 'auction.lots', 'compute_seller_costs', ids) for cost in costs: debit += cost['amount'] diff --git a/addons/auction/wizard/auction_aie_send.py b/addons/auction/wizard/auction_aie_send.py index 51368349a98..238f9923677 100644 --- a/addons/auction/wizard/auction_aie_send.py +++ b/addons/auction/wizard/auction_aie_send.py @@ -142,7 +142,7 @@ class auction_lots_send_aie(osv.osv_memory): for (ref,id) in ids: # ids_attach = service.execute(db_name,uid, 'ir.attachment', 'search', [('res_model','=','auction.lots'), ('res_id', '=',id)]) - datas = service.execute(cr.db_name,uid, 'auction.lots', 'read',[id], ['name','image']) + datas = service.execute(cr.db_name, uid, 'auction.lots', 'read', [id], ['name','image']) if len(datas): bin = base64.decodestring(datas[0]['image']) fname = datas[0]['name'] diff --git a/addons/auction/wizard/auction_catalog_flagey_report.py b/addons/auction/wizard/auction_catalog_flagey_report.py index d8fec4b6d95..97440a6680c 100644 --- a/addons/auction/wizard/auction_catalog_flagey_report.py +++ b/addons/auction/wizard/auction_catalog_flagey_report.py @@ -52,9 +52,9 @@ class auction_catalog_flagey(osv.osv_memory): """ lots_obj = self.pool.get('auction.lots') auc_dates_obj = self.pool.get('auction.dates') - current_auction = auc_dates_obj.browse(cr,uid,context.get('active_ids', [])) - v_lots = lots_obj.search(cr,uid,[('auction_id','=',current_auction.id)]) - v_ids = lots_obj.browse(cr,uid,v_lots) + current_auction = auc_dates_obj.browse(cr, uid, context.get('active_ids', [])) + v_lots = lots_obj.search(cr, uid, [('auction_id','=',current_auction.id)]) + v_ids = lots_obj.browse(cr, uid, v_lots) for ab in v_ids: if not ab.auction_id : raise osv.except_osv('Error!','No Lots belong to this Auction Date') diff --git a/addons/auction/wizard/auction_lots_buyer_map.py b/addons/auction/wizard/auction_lots_buyer_map.py index b20250edc38..bee39e0d258 100644 --- a/addons/auction/wizard/auction_lots_buyer_map.py +++ b/addons/auction/wizard/auction_lots_buyer_map.py @@ -84,7 +84,7 @@ class wiz_auc_lots_buyer_map(osv.osv_memory): """ rec_ids = context and context.get('active_ids',False) or False assert rec_ids, _('Active IDs not Found') - datas = self.read(cr, uid, ids[0],['ach_login','ach_uid']) + datas = self.read(cr, uid, ids[0], ['ach_login','ach_uid']) lots_obj = self.pool.get('auction.lots') recs = lots_obj.browse(cr, uid, rec_ids, context) for rec in recs: diff --git a/addons/auction/wizard/auction_lots_cancel.py b/addons/auction/wizard/auction_lots_cancel.py index edf530ac8aa..35207ff3bfc 100644 --- a/addons/auction/wizard/auction_lots_cancel.py +++ b/addons/auction/wizard/auction_lots_cancel.py @@ -43,11 +43,11 @@ class auction_lots_cancel(osv.osv): lots_obj = self.pool.get('auction.lots') invoice_obj = self.pool.get('account.invoice') - lot = lots_obj.browse(cr,uid,context['active_id'],context) + lot = lots_obj.browse(cr, uid, context['active_id'], context) 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: - customer_refund_inv_id = invoice_obj.refund(cr, uid,[lot.sel_inv_id.id]) + customer_refund_inv_id = invoice_obj.refund(cr, uid, [lot.sel_inv_id.id]) return {} _columns = { diff --git a/addons/auction/wizard/auction_lots_invoice.py b/addons/auction/wizard/auction_lots_invoice.py index 9581941266f..999db109490 100644 --- a/addons/auction/wizard/auction_lots_invoice.py +++ b/addons/auction/wizard/auction_lots_invoice.py @@ -50,7 +50,7 @@ class auction_lots_invoice(osv.osv_memory): res = super(auction_lots_invoice, self).default_get(cr, uid, fields, context=context) service = netsvc.LocalService("object_proxy") lots = service.execute(cr.dbname, uid, 'auction.lots', 'read', context.get('active_ids', [])) - auction = service.execute(cr.dbname,uid, 'auction.dates', 'read', [lots[0]['auction_id'][0]])[0] + auction = service.execute(cr.dbname, uid, 'auction.dates', 'read', [lots[0]['auction_id'][0]])[0] price = 0.0 price_topay = 0.0 diff --git a/addons/auction/wizard/auction_transfer_unsold_object.py b/addons/auction/wizard/auction_transfer_unsold_object.py index 47aadc25d59..3e50a32f598 100644 --- a/addons/auction/wizard/auction_transfer_unsold_object.py +++ b/addons/auction/wizard/auction_transfer_unsold_object.py @@ -66,14 +66,14 @@ class auction_transfer_unsold_object(osv.osv): bid_line_obj = self.pool.get('auction.bid_line') lots_obj = self.pool.get('auction.lots') lot_history_obj = self.pool.get('auction.lot.history') - line_ids= bid_line_obj.search(cr,uid,[('lot_id','in',context['active_ids'])]) + line_ids= bid_line_obj.search(cr, uid, [('lot_id','in',context['active_ids'])]) bid_line_obj.unlink(cr, uid, line_ids) res = self.browse(cr, uid, ids) 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): - 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, + new_id = lot_history_obj.create(cr, uid, {'auction_id':rec.auction_id.id,'lot_id':rec.id,'price': rec.obj_ret, 'name': rec.auction_id.auction1}) + up_auction = lots_obj.write(cr, uid, [rec.id], {'auction_id': res[0].auction_id_to.id, 'obj_ret':None, 'obj_price':None, 'ach_login':None, diff --git a/addons/base_contact/base_contact.py b/addons/base_contact/base_contact.py index 23589fd2d6d..2bedf9d15fa 100644 --- a/addons/base_contact/base_contact.py +++ b/addons/base_contact/base_contact.py @@ -59,18 +59,18 @@ class res_partner_contact(osv.osv): return res _columns = { - 'name': fields.char('Last Name', size=30,required=True), + 'name': fields.char('Last Name', size=30, required=True), 'first_name': fields.char('First Name', size=30), - 'mobile': fields.char('Mobile',size=30), + 'mobile': fields.char('Mobile', size=30), 'title': fields.selection(_title_get, 'Title'), - 'website': fields.char('Website',size=120), - 'lang_id': fields.many2one('res.lang','Language'), - 'job_ids': fields.one2many('res.partner.job','contact_id','Functions and Addresses'), + 'website': fields.char('Website', size=120), + 'lang_id': fields.many2one('res.lang', 'Language'), + 'job_ids': fields.one2many('res.partner.job', 'contact_id', 'Functions and Addresses'), 'country_id': fields.many2one('res.country','Nationality'), 'birthdate': fields.date('Birth Date'), 'active': fields.boolean('Active', help="If the active field is set to true,\ it will allow you to hide the partner contact without removing it."), - 'partner_id': fields.related('job_ids','address_id','partner_id',type='many2one',\ + 'partner_id': fields.related('job_ids', 'address_id', 'partner_id', type='many2one',\ relation='res.partner', string='Main Employer'), 'function': fields.related('job_ids', 'function', type='char', \ string='Main Function'), diff --git a/addons/base_module_quality/speed_test/speed_test.py b/addons/base_module_quality/speed_test/speed_test.py index f3d802451f4..5b78b5e096f 100644 --- a/addons/base_module_quality/speed_test/speed_test.py +++ b/addons/base_module_quality/speed_test/speed_test.py @@ -61,7 +61,7 @@ This test checks the speed of the module. Note that at least 5 demo data is need # remove osv_memory class becaz it does not have demo data if obj_list: - cr.execute("select w.res_model from ir_actions_todo as t left join ir_act_window as w on t.action_id=w.id where w.res_model =ANY(%s)",(obj_list,)) + cr.execute("select w.res_model from ir_actions_todo as t left join ir_act_window as w on t.action_id=w.id where w.res_model IN %s",(tuple(obj_list),)) res = cr.fetchall() print res for remove_obj in res: diff --git a/addons/crm/crm.py b/addons/crm/crm.py index 618dd55cc21..7510bc48914 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -465,7 +465,7 @@ class crm_case_section(osv.osv): level = 100 while len(ids): - cr.execute('select distinct parent_id from crm_case_section where id =ANY(%s)', (ids,)) + cr.execute('select distinct parent_id from crm_case_section where id IN %s', (tuple(ids),)) ids = filter(None, map(lambda x: x[0], cr.fetchall())) if not level: return False diff --git a/addons/crm/report/report_businessopp.py b/addons/crm/report/report_businessopp.py index 9e08a9941ee..5bce5fc6ef0 100644 --- a/addons/crm/report/report_businessopp.py +++ b/addons/crm/report/report_businessopp.py @@ -69,7 +69,7 @@ class report_custom(report_int): cr.execute('select probability, planned_revenue, planned_cost, user_id,\ res_users.name as name from crm_case left join res_users on \ - (crm_case.user_id=res_users.id) where crm_case.id =ANY(%s) order by user_id',(ids,)) + (crm_case.user_id=res_users.id) where crm_case.id IN %s order by user_id',(tuple(ids),)) res = cr.dictfetchall() for row in res: diff --git a/addons/crm_profiling/crm_profiling.py b/addons/crm_profiling/crm_profiling.py index 760c9b20bba..a14741415ea 100644 --- a/addons/crm_profiling/crm_profiling.py +++ b/addons/crm_profiling/crm_profiling.py @@ -33,7 +33,7 @@ def _get_answers(cr, uid, ids): query = """ select distinct(answer) from profile_question_yes_rel - where profile=ANY(%s)""" + where profile IN %s""" cr.execute(query, (ids,)) ans_yes = [x[0] for x in cr.fetchall()] @@ -41,9 +41,9 @@ def _get_answers(cr, uid, ids): query = """ select distinct(answer) from profile_question_no_rel - where profile=ANY(%s)""" + where profile IN %s""" - cr.execute(query, (ids,)) + cr.execute(query, (tuple(ids),)) ans_no = [x[0] for x in cr.fetchall()] return [ans_yes, ans_no] @@ -61,7 +61,7 @@ def _get_parents(cr, uid, ids): select distinct(parent_id) from crm_segmentation where parent_id is not null - and id=ANY(%s)""",(ids,)) + and id IN %s""",(tuple(ids),)) parent_ids = [x[0] for x in cr.fetchall()] diff --git a/addons/document/content_index.py b/addons/document/content_index.py index a13ba35b60a..e7f88834647 100644 --- a/addons/document/content_index.py +++ b/addons/document/content_index.py @@ -27,7 +27,7 @@ class NhException(Exception): from subprocess import Popen, PIPE -class indexer(): +class indexer(object): """ An indexer knows how to parse the content of some file. Typically, one indexer should be instantiated per file @@ -43,7 +43,7 @@ class indexer(): def _getExtensions(self): return [] - def _getDefMime(self,ext): + def _getDefMime(self, ext): """ Return a mimetype for this document type, ideally the closest to the extension ext. """ mts = self._getMimeTypes(); @@ -51,7 +51,7 @@ class indexer(): return mts[0] return None - def indexContent(self,content,filename=None, realfile = None): + def indexContent(self, content, filename=None, realfile = None): """ Use either content or the real file, to index. Some parsers will work better with the actual content, others parse a file easier. Try the @@ -111,7 +111,7 @@ def mime_match(mime, mdict): return (None, None) -class contentIndex(): +class contentIndex(object): __logger = logging.getLogger('addons.document.content_index') def __init__(self): self.mimes = {} @@ -132,7 +132,7 @@ class contentIndex(): if not f: raise Exception("Your indexer should at least suport a mimetype or extension") - def doIndex(self,content, filename=None, content_type=None, realfname = None, debug=False): + def doIndex(self, content, filename=None, content_type=None, realfname = None, debug=False): fobj = None fname = None mime = None diff --git a/addons/document/directory_report.py b/addons/document/directory_report.py index a7a3d80191b..a4cd2f45068 100644 --- a/addons/document/directory_report.py +++ b/addons/document/directory_report.py @@ -35,10 +35,10 @@ class ir_action_report_xml(osv.osv): def _model_get(self, cr, uid, ids, name, arg, context): res = {} model_pool = self.pool.get('ir.model') - for data in self.read(cr,uid,ids,['model']): + for data in self.read(cr, uid, ids, ['model']): model = data.get('model',False) if model: - model_id =model_pool.search(cr,uid,[('model','=',model)]) + model_id =model_pool.search(cr, uid, [('model','=',model)]) if model_id: res[data.get('id')] = model_id[0] else: @@ -51,14 +51,14 @@ class ir_action_report_xml(osv.osv): model_id= args[0][2] if not model_id: return [] - model = self.pool.get('ir.model').read(cr,uid,[model_id])[0]['model'] - report_id = self.search(cr,uid,[('model','=',model)]) + model = self.pool.get('ir.model').read(cr, uid, [model_id])[0]['model'] + report_id = self.search(cr, uid, [('model','=',model)]) if not report_id: return [('id','=','0')] return [('id','in',report_id)] _columns={ - 'model_id' : fields.function(_model_get,fnct_search=_model_search,method=True,string='Model Id'), + 'model_id' : fields.function(_model_get, fnct_search=_model_search, method=True, string='Model Id'), } ir_action_report_xml() diff --git a/addons/document/document_directory.py b/addons/document/document_directory.py index e395f96833d..1d0bbf3ed7c 100644 --- a/addons/document/document_directory.py +++ b/addons/document/document_directory.py @@ -78,10 +78,10 @@ class document_directory(osv.osv): return False return objid.browse(cr, uid, mid, context=context).res_id - def _get_def_storage(self,cr,uid,context=None): + def _get_def_storage(self, cr, uid, context=None): if context and context.has_key('default_parent_id'): # Use the same storage as the parent.. - diro = self.browse(cr,uid,context['default_parent_id']) + diro = self.browse(cr, uid, context['default_parent_id']) if diro.storage_id: return diro.storage_id.id objid=self.pool.get('ir.model.data') @@ -119,7 +119,7 @@ class document_directory(osv.osv): """ Return the full path to this directory, in a list, root first """ def _parent(dir_id, path): - parent=self.browse(cr,uid,dir_id) + parent=self.browse(cr, uid, dir_id) if parent.parent_id and not parent.ressource_parent_type_id: _parent(parent.parent_id.id,path) path.append(parent.name) @@ -130,12 +130,12 @@ class document_directory(osv.osv): _parent(dir_id, path) return path - def ol_get_resource_path(self,cr,uid,dir_id,res_model,res_id): + def ol_get_resource_path(self, cr, uid, dir_id, res_model, res_id): # this method will be used in process module # to be need test and Improvement if resource dir has parent resource (link resource) path=[] def _parent(dir_id,path): - parent=self.browse(cr,uid,dir_id) + parent=self.browse(cr, uid, dir_id) if parent.parent_id and not parent.ressource_parent_type_id: _parent(parent.parent_id.id,path) path.append(parent.name) @@ -144,10 +144,10 @@ class document_directory(osv.osv): return path directory=self.browse(cr,uid,dir_id) - model_ids=self.pool.get('ir.model').search(cr,uid,[('model','=',res_model)]) + model_ids=self.pool.get('ir.model').search(cr, uid, [('model','=',res_model)]) if directory: _parent(dir_id,path) - path.append(self.pool.get(directory.ressource_type_id.model).browse(cr,uid,res_id).name) + path.append(self.pool.get(directory.ressource_type_id.model).browse(cr, uid, res_id).name) #user=self.pool.get('res.users').browse(cr,uid,uid) #return "ftp://%s:%s@localhost:%s/%s/%s"%(user.login,user.password,config.get('ftp_server_port',8021),cr.dbname,'/'.join(path)) # No way we will return the password! @@ -195,7 +195,7 @@ class document_directory(osv.osv): context['lang'] = lang try: #just instrumentation - return nodes.get_node_context(cr, uid, context).get_uri(cr,uri) + return nodes.get_node_context(cr, uid, context).get_uri(cr, uri) except Exception,e: print "exception: ",e raise @@ -235,15 +235,15 @@ class document_directory(osv.osv): default ={} name = self.read(cr, uid, [id])[0]['name'] default.update({'name': name+ " (copy)"}) - return super(document_directory,self).copy(cr,uid,id,default,context) + return super(document_directory,self).copy(cr, uid, id, default, context) - def _check_duplication(self, cr, uid,vals,ids=[],op='create'): + def _check_duplication(self, cr, uid, vals, ids=[], op='create'): name=vals.get('name',False) parent_id=vals.get('parent_id',False) ressource_parent_type_id=vals.get('ressource_parent_type_id',False) ressource_id=vals.get('ressource_id',0) if op=='write': - for directory in self.browse(cr,uid,ids): + for directory in self.browse(cr, uid, ids): if not name: name=directory.name if not parent_id: @@ -261,12 +261,12 @@ class document_directory(osv.osv): return False return True def write(self, cr, uid, ids, vals, context=None): - if not self._check_duplication(cr,uid,vals,ids,op='write'): + if not self._check_duplication(cr, uid, vals, ids, op='write'): raise osv.except_osv(_('ValidateError'), _('Directory name must be unique!')) - return super(document_directory,self).write(cr,uid,ids,vals,context=context) + return super(document_directory,self).write(cr, uid, ids, vals, context=context) def create(self, cr, uid, vals, context=None): - if not self._check_duplication(cr,uid,vals): + if not self._check_duplication(cr, uid, vals): raise osv.except_osv(_('ValidateError'), _('Directory name must be unique!')) if vals.get('name',False) and (vals.get('name').find('/')+1 or vals.get('name').find('@')+1 or vals.get('name').find('$')+1 or vals.get('name').find('#')+1) : raise osv.except_osv(_('ValidateError'), _('Directory name contains special characters!')) diff --git a/addons/document/document_storage.py b/addons/document/document_storage.py index d20870ff825..e680bca5983 100644 --- a/addons/document/document_storage.py +++ b/addons/document/document_storage.py @@ -309,7 +309,7 @@ class document_storage(osv.osv): if not fname: return None path = storage_bo.path - return ( storage_bo.id, 'file', os.path.join(path,fname)) + return ( storage_bo.id, 'file', os.path.join(path, fname)) else: raise TypeError("No %s storage" % boo.type) diff --git a/addons/document/nodes.py b/addons/document/nodes.py index d0815ef9c74..df1878ad798 100644 --- a/addons/document/nodes.py +++ b/addons/document/nodes.py @@ -42,7 +42,7 @@ import time # def get_node_context(cr, uid, context): - return node_context(cr,uid,context) + return node_context(cr, uid, context) class node_context(object): """ This is the root node, representing access to some particular @@ -60,7 +60,7 @@ class node_context(object): def get_uri(self, cr, uri): """ Although this fn passes back to doc.dir, it is needed since it is a potential caching point """ - (ndir, duri) = self._dirobj._locate_child(cr,self.uid, self.rootdir,uri, None, self) + (ndir, duri) = self._dirobj._locate_child(cr, self.uid, self.rootdir, uri, None, self) while duri: ndir = ndir.child(cr, duri[0]) if not ndir: @@ -158,7 +158,7 @@ class node_class(object): return True return False - def get_dav_eprop(self,cr,ns,prop): + def get_dav_eprop(self, cr, ns, prop): return None def rm(self, cr): @@ -205,19 +205,19 @@ class node_database(node_class): where2 = where + domain + [('type', '=', 'directory')] ids = dirobj.search(cr, uid, where2, context=ctx) res = [] - for dirr in dirobj.browse(cr,uid,ids,context=ctx): - res.append(node_dir(dirr.name,self,self.context,dirr)) + for dirr in dirobj.browse(cr, uid, ids, context=ctx): + res.append(node_dir(dirr.name, self, self.context,dirr)) where2 = where + domain + [('type', '=', 'ressource'), ('ressource_parent_type_id','=',False)] ids = dirobj.search(cr, uid, where2, context=ctx) - for dirr in dirobj.browse(cr,uid,ids,context=ctx): - res.append(node_res_dir(dirr.name,self,self.context,dirr)) + for dirr in dirobj.browse(cr, uid, ids, context=ctx): + res.append(node_res_dir(dirr.name, self, self.context, dirr)) fil_obj = dirobj.pool.get('ir.attachment') - ids = fil_obj.search(cr,uid,where,context=ctx) + ids = fil_obj.search(cr, uid, where, context=ctx) if ids: - for fil in fil_obj.browse(cr,uid,ids,context=ctx): - res.append(node_file(fil.name,self,self.context,fil)) + for fil in fil_obj.browse(cr, uid, ids, context=ctx): + res.append(node_file(fil.name, self, self.context, fil)) return res def _file_get(self,cr, nodename=False, directory_id=False): @@ -241,7 +241,7 @@ class node_database(node_class): class node_dir(node_database): our_type = 'collection' - def __init__(self,path, parent, context, dirr, dctx=None): + def __init__(self, path, parent, context, dirr, dctx=None): super(node_dir,self).__init__(path, parent,context) self.dir_id = dirr and dirr.id or False #todo: more info from dirr @@ -269,7 +269,7 @@ class node_dir(node_database): pass - def get_data(self,cr): + def get_data(self, cr): res = '' for child in self.children(cr): res += child.get_data(cr) @@ -277,7 +277,7 @@ class node_dir(node_database): - def _file_get(self,cr, nodename=False): + def _file_get(self, cr, nodename=False): return super(node_dir,self)._file_get(cr, nodename, self.dir_id) @@ -320,7 +320,7 @@ class node_dir(node_database): return dirobj.create(cr, uid, val) - def create_child(self,cr,path,data): + def create_child(self, cr, path, data): """ API function to create a child file object and node Return the node_* created """ @@ -336,10 +336,10 @@ class node_dir(node_database): # Datas are not set here } - fil_id = fil_obj.create(cr,uid, val, context=ctx) - fil = fil_obj.browse(cr,uid,fil_id,context=ctx) - fnode = node_file(path,self,self.context,fil) - fnode.set_data(cr,data,fil) + fil_id = fil_obj.create(cr, uid, val, context=ctx) + fil = fil_obj.browse(cr, uid, fil_id, context=ctx) + fnode = node_file(path, self, self.context, fil) + fnode.set_data(cr, data, fil) return fnode def get_etag(self, cr): @@ -365,8 +365,8 @@ class node_res_dir(node_class): node_dirs (with limited domain). """ our_type = 'collection' - def __init__(self,path, parent, context, dirr, dctx=None ): - super(node_res_dir,self).__init__(path, parent,context) + def __init__(self, path, parent, context, dirr, dctx=None ): + super(node_res_dir,self).__init__(path, parent, context) self.dir_id = dirr.id #todo: more info from dirr self.mimetype = 'application/x-directory' @@ -400,7 +400,7 @@ class node_res_dir(node_class): return res[0] return None - def _child_get(self,cr, name = None, domain=None): + def _child_get(self, cr, name = None, domain=None): """ return virtual children of resource, based on the foreign object. @@ -409,7 +409,6 @@ class node_res_dir(node_class): """ obj = self.context._dirobj.pool.get(self.res_model) if not obj: - print "couldn't find model", self.res_model return [] dirobj = self.context._dirobj uid = self.context.uid @@ -432,12 +431,12 @@ class node_res_dir(node_class): if obj._parent_name in obj.fields_get(cr, uid): where.append((obj._parent_name,'=',object2 and object2.id or False)) - resids = obj.search(cr,uid, where, context=ctx) + resids = obj.search(cr, uid, where, context=ctx) res = [] - for bo in obj.browse(cr,uid,resids,context=ctx): + for bo in obj.browse(cr, uid, resids, context=ctx): if not bo: continue - name = getattr(bo,self.namefield) + name = getattr(bo, self.namefield) if not name: continue # Yes! we can't do better but skip nameless records. @@ -479,7 +478,7 @@ class node_res_obj(node_class): dc2['this'] = res_bo for fld,expr in self.dctx_dict.items(): try: - self.dctx[fld] = safe_eval(expr,dc2) + self.dctx[fld] = safe_eval(expr, dc2) except Exception,e: print "Cannot eval %s for %s" % (expr, fld) print e @@ -490,11 +489,11 @@ class node_res_obj(node_class): def children(self, cr, domain=None): return self._child_get(cr, domain=domain) + self._file_get(cr) - def child(self,cr, name, domain=None): + def child(self, cr, name, domain=None): res = self._child_get(cr, name, domain=domain) if res: return res[0] - res = self._file_get(cr,name) + res = self._file_get(cr, name) if res: return res[0] return None @@ -509,9 +508,9 @@ class node_res_obj(node_class): #if self.domain: # where.extend(self.domain) # print "res_obj file_get clause", where - ids = cntobj.search(cr,uid,where,context=ctx) - for content in cntobj.browse(cr,uid,ids,context=ctx): - res3 = cntobj._file_get(cr,self,nodename,content, context=ctx) + ids = cntobj.search(cr, uid, where, context=ctx) + for content in cntobj.browse(cr, uid, ids, context=ctx): + res3 = cntobj._file_get(cr, self, nodename, content, context=ctx) if res3: res.extend(res3) @@ -524,15 +523,15 @@ class node_res_obj(node_class): ctx = self.context.context.copy() ctx.update(self.dctx) where = [('directory_id','=',self.dir_id) ] - ids = cntobj.search(cr,uid,where,context=ctx) - for content in cntobj.browse(cr,uid,ids,context=ctx): + ids = cntobj.search(cr, uid, where, context=ctx) + for content in cntobj.browse(cr, uid, ids, context=ctx): if content.extension == '.ics': # FIXME: call the content class! res['http://groupdav.org/'] = ('resourcetype',) return res - def get_dav_eprop(self,cr,ns,prop): + def get_dav_eprop(self, cr, ns, prop): if ns != 'http://groupdav.org/' or prop != 'resourcetype': - print "Who asked for %s:%s?" % (ns,prop) + print "Who asked for %s:%s?" % (ns, prop) return None res = {} cntobj = self.context._dirobj.pool.get('document.directory.content') @@ -541,12 +540,12 @@ class node_res_obj(node_class): ctx.update(self.dctx) where = [('directory_id','=',self.dir_id) ] ids = cntobj.search(cr,uid,where,context=ctx) - for content in cntobj.browse(cr,uid,ids,context=ctx): + for content in cntobj.browse(cr, uid, ids, context=ctx): if content.extension == '.ics': # FIXME: call the content class! return ('vevent-collection','http://groupdav.org/') return None - def _child_get(self,cr, name=None, domain=None): + def _child_get(self, cr, name=None, domain=None): dirobj = self.context._dirobj uid = self.context.uid ctx = self.context.context.copy() @@ -563,8 +562,8 @@ class node_res_obj(node_class): where1 = [] if obj._parent_name in obj.fields_get(cr, uid): where1 = where + [(obj._parent_name, '=', self.res_id)] - resids = obj.search(cr,uid, where1, context=ctx) - for bo in obj.browse(cr,uid,resids,context=ctx): + resids = obj.search(cr, uid, where1, context=ctx) + for bo in obj.browse(cr, uid, resids, context=ctx): namefield = directory.resource_field.name or 'name' if not bo: continue @@ -634,7 +633,7 @@ class node_res_obj(node_class): return dirobj.create(cr, uid, val) - def create_child(self,cr,path,data): + def create_child(self, cr, path, data): """ API function to create a child file object and node Return the node_* created """ @@ -652,18 +651,18 @@ class node_res_obj(node_class): # Datas are not set here } - fil_id = fil_obj.create(cr,uid, val, context=ctx) - fil = fil_obj.browse(cr,uid,fil_id,context=ctx) - fnode = node_file(path,self,self.context,fil) - fnode.set_data(cr,data,fil) + fil_id = fil_obj.create(cr, uid, val, context=ctx) + fil = fil_obj.browse(cr, uid, fil_id, context=ctx) + fnode = node_file(path, self, self.context, fil) + fnode.set_data(cr, data, fil) return fnode def _get_ttag(self,cr): - return 'rodir-%d-%d' % (self.dir_id,self.res_id) + return 'rodir-%d-%d' % (self.dir_id, self.res_id) class node_file(node_class): our_type = 'file' - def __init__(self,path, parent, context, fil): + def __init__(self, path, parent, context, fil): super(node_file,self).__init__(path, parent,context) self.file_id = fil.id #todo: more info from ir_attachment @@ -745,7 +744,7 @@ class node_file(node_class): stor = data_obj.browse(cr, self.context.uid, data_id, context=self.context.context).res_id assert stor stobj = self.context._dirobj.pool.get('document.storage') - return stobj.get_data(cr,self.context.uid,stor, self,self.context.context, fil_obj) + return stobj.get_data(cr, self.context.uid,stor, self,self.context.context, fil_obj) def get_data_len(self, cr, fil_obj = None): # TODO: verify with the storage object! @@ -768,14 +767,14 @@ class node_file(node_class): stor = data_obj.browse(cr, self.context.uid, data_id, context=self.context.context).res_id assert stor stobj = self.context._dirobj.pool.get('document.storage') - return stobj.set_data(cr,self.context.uid,stor, self, data, self.context.context, fil_obj) + return stobj.set_data(cr, self.context.uid,stor, self, data, self.context.context, fil_obj) def _get_ttag(self,cr): return 'file-%d' % self.file_id class node_content(node_class): our_type = 'content' - def __init__(self,path, parent, context, cnt, dctx = None, act_id=None): + def __init__(self, path, parent, context, cnt, dctx = None, act_id=None): super(node_content,self).__init__(path, parent,context) self.cnt_id = cnt.id self.create_date = False @@ -799,7 +798,7 @@ class node_content(node_class): res.name = self return res - def fill_fields(self,cr,dctx = None): + def fill_fields(self, cr, dctx = None): """ Try to read the object and fill missing fields, like mimetype, dates etc. This function must be different from the constructor, because @@ -817,7 +816,7 @@ class node_content(node_class): cntobj = self.context._dirobj.pool.get('document.directory.content') ctx = self.context.context.copy() ctx.update(self.dctx) - data = cntobj.process_read(cr,self.context.uid,self,ctx) + data = cntobj.process_read(cr, self.context.uid, self, ctx) if data: self.content_length = len(data) return data @@ -831,7 +830,7 @@ class node_content(node_class): cntobj = self.context._dirobj.pool.get('document.directory.content') ctx = self.context.context.copy() ctx.update(self.dctx) - return cntobj.process_write(cr,self.context.uid,self, data,ctx) + return cntobj.process_write(cr, self.context.uid, self, data, ctx) def _get_ttag(self,cr): return 'cnt-%d%s' % (self.cnt_id,(self.act_id and ('-' + str(self.act_id))) or '') diff --git a/addons/document/std_index.py b/addons/document/std_index.py index 2f2f2094bc3..c4f7d787d4d 100644 --- a/addons/document/std_index.py +++ b/addons/document/std_index.py @@ -44,7 +44,7 @@ class TxtIndex(indexer): def _getExtensions(self): return ['.txt', '.py'] - def _doIndexContent(self,content): + def _doIndexContent(self, content): return content cntIndex.register(TxtIndex()) @@ -56,7 +56,7 @@ class PptxIndex(indexer): def _getExtensions(self): return ['.pptx'] - def _doIndexFile(self,fname): + def _doIndexFile(self, fname): # pptx2txt.pl package not support in windows platform. # Download pptx2txt package from http://sourceforge.net/projects/pptx2txt/" link. # To install this tool, just copy pptx2txt.pl to appropriate place (e.g. /usr/bin directory) @@ -88,7 +88,7 @@ class DocxIndex(indexer): def _getExtensions(self): return ['.docx'] - def _doIndexFile(self,fname): + def _doIndexFile(self, fname): # docx2txt.pl package not support in windows platform. # Download docx2txt package from "http://sourceforge.net/projects/docx2txt/" link. # In case, you don't want to use Makefile for installation, you can follow these steps for manual installation. diff --git a/addons/document/test_cindex.py b/addons/document/test_cindex.py index dc5fcf7ebeb..7c0bcb987f3 100644 --- a/addons/document/test_cindex.py +++ b/addons/document/test_cindex.py @@ -27,20 +27,13 @@ for fname in args: fp = open(fname,'rb') content = fp.read() fp.close() - res = cntIndex.doIndex(content,fname,None,None,True) + res = cntIndex.doIndex(content, fname, None, None, True) else: res = cntIndex.doIndex(None, fname, None, fname,True) - if res: - print "Result: ", res[0] - print res[1] - else: - print "No result" except Exception,e: import traceback,sys tb_s = reduce(lambda x, y: x+y, traceback.format_exception( sys.exc_type, sys.exc_value, sys.exc_traceback)) - print "Traceback:",tb_s - print "Exception: ",e #eof diff --git a/addons/document_ftp/ftpserver/abstracted_fs.py b/addons/document_ftp/ftpserver/abstracted_fs.py index 66e4a994cba..60b3c24c7a9 100644 --- a/addons/document_ftp/ftpserver/abstracted_fs.py +++ b/addons/document_ftp/ftpserver/abstracted_fs.py @@ -265,7 +265,7 @@ class abstracted_fs: if object2: where += [('res_id','=',object2.id),('res_model','=',object2._name)] - cids = fobj.search(cr, uid,where) + cids = fobj.search(cr, uid, where) if len(cids): cid = cids[0] diff --git a/addons/document_ics/document_ics.py b/addons/document_ics/document_ics.py index 56998a9408a..a9c5c90fefb 100644 --- a/addons/document_ics/document_ics.py +++ b/addons/document_ics/document_ics.py @@ -85,9 +85,9 @@ class document_directory_content(osv.osv): _columns = { 'object_id': fields.many2one('ir.model', 'Object', oldname= 'ics_object_id'), - 'obj_iterate': fields.boolean('Iterate object',help="If set, a separate \ + 'obj_iterate': fields.boolean('Iterate object', help="If set, a separate \ instance will be created for each record of Object"), - 'fname_field': fields.char("Filename field",size=16,help="The field of the \ + 'fname_field': fields.char("Filename field", size=16, help="The field of the \ object used in the filename. Has to be a unique identifier."), 'ics_domain': fields.char('Domain', size=64), 'ics_field_ids': fields.one2many('document.directory.ics.fields', 'content_id', 'Fields Mapping') @@ -138,7 +138,7 @@ class document_directory_content(osv.osv): dctx2 = { 'active_id': ro['id'] } if fname_fld: dctx2['active_'+fname_fld] = ro[fname_fld] - n = node_content(tname, node, node.context,content,dctx=dctx2, act_id = ro['id']) + n = node_content(tname, node, node.context, content, dctx=dctx2, act_id = ro['id']) n.fill_fields(cr, dctx2) res2.append(n) return res2 diff --git a/addons/document_webdav/dav_fs.py b/addons/document_webdav/dav_fs.py index 0c2e52c8df7..88f855f75f0 100644 --- a/addons/document_webdav/dav_fs.py +++ b/addons/document_webdav/dav_fs.py @@ -62,7 +62,7 @@ class openerp_dav_handler(dav_interface): self.baseuri = parent.baseuri self.verbose = verbose - def get_propnames(self,uri): + def get_propnames(self, uri): props = self.PROPS self.parent.log_message('get propnames: %s' % uri) if uri[-1]=='/':uri=uri[:-1] @@ -104,7 +104,7 @@ class openerp_dav_handler(dav_interface): pname -- name of the property """ if self.M_NS.has_key(ns): - return dav_interface.get_prop(self,uri,ns,propname) + return dav_interface.get_prop(self, uri, ns, propname) if uri[-1]=='/':uri=uri[:-1] cr, uid, pool, dbname, uri2 = self.get_cr(uri) if not dbname: @@ -114,7 +114,7 @@ class openerp_dav_handler(dav_interface): if not node: cr.close() raise DAV_NotFound - res = node.get_dav_eprop(cr,ns,propname) + res = node.get_dav_eprop(cr, ns, propname) cr.close() return res @@ -149,7 +149,7 @@ class openerp_dav_handler(dav_interface): cr.close() return self.db_name_list - def get_childs(self,uri, filters=None): + def get_childs(self, uri, filters=None): """ return the child objects as self.baseuris for the given URI """ self.parent.log_message('get childs: %s' % uri) if uri[-1]=='/':uri=uri[:-1] @@ -160,7 +160,7 @@ class openerp_dav_handler(dav_interface): res = map(lambda x: self.urijoin(x), self.db_list()) return res result = [] - node = self.uri2object(cr,uid,pool, uri2[:]) + node = self.uri2object(cr, uid, pool, uri2[:]) if not node: if cr: cr.close() @@ -218,7 +218,7 @@ class openerp_dav_handler(dav_interface): uri2 = reluri.split('/')[2:] return cr, uid, pool, dbname, uri2 - def uri2object(self, cr,uid, pool,uri): + def uri2object(self, cr, uid, pool,uri): if not uid: return None return pool.get('document.directory').get_object(cr, uid, uri) @@ -230,7 +230,7 @@ class openerp_dav_handler(dav_interface): try: if not dbname: raise DAV_Error, 409 - node = self.uri2object(cr,uid,pool, uri2) + node = self.uri2object(cr, uid, pool, uri2) if not node: raise DAV_NotFound(uri2) try: @@ -277,7 +277,7 @@ class openerp_dav_handler(dav_interface): if not dbname: cr.close() return COLLECTION - node = self.uri2object(cr,uid,pool, uri2) + node = self.uri2object(cr, uid, pool, uri2) if not node: cr.close() raise DAV_NotFound(uri2) @@ -285,7 +285,7 @@ class openerp_dav_handler(dav_interface): return node.displayname @memoize(CACHE_SIZE) - def _get_dav_getcontentlength(self,uri): + def _get_dav_getcontentlength(self, uri): """ return the content length of an object """ self.parent.log_message('get length: %s' % uri) if uri[-1]=='/':uri=uri[:-1] @@ -321,7 +321,7 @@ class openerp_dav_handler(dav_interface): return str(result) @memoize(CACHE_SIZE) - def get_lastmodified(self,uri): + def get_lastmodified(self, uri): """ return the last modified date of the object """ if uri[-1]=='/':uri=uri[:-1] today = time.time() @@ -329,7 +329,7 @@ class openerp_dav_handler(dav_interface): if not dbname: return today try: - node = self.uri2object(cr,uid,pool, uri2) + node = self.uri2object(cr, uid, pool, uri2) if not node: raise DAV_NotFound(uri2) if node.write_date: @@ -340,14 +340,14 @@ class openerp_dav_handler(dav_interface): if cr: cr.close() @memoize(CACHE_SIZE) - def get_creationdate(self,uri): + def get_creationdate(self, uri): """ return the last modified date of the object """ if uri[-1]=='/':uri=uri[:-1] cr, uid, pool, dbname, uri2 = self.get_cr(uri) if not dbname: raise DAV_Error, 409 try: - node = self.uri2object(cr,uid,pool, uri2) + node = self.uri2object(cr, uid, pool, uri2) if not node: raise DAV_NotFound(uri2) if node.create_date: @@ -366,7 +366,7 @@ class openerp_dav_handler(dav_interface): if not dbname: return 'httpd/unix-directory' try: - node = self.uri2object(cr,uid,pool, uri2) + node = self.uri2object(cr, uid, pool, uri2) if not node: raise DAV_NotFound(uri2) result = node.mimetype @@ -393,7 +393,7 @@ class openerp_dav_handler(dav_interface): cr.close() return True - def put(self,uri,data,content_type=None): + def put(self, uri, data, content_type=None): """ put the object into the filesystem """ self.parent.log_message('Putting %s (%d), %s'%( misc.ustr(uri), data and len(data) or 0, content_type)) parent='/'.join(uri.split('/')[:-1]) @@ -401,7 +401,7 @@ class openerp_dav_handler(dav_interface): if not dbname: raise DAV_Forbidden try: - node = self.uri2object(cr,uid,pool, uri2[:]) + node = self.uri2object(cr, uid, pool, uri2[:]) except: node = False @@ -409,11 +409,11 @@ class openerp_dav_handler(dav_interface): ext = objname.find('.') >0 and objname.split('.')[1] or False if not node: - dir_node = self.uri2object(cr,uid,pool, uri2[:-1]) + dir_node = self.uri2object(cr, uid, pool, uri2[:-1]) if not dir_node: raise DAV_NotFound('Parent folder not found') try: - dir_node.create_child(cr,objname,data) + dir_node.create_child(cr, objname, data) except Exception,e: import traceback self.parent.log_error("Cannot create %s: %s", objname, str(e)) @@ -421,7 +421,7 @@ class openerp_dav_handler(dav_interface): raise DAV_Forbidden else: try: - node.set_data(cr,data) + node.set_data(cr, data) except Exception,e: import traceback self.parent.log_error("Cannot save %s: %s", objname, str(e)) @@ -433,7 +433,6 @@ class openerp_dav_handler(dav_interface): return 201 def rmcol(self,uri): - print ' REMOVE COLLL :::::', uri """ delete a collection """ if uri[-1]=='/':uri=uri[:-1] @@ -448,13 +447,12 @@ class openerp_dav_handler(dav_interface): return 204 def rm(self,uri): - print ' REMOVE EVENT :::::', uri if uri[-1]=='/':uri=uri[:-1] cr, uid, pool,dbname, uri2 = self.get_cr(uri) if not dbname: cr.close() raise DAV_Error, 409 - node = self.uri2object(cr,uid,pool, uri2) + node = self.uri2object(cr, uid, pool, uri2) res = node.rm(cr) if not res: raise OSError(1, 'Operation not permited.') @@ -467,7 +465,7 @@ class openerp_dav_handler(dav_interface): ### a rm directly ### - def delone(self,uri): + def delone(self, uri): """ delete a single resource You have to return a result dict of the form @@ -480,7 +478,7 @@ class openerp_dav_handler(dav_interface): parent='/'.join(uri.split('/')[:-1]) return res - def deltree(self,uri): + def deltree(self, uri): """ delete a collection You have to return a result dict of the form @@ -488,7 +486,7 @@ class openerp_dav_handler(dav_interface): or None if everything's ok """ if uri[-1]=='/':uri=uri[:-1] - res=deltree(self,uri) + res=deltree(self, uri) parent='/'.join(uri.split('/')[:-1]) return res @@ -497,7 +495,7 @@ class openerp_dav_handler(dav_interface): ### MOVE handlers (examples) ### - def moveone(self,src,dst,overwrite): + def moveone(self, src, dst, overwrite): """ move one resource with Depth=0 an alternative implementation would be @@ -514,10 +512,10 @@ class openerp_dav_handler(dav_interface): (untested!). This would not use the davcmd functions and thus can only detect errors directly on the root node. """ - res=moveone(self,src,dst,overwrite) + res=moveone(self, src, dst, overwrite) return res - def movetree(self,src,dst,overwrite): + def movetree(self, src, dst, overwrite): """ move a collection with Depth=infinity an alternative implementation would be @@ -534,14 +532,14 @@ class openerp_dav_handler(dav_interface): (untested!). This would not use the davcmd functions and thus can only detect errors directly on the root node""" - res=movetree(self,src,dst,overwrite) + res=movetree(self, src, dst, overwrite) return res ### ### COPY handlers ### - def copyone(self,src,dst,overwrite): + def copyone(self, src, dst, overwrite): """ copy one resource with Depth=0 an alternative implementation would be @@ -558,10 +556,10 @@ class openerp_dav_handler(dav_interface): (untested!). This would not use the davcmd functions and thus can only detect errors directly on the root node. """ - res=copyone(self,src,dst,overwrite) + res=copyone(self, src, dst, overwrite) return res - def copytree(self,src,dst,overwrite): + def copytree(self, src, dst, overwrite): """ copy a collection with Depth=infinity an alternative implementation would be @@ -577,7 +575,7 @@ class openerp_dav_handler(dav_interface): (untested!). This would not use the davcmd functions and thus can only detect errors directly on the root node""" - res=copytree(self,src,dst,overwrite) + res=copytree(self, src, dst, overwrite) return res ### @@ -588,15 +586,15 @@ class openerp_dav_handler(dav_interface): ### Look in davcmd.py for further details. ### - def copy(self,src,dst): + def copy(self, src, dst): src=urllib.unquote(src) dst=urllib.unquote(dst) ct = self._get_dav_getcontenttype(src) data = self.get_data(src) - self.put(dst,data,ct) + self.put(dst, data, ct) return 201 - def copycol(self,src,dst): + def copycol(self, src, dst): """ copy a collection. As this is not recursive (the davserver recurses itself) @@ -608,7 +606,7 @@ class openerp_dav_handler(dav_interface): return self.mkcol(dst) - def exists(self,uri): + def exists(self, uri): """ test if a resource exists """ result = False cr, uid, pool,dbname, uri2 = self.get_cr(uri) @@ -616,7 +614,7 @@ class openerp_dav_handler(dav_interface): if cr: cr.close() return True try: - node = self.uri2object(cr,uid,pool, uri2) + node = self.uri2object(cr, uid, pool, uri2) if node: result = True except: @@ -625,6 +623,6 @@ class openerp_dav_handler(dav_interface): return result @memoize(CACHE_SIZE) - def is_collection(self,uri): + def is_collection(self, uri): """ test if the given uri is a collection """ return self._get_dav_resourcetype(uri)==COLLECTION diff --git a/addons/document_webdav/webdav.py b/addons/document_webdav/webdav.py index b69c21d62ee..2406bc10492 100644 --- a/addons/document_webdav/webdav.py +++ b/addons/document_webdav/webdav.py @@ -29,7 +29,7 @@ import tools super_mk_prop_response = PROPFIND.mk_prop_response -def mk_prop_response(self,uri,good_props,bad_props,doc): +def mk_prop_response(self, uri, good_props, bad_props, doc): """ make a new result element We differ between the good props and the bad ones for diff --git a/addons/document_webdav/webdav_server.py b/addons/document_webdav/webdav_server.py index 5f88f90cf11..80b8b6bb898 100644 --- a/addons/document_webdav/webdav_server.py +++ b/addons/document_webdav/webdav_server.py @@ -53,7 +53,6 @@ class DAVHandler(FixSendError,DAVRequestHandler): verbose = False def get_userinfo(self,user,pw): - print "get_userinfo" return False def _log(self, message): netsvc.Logger().notifyChannel("webdav",netsvc.LOG_DEBUG,message) @@ -74,15 +73,15 @@ class DAVHandler(FixSendError,DAVRequestHandler): def setup(self): davpath = '/'+config.get_misc('webdav','vdir','webdav') - self.baseuri = "http://%s:%d/"% (self.server.server_name,self.server.server_port) + self.baseuri = "http://%s:%d/"% (self.server.server_name, self.server.server_port) self.IFACE_CLASS = openerp_dav_handler(self, self.verbose) def log_message(self, format, *args): - netsvc.Logger().notifyChannel('webdav',netsvc.LOG_DEBUG_RPC,format % args) + netsvc.Logger().notifyChannel('webdav', netsvc.LOG_DEBUG_RPC, format % args) def log_error(self, format, *args): - netsvc.Logger().notifyChannel('xmlrpc',netsvc.LOG_WARNING,format % args) + netsvc.Logger().notifyChannel('xmlrpc', netsvc.LOG_WARNING, format % args) def do_PUT(self): dc=self.IFACE_CLASS @@ -179,7 +178,7 @@ try: conf = OpenDAVConfig(**_dc) handler._config = conf reg_http_service(HTTPDir(directory,DAVHandler,OpenERPAuthProvider())) - netsvc.Logger().notifyChannel('webdav',netsvc.LOG_INFO,"WebDAV service registered at path: %s/ "% directory) + netsvc.Logger().notifyChannel('webdav', netsvc.LOG_INFO, "WebDAV service registered at path: %s/ "% directory) except Exception, e: logger = netsvc.Logger() logger.notifyChannel('webdav', netsvc.LOG_ERROR, 'Cannot launch webdav: %s' % e) diff --git a/addons/email_template/wizard/email_template_send_wizard.py b/addons/email_template/wizard/email_template_send_wizard.py index 7d27eab9adf..9934336d506 100755 --- a/addons/email_template/wizard/email_template_send_wizard.py +++ b/addons/email_template/wizard/email_template_send_wizard.py @@ -168,7 +168,6 @@ class email_template_send_wizard(osv.osv_memory): mail_ids = [] template = self._get_template(cr, uid, context) for id in context['src_rec_ids']: - print "@22222222222222222222222",ids screen_vals = self.read(cr, uid, ids[0], [],context) account = self.pool.get('email_template.account').read(cr, uid, screen_vals['from'], context=context) vals = { diff --git a/addons/event/event.py b/addons/event/event.py index 1985cf9cc7d..1354eac467c 100644 --- a/addons/event/event.py +++ b/addons/event/event.py @@ -200,7 +200,7 @@ class event_registration(osv.osv): return super(event_registration, self).write(cr, uid, *args, **argv) def mail_user_confirm(self, cr, uid, ids): - reg_ids = self.browse(cr,uid,ids) + reg_ids = self.browse(cr, uid, ids) for reg_id in reg_ids: src = reg_id.event_id.reply_to or False dest = [] diff --git a/addons/event_project/event.py b/addons/event_project/event.py index 2d17e7e146a..267e04144e6 100644 --- a/addons/event_project/event.py +++ b/addons/event_project/event.py @@ -47,13 +47,13 @@ class one2many_mod_task(fields.one2many): class event(osv.osv): _inherit = 'event.event' - def write(self, cr, uid, ids,vals, *args, **kwargs): + def write(self, cr, uid, ids, vals, *args, **kwargs): if 'date_begin' in vals and vals['date_begin']: for eve in self.browse(cr, uid, ids): if eve.project_id: self.pool.get('project.project').write(cr, uid, [eve.project_id.id], {'date_end':eve.date_begin[:10]}) - return super(event,self).write(cr, uid, ids,vals, *args, **kwargs) + return super(event,self).write(cr, uid, ids, vals, *args, **kwargs) _columns = { 'project_id': fields.many2one('project.project', 'Project', readonly=True), diff --git a/addons/event_project/wizard/project_wizard.py b/addons/event_project/wizard/project_wizard.py index fe70db08e7b..872cb073712 100644 --- a/addons/event_project/wizard/project_wizard.py +++ b/addons/event_project/wizard/project_wizard.py @@ -42,7 +42,7 @@ parameter_fields = { def _create_duplicate(self, cr, uid, data, context): event_obj=pooler.get_pool(cr.dbname).get('event.event') project_obj = pooler.get_pool(cr.dbname).get('project.project') - duplicate_project_id= project_obj.copy(cr, uid,data['form']['project_id'], {'active': True}) + duplicate_project_id= project_obj.copy(cr, uid, data['form']['project_id'], {'active': True}) project_obj.write(cr, uid, [duplicate_project_id], {'name': "copy of " + project_obj.browse(cr, uid, duplicate_project_id, context).name , 'date_start':time.strftime('%Y-%m-%d'),'date': event_obj.browse(cr, uid, [data['id']])[0].date_begin[0:10] }) event_obj.write(cr, uid, [data['id']], {'project_id': duplicate_project_id }) return {} diff --git a/addons/hr/hr.py b/addons/hr/hr.py index 841370a97f2..34c5b9ede9a 100644 --- a/addons/hr/hr.py +++ b/addons/hr/hr.py @@ -37,7 +37,7 @@ class hr_employee_category(osv.osv): def _check_recursion(self, cr, uid, ids): level = 100 while len(ids): - cr.execute('select distinct parent_id from hr_employee_category where id=ANY(%s)',(ids,)) + cr.execute('select distinct parent_id from hr_employee_category where id IN %s',(tuple(ids),)) ids = filter(None, map(lambda x:x[0], cr.fetchall())) if not level: return False @@ -111,8 +111,8 @@ class hr_employee(osv.osv): 'parent_id': fields.many2one('hr.employee', 'Manager', select=True), 'category_id' : fields.many2one('hr.employee.category', 'Category'), 'child_ids': fields.one2many('hr.employee', 'parent_id','Subordinates'), - 'resource_id': fields.many2one('resource.resource','Resource',ondelete='cascade'), - 'coach_id': fields.many2one('res.users','Coach'), + 'resource_id': fields.many2one('resource.resource', 'Resource', ondelete='cascade'), + 'coach_id': fields.many2one('res.users', 'Coach'), 'job_id': fields.many2one('hr.job', 'Job'), 'photo': fields.binary('Photo') } @@ -130,7 +130,7 @@ class hr_employee(osv.osv): def _check_recursion(self, cr, uid, ids): level = 100 while len(ids): - cr.execute('select distinct parent_id from hr_employee where id =ANY(%s)',(ids,)) + cr.execute('select distinct parent_id from hr_employee where id IN %s',(tuple(ids),)) ids = filter(None, map(lambda x:x[0], cr.fetchall())) if not level: return False diff --git a/addons/hr/hr_department.py b/addons/hr/hr_department.py index f31969129d8..9e190a2b0f7 100644 --- a/addons/hr/hr_department.py +++ b/addons/hr/hr_department.py @@ -61,7 +61,7 @@ class hr_department(osv.osv): def _check_recursion(self, cr, uid, ids): level = 100 while len(ids): - cr.execute('select distinct parent_id from hr_department where id =ANY(%s)',(ids,)) + cr.execute('select distinct parent_id from hr_department where id IN %s',(tuple(ids),)) ids = filter(None, map(lambda x:x[0], cr.fetchall())) if not level: return False @@ -120,7 +120,7 @@ class res_users(osv.osv): for arg in args: if arg[0] == 'parent_id': parent = arg[2] - child_ids = self._child_compute(cr, uid, parent,name, args, {}) + child_ids = self._child_compute(cr, uid, parent, name, args, {}) if not child_ids: return [('id', 'in', [0])] return [('id', 'in', child_ids.get(uid,[]))] @@ -155,14 +155,14 @@ class res_users(osv.osv): for arg in args: if arg[0] == 'child_ids': parent = arg[2] - child_ids = self._child_compute(cr, uid, parent,name, args, {}) + child_ids = self._child_compute(cr, uid, parent, name, args, {}) if not child_ids: return [('id', 'in', [0])] return [('id', 'in', child_ids.get(uid,[]))] _columns = { 'parent_id': fields.function(_parent_compute, relation='res.users',fnct_search=_parent_search, method=True, string="Managers", type='many2many'), - 'child_ids': fields.function(_child_compute, relation='res.users', fnct_search=_child_search,method=True, string="Subordinates", type='many2many'), + 'child_ids': fields.function(_child_compute, relation='res.users', fnct_search=_child_search, method=True, string="Subordinates", type='many2many'), 'context_department_id': fields.many2one('hr.department', 'Departments'), } res_users() diff --git a/addons/hr_attendance/hr_attendance.py b/addons/hr_attendance/hr_attendance.py index 043941eed88..9f5846601ef 100644 --- a/addons/hr_attendance/hr_attendance.py +++ b/addons/hr_attendance/hr_attendance.py @@ -104,7 +104,7 @@ class hr_employee(osv.osv): LEFT JOIN hr_attendance \ ON (hr_attendance.employee_id = foo.employee_id \ AND hr_attendance.name = foo.name) \ - WHERE hr_attendance.employee_id =ANY(%s)',(ids,)) + WHERE hr_attendance.employee_id IN %s',(tuple(ids),)) for res in cr.fetchall(): result[res[1]] = res[0] == 'sign_in' and 'present' or 'absent' return result diff --git a/addons/hr_attendance/report/attendance_errors.py b/addons/hr_attendance/report/attendance_errors.py index 77b3b5ba438..0c21892dc5c 100644 --- a/addons/hr_attendance/report/attendance_errors.py +++ b/addons/hr_attendance/report/attendance_errors.py @@ -36,7 +36,7 @@ class attendance_print(report_sxw.rml_parse): }) def _get_employees(self, emp_ids): - emp_obj_list = self.pool.get('hr.employee').browse(self.cr,self.uid,emp_ids) + emp_obj_list = self.pool.get('hr.employee').browse(self.cr, self.uid, emp_ids) return emp_obj_list # def _sign(self, dt): @@ -50,7 +50,7 @@ class attendance_print(report_sxw.rml_parse): # return dt.strftime(format) def _lst(self, employee_id, dt_from, dt_to, max, *args): - self.cr.execute("select name as date, create_date, action, create_date-name as delay from hr_attendance where employee_id=%s and to_char(name,'YYYY-mm-dd')<=%s and to_char(name,'YYYY-mm-dd')>=%s and action in (%s,%s) order by name", (employee_id, dt_to, dt_from, 'sign_in', 'sign_out')) + self.cr.execute("select name as date, create_date, action, create_date-name as delay from hr_attendance where employee_id=%s and to_char(name,'YYYY-mm-dd')<=%s and to_char(name,'YYYY-mm-dd')>=%s and action IN (%s,%s) order by name", (employee_id, dt_to, dt_from, 'sign_in', 'sign_out')) res = self.cr.dictfetchall() for r in res: if r['action'] == 'sign_out': @@ -66,7 +66,7 @@ class attendance_print(report_sxw.rml_parse): return res def _lst_total(self, employee_id, dt_from, dt_to, max, *args): - self.cr.execute("select name as date, create_date, action, create_date-name as delay from hr_attendance where employee_id=%s and to_char(name,'YYYY-mm-dd')<=%s and to_char(name,'YYYY-mm-dd')>=%s and action in (%s,%s) order by name", (employee_id, dt_to, dt_from, 'sign_in', 'sign_out')) + self.cr.execute("select name as date, create_date, action, create_date-name as delay from hr_attendance where employee_id=%s and to_char(name,'YYYY-mm-dd')<=%s and to_char(name,'YYYY-mm-dd')>=%s and action IN (%s,%s) order by name", (employee_id, dt_to, dt_from, 'sign_in', 'sign_out')) res = self.cr.dictfetchall() if not res: return ('/','/') diff --git a/addons/hr_attendance/wizard/hr_attendance_error.py b/addons/hr_attendance/wizard/hr_attendance_error.py index c14ddcd9032..47029822741 100644 --- a/addons/hr_attendance/wizard/hr_attendance_error.py +++ b/addons/hr_attendance/wizard/hr_attendance_error.py @@ -44,7 +44,7 @@ class hr_attendance_error(osv.osv_memory): data_error = self.read(cr, uid, ids)[0] date_from = data_error['init_date'] date_to = data_error['end_date'] - cr.execute("select id from hr_attendance where employee_id =ANY(%s) and to_char(name,'YYYY-mm-dd')<=%s and to_char(name,'YYYY-mm-dd')>=%s and action =ANY(%s) order by name" ,(context['active_ids'], date_to, date_from, ['sign_in','sign_out'])) + cr.execute("select id from hr_attendance where employee_id IN %s and to_char(name,'YYYY-mm-dd')<=%s and to_char(name,'YYYY-mm-dd')>=%s and action IN %s order by name" ,(tuple(context['active_ids']), date_to, date_from, tuple(['sign_in','sign_out']))) attendance_ids = [x[0] for x in cr.fetchall()] if not attendance_ids: raise osv.except_osv(_('No Data Available'), _('No records found for your selection!')) diff --git a/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py b/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py index aaaefc088a6..8562dc391a7 100644 --- a/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py +++ b/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py @@ -119,7 +119,7 @@ class hr_sign_in_out(osv.osv_memory): if last_att: last_att = last_att[0] if not att_id and not last_att: - model_data_ids = obj_model.search(cr,uid,[('model','=','ir.ui.view'),('name','=','view_hr_attendance_message')], context=context) + model_data_ids = obj_model.search(cr, uid, [('model','=','ir.ui.view'),('name','=','view_hr_attendance_message')], context=context) resource_id = obj_model.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id'] return { 'name': _('Sign in / Sign out'), @@ -135,7 +135,7 @@ class hr_sign_in_out(osv.osv_memory): if cond: return self.sign_out(cr, uid, data, context) else: - model_data_ids = self.pool.get('ir.model.data').search(cr,uid,[('model','=','ir.ui.view'),('name','=','view_hr_attendance_si_ask')], context=context) + model_data_ids = self.pool.get('ir.model.data').search(cr, uid, [('model','=','ir.ui.view'),('name','=','view_hr_attendance_si_ask')], context=context) resource_id = self.pool.get('ir.model.data').read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id'] return { 'name': _('Sign in / Sign out'), diff --git a/addons/hr_evaluation/hr_evaluation.py b/addons/hr_evaluation/hr_evaluation.py index a1d89f67b28..3c13a8ab63c 100644 --- a/addons/hr_evaluation/hr_evaluation.py +++ b/addons/hr_evaluation/hr_evaluation.py @@ -49,7 +49,7 @@ class hr_evaluation_plan_phase(osv.osv): _columns = { 'name': fields.char("Phase", size=64, required=True), 'sequence': fields.integer("Sequence"), - 'company_id': fields.related('plan_id','company_id',type='many2one',relation='res.company',string='Company',store=True), + 'company_id': fields.related('plan_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True), 'plan_id': fields.many2one('hr_evaluation.plan','Evaluation Plan', required=True, ondelete='cascade'), 'action': fields.selection([ ('top-down','Top-Down Appraisal Requests'), @@ -68,7 +68,7 @@ class hr_evaluation_plan_phase(osv.osv): 'wait': fields.boolean('Wait Previous Phases', help="Check this box if you want to wait that all preceeding phases " + "are finished before launching this phase."), - 'mail_feature': fields.boolean('Send mail for this phase',help="Check this box if you want to send mail to employees"+ + 'mail_feature': fields.boolean('Send mail for this phase', help="Check this box if you want to send mail to employees"+ "coming under this phase"), 'mail_body': fields.text('Email'), 'email_subject':fields.text('char') @@ -105,11 +105,11 @@ class hr_employee(osv.osv): } def run_employee_evaluation(self, cr, uid, automatic=False, use_new_cursor=False, context=None): - for id in self.browse(cr, uid, self.search(cr, uid, [],context=context),context=context): + for id in self.browse(cr, uid, self.search(cr, uid, [], context=context), context=context): if id.evaluation_plan_id and id.evaluation_date: if (dt.ISO.ParseAny(id.evaluation_date) + dt.RelativeDateTime(months = int(id.evaluation_plan_id.month_next))).strftime('%Y-%m-%d') <= time.strftime("%Y-%m-%d"): - self.write(cr, uid, id.id, {'evaluation_date' : (dt.ISO.ParseAny(id.evaluation_date) + dt.RelativeDateTime(months =+ int(id.evaluation_plan_id.month_next))).strftime('%Y-%m-%d')},context=context) - self.pool.get("hr_evaluation.evaluation").create(cr, uid, {'employee_id' : id.id, 'plan_id': id.evaluation_plan_id},context) + self.write(cr, uid, id.id, {'evaluation_date' : (dt.ISO.ParseAny(id.evaluation_date) + dt.RelativeDateTime(months =+ int(id.evaluation_plan_id.month_next))).strftime('%Y-%m-%d')}, context=context) + self.pool.get("hr_evaluation.evaluation").create(cr, uid, {'employee_id' : id.id, 'plan_id': id.evaluation_plan_id}, context) return True def onchange_evaluation_plan_id(self, cr, uid, ids, evaluation_plan_id, evaluation_date, context={}): @@ -117,7 +117,7 @@ class hr_employee(osv.osv): evaluation_plan_obj=self.pool.get('hr_evaluation.plan') if evaluation_plan_id: flag = False - evaluation_plan = evaluation_plan_obj.browse(cr, uid, [evaluation_plan_id],context=context)[0] + evaluation_plan = evaluation_plan_obj.browse(cr, uid, [evaluation_plan_id], context=context)[0] if not evaluation_date: evaluation_date=(dt.ISO.ParseAny(dt.now().strftime('%Y-%m-%d'))+ dt.RelativeDateTime(months=+evaluation_plan.month_first)).strftime('%Y-%m-%d') flag = True @@ -126,13 +126,13 @@ class hr_employee(osv.osv): evaluation_date=(dt.ISO.ParseAny(evaluation_date)+ dt.RelativeDateTime(months=+evaluation_plan.month_next)).strftime('%Y-%m-%d') flag = True if ids and flag: - self.pool.get("hr_evaluation.evaluation").create(cr, uid, {'employee_id' : ids[0], 'plan_id': evaluation_plan_id},context=context) + self.pool.get("hr_evaluation.evaluation").create(cr, uid, {'employee_id' : ids[0], 'plan_id': evaluation_plan_id}, context=context) return {'value': {'evaluation_date':evaluation_date}} def create(self, cr, uid, vals, context={}): id = super(hr_employee, self).create(cr, uid, vals, context=context) if vals.get('evaluation_plan_id', False): - self.pool.get("hr_evaluation.evaluation").create(cr, uid, {'employee_id' : id, 'plan_id': vals['evaluation_plan_id']},context=context) + self.pool.get("hr_evaluation.evaluation").create(cr, uid, {'employee_id' : id, 'plan_id': vals['evaluation_plan_id']}, context=context) return id hr_employee() @@ -163,7 +163,7 @@ class hr_evaluation(osv.osv): ('progress','Final Validation'), ('done','Done'), ('cancel','Cancelled'), - ], 'State', required=True,readonly=True), + ], 'State', required=True, readonly=True), 'date_close': fields.date('Ending Date'), 'progress' : fields.float("Progress"), } @@ -172,19 +172,19 @@ class hr_evaluation(osv.osv): 'state' : lambda *a: 'draft', } - def onchange_employee_id(self,cr,uid,ids,employee_id,context={}): + def onchange_employee_id(self, cr, uid, ids, employee_id, context={}): employee_obj=self.pool.get('hr.employee') evaluation_plan_id='' if employee_id: - for employee in employee_obj.browse(cr,uid,[employee_id],context=context): + for employee in employee_obj.browse(cr, uid, [employee_id], context=context): if employee and employee.evaluation_plan_id and employee.evaluation_plan_id.id: evaluation_plan_id=employee.evaluation_plan_id.id - employee_ids=employee_obj.search(cr,uid,[('parent_id','=',employee.id)],context=context) + employee_ids=employee_obj.search(cr, uid, [('parent_id','=',employee.id)], context=context) return {'value': {'plan_id':evaluation_plan_id}} - def button_plan_in_progress(self,cr, uid, ids, context={}): + def button_plan_in_progress(self, cr, uid, ids, context={}): apprai_id = [] - for evaluation in self.browse(cr,uid,ids, context): + for evaluation in self.browse(cr, uid, ids, context): wait = False for phase in evaluation.plan_id.phase_ids: childs = [] @@ -223,13 +223,13 @@ class hr_evaluation(osv.osv): sub = phase.email_subject dest = [child.work_email] if dest: - tools.email_send(src,dest,sub,body) + tools.email_send(src, dest, sub, body) - self.write(cr,uid,ids,{'state':'wait'},context=context) + self.write(cr, uid, ids, {'state':'wait'}, context=context) return True - def button_final_validation(self,cr, uid, ids, context={}): - self.write(cr,uid,ids,{'state':'progress'}) + def button_final_validation(self, cr, uid, ids, context={}): + self.write(cr, uid, ids, {'state':'progress'}) request_obj = self.pool.get('hr.evaluation.interview') for id in self.browse(cr, uid ,ids,context=context): if len(id.survey_request_ids) != len(request_obj.search(cr, uid, [('evaluation_id', '=', id.id),('state', '=', 'done')],context=context)): @@ -240,8 +240,8 @@ class hr_evaluation(osv.osv): self.write(cr,uid,ids,{'state':'done', 'date_close': time.strftime('%Y-%m-%d')}, context=context) return True - def button_cancel(self,cr, uid, ids, context={}): - self.write(cr,uid,ids,{'state':'cancel'}, context=context) + def button_cancel(self, cr, uid, ids, context={}): + self.write(cr, uid, ids,{'state':'cancel'}, context=context) return True hr_evaluation() diff --git a/addons/hr_evaluation/report/hr_evaluation_report.py b/addons/hr_evaluation/report/hr_evaluation_report.py index 504bdcd08f4..7c97ff5055e 100644 --- a/addons/hr_evaluation/report/hr_evaluation_report.py +++ b/addons/hr_evaluation/report/hr_evaluation_report.py @@ -30,7 +30,7 @@ class hr_evaluation_report(osv.osv): 'create_date': fields.date('Create Date', readonly=True), 'day': fields.char('Day', size=128, readonly=True), 'deadline': fields.date("Deadline", readonly=True), - 'request_id': fields.many2one('survey.request','Request_id', readonly=True), + 'request_id': fields.many2one('survey.request', 'Request_id', readonly=True), 'closed': fields.date("closed", readonly=True), 'year': fields.char('Year', size=4, readonly=True), 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py index e0d55bee5fe..d32a136e0d2 100644 --- a/addons/hr_expense/hr_expense.py +++ b/addons/hr_expense/hr_expense.py @@ -38,7 +38,7 @@ class hr_expense_expense(osv.osv): return super(hr_expense_expense, self).copy(cr, uid, id, default, context) def _amount(self, cr, uid, ids, field_name, arg, context): - cr.execute("SELECT s.id,COALESCE(SUM(l.unit_amount*l.unit_quantity),0) AS amount FROM hr_expense_expense s LEFT OUTER JOIN hr_expense_line l ON (s.id=l.expense_id) WHERE s.id =ANY(%s) GROUP BY s.id ",(ids,)) + cr.execute("SELECT s.id,COALESCE(SUM(l.unit_amount*l.unit_quantity),0) AS amount FROM hr_expense_expense s LEFT OUTER JOIN hr_expense_line l ON (s.id=l.expense_id) WHERE s.id IN %s GROUP BY s.id ",(tuple(ids),)) res = dict(cr.fetchall()) return res @@ -187,7 +187,7 @@ class hr_expense_line(osv.osv): def _amount(self, cr, uid, ids, field_name, arg, context): if not len(ids): return {} - cr.execute("SELECT l.id,COALESCE(SUM(l.unit_amount*l.unit_quantity),0) AS amount FROM hr_expense_line l WHERE id =ANY(%s) GROUP BY l.id ",(ids,)) + cr.execute("SELECT l.id,COALESCE(SUM(l.unit_amount*l.unit_quantity),0) AS amount FROM hr_expense_line l WHERE id IN %s GROUP BY l.id ",(tuple(ids),)) res = dict(cr.fetchall()) return res @@ -216,13 +216,13 @@ class hr_expense_line(osv.osv): context = {} v = {} if product_id: - product=self.pool.get('product.product').browse(cr,uid,product_id, context=context) + product=self.pool.get('product.product').browse(cr, uid, product_id, context=context) v['name']=product.name # Compute based on pricetype of employee company - pricetype_id = self.pool.get('hr.employee').browse(cr,uid,employee_id).user_id.company_id.property_valuation_price_type.id - context['currency_id']=self.pool.get('hr.employee').browse(cr,uid,employee_id).user_id.company_id.currency_id.id - pricetype=self.pool.get('product.price.type').browse(cr,uid,pricetype_id) + pricetype_id = self.pool.get('hr.employee').browse(cr, uid, employee_id).user_id.company_id.property_valuation_price_type.id + context['currency_id']=self.pool.get('hr.employee').browse(cr, uid, employee_id).user_id.company_id.currency_id.id + pricetype=self.pool.get('product.price.type').browse(cr, uid, pricetype_id) amount_unit=product.price_get(pricetype.field, context)[product.id] v['unit_amount']=amount_unit diff --git a/addons/hr_expense/report/hr_expense_report.py b/addons/hr_expense/report/hr_expense_report.py index 85fa541ec10..e2ec064dc4f 100644 --- a/addons/hr_expense/report/hr_expense_report.py +++ b/addons/hr_expense/report/hr_expense_report.py @@ -41,8 +41,8 @@ class hr_expense_report(osv.osv): 'employee_id': fields.many2one('hr.employee', "Employee's Name", readonly=True), 'date_confirm': fields.date('Confirmation Date', readonly=True), 'date_valid': fields.date('Validation Date', readonly=True), - 'invoice_id': fields.many2one('account.invoice', 'Invoice',readonly=True), - 'department_id':fields.many2one('hr.department','Department',readonly=True), + 'invoice_id': fields.many2one('account.invoice', 'Invoice', readonly=True), + 'department_id':fields.many2one('hr.department','Department', readonly=True), 'company_id':fields.many2one('res.company', 'Company', readonly=True), 'user_id':fields.many2one('res.users', 'Validation User', readonly=True), 'currency_id': fields.many2one('res.currency', 'Currency', readonly=True), diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index d564903ffee..9e3bfca0660 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -207,7 +207,7 @@ class hr_holidays(osv.osv): for record in self.browse(cr, uid, ids): if record.state=='validate': if record.case_id: - self.pool.get('crm.meeting').unlink(cr,uid,[record.case_id.id]) + self.pool.get('crm.meeting').unlink(cr, uid, [record.case_id.id]) if record.linked_request_ids: list_ids = [] [list_ids.append(i) for id in record.linked_request_ids] @@ -443,7 +443,7 @@ class hr_holidays(osv.osv): 'user_id' : record.user_id.id, 'date' : record.date_from, } - case_id = self.pool.get('crm.meeting').create(cr,uid,vals) + case_id = self.pool.get('crm.meeting').create(cr, uid, vals) self.write(cr, uid, ids, {'case_id':case_id}) return True diff --git a/addons/hr_holidays/report/holidays_summary_report.py b/addons/hr_holidays/report/holidays_summary_report.py index 77dde5b4575..31fbe91a5a2 100644 --- a/addons/hr_holidays/report/holidays_summary_report.py +++ b/addons/hr_holidays/report/holidays_summary_report.py @@ -42,12 +42,12 @@ def strToDate(dt): return -def emp_create_xml(self,cr,uid,dept,holiday_type,row_id,empid,name,som,eom): +def emp_create_xml(self, cr, uid, dept, holiday_type, row_id, empid, name, som, eom): display={} if dept==0: count=0 - p_id=pooler.get_pool(cr.dbname).get('hr.holidays').search(cr,uid,[('employee_id','in',[empid,False]), ('type', '=', 'remove')]) - ids_date = pooler.get_pool(cr.dbname).get('hr.holidays').read(cr,uid,p_id,['date_from','date_to','holiday_status_id','state']) + p_id=pooler.get_pool(cr.dbname).get('hr.holidays').search(cr, uid, [('employee_id','in',[empid,False]), ('type', '=', 'remove')]) + ids_date = pooler.get_pool(cr.dbname).get('hr.holidays').read(cr, uid, p_id, ['date_from','date_to','holiday_status_id','state']) for index in range(1,61): diff=index-1 @@ -211,9 +211,9 @@ class report_custom(report_rml): if data['model']=='hr.employee': for id in data['form']['emp']: - items = pooler.get_pool(cr.dbname).get('hr.employee').read(cr,uid,id,['id','name']) + items = pooler.get_pool(cr.dbname).get('hr.employee').read(cr, uid, id, ['id','name']) - emp_xml += emp_create_xml(self,cr,uid,0,holiday_type,row_id,items['id'],items['name'],som, eom) + emp_xml += emp_create_xml(self, cr, uid, 0, holiday_type, row_id, items['id'], items['name'], som, eom) row_id = row_id +1 elif data['model']=='ir.ui.menu': @@ -234,19 +234,19 @@ class report_custom(report_rml): continue dept_done=0 for d in range(0,len(result)): - emp_id[d]=pooler.get_pool(cr.dbname).get('hr.employee').search(cr,uid,[('user_id','=',result[d][0])]) - items = pooler.get_pool(cr.dbname).get('hr.employee').read(cr,uid,emp_id[d],['id','name']) + emp_id[d]=pooler.get_pool(cr.dbname).get('hr.employee').search(cr, uid, [('user_id','=',result[d][0])]) + items = pooler.get_pool(cr.dbname).get('hr.employee').read(cr, uid, emp_id[d], ['id','name']) for item in items: # if item['id'] in done: # continue # else: if dept_done==0: - emp_xml += emp_create_xml(self,cr,uid,1,holiday_type,row_id,dept.id,dept.name,som, eom) + emp_xml += emp_create_xml(self, cr, uid, 1, holiday_type, row_id, dept.id, dept.name, som, eom) row_id = row_id +1 dept_done=1 # done[item['id']] = 1 - emp_xml += emp_create_xml(self,cr,uid,0,holiday_type,row_id,item['id'],item['name'],som, eom) + emp_xml += emp_create_xml(self, cr, uid, 0, holiday_type, row_id, item['id'], item['name'], som, eom) row_id = row_id +1 # Computing the xml diff --git a/addons/hr_holidays/report/hr_holidays_report.py b/addons/hr_holidays/report/hr_holidays_report.py index a429f6ab63d..38995351a32 100644 --- a/addons/hr_holidays/report/hr_holidays_report.py +++ b/addons/hr_holidays/report/hr_holidays_report.py @@ -32,7 +32,7 @@ class hr_holidays_report(osv.osv): 'day': fields.char('Day', size=15, readonly=True), 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), ('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'), - ('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True), + ('10','October'), ('11','November'), ('12','December')], 'Month', readonly=True), 'date_from' : fields.datetime('Start Date', readonly=True), 'date_to' : fields.datetime('End Date', readonly=True), 'number_of_days_temp': fields.float('Number of Days', readonly=True), @@ -85,10 +85,10 @@ class hr_holidays_remaining_leaves_user(osv.osv): _description = "Total holidays by type" _auto = False _columns = { - 'name': fields.char('Employee',size=64), + 'name': fields.char('Employee', size=64), 'no_of_leaves': fields.integer('Remaining leaves'), - 'user_id': fields.many2one('res.users','User'), - 'leave_type': fields.char('Leave Type',size=64), + 'user_id': fields.many2one('res.users', 'User'), + 'leave_type': fields.char('Leave Type', size=64), } def init(self, cr): diff --git a/addons/hr_timesheet/hr_timesheet.py b/addons/hr_timesheet/hr_timesheet.py index f0340109cc7..ea13dba89e6 100644 --- a/addons/hr_timesheet/hr_timesheet.py +++ b/addons/hr_timesheet/hr_timesheet.py @@ -44,7 +44,7 @@ class hr_analytic_timesheet(osv.osv): _order = "id desc" _columns = { 'line_id' : fields.many2one('account.analytic.line', 'Analytic line', ondelete='cascade'), - 'partner_id': fields.related('account_id', 'partner_id', type='many2one', string='Partner Id',relation='account.analytic.account',store=True), + 'partner_id': fields.related('account_id', 'partner_id', type='many2one', string='Partner Id', relation='account.analytic.account', store=True), } def unlink(self, cr, uid, ids, context={}): @@ -123,7 +123,7 @@ class hr_analytic_timesheet(osv.osv): def on_change_date(self, cr, uid, ids, date): if ids: - new_date = self.read(cr,uid,ids[0],['date'])['date'] + new_date = self.read(cr, uid, ids[0], ['date'])['date'] if date != new_date: warning = {'title':'User Alert!','message':'Changing the date will let this entry appear in the timesheet of the new date.'} return {'value':{},'warning':warning} diff --git a/addons/hr_timesheet/wizard/hr_timesheet_sign_in_out.py b/addons/hr_timesheet/wizard/hr_timesheet_sign_in_out.py index dc1a6723786..cc960aa4e3d 100644 --- a/addons/hr_timesheet/wizard/hr_timesheet_sign_in_out.py +++ b/addons/hr_timesheet/wizard/hr_timesheet_sign_in_out.py @@ -118,7 +118,7 @@ class hr_si_project(osv.osv_memory): in_out = res == 'sign_out' and 'out' or 'in' #TODO: invert sign_in et sign_out model_data_ids = obj_model.search(cr,uid,[('model','=','ir.ui.view'),('name','=','view_hr_timesheet_sign_%s' % in_out)]) - resource_id = obj_model.read(cr,uid,model_data_ids,fields=['res_id'])[0]['res_id'] + resource_id = obj_model.read(cr, uid, model_data_ids, fields=['res_id'])[0]['res_id'] return { 'name': 'Sign in / Sign out', 'view_type': 'form', diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py index c20c7110b63..2190a1c8149 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py @@ -59,13 +59,13 @@ class account_analytic_account(osv.osv): 'amount_max': fields.float('Max. Invoice Price'), 'amount_invoiced': fields.function(_invoiced_calc, method=True, string='Invoiced Amount', help="Total invoiced"), - 'to_invoice': fields.many2one('hr_timesheet_invoice.factor','Reinvoice Costs', + 'to_invoice': fields.many2one('hr_timesheet_invoice.factor', 'Reinvoice Costs', help="Fill this field if you plan to automatically generate invoices based " \ "on the costs in this analytic account: timesheets, expenses, ..." \ "You can configure an automatic invoice rate on analytic accounts."), } _defaults = { - 'pricelist_id': lambda self,cr, uid, ctx: ctx.get('pricelist_id', False), + 'pricelist_id': lambda self, cr, uid, ctx: ctx.get('pricelist_id', False), } account_analytic_account() diff --git a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py index 89ff5e92697..8c64514e576 100644 --- a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py +++ b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py @@ -54,7 +54,7 @@ class hr_timesheet_invoice_create(osv.osv_memory): if obj_acc.invoice_id and obj_acc.invoice_id.state !='cancel': raise osv.except_osv(_('Warning'),_('The analytic entry "%s" is already invoiced!')%(obj_acc.name,)) - cr.execute("SELECT distinct(account_id) from account_analytic_line where id =ANY(%s)",(context['active_ids'],)) + cr.execute("SELECT distinct(account_id) from account_analytic_line where id IN %s",(tuple(context['active_ids']),)) account_ids = cr.fetchall() return [x[0] for x in account_ids] @@ -115,8 +115,8 @@ class hr_timesheet_invoice_create(osv.osv_memory): cr.execute("SELECT product_id, to_invoice, sum(unit_amount) " \ "FROM account_analytic_line as line " \ "WHERE account_id = %s " \ - "AND id =ANY(%s) AND to_invoice IS NOT NULL " \ - "GROUP BY product_id,to_invoice", (account.id,context['active_ids'],)) + "AND id IN %s AND to_invoice IS NOT NULL " \ + "GROUP BY product_id,to_invoice", (account.id,tuple(context['active_ids']),)) for product_id,factor_id,qty in cr.fetchall(): product = pool.get('product.product').browse(cr, uid, product_id, context2) @@ -159,7 +159,7 @@ class hr_timesheet_invoice_create(osv.osv_memory): # # Compute for lines # - cr.execute("SELECT * FROM account_analytic_line WHERE account_id = %s and id = ANY (%s) AND product_id=%s and to_invoice=%s", (account.id, data['ids'], product_id, factor_id)) + cr.execute("SELECT * FROM account_analytic_line WHERE account_id = %s and id IN %s AND product_id=%s and to_invoice=%s", (account.id, tuple(data['ids']), product_id, factor_id)) line_ids = cr.dictfetchall() note = [] @@ -181,7 +181,7 @@ class hr_timesheet_invoice_create(osv.osv_memory): curr_line['note'] = "\n".join(map(lambda x: unicode(x) or '',note)) pool.get('account.invoice.line').create(cr, uid, curr_line) - cr.execute("update account_analytic_line set invoice_id=%s WHERE account_id = %s and id =ANY(%s)" ,(last_invoice, account.id,data['ids'])) + cr.execute("update account_analytic_line set invoice_id=%s WHERE account_id = %s and id IN %s" ,(last_invoice, account.id,tuple(data['ids']))) self.pool.get('account.invoice').button_reset_taxes(cr, uid, [last_invoice], context) diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 5ace7f64ebd..2eb352974d7 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -102,7 +102,7 @@ class hr_timesheet_sheet(osv.osv): LEFT JOIN hr_timesheet_sheet_sheet_day AS day \ ON (sheet.id = day.sheet_id \ AND day.name = sheet.date_current) \ - WHERE sheet.id =ANY(%s)',(ids,)) + WHERE sheet.id IN %s',(tuple(ids),)) for record in cr.fetchall(): res[record[0]] = {} res[record[0]]['total_attendance_day'] = record[1] @@ -118,7 +118,7 @@ class hr_timesheet_sheet(osv.osv): FROM hr_timesheet_sheet_sheet s \ LEFT JOIN hr_timesheet_sheet_sheet_day d \ ON (s.id = d.sheet_id) \ - WHERE s.id =ANY(%s) GROUP BY s.id',(ids,)) + WHERE s.id IN %s GROUP BY s.id',(tuple(ids),)) for record in cr.fetchall(): res[record[0]] = {} res[record[0]]['total_attendance'] = record[1] @@ -368,7 +368,7 @@ class hr_timesheet_line(osv.osv): ON (s.date_to >= al.date \ AND s.date_from <= al.date \ AND s.user_id = al.user_id) \ - WHERE l.id =ANY(%s) GROUP BY l.id',(ids,)) + WHERE l.id IN %s GROUP BY l.id',(tuple(ids),)) res = dict(cursor.fetchall()) sheet_names = {} for sheet_id, name in sheet_obj.name_get(cursor, user, res.values(), @@ -487,7 +487,7 @@ class hr_attendance(osv.osv): ON (s.date_to >= date_trunc('day',a.name) \ AND s.date_from <= a.name \ AND s.user_id = r.user_id) \ - WHERE a.id =ANY(%s) GROUP BY a.id",(ids,)) + WHERE a.id IN %s GROUP BY a.id",(tuple(ids),)) res = dict(cursor.fetchall()) sheet_names = {} for sheet_id, name in sheet_obj.name_get(cursor, user, res.values(), diff --git a/addons/idea/idea.py b/addons/idea/idea.py index 14fb24ee607..171ff85505f 100644 --- a/addons/idea/idea.py +++ b/addons/idea/idea.py @@ -66,11 +66,11 @@ class idea_idea(osv.osv): sql = """SELECT i.id, avg(v.score::integer) FROM idea_idea i LEFT OUTER JOIN idea_vote v ON i.id = v.idea_id - WHERE i.id = ANY(%s) + WHERE i.id IN %s GROUP BY i.id """ - cr.execute(sql, (ids,)) + cr.execute(sql, (tuple(ids),)) return dict(cr.fetchall()) def _vote_count(self, cr, uid, ids, name, arg, context=None): @@ -86,11 +86,11 @@ class idea_idea(osv.osv): sql = """SELECT i.id, COUNT(1) FROM idea_idea i LEFT OUTER JOIN idea_vote v ON i.id = v.idea_id - WHERE i.id = ANY(%s) + WHERE i.id IN %s GROUP BY i.id """ - cr.execute(sql, (ids,)) + cr.execute(sql, (tuple(ids),)) return dict(cr.fetchall()) def _comment_count(self, cr, uid, ids, name, arg, context=None): @@ -106,11 +106,11 @@ class idea_idea(osv.osv): sql = """SELECT i.id, COUNT(1) FROM idea_idea i LEFT OUTER JOIN idea_comment c ON i.id = c.idea_id - WHERE i.id = ANY(%s) + WHERE i.id IN %s GROUP BY i.id """ - cr.execute(sql, (ids,)) + cr.execute(sql, (tuple(ids),)) return dict(cr.fetchall()) def _vote_read(self, cr, uid, ids, name, arg, context = None): diff --git a/addons/l10n_be/wizard/l10_be_partner_vat_listing.py b/addons/l10n_be/wizard/l10_be_partner_vat_listing.py index 24a9541a2a2..415db0ba067 100644 --- a/addons/l10n_be/wizard/l10_be_partner_vat_listing.py +++ b/addons/l10n_be/wizard/l10_be_partner_vat_listing.py @@ -81,7 +81,7 @@ class partner_vat(osv.osv_memory): break if not go_ahead: continue - cursor.execute('select b.code, sum(credit)-sum(debit) from account_move_line l left join account_account a on (l.account_id=a.id) left join account_account_type b on (a.user_type=b.id) where b.code in %s and l.partner_id=%s and l.period_id=ANY(%s) group by b.code',(('produit','tax'),obj_partner.id,period,)) + cursor.execute('select b.code, sum(credit)-sum(debit) from account_move_line l left join account_account a on (l.account_id=a.id) left join account_account_type b on (a.user_type=b.id) where b.code IN %s and l.partner_id=%s and l.period_id IN %s group by b.code',(('produit','tax'),obj_partner.id,tuple(period),)) line_info = cursor.fetchall() if not line_info: continue diff --git a/addons/l10n_ch/dta.py b/addons/l10n_ch/dta.py index 2778acc14bd..25b16222b19 100644 --- a/addons/l10n_ch/dta.py +++ b/addons/l10n_ch/dta.py @@ -59,7 +59,7 @@ account_dta() class account_dta_line(osv.osv): """Class that represent a DTA order line, - each lin corressponds to a payment instruction""" + each line corressponds to a payment instruction""" _name = "account.dta.line" _description = "DTA line" _columns = { diff --git a/addons/l10n_ch/wizard/bvr_import.py b/addons/l10n_ch/wizard/bvr_import.py index 55caf5c4162..12e8012f643 100644 --- a/addons/l10n_ch/wizard/bvr_import.py +++ b/addons/l10n_ch/wizard/bvr_import.py @@ -71,7 +71,7 @@ def _reconstruct_invoice_ref(cursor, user, reference, context): cursor.execute('SELECT l.id ' \ 'FROM account_move_line l, account_invoice i ' \ 'WHERE l.move_id = i.move_id AND l.reconcile_id is NULL ' \ - 'AND i.id =ANY(%s)',([id_invoice],)) + 'AND i.id IN %s',(tuple([id_invoice]),)) inv_line = [] for id_line in cursor.fetchall(): inv_line.append(id_line[0]) diff --git a/addons/l10n_fr/report/base_report.py b/addons/l10n_fr/report/base_report.py index 1de66123f2c..03ebce690fd 100644 --- a/addons/l10n_fr/report/base_report.py +++ b/addons/l10n_fr/report/base_report.py @@ -45,7 +45,7 @@ class base_report(report_sxw.rml_parse): period_query_cond=self.pool.get('account.period').search(self.cr, self.uid,[('fiscalyear_id','=',form['fiscalyear'])]) - self.cr.execute("SELECT MIN(date_start) AS date_start, MAX(date_stop) AS date_stop FROM account_period WHERE id =ANY(%s)",(period_query_cond,)) + self.cr.execute("SELECT MIN(date_start) AS date_start, MAX(date_stop) AS date_stop FROM account_period WHERE id IN %s",(tuple(period_query_cond),)) dates =self.cr.dictfetchall() self._set_variable('date_start', dates[0]['date_start']) self._set_variable('date_stop', dates[0]['date_stop']) diff --git a/addons/lunch/lunch.py b/addons/lunch/lunch.py index 88d080c11bd..8dfce4acaff 100644 --- a/addons/lunch/lunch.py +++ b/addons/lunch/lunch.py @@ -144,9 +144,9 @@ class lunch_order(osv.osv): } _defaults = { - 'user_id': lambda self,cr,uid,context: uid, - 'date': lambda self,cr,uid,context: time.strftime('%Y-%m-%d'), - 'state': lambda self,cr,uid,context: 'draft', + 'user_id': lambda self, cr, uid, context: uid, + 'date': lambda self, cr, uid, context: time.strftime('%Y-%m-%d'), + 'state': lambda self, cr, uid, context: 'draft', } def confirm(self, cr, uid, ids, box, context): diff --git a/addons/lunch/wizard/lunch_cashbox_clean.py b/addons/lunch/wizard/lunch_cashbox_clean.py index 1956dc6d4b7..923629502ab 100644 --- a/addons/lunch/wizard/lunch_cashbox_clean.py +++ b/addons/lunch/wizard/lunch_cashbox_clean.py @@ -40,12 +40,12 @@ class lunch_cashbox_clean(osv.osv_memory): cashmove_ref = self.pool.get('lunch.cashmove') cr.execute("select user_cashmove, box,sum(amount) from lunch_cashmove \ - where active = 't' and box in (%s) group by user_cashmove, \ - box" % ','.join(map(str, data))) + where active = 't' and box IN %s group by user_cashmove, \ + box" , (tuple(data),)) res = cr.fetchall() cr.execute("update lunch_cashmove set active = 'f' where active= 't' \ - and box in (%s)" % ','.join(map(str, data))) + and box IN %s" , (tuple(data),)) for (user_id, box_id, amount) in res: cashmove_ref.create(cr, uid, {'name': 'Summary for user' + str(user_id), diff --git a/addons/marketing_campaign/marketing_campaign.py b/addons/marketing_campaign/marketing_campaign.py index 4ed49a7c954..86eea3f7631 100644 --- a/addons/marketing_campaign/marketing_campaign.py +++ b/addons/marketing_campaign/marketing_campaign.py @@ -273,7 +273,6 @@ class marketing_campaign_activity(osv.osv): return True def process_wi_email(self, cr, uid, activity, workitem, context=None): - print 'Sending Email Init', activity.name return self.pool.get('email.template').generate_mail(cr, uid, activity.email_template_id.id, [workitem.res_id], context=context) def process_wi_action(self, cr, uid, activity, workitem, context={}): @@ -284,10 +283,8 @@ class marketing_campaign_activity(osv.osv): def process(self, cr, uid, act_id, wi_id, context={}): activity = self.browse(cr, uid, act_id) - print 'Process', activity.name workitem_obj = self.pool.get('marketing.campaign.workitem') workitem = workitem_obj.browse(cr, uid, wi_id, context=context) - print 'WI', workitem, activity.type return self._actions[activity.type](cr, uid, activity, workitem, context) marketing_campaign_activity() diff --git a/addons/membership/membership.py b/addons/membership/membership.py index caabbb9090d..1ef69c142c6 100644 --- a/addons/membership/membership.py +++ b/addons/membership/membership.py @@ -150,7 +150,7 @@ class membership_line(osv.osv): ) JOIN account_invoice ai ON ( ai.id = ail.invoice_id) - WHERE ml.id =ANY(%s)''',(ids,)) + WHERE ml.id IN %s''',(tuple(ids),)) res = cr.fetchall() for r in res: if r[0] and r[0] < 0: @@ -413,7 +413,7 @@ class Partner(osv.osv): def _check_recursion(self, cr, uid, ids): level = 100 while len(ids): - cr.execute('select distinct associate_member from res_partner where id =ANY(%s)',(ids,)) + cr.execute('select distinct associate_member from res_partner where id IN %s',(tuple(ids),)) ids = filter(None, map(lambda x:x[0], cr.fetchall())) if not level: return False @@ -447,7 +447,7 @@ class Product(osv.osv): def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): if ('product' in context) and (context['product']=='membership_product'): model_data_ids_form = self.pool.get('ir.model.data').search(cr,user,[('model','=','ir.ui.view'),('name','in',['membership_products_form','membership_products_tree'])]) - resource_id_form = self.pool.get('ir.model.data').read(cr,user,model_data_ids_form,fields=['res_id','name']) + resource_id_form = self.pool.get('ir.model.data').read(cr, user, model_data_ids_form, fields=['res_id','name']) dict_model={} for i in resource_id_form: dict_model[i['name']]=i['res_id'] @@ -484,10 +484,10 @@ class Invoice(osv.osv): member_line_obj = self.pool.get('membership.membership_line') today = time.strftime('%Y-%m-%d') for invoice in self.browse(cr, uid, ids): - mlines = member_line_obj.search(cr,uid, + mlines = member_line_obj.search(cr, uid, [('account_invoice_line','in', [ l.id for l in invoice.invoice_line])], context) - member_line_obj.write(cr,uid,mlines, {'date_cancel':today}, context) + member_line_obj.write(cr, uid, mlines, {'date_cancel':today}, context) return super(Invoice, self).action_cancel(cr, uid, ids, context) Invoice() diff --git a/addons/membership/wizard/membership_invoice.py b/addons/membership/wizard/membership_invoice.py index 45d5c538b15..39589f58e27 100644 --- a/addons/membership/wizard/membership_invoice.py +++ b/addons/membership/wizard/membership_invoice.py @@ -43,7 +43,7 @@ class membership_invoice(osv.osv_memory): cr.execute(''' SELECT partner_id, id, type FROM res_partner_address - WHERE partner_id =ANY(%s)''',(partner_ids,)) + WHERE partner_id IN %s''',(tuple(partner_ids),)) fetchal = cr.fetchall() if not fetchal: raise osv.except_osv(_('Error !'), _('No Address defined for this partner')) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 26cecf79faa..e8e8adbaeca 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -201,7 +201,7 @@ class mrp_bom(osv.osv): 'property_ids': fields.many2many('mrp.property', 'mrp_bom_property_rel', 'bom_id','property_id', 'Properties'), 'revision_ids': fields.one2many('mrp.bom.revision', 'bom_id', 'BoM Revisions'), 'revision_type': fields.selection([('numeric','numeric indices'),('alpha','alphabetical indices')], 'Index type'), - 'child_complete_ids': fields.function(_child_compute,relation='mrp.bom', method=True, string="BoM Hierarchy", type='many2many'), + 'child_complete_ids': fields.function(_child_compute, relation='mrp.bom', method=True, string="BoM Hierarchy", type='many2many'), 'company_id': fields.many2one('res.company','Company',required=True), } _defaults = { @@ -221,7 +221,7 @@ class mrp_bom(osv.osv): def _check_recursion(self, cr, uid, ids): level = 100 while len(ids): - cr.execute('select distinct bom_id from mrp_bom where id =ANY(%s)',(ids,)) + cr.execute('select distinct bom_id from mrp_bom where id IN %s',(tuple(ids),)) ids = filter(None, map(lambda x:x[0], cr.fetchall())) if not level: return False diff --git a/addons/mrp/report/workcenter_load.py b/addons/mrp/report/workcenter_load.py index 248e9e5707e..8e5b9bff7ba 100644 --- a/addons/mrp/report/workcenter_load.py +++ b/addons/mrp/report/workcenter_load.py @@ -104,7 +104,7 @@ class report_custom(report_int): "WHERE mrp_production_workcenter_line.production_id=mrp_production.id "\ "AND mrp_production_workcenter_line.workcenter_id=mrp_workcenter.id "\ "AND mrp_production.state NOT IN ('cancel','done') "\ - "AND mrp_workcenter.id =ANY(%s)",(ids,)) + "AND mrp_workcenter.id IN %s",(tuple(ids),)) res = cr.dictfetchone() if not res['stop']: res['stop'] = time.strftime('%Y-%m-%d %H:%M:%S') @@ -135,8 +135,8 @@ class report_custom(report_int): # select workcenters cr.execute( "SELECT mw.id, rs.name FROM mrp_workcenter mw, resource_resource rs " \ - "WHERE mw.id=ANY(%s) and mw.resource_id=rs.id " \ - "ORDER BY mw.id" ,(ids,)) + "WHERE mw.id IN %s and mw.resource_id=rs.id " \ + "ORDER BY mw.id" ,(tuple(ids),)) workcenters = cr.dictfetchall() data = [] diff --git a/addons/mrp_repair/mrp_repair.py b/addons/mrp_repair/mrp_repair.py index e31b4e05594..d87e16adf40 100644 --- a/addons/mrp_repair/mrp_repair.py +++ b/addons/mrp_repair/mrp_repair.py @@ -147,7 +147,7 @@ class mrp_repair(osv.osv): 'deliver_bool': lambda *a: True, 'name': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'mrp.repair'), 'invoice_method': lambda *a: 'none', - 'pricelist_id': lambda self, cr, uid,context : self.pool.get('product.pricelist').search(cr,uid,[('type','=','sale')])[0] + 'pricelist_id': lambda self, cr, uid,context : self.pool.get('product.pricelist').search(cr, uid, [('type','=','sale')])[0] } def copy(self, cr, uid, id, default=None, context=None): diff --git a/addons/olap/olap.py b/addons/olap/olap.py index 835c0110b5b..317a56dd7c3 100644 --- a/addons/olap/olap.py +++ b/addons/olap/olap.py @@ -359,25 +359,17 @@ class olap_schema(osv.osv ): if not ids: raise 'Schema not found !' schema = self.browse(cr, uid, ids[0], context) - print 'Parsing MDX...' - print ' ', request mdx_parser = cube.mdx_parser() mdx = mdx_parser.parse(request) - print 'Validating MDX...' mdx.preprocess() validate, cubex = mdx.validate(schema) - print 'Running MDX...' res_comp = self.pool.get('res.company').search(cr, uid, ([])) res_comp = self.pool.get('res.company').browse(cr, uid, res_comp) currency = res_comp[0].currency_id.name - print " Default Currency", currency data = mdx.run(currency) - print 'Running Done...' - print 'Formatting Output...' - if cubex.query_log: log = context.get('log') @@ -1597,7 +1589,7 @@ class bi_load_db_wizard(osv.osv_memory): from INFORMATION_schema.key_column_usage where - constraint_name in ( + constraint_name IN ( select constraint_name from INFORMATION_SCHEMA.table_constraints where constraint_type = 'FOREIGN KEY')""") @@ -1633,7 +1625,7 @@ class bi_load_db_wizard(osv.osv_memory): cols = {} if tables_id: cr.execute('select column_db_name,id,table_id from \ - olap_database_columns where table_id in (' + ','.join(tables_id) + ')') + olap_database_columns where table_id IN (' + ','.join(tables_id) + ')') else: cr.execute('select column_db_name,id,table_id from olap_database_columns') @@ -1681,10 +1673,10 @@ class bi_load_db_wizard(osv.osv_memory): from INFORMATION_schema.key_column_usage where table_schema= %s and - constraint_name in ( + constraint_name IN ( select constraint_name from INFORMATION_SCHEMA .table_constraints where - constraint_type in('PRIMARY KEY','FOREIGN KEY')) + constraint_type IN ('PRIMARY KEY','FOREIGN KEY')) """, (db_name)) for constraint in cr_db.fetchall(): @@ -1722,7 +1714,7 @@ class bi_load_db_wizard(osv.osv_memory): cols = {} if tables_id: cr.execute('select column_db_name,id,table_id from \ - olap_database_columns where table_id in (' + ','.join(tables_id) + ')') + olap_database_columns where table_id IN (' + ','.join(tables_id) + ')') else: cr.execute('select column_db_name,id,table_id from olap_database_columns') @@ -1809,7 +1801,7 @@ class bi_load_db_wizard(osv.osv_memory): from all_cons_columns where - constraint_name in ( + constraint_name IN ( select constraint_name from all_constraints where constraint_type = 'R' and owner = %s) diff --git a/addons/olap/wizard/wizard_load_data.py b/addons/olap/wizard/wizard_load_data.py index 0e7ae8a1508..989c6330469 100644 --- a/addons/olap/wizard/wizard_load_data.py +++ b/addons/olap/wizard/wizard_load_data.py @@ -73,7 +73,7 @@ def olap_db_connect(self,cr,uid,part,context={}): tables_id = map(lambda x: str(tables[x]),tables) cols={} if tables_id: - cr.execute('select column_db_name,id,table_id from olap_database_columns where table_id in (' + ','.join(tables_id) +')') + cr.execute('select column_db_name,id,table_id from olap_database_columns where table_id IN (' + ','.join(tables_id) +')') else: cr.execute('select column_db_name,id,table_id from olap_database_columns') @@ -120,7 +120,7 @@ def olap_db_connect(self,cr,uid,part,context={}): from INFORMATION_schema.key_column_usage where - constraint_name in ( + constraint_name IN ( select constraint_name from INFORMATION_SCHEMA .table_constraints where constraint_type = 'PRIMARY KEY')""") @@ -138,7 +138,7 @@ def olap_db_connect(self,cr,uid,part,context={}): from INFORMATION_schema.constraint_column_usage where - constraint_name in ( + constraint_name IN ( select constraint_name from INFORMATION_SCHEMA.table_constraints where constraint_type = 'FOREIGN KEY')""") @@ -149,7 +149,7 @@ def olap_db_connect(self,cr,uid,part,context={}): from INFORMATION_schema.key_column_usage where - constraint_name in ( + constraint_name IN ( select constraint_name from INFORMATION_SCHEMA.table_constraints where constraint_type = 'FOREIGN KEY')""") @@ -181,7 +181,7 @@ def olap_db_connect(self,cr,uid,part,context={}): tables_id = map(lambda x: str(tables[x]),tables) cols={} if tables_id: - cr.execute('select column_db_name,id,table_id from olap_database_columns where table_id in (' + ','.join(tables_id) +')') + cr.execute('select column_db_name,id,table_id from olap_database_columns where table_id IN (' + ','.join(tables_id) +')') else: cr.execute('select column_db_name,id,table_id from olap_database_columns') @@ -228,10 +228,10 @@ def olap_db_connect(self,cr,uid,part,context={}): from INFORMATION_schema.key_column_usage where table_schema= %s and - constraint_name in ( + constraint_name IN ( select constraint_name from INFORMATION_SCHEMA .table_constraints where - constraint_type in('PRIMARY KEY','FOREIGN KEY')) + constraint_type IN ('PRIMARY KEY','FOREIGN KEY')) """,(db_name)) for constraint in cr_db.fetchall(): @@ -267,7 +267,7 @@ def olap_db_connect(self,cr,uid,part,context={}): tables_id = map(lambda x: str(tables[x]),tables) cols={} if tables_id: - cr.execute('select column_db_name,id,table_id from olap_database_columns where table_id in (' + ','.join(tables_id) +')') + cr.execute('select column_db_name,id,table_id from olap_database_columns where table_id IN (' + ','.join(tables_id) +')') else: cr.execute('select column_db_name,id,table_id from olap_database_columns') @@ -323,7 +323,7 @@ def olap_db_connect(self,cr,uid,part,context={}): from all_cons_columns where - constraint_name in ( + constraint_name IN ( select constraint_name from all_constraints where constraint_type = 'P' and owner= %s) @@ -353,7 +353,7 @@ def olap_db_connect(self,cr,uid,part,context={}): from all_cons_columns where - constraint_name in ( + constraint_name IN ( select constraint_name from all_constraints where constraint_type = 'R' and owner = %s) diff --git a/addons/partner_geo_assign/partner_geo_assign.py b/addons/partner_geo_assign/partner_geo_assign.py index 2ed96e3125d..74e0a7ff17f 100644 --- a/addons/partner_geo_assign/partner_geo_assign.py +++ b/addons/partner_geo_assign/partner_geo_assign.py @@ -72,7 +72,7 @@ class crm_lead(osv.osv): _columns = { 'partner_latitude': fields.float('Geo Latitude', digits=(16,2)), 'partner_longitude': fields.float('Geo Longitude', digits=(16,2)), - 'partner_assigned_id': fields.many2one('res.partner','Assigned Partner') + 'partner_assigned_id': fields.many2one('res.partner','Assigned Partner'), 'date_assign': fields.date('Assignation Date') } def assign_partner(self, cr, uid, ids, context=None): diff --git a/addons/point_of_sale/pos.py b/addons/point_of_sale/pos.py index e0e2d9c5c5d..1bfc619f9d0 100644 --- a/addons/point_of_sale/pos.py +++ b/addons/point_of_sale/pos.py @@ -96,7 +96,7 @@ class pos_order(osv.osv): ) AS amount FROM pos_order p LEFT OUTER JOIN pos_order_line l ON (p.id=l.order_id) - WHERE p.id =ANY(%s) GROUP BY p.id """,(ids,)) + WHERE p.id IN %s GROUP BY p.id """,(tuple(ids),)) res = dict(cr.fetchall()) for rec in self.browse(cr, uid, ids, context): if rec.partner_id \ @@ -287,10 +287,10 @@ class pos_order(osv.osv): 'user_id': fields.many2one('res.users', 'Connected Salesman', readonly=True), 'user_salesman_id': fields.many2one('res.users', 'Salesman', required=True), 'sale_manager': fields.many2one('res.users', 'Salesman Manager'), - 'amount_tax': fields.function(_amount_all, method=True, string='Taxes',digits_compute=dp.get_precision('Point Of Sale'), multi='all'), + 'amount_tax': fields.function(_amount_all, method=True, string='Taxes', digits_compute=dp.get_precision('Point Of Sale'), multi='all'), 'amount_total': fields.function(_amount_total, method=True, string='Total'), - 'amount_paid': fields.function(_amount_all, 'Paid', states={'draft': [('readonly', False)]}, readonly=True, method=True,digits_compute=dp.get_precision('Point Of Sale'), multi='all'), - 'amount_return': fields.function(_amount_all, 'Returned', method=True,digits_compute=dp.get_precision('Point Of Sale'), multi='all'), + 'amount_paid': fields.function(_amount_all, 'Paid', states={'draft': [('readonly', False)]}, readonly=True, method=True, digits_compute=dp.get_precision('Point Of Sale'), multi='all'), + 'amount_return': fields.function(_amount_all, 'Returned', method=True, digits_compute=dp.get_precision('Point Of Sale'), multi='all'), 'lines': fields.one2many('pos.order.line', 'order_id', 'Order Lines', states={'draft': [('readonly', False)]}, readonly=True), 'price_type': fields.selection([ ('tax_excluded','Tax excluded') diff --git a/addons/point_of_sale/report/account_statement.py b/addons/point_of_sale/report/account_statement.py index 6b863a40469..8d88eab63e6 100644 --- a/addons/point_of_sale/report/account_statement.py +++ b/addons/point_of_sale/report/account_statement.py @@ -32,7 +32,7 @@ class account_statement(report_sxw.rml_parse): 'time': time, 'get_total':self._get_total, }) - def _get_total(self,statement_line_ids): + def _get_total(self, statement_line_ids): total = 0.0 for line in statement_line_ids: total += line.amount diff --git a/addons/point_of_sale/report/all_closed_cashbox_of_the_day.py b/addons/point_of_sale/report/all_closed_cashbox_of_the_day.py index 2490d5719cd..608696ba70f 100644 --- a/addons/point_of_sale/report/all_closed_cashbox_of_the_day.py +++ b/addons/point_of_sale/report/all_closed_cashbox_of_the_day.py @@ -52,7 +52,7 @@ class all_closed_cashbox_of_the_day(report_sxw.rml_parse): LEFT JOIN account_period as ap ON ap.id = abs.period_id LEFT JOIN res_users as ru ON ru.id = abs.user_id LEFT JOIN res_company as rc ON rc.id = abs.company_id - WHERE to_char(date_trunc('day',abs.date),'YYYY-MM-DD')::date = current_date and abs.state in ('confirm','open') and abs.user_id = %d"""%(user.id) + WHERE to_char(date_trunc('day',abs.date),'YYYY-MM-DD')::date = current_date and abs.state IN ('confirm','open') and abs.user_id = %d"""%(user.id) self.cr.execute(sql) data = self.cr.dictfetchall() return data @@ -80,7 +80,7 @@ class all_closed_cashbox_of_the_day(report_sxw.rml_parse): self.cr.execute(""" select sum(absl.amount) from account_bank_statement as abs LEFT JOIN account_bank_statement_line as absl ON abs.id = absl.statement_id WHERE abs.journal_id = %d - and abs.state in ('confirm','open') + and abs.state IN ('confirm','open') and abs.date = '%s' and abs.user_id = %d """%(data,date,user.id)) @@ -109,7 +109,7 @@ class all_closed_cashbox_of_the_day(report_sxw.rml_parse): total_starting_bal = 0.0 sql = """ SELECT abs.id,abs.balance_end_real as net_total FROM account_bank_statement as abs WHERE to_char(date_trunc('day',abs.date),'YYYY-MM-DD')::date = current_date - and abs.state in ('confirm','open') + and abs.state IN ('confirm','open') and abs.user_id = %d"""%(user.id) self.cr.execute(sql) res = self.cr.dictfetchall() @@ -131,7 +131,7 @@ class all_closed_cashbox_of_the_day(report_sxw.rml_parse): total_starting_bal = 0.0 sql = """select sum(absl.amount) as net_total from account_bank_statement as abs LEFT JOIN account_bank_statement_line as absl ON abs.id = absl.statement_id - where abs.state in ('confirm','open') and abs.user_id = %d + where abs.state IN ('confirm','open') and abs.user_id = %d and to_char(date_trunc('day',abs.date),'YYYY-MM-DD')::date = current_date """%(user.id) self.cr.execute(sql) diff --git a/addons/point_of_sale/report/pos_details.py b/addons/point_of_sale/report/pos_details.py index 3ab4055f04d..a548f10c1b7 100644 --- a/addons/point_of_sale/report/pos_details.py +++ b/addons/point_of_sale/report/pos_details.py @@ -39,7 +39,7 @@ class pos_details(report_sxw.rml_parse): data={} self.cr.execute ("select po.name as pos_name,po.date_order,pt.name ,pol.qty,pol.price_unit,pol.discount,po.invoice_id,sum((pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0))) as Total " \ "from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt,res_users as ru,res_company as rc " \ - "where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id and po.state in ('done','paid','invoiced') " \ + "where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id and po.state IN ('done','paid','invoiced') " \ "and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date >= %s and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date <= %s " \ "and po.user_id = ru.id and rc.id = %s and ru.id = %s " \ "group by po.name,pol.qty,po.date_order,pt.name,pol.price_unit,pol.discount,po.invoice_id " \ @@ -57,7 +57,7 @@ class pos_details(report_sxw.rml_parse): qty=[] self.cr.execute("select sum(pol.qty) as qty " \ "from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt,res_users as ru,res_company as rc " \ - "where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id and po.state in ('done','paid','invoiced') " \ + "where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id and po.state IN ('done','paid','invoiced') " \ " and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date >= %s and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date <= %s " \ "and po.user_id = ru.id and rc.id = %s and ru.id = %s " \ ,(form['date_start'],form['date_end'],str(user.company_id.id),str(self.uid))) @@ -65,7 +65,11 @@ class pos_details(report_sxw.rml_parse): return qty[0] or 0.00 def _get_sales_total_2(self, form,user): - self.cr.execute("sELECT sum((pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0))) as Total from pos_order_line as pol , pos_order po, product_product as pp,product_template as pt where po.company_id='%s' and po.id=pol.order_id and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date >= '%s' and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date <= '%s' and po.state in ('paid','invoiced','done') and pt.id=pp.product_tmpl_id and pol.product_id=pp.id"% (str(user.company_id.id),form['date_start'],form['date_end'])) + self.cr.execute("select sum((pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0))) as Total " \ + "from pos_order_line as pol , pos_order po, product_product as pp,product_template as pt " \ + " where po.company_id='%s' and po.id=pol.order_id and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date >= '%s' " \ + " and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date <= '%s' and po.state IN ('paid','invoiced','done') " \ + " and pt.id=pp.product_tmpl_id and pol.product_id=pp.id"% (str(user.company_id.id),form['date_start'],form['date_end'])) res2=self.cr.fetchone() return res2 and res2[0] or 0.0 @@ -144,11 +148,9 @@ class pos_details(report_sxw.rml_parse): a_l=[] for r in st_id : a_l.append(r['id']) - a = ','.join(map(str,a_l)) self.cr.execute("select aj.name,sum(amount) from account_bank_statement_line as absl,account_bank_statement as abs,account_journal as aj " \ - "where absl.statement_id = abs.id and abs.journal_id = aj.id and absl.id in (%s) " \ - "group by aj.name " \ - %(a)) + "where absl.statement_id = abs.id and abs.journal_id = aj.id and absl.id IN %s " \ + "group by aj.name ",(tuple(a_l),)) data=self.cr.dictfetchall() return data diff --git a/addons/point_of_sale/report/pos_payment_report.py b/addons/point_of_sale/report/pos_payment_report.py index ceb824cf014..d1f330037e7 100644 --- a/addons/point_of_sale/report/pos_payment_report.py +++ b/addons/point_of_sale/report/pos_payment_report.py @@ -43,14 +43,14 @@ class pos_payment_report(report_sxw.rml_parse): "(pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0)) as total " \ "from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt " \ "where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id " \ - "and po.state in ('paid','invoiced') and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date = current_date and po.id=%d"%(obj.id)) + "and po.state IN ('paid','invoiced') and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date = current_date and po.id=%d"%(obj.id)) data=self.cr.dictfetchall() else : self.cr.execute ("select pt.name,pol.qty,pol.discount,pol.price_unit, " \ "(pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0)) as total " \ "from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt " \ "where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id " \ - "and po.state in ('paid','invoiced') and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date = current_date") + "and po.state IN ('paid','invoiced') and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date = current_date") data=self.cr.dictfetchall() for d in data: diff --git a/addons/point_of_sale/report/pos_payment_report_date.py b/addons/point_of_sale/report/pos_payment_report_date.py index 82723a43125..7bf2578d84d 100644 --- a/addons/point_of_sale/report/pos_payment_report_date.py +++ b/addons/point_of_sale/report/pos_payment_report_date.py @@ -42,7 +42,7 @@ class pos_payment_report_date(report_sxw.rml_parse): "(pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0)) as total " \ "from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt " \ "where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id " \ - "and po.state in ('paid','invoiced') and po.date_order >= %s and po.date_order <= %s and po.user_id in %s " \ + "and po.state IN ('paid','invoiced') and po.date_order >= %s and po.date_order <= %s and po.user_id IN %s " \ ,(dt1,dt2,tuple(form['user_id']))) data=self.cr.dictfetchall() return data @@ -54,7 +54,7 @@ class pos_payment_report_date(report_sxw.rml_parse): self.cr.execute ("select sum(pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0)) " \ "from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt " \ "where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id " \ - "and po.state in ('paid','invoiced') and po.date_order >= %s and po.date_order <= %s and po.user_id in %s " \ + "and po.state IN ('paid','invoiced') and po.date_order >= %s and po.date_order <= %s and po.user_id IN %s " \ ,(dt1,dt2,tuple(form['user_id']))) res=self.cr.fetchone()[0] return res diff --git a/addons/point_of_sale/report/pos_payment_report_user.py b/addons/point_of_sale/report/pos_payment_report_user.py index 9af9377d64c..418a0271a64 100644 --- a/addons/point_of_sale/report/pos_payment_report_user.py +++ b/addons/point_of_sale/report/pos_payment_report_user.py @@ -36,25 +36,23 @@ class pos_payment_report_user(report_sxw.rml_parse): def __pos_payment_user__(self,form): data={} ids = form['user_id'] - idss = map(str, ids) sql = "select pt.name,pol.qty,pol.discount,pol.price_unit, " \ "(pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0)) as total " \ "from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt " \ "where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id " \ "and po.state in ('paid','invoiced') and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date = current_date " \ - "and po.user_id in (%s)" % (",".join(idss), ) + "and po.user_id IN %s",(tuple(ids), ) self.cr.execute (sql) data=self.cr.dictfetchall() return data def __pos_payment_user__total__(self,form): res=[] ids = form['user_id'][0][-1] - idss = map(str, ids) self.cr.execute ("select sum(pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0)) " \ "from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt " \ "where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id " \ "and po.state='paid' and to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date = current_date " \ - "and po.user_id in (%s)" % (",".join(idss), )) + "and po.user_id IN %s",(tuple(ids),)) res=self.cr.fetchone() res = res and res[0] or None diff --git a/addons/point_of_sale/report/pos_sales_user.py b/addons/point_of_sale/report/pos_sales_user.py index b1b7272a030..1bb78808591 100644 --- a/addons/point_of_sale/report/pos_sales_user.py +++ b/addons/point_of_sale/report/pos_sales_user.py @@ -41,7 +41,7 @@ class pos_sales_user(report_sxw.rml_parse): self.cr.execute("select po.name as pos,po.date_order,ru.name as user,po.state,rc.name " \ "from pos_order as po,res_users as ru,res_company as rc " \ "where po.date_order >= %s and po.date_order <= %s " \ - "and po.company_id=rc.id and po.user_id=ru.id and po.user_id in %s " \ + "and po.company_id=rc.id and po.user_id=ru.id and po.user_id IN %s " \ ,(dt1,dt2,tuple(form['user_id']))) data = self.cr.dictfetchall() diff --git a/addons/point_of_sale/report/pos_sales_user_today.py b/addons/point_of_sale/report/pos_sales_user_today.py index a5caf899069..8344f4221c7 100644 --- a/addons/point_of_sale/report/pos_sales_user_today.py +++ b/addons/point_of_sale/report/pos_sales_user_today.py @@ -37,12 +37,11 @@ class pos_sales_user_today(report_sxw.rml_parse): def _get_data(self,form): data={} ids = form['user_id'] - idss = map(str, ids) self.cr.execute("select po.name as pos,po.date_order,ru.name as user,po.state,rc.name " \ "from pos_order as po,res_users as ru,res_company as rc " \ "where to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::date = current_date " \ - "and po.company_id=rc.id and po.user_id=ru.id and po.user_id in (%s)"% (",".join(idss), )) + "and po.company_id=rc.id and po.user_id=ru.id and po.user_id IN %s" ,(tuple(ids), )) data = self.cr.dictfetchall() return data diff --git a/addons/point_of_sale/report/pos_users_product.py b/addons/point_of_sale/report/pos_users_product.py index 2fcf35988c9..234599cbc95 100644 --- a/addons/point_of_sale/report/pos_users_product.py +++ b/addons/point_of_sale/report/pos_users_product.py @@ -43,9 +43,8 @@ class pos_user_product(report_sxw.rml_parse): a_l=[] for r in data: a_l.append(r['id']) - a = ','.join(map(str,a_l)) if len(a): - sql2="""SELECT sum(qty) as qty,l.price_unit*sum(l.qty) as amt,t.name as name from product_product p, product_template t, pos_order_line l where order_id in (%s) and p.product_tmpl_id=t.id and l.product_id=p.id group by t.name, l.price_unit"""%(a) + sql2="""SELECT sum(qty) as qty,l.price_unit*sum(l.qty) as amt,t.name as name from product_product p, product_template t, pos_order_line l where order_id IN %s and p.product_tmpl_id=t.id and l.product_id=p.id group by t.name, l.price_unit""",(tuple(a_l),) self.cr.execute(sql2) data = self.cr.dictfetchall() for d in data: diff --git a/addons/point_of_sale/wizard/pos_add_product.py b/addons/point_of_sale/wizard/pos_add_product.py index 5150e10f99f..c0604fc0bee 100644 --- a/addons/point_of_sale/wizard/pos_add_product.py +++ b/addons/point_of_sale/wizard/pos_add_product.py @@ -74,8 +74,8 @@ class add_product(osv.osv_memory): record_id = context and context.get('active_id', False) order_obj= self.pool.get('pos.order') order_line_obj= self.pool.get('pos.order.line') - obj=order_obj.browse(cr,uid, record_id) - order_obj.write(cr,uid,[record_id],{'state':'done'}) + obj=order_obj.browse(cr, uid, record_id) + order_obj.write(cr, uid, [record_id], {'state':'done'}) if obj.amount_total != obj.amount_paid: return { 'name': _('Make Payment'), diff --git a/addons/point_of_sale/wizard/pos_payment.py b/addons/point_of_sale/wizard/pos_payment.py index aa4d200467a..cd8a85ea8c2 100644 --- a/addons/point_of_sale/wizard/pos_payment.py +++ b/addons/point_of_sale/wizard/pos_payment.py @@ -47,7 +47,7 @@ class pos_make_payment(osv.osv_memory): active_id = context and context.get('active_id',False) if active_id: j_obj = self.pool.get('account.journal') - company_id = self.pool.get('res.users').browse(cr,uid,uid).company_id.id + company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id journal = j_obj.search(cr, uid, [('type', '=', 'cash'), ('company_id', '=', company_id)]) if journal: @@ -141,7 +141,7 @@ class pos_make_payment(osv.osv_memory): invoice_wanted = data['invoice_wanted'] jrnl_used=False if data.get('journal',False): - jrnl_used=jrnl_obj.browse(cr,uid,data['journal']) + jrnl_used=jrnl_obj.browse(cr, uid, data['journal']) order_obj.write(cr, uid, [active_id], {'invoice_wanted': invoice_wanted}) order_obj.add_payment(cr, uid, active_id, data, context=context) # Todo need to check @@ -150,10 +150,10 @@ class pos_make_payment(osv.osv_memory): # order_obj.action_paid(cr,uid,[active_id],context) if order_obj.test_paid(cr, uid, [active_id]): if order.partner_id and order.invoice_wanted: - return self.create_invoice(cr,uid,ids,context) + return self.create_invoice(cr, uid, ids, context) else: context.update({'flag': True}) - order_obj.action_paid(cr,uid,[active_id],context) + order_obj.action_paid(cr, uid, [active_id], context) if context.get('return'): order_obj.write(cr, uid, [active_id],{'state':'done'}) else: diff --git a/addons/point_of_sale/wizard/pos_return.py b/addons/point_of_sale/wizard/pos_return.py index 13a31057d28..0acd19bbf32 100644 --- a/addons/point_of_sale/wizard/pos_return.py +++ b/addons/point_of_sale/wizard/pos_return.py @@ -181,7 +181,7 @@ class pos_return(osv.osv_memory): for order_id in order_obj.browse(cr, uid, [active_id], context=context): prop_ids = property_obj.search(cr, uid,[('name', '=', 'property_stock_customer')]) - val = property_obj.browse(cr, uid,prop_ids[0]).value_reference + val = property_obj.browse(cr, uid, prop_ids[0]).value_reference cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order_id.shop_id.warehouse_id.id)) res=cr.fetchone() location_id=res and res[0] or None @@ -191,7 +191,7 @@ class pos_return(osv.osv_memory): 'move_lines':[], 'state':'draft', 'type':'in', 'type':'in', 'date':date_cur}) - new_order=order_obj.copy(cr,uid,order_id.id, {'name': 'Refund %s'%order_id.name, + new_order=order_obj.copy(cr, uid, order_id.id, {'name': 'Refund %s'%order_id.name, 'lines':[], 'statement_ids':[], 'picking_id':[]}) @@ -203,7 +203,7 @@ class pos_return(osv.osv_memory): qty= line.qty new_move=stock_move_obj.create(cr, uid,{ 'product_qty': qty , - 'product_uos_qty': uom_obj._compute_qty(cr, uid,qty ,line.product_id.uom_id.id), + 'product_uos_qty': uom_obj._compute_qty(cr, uid, qty ,line.product_id.uom_id.id), 'picking_id':new_picking, 'product_uom':line.product_id.uom_id.id, 'location_id':location_id, @@ -217,7 +217,7 @@ class pos_return(osv.osv_memory): }) order_obj.write(cr,uid, active_id, {'state':'done'}) order_obj.write(cr,uid, new_order, {'state':'done'}) - wf_service.trg_validate(uid, 'stock.picking',new_picking,'button_confirm', cr) + wf_service.trg_validate(uid, 'stock.picking', new_picking, 'button_confirm', cr) picking_obj.force_assign(cr, uid, [new_picking], context) act = { 'domain': "[('id', 'in', ["+str(new_order)+"])]", @@ -263,20 +263,20 @@ class add_product(osv.osv_memory): prod_obj=self.pool.get('product.product') wf_service = netsvc.LocalService("workflow") return_boj=self.pool.get('pos.return') - order_obj.add_product(cr, uid, active_id,data['product_id'],data['quantity'], context=context) + order_obj.add_product(cr, uid, active_id, data['product_id'], data['quantity'], context=context) for order_id in order_obj.browse(cr, uid, [active_id], context=context): prod=data['product_id'] qty=data['quantity'] - prop_ids = property_obj.search(cr, uid,[('name', '=', 'property_stock_customer')]) - val = property_obj.browse(cr, uid,prop_ids[0]).value_reference + prop_ids = property_obj.search(cr, uid, [('name', '=', 'property_stock_customer')]) + val = property_obj.browse(cr, uid, prop_ids[0]).value_reference cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order_id.shop_id.warehouse_id.id)) res=cr.fetchone() location_id=res and res[0] or None stock_dest_id = val.id - prod_id=prod_obj.browse(cr,uid,prod) - new_picking=picking_obj.create(cr,uid,{ + prod_id=prod_obj.browse(cr, uid, prod) + new_picking=picking_obj.create(cr, uid,{ 'name':'%s (Added)' %order_id.name, 'move_lines':[], 'state':'draft', @@ -284,7 +284,7 @@ class add_product(osv.osv_memory): 'date':date_cur, }) new_move=stock_move_obj.create(cr, uid,{ 'product_qty': qty, - 'product_uos_qty': uom_obj._compute_qty(cr, uid,prod_id.uom_id.id, qty, prod_id.uom_id.id), + 'product_uos_qty': uom_obj._compute_qty(cr, uid, prod_id.uom_id.id, qty, prod_id.uom_id.id), 'picking_id':new_picking, 'product_uom':prod_id.uom_id.id, 'location_id':location_id, @@ -294,7 +294,7 @@ class add_product(osv.osv_memory): 'date':date_cur, 'date_planned':date_cur,}) - wf_service.trg_validate(uid, 'stock.picking',new_picking,'button_confirm', cr) + wf_service.trg_validate(uid, 'stock.picking', new_picking, 'button_confirm', cr) picking_obj.force_assign(cr, uid, [new_picking], context) order_obj.write(cr,uid,active_id,{'picking_id':new_picking}) @@ -330,8 +330,8 @@ class add_product(osv.osv_memory): wf_service = netsvc.LocalService("workflow") for order_id in order_obj.browse(cr, uid, active_ids, context=context): - prop_ids =property_obj.search(cr, uid,[('name', '=', 'property_stock_customer')]) - val = property_obj.browse(cr, uid,prop_ids[0]).value_reference + prop_ids =property_obj.search(cr, uid, [('name', '=', 'property_stock_customer')]) + val = property_obj.browse(cr, uid, prop_ids[0]).value_reference cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order_id.shop_id.warehouse_id.id)) res=cr.fetchone() location_id=res and res[0] or None @@ -339,8 +339,8 @@ class add_product(osv.osv_memory): order_obj.write(cr,uid,[order_id.id],{'type_rec':'Exchange'}) if order_id.invoice_id: - invoice_obj.refund(cr, uid, [order_id.invoice_id.id],time.strftime('%Y-%m-%d'), False, order_id.name) - new_picking=picking_obj.create(cr,uid,{ + invoice_obj.refund(cr, uid, [order_id.invoice_id.id], time.strftime('%Y-%m-%d'), False, order_id.name) + new_picking=picking_obj.create(cr, uid,{ 'name':'%s (return)' %order_id.name, 'move_lines':[], 'state':'draft', 'type':'in', @@ -350,7 +350,7 @@ class add_product(osv.osv_memory): if line.id and data.has_key(key): new_move=stock_move_obj.create(cr, uid,{ 'product_qty': data['return%s' %line.id ], - 'product_uos_qty': uom_obj._compute_qty(cr, uid,data['return%s' %line.id] ,line.product_id.uom_id.id), + 'product_uos_qty': uom_obj._compute_qty(cr, uid, data['return%s' %line.id], line.product_id.uom_id.id), 'picking_id':new_picking, 'product_uom':line.product_id.uom_id.id, 'location_id':location_id, diff --git a/addons/product/pricelist.py b/addons/product/pricelist.py index 2c79d0e3a50..9256f42943b 100644 --- a/addons/product/pricelist.py +++ b/addons/product/pricelist.py @@ -228,10 +228,9 @@ class product_pricelist(osv.osv): if sinfo: cr.execute('SELECT * ' \ 'FROM pricelist_partnerinfo ' \ - 'WHERE suppinfo_id IN (' + \ - ','.join(map(str, sinfo)) + ') ' \ + 'WHERE suppinfo_id IN %s' \ 'AND min_quantity <= %s ' \ - 'ORDER BY min_quantity DESC LIMIT 1', (qty,)) + 'ORDER BY min_quantity DESC LIMIT 1', (tuple(sinfo),qty,)) res2 = cr.dictfetchone() if res2: price = res2['price'] diff --git a/addons/product/product.py b/addons/product/product.py index 972270a9857..e4d111f1d7d 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -220,7 +220,7 @@ class product_category(osv.osv): def _check_recursion(self, cr, uid, ids): level = 100 while len(ids): - cr.execute('select distinct parent_id from product_category where id =ANY(%s)',(ids,)) + cr.execute('select distinct parent_id from product_category where id IN %s',(tuple(ids),)) ids = filter(None, map(lambda x:x[0], cr.fetchall())) if not level: return False @@ -458,7 +458,7 @@ class product_product(osv.osv): 'packaging' : fields.one2many('product.packaging', 'product_id', 'Logistical Units', help="Gives the different ways to package the same product. This has no impact on the picking order and is mainly used if you use the EDI module."), 'price_extra': fields.float('Variant Price Extra', digits_compute=dp.get_precision('Sale Price')), 'price_margin': fields.float('Variant Price Margin', digits_compute=dp.get_precision('Sale Price')), - 'pricelist_id': fields.dummy(string='Pricelist',relation='product.pricelist', type='many2one'), + 'pricelist_id': fields.dummy(string='Pricelist', relation='product.pricelist', type='many2one'), } def onchange_uom(self, cursor, user, ids, uom_id,uom_po_id): diff --git a/addons/product/report/pricelist.py b/addons/product/report/pricelist.py index c3f57024cf3..e5556f193b0 100644 --- a/addons/product/report/pricelist.py +++ b/addons/product/report/pricelist.py @@ -33,8 +33,8 @@ class report_custom(report_rml): price_list_id = data['form']['price_list'] - product_categ_id =pool.get('product.category').search(cr,uid,[]) - currency = pool.get('product.pricelist').read(cr,uid,[price_list_id],['currency_id','name'])[0] + product_categ_id =pool.get('product.category').search(cr, uid, []) + currency = pool.get('product.pricelist').read(cr, uid, [price_list_id], ['currency_id','name'])[0] qty =[] @@ -68,10 +68,10 @@ class report_custom(report_rml): product_xml.append("") for p_categ_id in product_categ_id: - product_ids = pool.get('product.product').search(cr,uid,[('id','in',ids),('categ_id','=',p_categ_id)]) + product_ids = pool.get('product.product').search(cr, uid, [('id','in',ids),('categ_id','=',p_categ_id)]) if product_ids: - categ_name = pool.get('product.category').read(cr,uid,[p_categ_id],['name']) - products = pool.get('product.product').read(cr,uid,product_ids,['id','name','code']) + categ_name = pool.get('product.category').read(cr, uid, [p_categ_id], ['name']) + products = pool.get('product.product').read(cr, uid, product_ids, ['id','name','code']) pro = [] i=0 pro.append('' % (categ_name[0]['name'])) @@ -90,11 +90,11 @@ class report_custom(report_rml): pro.append('' % (x['name'])) temp = [] for q in qty: - price_dict = pool.get('product.pricelist').price_get(cr,uid,[price_list_id],x['id'],q) + price_dict = pool.get('product.pricelist').price_get(cr, uid, [price_list_id], x['id'], q) if price_dict[price_list_id]: price = price_dict[price_list_id] else: - res = pool.get('product.product').read(cr, uid,[x['id']]) + res = pool.get('product.product').read(cr, uid, [x['id']]) price = res[0]['list_price'] # temp.append(''%(price_list[i][x['id']]*q[2]['name'],currency['currency_id'][1])) diff --git a/addons/product/report/product_pricelist.py b/addons/product/report/product_pricelist.py index 3910e6c161a..5a56a45c785 100644 --- a/addons/product/report/product_pricelist.py +++ b/addons/product/report/product_pricelist.py @@ -61,12 +61,12 @@ class product_pricelist(report_sxw.rml_parse): def _get_pricelist(self, pricelist_id): pool = pooler.get_pool(self.cr.dbname) - pricelist = pool.get('product.pricelist').read(self.cr,self.uid,[pricelist_id],['name'])[0] + pricelist = pool.get('product.pricelist').read(self.cr, self.uid, [pricelist_id], ['name'])[0] return pricelist['name'] def _get_currency(self, pricelist_id): pool = pooler.get_pool(self.cr.dbname) - pricelist = pool.get('product.pricelist').read(self.cr,self.uid,[pricelist_id],['currency_id'])[0] + pricelist = pool.get('product.pricelist').read(self.cr, self.uid, [pricelist_id], ['currency_id'])[0] return pricelist['currency_id'][1] def _get_categories(self, products,form): @@ -80,11 +80,11 @@ class product_pricelist(report_sxw.rml_parse): pro_ids.append(product.id) if product.categ_id.id not in cat_ids: cat_ids.append(product.categ_id.id) - cats = pool.get('product.category').read(self.cr,self.uid,cat_ids,['name']) + cats = pool.get('product.category').read(self.cr, self.uid, cat_ids, ['name']) for cat in cats: - product_ids=pool.get('product.product').search(self.cr,self.uid,[('id','in',pro_ids),('categ_id','=',cat['id'])]) + product_ids=pool.get('product.product').search(self.cr, self.uid, [('id','in',pro_ids),('categ_id','=',cat['id'])]) products = [] - for product in pool.get('product.product').read(self.cr,self.uid,product_ids,['name','code']): + for product in pool.get('product.product').read(self.cr, self.uid, product_ids, ['name','code']): val={ 'id':product['id'], 'name':product['name'], @@ -95,7 +95,7 @@ class product_pricelist(report_sxw.rml_parse): if qty == 0: val['qty'+str(i)] = "" else: - val['qty'+str(i)]=self._get_price(self.pricelist,product['id'],qty) + val['qty'+str(i)]=self._get_price(self.pricelist, product['id'], qty) i += 1 products.append(val) res.append({'name':cat['name'],'products':products}) @@ -103,11 +103,11 @@ class product_pricelist(report_sxw.rml_parse): def _get_price(self,pricelist_id, product_id,qty): pool = pooler.get_pool(self.cr.dbname) - price_dict = pool.get('product.pricelist').price_get(self.cr,self.uid,[pricelist_id],product_id,qty) + price_dict = pool.get('product.pricelist').price_get(self.cr, self.uid, [pricelist_id], product_id,qty) if price_dict[pricelist_id]: price = self.formatLang(price_dict[pricelist_id]) else: - res = pool.get('product.product').read(self.cr, self.uid,[product_id]) + res = pool.get('product.product').read(self.cr, self.uid, [product_id]) price = self.formatLang(res[0]['list_price']) return price diff --git a/addons/product_margin/product_margin.py b/addons/product_margin/product_margin.py index 1bef9e54047..87cfc2a1cc7 100644 --- a/addons/product_margin/product_margin.py +++ b/addons/product_margin/product_margin.py @@ -64,7 +64,7 @@ class product_product(osv.osv): from account_invoice_line l left join account_invoice i on (l.invoice_id = i.id) left join product_template product on (product.id=l.product_id) - where l.product_id = %s and i.state in %s and i.type in %s and i.date_invoice>=%s and i.date_invoice<=%s + where l.product_id = %s and i.state in %s and i.type IN %s and i.date_invoice>=%s and i.date_invoice<=%s """,(val.id,states,invoice_types,date_from,date_to)) result=cr.fetchall()[0] if 'sale_avg_price' in field_names or 'sale_num_invoiced' in field_names or 'turnover' in field_names or 'sale_expected' in field_names: diff --git a/addons/project/project.py b/addons/project/project.py index d511757c8dc..7abd90c09c5 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -92,10 +92,10 @@ class project(osv.osv): FROM project_task WHERE - project_id =ANY(%s) AND + project_id IN %s AND state<>'cancelled' GROUP BY - project_id''',(ids2,)) + project_id''',(tuple(ids2),)) progress = dict(map(lambda x: (x[0], (x[1], x[2], x[3])), cr.fetchall())) for project in self.browse(cr, uid, ids, context=context): s = [0.0, 0.0, 0.0] @@ -196,7 +196,7 @@ class project(osv.osv): res = super(project, self).copy(cr, uid, id, default, context) ids = self.search(cr, uid, [('parent_id','child_of', [res])]) if ids: - cr.execute('update project_task set active=True where project_id =ANY(%s)',(ids,)) + cr.execute('update project_task set active=True where project_id IN %s',(tuple(ids),)) return res def duplicate_template(self, cr, uid, ids, context={}): @@ -272,7 +272,7 @@ class task(osv.osv): # Compute: effective_hours, total_hours, progress def _hours_get(self, cr, uid, ids, field_names, args, context=None): res = {} - cr.execute("SELECT task_id, COALESCE(SUM(hours),0) FROM project_task_work WHERE task_id =ANY(%s) GROUP BY task_id",(ids,)) + cr.execute("SELECT task_id, COALESCE(SUM(hours),0) FROM project_task_work WHERE task_id IN %s GROUP BY task_id",(tuple(ids),)) hours = dict(cr.fetchall()) for task in self.browse(cr, uid, ids, context=context): res[task.id] = {'effective_hours': hours.get(task.id, 0.0), 'total_hours': task.remaining_hours + hours.get(task.id, 0.0)} diff --git a/addons/project/project_resource.py b/addons/project/project_resource.py index 75dd94ad5a3..478fd4316bc 100644 --- a/addons/project/project_resource.py +++ b/addons/project/project_resource.py @@ -18,10 +18,10 @@ def leaves_resource(cr,uid,calendar_id,resource_id=False,resource_calendar=False resource_leaves_pool = pool.get('resource.calendar.leaves') leaves = [] if resource_id: - resource_leave_ids = resource_leaves_pool.search(cr,uid,['|',('calendar_id','=',calendar_id),('calendar_id','=',resource_calendar),('resource_id','=',resource_id)]) + resource_leave_ids = resource_leaves_pool.search(cr, uid, ['|',('calendar_id','=',calendar_id),('calendar_id','=',resource_calendar),('resource_id','=',resource_id)]) else: - resource_leave_ids = resource_leaves_pool.search(cr,uid,[('calendar_id','=',calendar_id),('resource_id','=',False)]) - res_leaves = resource_leaves_pool.read(cr,uid,resource_leave_ids,['date_from','date_to']) + resource_leave_ids = resource_leaves_pool.search(cr, uid, [('calendar_id','=',calendar_id),('resource_id','=',False)]) + res_leaves = resource_leaves_pool.read(cr, uid, resource_leave_ids, ['date_from','date_to']) for leave in range(len(res_leaves)): dt_start = datetime.datetime.strptime(res_leaves[leave]['date_from'],'%Y-%m-%d %H:%M:%S') dt_end = datetime.datetime.strptime(res_leaves[leave]['date_to'],'%Y-%m-%d %H:%M:%S') @@ -42,8 +42,8 @@ def compute_working_calendar(cr,uid,calendar_id): wk_time = {} wktime_list = [] wktime_cal = [] - week_ids = resource_week_pool.search(cr,uid,[('calendar_id','=',calendar_id)]) - week_obj = resource_week_pool.read(cr,uid,week_ids,['dayofweek','hour_from','hour_to']) + week_ids = resource_week_pool.search(cr, uid, [('calendar_id','=',calendar_id)]) + week_obj = resource_week_pool.read(cr, uid, week_ids, ['dayofweek','hour_from','hour_to']) # Converting time formats into appropriate format required # and creating a list like [('mon', '8:00-12:00'), ('mon', '13:00-18:00')] @@ -53,8 +53,8 @@ def compute_working_calendar(cr,uid,calendar_id): day = wk[week['dayofweek']] wk_days[week['dayofweek']] = wk[week['dayofweek']] - hour_from_str = timeformat_convert(cr,uid,week['hour_from']) - hour_to_str = timeformat_convert(cr,uid,week['hour_to']) + hour_from_str = timeformat_convert(cr, uid, week['hour_from']) + hour_to_str = timeformat_convert(cr, uid, week['hour_to']) res_str = hour_from_str + '-' + hour_to_str wktime_list.append((day,res_str)) diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index 0f6979cca9c..c763306e602 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -182,7 +182,7 @@ class project_issue(osv.osv, crm.crm_case): } def _get_project(self, cr, uid, 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.context_project_id: return user.context_project_id.id return False diff --git a/addons/project_long_term/project_long_term.py b/addons/project_long_term/project_long_term.py index 57fbd1abb5f..f1c40a4c8ba 100644 --- a/addons/project_long_term/project_long_term.py +++ b/addons/project_long_term/project_long_term.py @@ -45,7 +45,7 @@ class project_phase(osv.osv): next_ids = [rec.id for rec in next_ids] # iter prev_ids while prev_ids: - cr.execute('select distinct prv_phase_id from project_phase_rel where next_phase_id in ('+','.join(map(str, prev_ids))+')') + cr.execute('select distinct prv_phase_id from project_phase_rel where next_phase_id IN %s',(tuple(prev_ids),)) prv_phase_ids = filter(None, map(lambda x: x[0], cr.fetchall())) if data_phase.id in prv_phase_ids: return False @@ -55,7 +55,7 @@ class project_phase(osv.osv): prev_ids = prv_phase_ids # iter next_ids while next_ids: - cr.execute('select distinct next_phase_id from project_phase_rel where prv_phase_id in ('+','.join(map(str, next_ids))+')') + cr.execute('select distinct next_phase_id from project_phase_rel where prv_phase_id IN %s',(tuple(next_ids),)) next_phase_ids = filter(None, map(lambda x: x[0], cr.fetchall())) if data_phase.id in next_phase_ids: return False diff --git a/addons/project_planning/project_planning.py b/addons/project_planning/project_planning.py index 09a105cfb53..2124b59b5c3 100644 --- a/addons/project_planning/project_planning.py +++ b/addons/project_planning/project_planning.py @@ -235,7 +235,7 @@ class report_account_analytic_planning_user(osv.osv): for line in self.browse(cr, uid, ids, context): if line.user_id: cr.execute("""select COALESCE(sum(tasks.remaining_hours),0) from project_task tasks \ - where tasks.planning_line_id in (select id from report_account_analytic_planning_line\ + where tasks.planning_line_id IN (select id from report_account_analytic_planning_line\ where planning_id = %s and user_id=%s)""", (line.planning_id.id, line.user_id.id,)) result[line.id] = cr.fetchall()[0][0] / div * div2 diff --git a/addons/project_retro_planning/project_retro_planning.py b/addons/project_retro_planning/project_retro_planning.py index 3300ac0eebe..5d7839ae5fd 100644 --- a/addons/project_retro_planning/project_retro_planning.py +++ b/addons/project_retro_planning/project_retro_planning.py @@ -29,7 +29,7 @@ class project_project(osv.osv): def write(self, cr, uid, ids,vals, *args, **kwargs): if 'date' in vals and vals['date']: - data_project = self.browse(cr,uid,ids) + data_project = self.browse(cr, uid, ids) for prj in data_project: c= date(*time.strptime(vals['date'],'%Y-%m-%d')[:3]) if prj.date: @@ -38,9 +38,9 @@ class project_project(osv.osv): start_dt = (datetime(*time.strptime(task.date_start,'%Y-%m-%d %H:%M:%S')[:6])+(c-d)).strftime('%Y-%m-%d %H:%M:%S') if task.date_deadline: deadline_dt = (datetime(*time.strptime(task.date_deadline,'%Y-%m-%d %H:%M:%S')[:6])+(c-d)).strftime('%Y-%m-%d %H:%M:%S') - self.pool.get('project.task').write(cr,uid,task.id,{'date_start':start_dt, 'date_deadline':deadline_dt}) + self.pool.get('project.task').write(cr, uid, task.id, {'date_start':start_dt, 'date_deadline':deadline_dt}) else: - self.pool.get('project.task').write(cr,uid,task.id,{'date_start':start_dt}) + self.pool.get('project.task').write(cr, uid, task.id, {'date_start':start_dt}) return super(project_project,self).write(cr, uid, ids, vals, *args, **kwargs) project_project() diff --git a/addons/project_timesheet/project_timesheet.py b/addons/project_timesheet/project_timesheet.py index f332067b88f..44e9048f253 100644 --- a/addons/project_timesheet/project_timesheet.py +++ b/addons/project_timesheet/project_timesheet.py @@ -88,7 +88,7 @@ class project_work(osv.osv): prod_id, amount, unit, context=kwargs['context']) vals_line['amount'] = (-1) * vals['hours']* (amount_unit['value']['amount'] or 0.0) - obj_timesheet.write(cr, uid,[timeline_id], vals_line, {}) + obj_timesheet.write(cr, uid, [timeline_id], vals_line, {}) vals['hr_analytic_timesheet_id'] = timeline_id return super(project_work,self).create(cr, uid, vals, *args, **kwargs) diff --git a/addons/project_timesheet/report/task_report.py b/addons/project_timesheet/report/task_report.py index c8ef453666f..1e1a165b169 100644 --- a/addons/project_timesheet/report/task_report.py +++ b/addons/project_timesheet/report/task_report.py @@ -95,8 +95,8 @@ class report_timesheet_task_user(osv.osv): for record in self.browse(cr, uid, ids,context): last_date = mx.DateTime.strptime(record.name, '%Y-%m-%d') + mx.DateTime.RelativeDateTime(months=1) - 1 task_obj=self.pool.get('project.task.work') - task_ids = task_obj.search(cr,uid,[('user_id','=',record.user_id.id),('date','>=',record.name),('date','<=',last_date.strftime('%Y-%m-%d'))]) - tsk_hrs = task_obj.read(cr,uid,task_ids,['hours','date','user_id']) + task_ids = task_obj.search(cr, uid, [('user_id','=',record.user_id.id),('date','>=',record.name),('date','<=',last_date.strftime('%Y-%m-%d'))]) + tsk_hrs = task_obj.read(cr, uid, task_ids, ['hours','date','user_id']) total = 0.0 for hrs in tsk_hrs: total += hrs['hours'] @@ -109,8 +109,8 @@ class report_timesheet_task_user(osv.osv): for record in self.browse(cr, uid, ids, context): last_date = mx.DateTime.strptime(record.name, '%Y-%m-%d') + mx.DateTime.RelativeDateTime(months=1) - 1 obj=self.pool.get('hr_timesheet_sheet.sheet.day') - sheet_ids = obj.search(cr,uid,[('sheet_id.user_id','=',record.user_id.id),('name','>=',record.name),('name','<=',last_date.strftime('%Y-%m-%d'))]) - data_days = obj.read(cr,uid,sheet_ids,['name','sheet_id.user_id','total_attendance']) + sheet_ids = obj.search(cr, uid, [('sheet_id.user_id','=',record.user_id.id),('name','>=',record.name),('name','<=',last_date.strftime('%Y-%m-%d'))]) + data_days = obj.read(cr, uid, sheet_ids, ['name','sheet_id.user_id','total_attendance']) total = 0.0 for day_attendance in data_days: total += day_attendance['total_attendance'] diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index af00075a6d3..6d067385d2a 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -116,7 +116,7 @@ class purchase_order(osv.osv): LEFT JOIN stock_picking p on (p.id=m.picking_id) WHERE - p.purchase_id = ANY(%s) GROUP BY m.state, p.purchase_id''',(ids,)) + p.purchase_id IN %s GROUP BY m.state, p.purchase_id''',(tuple(ids),)) for oid,nbr,state in cr.fetchall(): if state=='cancel': continue @@ -630,7 +630,7 @@ class purchase_order_line(osv.osv): if not product: return {'value': {'price_unit': price_unit or 0.0, 'name': name or '', 'notes': notes or'', 'product_uom' : uom or False}, 'domain':{'product_uom':[]}} - prod= self.pool.get('product.product').browse(cr, uid,product) + prod= self.pool.get('product.product').browse(cr, uid, product) lang=False if partner_id: lang=self.pool.get('res.partner').read(cr, uid, partner_id, ['lang'])['lang'] diff --git a/addons/resource/faces/pcalendar.py b/addons/resource/faces/pcalendar.py index b894a2b66a7..aba9635fc4b 100644 --- a/addons/resource/faces/pcalendar.py +++ b/addons/resource/faces/pcalendar.py @@ -941,20 +941,11 @@ if __name__ == '__main__': cal = Calendar() start = EndDate("10.1.2005") - print "start", start.strftime(), type(start) delay = Minutes("4H") - print "delay", delay, delay.strftime() - print "Start", cal.StartDate is StartDate - print "base", cal.StartDate.__bases__[0] == StartDate.__bases__[0] - print "type", type(start) - - print "convert start" start2 = cal.StartDate(start) - print "convert end" start3 = cal.StartDate("10.1.2005") - print "start2", start2.strftime(), type(start2) #@-node:@file pcalendar.py #@-leo diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 07cb7e34b50..51542ff1376 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -114,7 +114,7 @@ class sale_order(osv.osv): LEFT JOIN procurement_order mp on (mp.move_id=m.id) WHERE - p.sale_id = ANY(%s) GROUP BY mp.state, p.sale_id''',(ids,)) + p.sale_id IN %s GROUP BY mp.state, p.sale_id''',(tuple(ids),)) for oid, nbr, mp_state in cr.fetchall(): if mp_state == 'cancel': continue @@ -322,7 +322,7 @@ class sale_order(osv.osv): def action_cancel_draft(self, cr, uid, ids, *args): if not len(ids): return False - cr.execute('select id from sale_order_line where order_id = ANY(%s) and state=%s',(ids,'cancel')) + cr.execute('select id from sale_order_line where order_id IN %s and state=%s',(tuple(ids),'cancel')) line_ids = map(lambda x: x[0], cr.fetchall()) self.write(cr, uid, ids, {'state': 'draft', 'invoice_ids': [], 'shipped': 0}) self.pool.get('sale.order.line').write(cr, uid, line_ids, {'invoiced': False, 'state': 'draft', 'invoice_lines': [(6, 0, [])]}) @@ -832,8 +832,8 @@ class sale_order_line(osv.osv): \n* The \'Done\' state is set automatically when sale order is set as done. \ \n* The \'Cancelled\' state is set automatically when user cancel sale order.'), 'order_partner_id': fields.related('order_id', 'partner_id', type='many2one', relation='res.partner', string='Customer'), - 'salesman_id':fields.related('order_id','user_id',type='many2one',relation='res.users',string='Salesman'), - 'company_id': fields.related('order_id','company_id',type='many2one',relation='res.company',string='Company',store=True), + 'salesman_id':fields.related('order_id', 'user_id', type='many2one', relation='res.users', string='Salesman'), + 'company_id': fields.related('order_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True), } _order = 'sequence, id' _defaults = { diff --git a/addons/scrum/report/_burndown.py b/addons/scrum/report/_burndown.py index 7f5239e1224..6f0db24bcb6 100644 --- a/addons/scrum/report/_burndown.py +++ b/addons/scrum/report/_burndown.py @@ -26,13 +26,13 @@ import time def compute_burndown(cr, uid, tasks_id, date_start, date_stop): latest = False if len(tasks_id): - cr.execute('select id,create_date,state,planned_hours from project_task where id = ANY(%s) order by create_date',(tasks_id,)) + cr.execute('select id,create_date,state,planned_hours from project_task where id IN %s order by create_date',(tuple(tasks_id),)) tasks = cr.fetchall() - cr.execute('select w.date,w.hours from project_task_work w left join project_task t on (t.id=w.task_id) where t.id = ANY(%s) and t.state in (%s,%s) order by date',(tasks_id,'open','progress',)) + cr.execute('select w.date,w.hours from project_task_work w left join project_task t on (t.id=w.task_id) where t.id IN %s and t.state in (%s,%s) order by date',(tuple(tasks_id),'open','progress',)) tasks2 = cr.fetchall() - cr.execute('select date_end,planned_hours from project_task where id =ANY(%s) and state in (%s,%s) order by date_end' ,(tasks_id,'cancelled','done',)) + cr.execute('select date_end,planned_hours from project_task where id IN %s and state in (%s,%s) order by date_end' ,(tuple(tasks_id),'cancelled','done',)) tasks2 += cr.fetchall() tasks2.sort() else: diff --git a/addons/scrum/report/task_burndown.py b/addons/scrum/report/task_burndown.py index 36296bcee5f..efd285c357e 100644 --- a/addons/scrum/report/task_burndown.py +++ b/addons/scrum/report/task_burndown.py @@ -43,9 +43,9 @@ class external_pdf(render): def burndown_chart(cr, uid, tasks_id, date_start, date_stop): latest = False - cr.execute('select id,date_start,state,planned_hours from project_task where id = ANY(%s) order by date_start'(tasks_id,)) + cr.execute('select id,date_start,state,planned_hours from project_task where id IN %s order by date_start'(tuple(tasks_id),)) tasks = cr.fetchall() - cr.execute('select id,date_end,state,planned_hours*progress/100 from project_task where id =ANY(%s) and state in (%s,%s) order by date_end', (tasks_id,'progress','done',)) + cr.execute('select id,date_end,state,planned_hours*progress/100 from project_task where id IN %s and state in (%s,%s) order by date_end', (tuple(tasks_id),'progress','done',)) tasks2 = cr.fetchall() current_date = date_start total = 0 @@ -72,14 +72,14 @@ class report_tasks(report_int): io = StringIO.StringIO() if 'date_start' not in datas: - cr.execute('select min(date_start) from project_task where id = ANY(%s)',(ids,)) + cr.execute('select min(date_start) from project_task where id IN %s',(tuple(ids),)) dt = cr.fetchone()[0] if dt: datas['date_start'] = dt[:10] else: datas['date_start'] = time.strftime('%Y-%m-%d') if 'date_stop' not in datas: - cr.execute('select max(date_start),max(date_end) from project_task where id = ANY(%s)',(ids,)) + cr.execute('select max(date_start),max(date_end) from project_task where id IN %s',(tuple(ids),)) res = cr.fetchone() datas['date_stop'] = (res[0] and res[0][:10]) or time.strftime('%Y-%m-%d') if res[1] and datas['date_stop'] ANY(%s)'\ - 'and location_dest_id =ANY(%s)'\ - 'and product_id =ANY(%s)'\ - 'and state in %s' + (date_str and 'and '+date_str+' ' or '') +''\ - 'group by product_id,product_uom',(location_ids,location_ids,ids,tuple(states),) + 'where location_id NOT IN %s'\ + 'and location_dest_id IN %s'\ + 'and product_id IN %s'\ + 'and state IN %s' + (date_str and 'and '+date_str+' ' or '') +''\ + 'group by product_id,product_uom',(tuple(location_ids),tuple(location_ids),tuple(ids),tuple(states),) ) results = cr.fetchall() if 'out' in what: @@ -254,11 +254,11 @@ class product_product(osv.osv): cr.execute( 'select sum(product_qty), product_id, product_uom '\ 'from stock_move '\ - 'where location_id = ANY(%s)'\ - 'and location_dest_id <> ANY(%s) '\ - 'and product_id =ANY(%s)'\ + 'where location_id IN %s'\ + 'and location_dest_id NOT IN %s '\ + 'and product_id IN %s'\ 'and state in %s' + (date_str and 'and '+date_str+' ' or '') + ''\ - 'group by product_id,product_uom',(location_ids,location_ids,ids,tuple(states),) + 'group by product_id,product_uom',(tuple(location_ids),tuple(location_ids),tuple(ids),tuple(states),) ) results2 = cr.fetchall() uom_obj = self.pool.get('product.uom') diff --git a/addons/stock/report/product_stock.py b/addons/stock/report/product_stock.py index f9a61a8989a..e55405381b4 100644 --- a/addons/stock/report/product_stock.py +++ b/addons/stock/report/product_stock.py @@ -71,10 +71,10 @@ class report_stock(report_int): cr.execute("select sum(r.product_qty * u.factor), r.date_planned, r.product_id " "from stock_move r left join product_uom u on (r.product_uom=u.id) " - "where state in %s" - "and location_id=ANY(%s)" - "and product_id=ANY(%s)" - "group by date_planned,product_id",(('confirmed','assigned','waiting'),loc_ids ,product_ids,)) + "where state IN %s" + "and location_id IN %s" + "and product_id IN %s" + "group by date_planned,product_id",(('confirmed','assigned','waiting'),tuple(loc_ids) ,tuple(product_ids),)) for (qty, dt, prod_id) in cr.fetchall(): if dt<=dt_from: dt= (datetime.now() + relativedelta(days=1)).strftime('%Y-%m-%d') @@ -85,10 +85,10 @@ class report_stock(report_int): cr.execute("select sum(r.product_qty * u.factor), r.date_planned, r.product_id " "from stock_move r left join product_uom u on (r.product_uom=u.id) " - "where state in %s" - "and location_dest_id=ANY(%s)" - "and product_id=ANY(%s)" - "group by date_planned,product_id",(('confirmed','assigned','waiting'),loc_ids ,product_ids,)) + "where state IN %s" + "and location_dest_id IN %s" + "and product_id IN %s" + "group by date_planned,product_id",(('confirmed','assigned','waiting'),tuple(loc_ids) ,tuple(product_ids),)) for (qty, dt, prod_id) in cr.fetchall(): if dt<=dt_from: diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 924bf69c520..14462bda200 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -539,9 +539,9 @@ class stock_picking(osv.osv): from stock_move where - picking_id=ANY(%s) + picking_id IN %s group by - picking_id""",(ids,)) + picking_id""",(tuple(ids),)) for pick, dt1, dt2 in cr.fetchall(): res[pick]['min_date'] = dt1 res[pick]['max_date'] = dt2 @@ -1230,7 +1230,7 @@ class stock_production_lot(osv.osv): from stock_report_prodlots where - location_id =ANY(%s) and prodlot_id =ANY(%s) group by prodlot_id''',(locations,ids,)) + location_id IN %s and prodlot_id IN %s group by prodlot_id''',(tuple(locations),tuple(ids),)) res.update(dict(cr.fetchall())) return res @@ -1245,8 +1245,8 @@ class stock_production_lot(osv.osv): from stock_report_prodlots where - location_id =ANY(%s) group by prodlot_id - having sum(name) '''+ str(args[0][1]) + str(args[0][2]),(locations,)) + location_id IN %s group by prodlot_id + having sum(name) '''+ str(args[0][1]) + str(args[0][2]),(tuple(locations),)) res = cr.fetchall() ids = [('id', 'in', map(lambda x: x[0], res))] return ids diff --git a/addons/stock_planning/stock_planning.py b/addons/stock_planning/stock_planning.py index d4d7337bbb0..0c957d8b72e 100644 --- a/addons/stock_planning/stock_planning.py +++ b/addons/stock_planning/stock_planning.py @@ -374,21 +374,21 @@ class stock_sale_forecast(osv.osv): def _sales_per_users(self, cr, uid, so, so_line, company, users): cr.execute("SELECT sum(sol.product_uom_qty) FROM sale_order_line AS sol LEFT JOIN sale_order AS s ON (s.id = sol.order_id) " \ - "WHERE (sol.id IN (%s)) AND (s.state NOT IN (\'draft\',\'cancel\')) AND (s.id IN (%s)) AND (s.company_id=%s) " \ - "AND (s.user_id IN (%s)) " %(so_line, so, company, users)) + "WHERE (sol.id IN %s) AND (s.state NOT IN (\'draft\',\'cancel\')) AND (s.id IN %s) AND (s.company_id=%s) " \ + "AND (s.user_id IN %s) " %(tuple(so_line), tuple(so), company, tuple(users))) ret = cr.fetchone()[0] or 0.0 return ret def _sales_per_warehouse(self, cr, uid, so, so_line, company, shops): cr.execute("SELECT sum(sol.product_uom_qty) FROM sale_order_line AS sol LEFT JOIN sale_order AS s ON (s.id = sol.order_id) " \ - "WHERE (sol.id IN (%s)) AND (s.state NOT IN (\'draft\',\'cancel\')) AND (s.id IN (%s))AND (s.company_id=%s) " \ - "AND (s.shop_id IN (%s))" %(so_line, so, company, shops)) + "WHERE (sol.id IN %s) AND (s.state NOT IN (\'draft\',\'cancel\')) AND (s.id IN %s)AND (s.company_id=%s) " \ + "AND (s.shop_id IN %s)" %(tuple(so_line), tuple(so), company, tuple(shops))) ret = cr.fetchone()[0] or 0.0 return ret def _sales_per_company(self, cr, uid, so, so_line, company, ): cr.execute("SELECT sum(sol.product_uom_qty) FROM sale_order_line AS sol LEFT JOIN sale_order AS s ON (s.id = sol.order_id) " \ - "WHERE (sol.id IN (%s)) AND (s.state NOT IN (\'draft\',\'cancel\')) AND (s.id IN (%s)) AND (s.company_id=%s)"%(so_line, so, company)) + "WHERE (sol.id IN %s) AND (s.state NOT IN (\'draft\',\'cancel\')) AND (s.id IN %s) AND (s.company_id=%s)"%(tuple(so_line), tuple(so), company)) ret = cr.fetchone()[0] or 0.0 return ret @@ -411,7 +411,7 @@ class stock_sale_forecast(osv.osv): dept_id = obj.analyzed_dept_id.id and [obj.analyzed_dept_id.id] or [] dept_ids = dept_obj.search(cr,uid,[('parent_id','child_of',dept_id)]) dept_ids_set = ','.join(map(str,dept_ids)) - cr.execute("SELECT user_id FROM hr_department_user_rel WHERE (department_id IN (%s))" %(dept_ids_set)) + cr.execute("SELECT user_id FROM hr_department_user_rel WHERE (department_id IN %s)" %(tuple(dept_ids_set),)) dept_users = [x for x, in cr.fetchall()] dept_users_set = ','.join(map(str,dept_users)) else: diff --git a/addons/survey/survey.py b/addons/survey/survey.py index c86f13b262f..8cac202fe40 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -211,8 +211,8 @@ class survey_question(osv.osv): return {} val = {} cr.execute("select question_id, count(id) as Total_response from \ - survey_response_line where state='done' and question_id in (%s)\ - group by question_id" % ",".join(map(str, map(int, ids)))) + survey_response_line where state='done' and question_id IN %s\ + group by question_id" ,(tuple(ids),)) ids1 = copy.deepcopy(ids) for rec in cr.fetchall(): ids1.remove(rec[0]) diff --git a/addons/survey/wizard/survey_answer.py b/addons/survey/wizard/survey_answer.py index b5f88f20432..4b44b6a1753 100644 --- a/addons/survey/wizard/survey_answer.py +++ b/addons/survey/wizard/survey_answer.py @@ -448,7 +448,6 @@ class survey_question_wiz(osv.osv_memory): fp.close(); except Exception,e: - print 'Exception in create report:',e return (False, str(e)) return (True, ret_file_name) diff --git a/addons/wiki/wizard/wiki_make_index.py b/addons/wiki/wizard/wiki_make_index.py index 24ebf19855e..98cc001fe8c 100644 --- a/addons/wiki/wizard/wiki_make_index.py +++ b/addons/wiki/wizard/wiki_make_index.py @@ -39,8 +39,8 @@ class wiki_make_index(osv.osv_memory): for index_obj in self.browse(cr, uid, ids): wiki_pool = self.pool.get('wiki.wiki') - cr.execute("Select id, section from wiki_wiki where id = ANY(%s) \ - order by section ", (data,)) + cr.execute("Select id, section from wiki_wiki where id IN %s \ + order by section ", (tuple(data),)) lst0 = cr.fetchall() lst = [] s_ids = {}