[MERGE] merge with trunk addons and remove conficts

bzr revid: mra@mra-laptop-20100618083859-5jbrk4u9l2vojxu6
This commit is contained in:
Mustufa Rangwala 2010-06-18 14:08:59 +05:30
commit 3be7801205
182 changed files with 1366 additions and 1529 deletions

View File

@ -30,6 +30,25 @@ from tools.misc import currency
from tools.translate import _
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"
@ -167,6 +186,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=[]
@ -226,18 +246,31 @@ class account_account(osv.osv):
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
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 ",
'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)
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 ids2:
if children_and_consolidated:
aml_query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
wheres = [""]
@ -245,24 +278,33 @@ class account_account(osv.osv):
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,))
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
ids2.reverse()
brs = list(self.browse(cr, uid, ids2, context=context))
children_and_consolidated.reverse()
brs = list(self.browse(cr, uid, children_and_consolidated, context=context))
sums = {}
while brs:
current = brs[0]
@ -389,8 +431,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
@ -907,7 +951,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)
@ -1006,7 +1053,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
@ -1019,7 +1069,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={}):
@ -1138,7 +1190,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
@ -1292,24 +1347,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):
@ -1326,12 +1383,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']:
@ -1342,7 +1401,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'
@ -1390,16 +1449,6 @@ 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:
@ -1408,6 +1457,7 @@ class account_tax_code(osv.osv):
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'])
]
@ -1979,16 +2029,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'])
]
@ -2098,16 +2139,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'])
]

View File

@ -299,7 +299,8 @@ class account_move_line(osv.osv):
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,))
'AND l.id IN %s',
(tuple(ids),))
invoice_ids = []
for line_id, invoice_id in cursor.fetchall():
res[line_id] = invoice_id
@ -647,10 +648,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):

View File

@ -20,6 +20,7 @@
##############################################################################
import time
from operator import itemgetter
import decimal_precision as dp
import netsvc
@ -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):
@ -896,7 +898,8 @@ 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))+')')
'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:
@ -1129,7 +1132,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:

View File

@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
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'
@ -117,27 +115,33 @@ class res_partner(osv.osv):
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,

View File

@ -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:
@ -108,61 +102,25 @@ class account_analytic_balance(report_sxw.rml_parse):
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',

View File

@ -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

View File

@ -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):

View File

@ -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)

View File

@ -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',

View File

@ -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 = {}

View File

@ -18,7 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
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):
@ -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:
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:
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:
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:
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)

View File

@ -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']
@ -106,14 +107,21 @@ 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()
period_min = res[0]['start_date']
period_max = res[0]['stop_date']
@ -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:
@ -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

View File

@ -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,
@ -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 + ") " \
"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)
@ -353,12 +349,13 @@ class partner_balance(report_sxw.rml_parse):
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
@ -371,12 +368,13 @@ class partner_balance(report_sxw.rml_parse):
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
@ -388,13 +386,14 @@ class partner_balance(report_sxw.rml_parse):
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
@ -406,16 +405,17 @@ class partner_balance(report_sxw.rml_parse):
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:
@ -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:

View File

@ -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,
@ -89,6 +88,7 @@ class tax_report(rml_parse.rml_parse):
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 +') \

View File

@ -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:
@ -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:
@ -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:
@ -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
@ -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

View File

@ -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

View File

@ -37,16 +37,7 @@ class account_open_closed_fiscalyear(osv.osv_memory):
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)])
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()

View File

@ -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':

View File

@ -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]),

View File

@ -124,7 +124,7 @@ def _coda_parsing(self, cr, uid, data, context):
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")))])
# bank_statement['period_id'] = period_id and period_id[0] or False
bank_statement['period_id'] = period_id[0]
bank_statement['state']='draft'
elif line[0] == '1':
# old balance data

View File

@ -18,7 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
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):

View File

@ -144,19 +144,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)
@ -218,8 +208,8 @@ 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':
@ -238,61 +228,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 {}
@ -328,15 +263,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):
@ -371,11 +297,6 @@ class payment_line(osv.osv):
'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),
'bank_id': fields.many2one('res.partner.bank', 'Destination Bank account'),
@ -385,21 +306,12 @@ class payment_line(osv.osv):
'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'),
'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),
'state': fields.selection([('normal','Free'), ('structured','Structured')], 'Communication Type', required=True)

View File

@ -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)

View File

@ -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:
@ -61,13 +61,11 @@ class account_analytic_account(osv.osv):
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:

View File

@ -97,12 +97,18 @@ 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, {})
@ -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:

View File

@ -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)

View File

@ -54,7 +54,10 @@ 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:
@ -64,52 +67,52 @@ class auction_total_rml(report_sxw.rml_parse):
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])

View File

@ -49,7 +49,8 @@ class buyer_list(report_sxw.rml_parse):
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:
@ -69,13 +70,16 @@ class buyer_list(report_sxw.rml_parse):
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']

View File

@ -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')

View File

@ -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:

View File

@ -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

View File

@ -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:

View File

@ -33,17 +33,17 @@ 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,))
cr.execute(query, (tuple(ids),))
ans_yes = [x[0] for x in cr.fetchall()]
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()]

View File

@ -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
@ -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 = {}

View File

@ -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

View File

@ -31,16 +31,9 @@ for fname in args:
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

View File

@ -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,7 +447,6 @@ 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:

View File

@ -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)

View File

@ -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 = {

View File

@ -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
@ -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

View File

@ -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

View File

@ -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

View File

@ -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 ('/','/')

View File

@ -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!'))

View File

@ -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

View File

@ -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 = self.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 = %s AND product_id=%s and to_invoice=%s", (account.id, data['id'], 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))
self.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 =%s" ,(last_invoice, account.id,data['id']))
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)

View File

@ -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]
@ -371,7 +371,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(),
@ -490,7 +490,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(),

View File

@ -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):

View File

@ -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

View File

@ -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 = {

View File

@ -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])

View File

@ -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'])

View File

@ -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),

View File

@ -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()

View File

@ -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

View File

@ -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'))

View File

@ -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

View File

@ -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 = []

View File

@ -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)

View File

@ -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)

View File

@ -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):

View File

@ -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 \

View File

@ -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)

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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

View File

@ -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()

View File

@ -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

View File

@ -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:

View File

@ -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']

View File

@ -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

View File

@ -62,7 +62,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:

View File

@ -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)}

View File

@ -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

View File

@ -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

View File

@ -28,7 +28,6 @@ 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)
project_task = self.pool.get('project.task')
for prj in data_project:
new_end_date = date(*time.strptime(vals['date'],'%Y-%m-%d')[:3])
if prj.date:
@ -36,10 +35,10 @@ class project_project(osv.osv):
for task in prj.tasks:
start_dt = (datetime(*time.strptime(task.date_start,'%Y-%m-%d %H:%M:%S')[:6])+(new_end_date-old_end_date)).strftime('%Y-%m-%d %H:%M:%S')
if task.date_deadline:
deadline_dt = (datetime(*time.strptime(task.date_deadline,'%Y-%m-%d')[:6])+(new_end_date-old_end_date)).strftime('%Y-%m-%d')
project_task.write(cr,uid,task.id,{'date_start':start_dt, 'date_deadline':deadline_dt})
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})
else:
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()

View File

@ -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

View File

@ -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

View File

@ -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, [])]})

View File

@ -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:

View File

@ -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']<res[1]:

View File

@ -242,11 +242,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)'\
'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')

View File

@ -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:

View File

@ -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
@ -1234,7 +1234,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
@ -1249,8 +1249,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

View File

@ -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:

View File

@ -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])

View File

@ -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)

View File

@ -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 = {}