[FIX] Security fixes for sql injections
bzr revid: jma@tinyerp.com-20100610133419-fwbc1xp0xoq77n90
This commit is contained in:
parent
a4d86b14fe
commit
4cf1362e3b
|
@ -20,6 +20,7 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
from operator import itemgetter
|
||||||
import netsvc
|
import netsvc
|
||||||
|
|
||||||
from osv import fields, osv
|
from osv import fields, osv
|
||||||
|
@ -33,6 +34,25 @@ from dateutil.relativedelta import relativedelta
|
||||||
|
|
||||||
from tools import config
|
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):
|
class account_payment_term(osv.osv):
|
||||||
_name = "account.payment.term"
|
_name = "account.payment.term"
|
||||||
_description = "Payment Term"
|
_description = "Payment Term"
|
||||||
|
@ -170,6 +190,7 @@ class account_account(osv.osv):
|
||||||
_name = "account.account"
|
_name = "account.account"
|
||||||
_description = "Account"
|
_description = "Account"
|
||||||
_parent_store = True
|
_parent_store = True
|
||||||
|
logger = netsvc.Logger()
|
||||||
|
|
||||||
def _get_children_and_consol(self, cr, uid, ids, context={}):
|
def _get_children_and_consol(self, cr, uid, ids, context={}):
|
||||||
ids2=[]
|
ids2=[]
|
||||||
|
@ -228,66 +249,88 @@ class account_account(osv.osv):
|
||||||
if ids3:
|
if ids3:
|
||||||
ids3 = self._get_children_and_consol(cr, uid, ids3, context)
|
ids3 = self._get_children_and_consol(cr, uid, ids3, context)
|
||||||
return ids2 + ids3
|
return ids2 + ids3
|
||||||
|
|
||||||
def __compute(self, cr, uid, ids, field_names, arg, context={}, query=''):
|
def __compute(self, cr, uid, ids, field_names, arg=None, context=None,
|
||||||
#compute the balance/debit/credit accordingly to the value of field_name for the given account ids
|
query='', query_params=()):
|
||||||
mapping = {
|
""" compute the balance, debit and/or credit for the provided
|
||||||
'balance': "COALESCE(SUM(l.debit),0) - COALESCE(SUM(l.credit), 0) as balance ",
|
account ids
|
||||||
'debit': "COALESCE(SUM(l.debit), 0) as debit ",
|
Arguments:
|
||||||
'credit': "COALESCE(SUM(l.credit), 0) as credit "
|
`ids`: account ids
|
||||||
}
|
`field_names`: the fields to compute (a list of any of
|
||||||
#get all the necessary accounts
|
'balance', 'debit' and 'credit')
|
||||||
ids2 = self._get_children_and_consol(cr, uid, ids, context)
|
`arg`: unused fields.function stuff
|
||||||
#compute for each account the balance/debit/credit from the move lines
|
`query`: additional query filter (as a string)
|
||||||
accounts = {}
|
`query_params`: parameters for the provided query string
|
||||||
if ids2:
|
(__compute will handle their escaping) as a
|
||||||
aml_query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
|
tuple
|
||||||
|
"""
|
||||||
wheres = [""]
|
mapping = {
|
||||||
if query.strip():
|
'balance': "COALESCE(SUM(l.debit),0) " \
|
||||||
wheres.append(query.strip())
|
"- COALESCE(SUM(l.credit), 0) as balance",
|
||||||
if aml_query.strip():
|
'debit': "COALESCE(SUM(l.debit), 0) as debit",
|
||||||
wheres.append(aml_query.strip())
|
'credit': "COALESCE(SUM(l.credit), 0) as credit"
|
||||||
query = " AND ".join(wheres)
|
}
|
||||||
|
#get all the necessary accounts
|
||||||
cr.execute("SELECT l.account_id as id, " +\
|
children_and_consolidated = self._get_children_and_consol(cr, uid, ids, context=context)
|
||||||
' , '.join(map(lambda x: mapping[x], field_names)) +
|
#compute for each account the balance/debit/credit from the move lines
|
||||||
"FROM " \
|
accounts = {}
|
||||||
"account_move_line l " \
|
if children_and_consolidated:
|
||||||
"WHERE " \
|
aml_query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
|
||||||
"l.account_id =ANY(%s) " \
|
|
||||||
+ query +
|
wheres = [""]
|
||||||
" GROUP BY l.account_id",(ids2,))
|
if query.strip():
|
||||||
|
wheres.append(query.strip())
|
||||||
for res in cr.dictfetchall():
|
if aml_query.strip():
|
||||||
accounts[res['id']] = res
|
wheres.append(aml_query.strip())
|
||||||
|
filters = " AND ".join(wheres)
|
||||||
|
self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG,
|
||||||
# consolidate accounts with direct children
|
'Filters: %s'%filters)
|
||||||
ids2.reverse()
|
# IN might not work ideally in case there are too many
|
||||||
brs = list(self.browse(cr, uid, ids2, context=context))
|
# children_and_consolidated, in that case join on a
|
||||||
sums = {}
|
# values() e.g.:
|
||||||
while brs:
|
# SELECT l.account_id as id FROM account_move_line l
|
||||||
current = brs[0]
|
# INNER JOIN (VALUES (id1), (id2), (id3), ...) AS tmp (id)
|
||||||
can_compute = True
|
# ON l.account_id = tmp.id
|
||||||
for child in current.child_id:
|
# or make _get_children_and_consol return a query and join on that
|
||||||
if child.id not in sums:
|
request = ("SELECT l.account_id as id, " +\
|
||||||
can_compute = False
|
' , '.join(map(mapping.__getitem__, field_names)) +
|
||||||
try:
|
" FROM account_move_line l" \
|
||||||
brs.insert(0, brs.pop(brs.index(child)))
|
" WHERE l.account_id IN %s " \
|
||||||
except ValueError:
|
+ filters +
|
||||||
brs.insert(0, child)
|
" GROUP BY l.account_id")
|
||||||
if can_compute:
|
params = (tuple(children_and_consolidated),) + query_params
|
||||||
brs.pop(0)
|
cr.execute(request, params)
|
||||||
for fn in field_names:
|
self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG,
|
||||||
sums.setdefault(current.id, {})[fn] = accounts.get(current.id, {}).get(fn, 0.0)
|
'Status: %s'%cr.statusmessage)
|
||||||
if current.child_id:
|
|
||||||
sums[current.id][fn] += sum(sums[child.id][fn] for child in current.child_id)
|
for res in cr.dictfetchall():
|
||||||
res = {}
|
accounts[res['id']] = res
|
||||||
null_result = dict((fn, 0.0) for fn in field_names)
|
|
||||||
for id in ids:
|
# consolidate accounts with direct children
|
||||||
res[id] = sums.get(id, null_result)
|
children_and_consolidated.reverse()
|
||||||
return res
|
brs = list(self.browse(cr, uid, children_and_consolidated, context=context))
|
||||||
|
sums = {}
|
||||||
|
while brs:
|
||||||
|
current = brs[0]
|
||||||
|
can_compute = True
|
||||||
|
for child in current.child_id:
|
||||||
|
if child.id not in sums:
|
||||||
|
can_compute = False
|
||||||
|
try:
|
||||||
|
brs.insert(0, brs.pop(brs.index(child)))
|
||||||
|
except ValueError:
|
||||||
|
brs.insert(0, child)
|
||||||
|
if can_compute:
|
||||||
|
brs.pop(0)
|
||||||
|
for fn in field_names:
|
||||||
|
sums.setdefault(current.id, {})[fn] = accounts.get(current.id, {}).get(fn, 0.0)
|
||||||
|
if current.child_id:
|
||||||
|
sums[current.id][fn] += sum(sums[child.id][fn] for child in current.child_id)
|
||||||
|
res = {}
|
||||||
|
null_result = dict((fn, 0.0) for fn in field_names)
|
||||||
|
for id in ids:
|
||||||
|
res[id] = sums.get(id, null_result)
|
||||||
|
return res
|
||||||
|
|
||||||
def _get_company_currency(self, cr, uid, ids, field_name, arg, context={}):
|
def _get_company_currency(self, cr, uid, ids, field_name, arg, context={}):
|
||||||
result = {}
|
result = {}
|
||||||
|
@ -392,8 +435,10 @@ class account_account(osv.osv):
|
||||||
if (obj_self in obj_self.child_consol_ids) or (p_id and (p_id is obj_self.id)):
|
if (obj_self in obj_self.child_consol_ids) or (p_id and (p_id is obj_self.id)):
|
||||||
return False
|
return False
|
||||||
while(ids):
|
while(ids):
|
||||||
cr.execute('select distinct child_id from account_account_consol_rel where parent_id =ANY(%s)',(ids,))
|
cr.execute('SELECT DISTINCT child_id '\
|
||||||
child_ids = filter(None, map(lambda x: x[0], cr.fetchall()))
|
'FROM account_account_consol_rel '\
|
||||||
|
'WHERE parent_id IN %s', (tuple(ids),))
|
||||||
|
child_ids = map(itemgetter(0), cr.fetchall())
|
||||||
c_ids = child_ids
|
c_ids = child_ids
|
||||||
if (p_id and (p_id in c_ids)) or (obj_self.id in c_ids):
|
if (p_id and (p_id in c_ids)) or (obj_self.id in c_ids):
|
||||||
return False
|
return False
|
||||||
|
@ -883,7 +928,10 @@ class account_move(osv.osv):
|
||||||
|
|
||||||
def _amount_compute(self, cr, uid, ids, name, args, context, where =''):
|
def _amount_compute(self, cr, uid, ids, name, args, context, where =''):
|
||||||
if not ids: return {}
|
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())
|
result = dict(cr.fetchall())
|
||||||
for id in ids:
|
for id in ids:
|
||||||
result.setdefault(id, 0.0)
|
result.setdefault(id, 0.0)
|
||||||
|
@ -982,7 +1030,10 @@ class account_move(osv.osv):
|
||||||
if new_name:
|
if new_name:
|
||||||
self.write(cr, uid, [move.id], {'name':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:
|
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" !'))
|
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
|
return True
|
||||||
|
@ -995,7 +1046,9 @@ class account_move(osv.osv):
|
||||||
if not line.journal_id.update_posted:
|
if not line.journal_id.update_posted:
|
||||||
raise osv.except_osv(_('Error !'), _('You can not modify a posted entry of this journal !\nYou should set the journal to allow cancelling entries if you want to do that.'))
|
raise osv.except_osv(_('Error !'), _('You can not modify a posted entry of this journal !\nYou should set the journal to allow cancelling entries if you want to do that.'))
|
||||||
if len(ids):
|
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
|
return True
|
||||||
|
|
||||||
def write(self, cr, uid, ids, vals, context={}):
|
def write(self, cr, uid, ids, vals, context={}):
|
||||||
|
@ -1114,7 +1167,10 @@ class account_move(osv.osv):
|
||||||
else:
|
else:
|
||||||
line_id2 = 0
|
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
|
result = cr.fetchone()[0] or 0.0
|
||||||
cr.execute('update account_move_line set '+mode2+'=%s where id=%s', (result, line_id))
|
cr.execute('update account_move_line set '+mode2+'=%s where id=%s', (result, line_id))
|
||||||
return True
|
return True
|
||||||
|
@ -1268,24 +1324,26 @@ class account_tax_code(osv.osv):
|
||||||
|
|
||||||
This code is used for some tax declarations.
|
This code is used for some tax declarations.
|
||||||
"""
|
"""
|
||||||
def _sum(self, cr, uid, ids, name, args, context, where =''):
|
def _sum(self, cr, uid, ids, name, args, context,where ='', where_params=()):
|
||||||
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
|
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
|
||||||
if context.get('based_on', 'invoices') == 'payments':
|
if context.get('based_on', 'invoices') == 'payments':
|
||||||
cr.execute('SELECT line.tax_code_id, sum(line.tax_amount) \
|
cr.execute('SELECT line.tax_code_id, sum(line.tax_amount) \
|
||||||
FROM account_move_line AS line, \
|
FROM account_move_line AS line, \
|
||||||
account_move AS move \
|
account_move AS move \
|
||||||
LEFT JOIN account_invoice invoice ON \
|
LEFT JOIN account_invoice invoice ON \
|
||||||
(invoice.move_id = move.id) \
|
(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 move.id = line.move_id \
|
||||||
AND ((invoice.state = \'paid\') \
|
AND ((invoice.state = \'paid\') \
|
||||||
OR (invoice.id IS NULL)) \
|
OR (invoice.id IS NULL)) \
|
||||||
GROUP BY line.tax_code_id',(ids2,))
|
GROUP BY line.tax_code_id',
|
||||||
|
(parent_ids,)+where_params)
|
||||||
else:
|
else:
|
||||||
cr.execute('SELECT line.tax_code_id, sum(line.tax_amount) \
|
cr.execute('SELECT line.tax_code_id, sum(line.tax_amount) \
|
||||||
FROM account_move_line AS line \
|
FROM account_move_line AS line \
|
||||||
WHERE line.tax_code_id =ANY(%s) '+where+' \
|
WHERE line.tax_code_id in %s '+where+' \
|
||||||
GROUP BY line.tax_code_id',(ids2,))
|
GROUP BY line.tax_code_id',
|
||||||
|
(parent_ids,)+where_params)
|
||||||
res=dict(cr.fetchall())
|
res=dict(cr.fetchall())
|
||||||
for record in self.browse(cr, uid, ids, context):
|
for record in self.browse(cr, uid, ids, context):
|
||||||
def _rec_get(record):
|
def _rec_get(record):
|
||||||
|
@ -1302,12 +1360,14 @@ class account_tax_code(osv.osv):
|
||||||
else:
|
else:
|
||||||
fiscalyear_id = self.pool.get('account.fiscalyear').find(cr, uid, exception=False)
|
fiscalyear_id = self.pool.get('account.fiscalyear').find(cr, uid, exception=False)
|
||||||
where = ''
|
where = ''
|
||||||
|
where_params = ()
|
||||||
if fiscalyear_id:
|
if fiscalyear_id:
|
||||||
pids = map(lambda x: str(x.id), self.pool.get('account.fiscalyear').browse(cr, uid, fiscalyear_id).period_ids)
|
pids = map(lambda x: str(x.id), self.pool.get('account.fiscalyear').browse(cr, uid, fiscalyear_id).period_ids)
|
||||||
if pids:
|
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,
|
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):
|
def _sum_period(self, cr, uid, ids, name, args, context):
|
||||||
if 'period_id' in context and context['period_id']:
|
if 'period_id' in context and context['period_id']:
|
||||||
|
@ -1318,7 +1378,7 @@ class account_tax_code(osv.osv):
|
||||||
return dict.fromkeys(ids, 0.0)
|
return dict.fromkeys(ids, 0.0)
|
||||||
period_id = period_id[0]
|
period_id = period_id[0]
|
||||||
return self._sum(cr, uid, ids, name, args, context,
|
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'
|
_name = 'account.tax.code'
|
||||||
_description = 'Tax Code'
|
_description = 'Tax Code'
|
||||||
|
@ -1366,24 +1426,15 @@ class account_tax_code(osv.osv):
|
||||||
'sign': lambda *args: 1.0,
|
'sign': lambda *args: 1.0,
|
||||||
'notprintable': lambda *a: False,
|
'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):
|
def copy(self, cr, uid, id, default=None, context=None):
|
||||||
if default is None:
|
if default is None:
|
||||||
default = {}
|
default = {}
|
||||||
default = default.copy()
|
default = default.copy()
|
||||||
default.update({'line_ids': []})
|
default.update({'line_ids': []})
|
||||||
return super(account_tax_code, self).copy(cr, uid, id, default, context)
|
return super(account_tax_code, self).copy(cr, uid, id, default, context)
|
||||||
|
|
||||||
|
_check_recursion = check_cycle
|
||||||
_constraints = [
|
_constraints = [
|
||||||
(_check_recursion, 'Error ! You can not create recursive accounts.', ['parent_id'])
|
(_check_recursion, 'Error ! You can not create recursive accounts.', ['parent_id'])
|
||||||
]
|
]
|
||||||
|
@ -1922,16 +1973,7 @@ class account_account_template(osv.osv):
|
||||||
'nocreate': lambda *a: False,
|
'nocreate': lambda *a: False,
|
||||||
}
|
}
|
||||||
|
|
||||||
def _check_recursion(self, cr, uid, ids):
|
_check_recursion = check_cycle
|
||||||
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
|
|
||||||
|
|
||||||
_constraints = [
|
_constraints = [
|
||||||
(_check_recursion, 'Error ! You can not create recursive account templates.', ['parent_id'])
|
(_check_recursion, 'Error ! You can not create recursive account templates.', ['parent_id'])
|
||||||
]
|
]
|
||||||
|
@ -2042,16 +2084,7 @@ class account_tax_code_template(osv.osv):
|
||||||
return [(x['id'], (x['code'] and x['code'] + ' - ' or '') + x['name']) \
|
return [(x['id'], (x['code'] and x['code'] + ' - ' or '') + x['name']) \
|
||||||
for x in reads]
|
for x in reads]
|
||||||
|
|
||||||
def _check_recursion(self, cr, uid, ids):
|
_check_recursion = check_cycle
|
||||||
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
|
|
||||||
|
|
||||||
_constraints = [
|
_constraints = [
|
||||||
(_check_recursion, 'Error ! You can not create recursive Tax Codes.', ['parent_id'])
|
(_check_recursion, 'Error ! You can not create recursive Tax Codes.', ['parent_id'])
|
||||||
]
|
]
|
||||||
|
|
|
@ -298,9 +298,10 @@ class account_move_line(osv.osv):
|
||||||
for line_id in ids:
|
for line_id in ids:
|
||||||
res[line_id] = False
|
res[line_id] = False
|
||||||
cursor.execute('SELECT l.id, i.id ' \
|
cursor.execute('SELECT l.id, i.id ' \
|
||||||
'FROM account_move_line l, account_invoice i ' \
|
'FROM account_move_line l, account_invoice i ' \
|
||||||
'WHERE l.move_id = i.move_id ' \
|
'WHERE l.move_id = i.move_id ' \
|
||||||
'AND l.id =ANY(%s)',(ids,))
|
'AND l.id in %s',
|
||||||
|
(tuple(ids),))
|
||||||
invoice_ids = []
|
invoice_ids = []
|
||||||
for line_id, invoice_id in cursor.fetchall():
|
for line_id, invoice_id in cursor.fetchall():
|
||||||
res[line_id] = invoice_id
|
res[line_id] = invoice_id
|
||||||
|
@ -620,10 +621,11 @@ class account_move_line(osv.osv):
|
||||||
else:
|
else:
|
||||||
date = time.strftime('%Y-%m-%d')
|
date = time.strftime('%Y-%m-%d')
|
||||||
|
|
||||||
cr.execute('SELECT account_id, reconcile_id \
|
cr.execute('SELECT account_id, reconcile_id '\
|
||||||
FROM account_move_line \
|
'FROM account_move_line '\
|
||||||
WHERE id =ANY(%s) \
|
'WHERE id IN %s '\
|
||||||
GROUP BY account_id,reconcile_id',(ids,))
|
'GROUP BY account_id,reconcile_id',
|
||||||
|
(tuple(ids),))
|
||||||
r = cr.fetchall()
|
r = cr.fetchall()
|
||||||
#TODO: move this check to a constraint in the account_move_reconcile object
|
#TODO: move this check to a constraint in the account_move_reconcile object
|
||||||
if (len(r) != 1) and not context.get('fy_closing', False):
|
if (len(r) != 1) and not context.get('fy_closing', False):
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
from operator import itemgetter
|
||||||
import decimal_precision as dp
|
import decimal_precision as dp
|
||||||
|
|
||||||
import netsvc
|
import netsvc
|
||||||
|
@ -564,12 +565,13 @@ class account_invoice(osv.osv):
|
||||||
def move_line_id_payment_get(self, cr, uid, ids, *args):
|
def move_line_id_payment_get(self, cr, uid, ids, *args):
|
||||||
res = []
|
res = []
|
||||||
if not ids: return res
|
if not ids: return res
|
||||||
cr.execute('select \
|
cr.execute('SELECT l.id '\
|
||||||
l.id \
|
'FROM account_move_line l '\
|
||||||
from account_move_line l \
|
'LEFT JOIN account_invoice i ON (i.move_id=l.move_id) '\
|
||||||
left join account_invoice i on (i.move_id=l.move_id) \
|
'WHERE i.id IN %s '\
|
||||||
where i.id in ('+','.join(map(str,map(int, ids)))+') and l.account_id=i.account_id')
|
'AND l.account_id=i.account_id',
|
||||||
res = map(lambda x: x[0], cr.fetchall())
|
(tuple(ids),))
|
||||||
|
res = map(itemgetter(0), cr.fetchall())
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def copy(self, cr, uid, id, default=None, context=None):
|
def copy(self, cr, uid, id, default=None, context=None):
|
||||||
|
@ -888,8 +890,9 @@ class account_invoice(osv.osv):
|
||||||
|
|
||||||
def action_number(self, cr, uid, ids, *args):
|
def action_number(self, cr, uid, ids, *args):
|
||||||
cr.execute('SELECT id, type, number, move_id, reference ' \
|
cr.execute('SELECT id, type, number, move_id, reference ' \
|
||||||
'FROM account_invoice ' \
|
'FROM account_invoice ' \
|
||||||
'WHERE id IN ('+','.join(map(str, ids))+')')
|
'WHERE id IN %s',
|
||||||
|
(tuple(ids),))
|
||||||
obj_inv = self.browse(cr, uid, ids)[0]
|
obj_inv = self.browse(cr, uid, ids)[0]
|
||||||
for (id, invtype, number, move_id, reference) in cr.fetchall():
|
for (id, invtype, number, move_id, reference) in cr.fetchall():
|
||||||
if not number:
|
if not number:
|
||||||
|
@ -1112,7 +1115,9 @@ class account_invoice(osv.osv):
|
||||||
move_ids = [move_id,]
|
move_ids = [move_id,]
|
||||||
if invoice.move_id:
|
if invoice.move_id:
|
||||||
move_ids.append(invoice.move_id.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()) )
|
lines = line.browse(cr, uid, map(lambda x: x[0], cr.fetchall()) )
|
||||||
for l in lines+invoice.payment_ids:
|
for l in lines+invoice.payment_ids:
|
||||||
if l.account_id.id==src_account_id:
|
if l.account_id.id==src_account_id:
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
from operator import itemgetter
|
||||||
|
|
||||||
from osv import fields, osv
|
from osv import fields, osv
|
||||||
import ir
|
import ir
|
||||||
|
@ -88,22 +89,19 @@ class res_partner(osv.osv):
|
||||||
_name = 'res.partner'
|
_name = 'res.partner'
|
||||||
_inherit = 'res.partner'
|
_inherit = 'res.partner'
|
||||||
_description = 'Partner'
|
_description = 'Partner'
|
||||||
|
|
||||||
def _credit_debit_get(self, cr, uid, ids, field_names, arg, context):
|
def _credit_debit_get(self, cr, uid, ids, field_names, arg, context):
|
||||||
query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
|
query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
|
||||||
cr.execute("""select
|
cr.execute("""SELECT l.partner_id, a.type, SUM(l.debit-l.credit)
|
||||||
l.partner_id, a.type, sum(l.debit-l.credit)
|
FROM account_move_line l
|
||||||
from
|
LEFT JOIN account_account a ON (l.account_id=a.id)
|
||||||
account_move_line l
|
WHERE a.type IN ('receivable','payable')
|
||||||
left join
|
AND l.partner_id in %s
|
||||||
account_account a on (l.account_id=a.id)
|
AND l.reconcile_id IS NULL
|
||||||
where
|
AND """ + query + """
|
||||||
a.type =ANY(%s) and
|
GROUP BY l.partner_id, a.type
|
||||||
l.partner_id =ANY(%s) and
|
""",
|
||||||
l.reconcile_id is null and
|
(tuple(ids),))
|
||||||
"""+query+"""
|
|
||||||
group by
|
|
||||||
l.partner_id, a.type
|
|
||||||
""",(['receivable','payable'],ids,))
|
|
||||||
tinvert = {
|
tinvert = {
|
||||||
'credit': 'receivable',
|
'credit': 'receivable',
|
||||||
'debit': 'payable'
|
'debit': 'payable'
|
||||||
|
@ -116,28 +114,34 @@ class res_partner(osv.osv):
|
||||||
if val is None: val=0
|
if val is None: val=0
|
||||||
res[pid][maps[type]] = (type=='receivable') and val or -val
|
res[pid][maps[type]] = (type=='receivable') and val or -val
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def _asset_difference_search(self, cr, uid, obj, name, type, args, context=None):
|
||||||
|
if not len(args):
|
||||||
|
return []
|
||||||
|
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(itemgetter(0), res))]
|
||||||
|
|
||||||
def _credit_search(self, cr, uid, obj, name, args, context):
|
def _credit_search(self, cr, uid, obj, name, args, context):
|
||||||
if not len(args):
|
return self._asset_difference_search(cr, uid, obj, name, 'receivable', args, context=context)
|
||||||
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',) )
|
|
||||||
res = cr.fetchall()
|
|
||||||
if not len(res):
|
|
||||||
return [('id','=','0')]
|
|
||||||
return [('id','in',map(lambda x:x[0], res))]
|
|
||||||
|
|
||||||
def _debit_search(self, cr, uid, obj, name, args, context):
|
def _debit_search(self, cr, uid, obj, name, args, context):
|
||||||
if not len(args):
|
return self._asset_difference_search(cr, uid, obj, name, 'payable', args, context=context)
|
||||||
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))]
|
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'credit': fields.function(_credit_debit_get,
|
'credit': fields.function(_credit_debit_get,
|
||||||
|
|
|
@ -32,15 +32,9 @@ class account_analytic_balance(report_sxw.rml_parse):
|
||||||
'get_objects': self._get_objects,
|
'get_objects': self._get_objects,
|
||||||
'lines_g': self._lines_g,
|
'lines_g': self._lines_g,
|
||||||
'move_sum': self._move_sum,
|
'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_all': self._sum_all,
|
||||||
# 'sum_debit': self._sum_debit,
|
|
||||||
# 'sum_credit': self._sum_credit,
|
|
||||||
'sum_balance': self._sum_balance,
|
'sum_balance': self._sum_balance,
|
||||||
# 'sum_quantity': self._sum_quantity,
|
|
||||||
'move_sum_balance': self._move_sum_balance,
|
'move_sum_balance': self._move_sum_balance,
|
||||||
# 'move_sum_quantity': self._move_sum_quantity,
|
|
||||||
})
|
})
|
||||||
self.acc_ids = []
|
self.acc_ids = []
|
||||||
self.read_data = []
|
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 \
|
sum(aal.amount) AS balance, sum(aal.unit_amount) AS quantity \
|
||||||
FROM account_analytic_line AS aal, account_account AS aa \
|
FROM account_analytic_line AS aal, account_account AS aa \
|
||||||
WHERE (aal.general_account_id=aa.id) \
|
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 \
|
AND (date>=%s) AND (date<=%s) AND aa.active \
|
||||||
GROUP BY aal.general_account_id, aa.name, aa.code, aal.code \
|
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()
|
res = self.cr.dictfetchall()
|
||||||
|
|
||||||
for r in res:
|
for r in res:
|
||||||
|
@ -107,62 +101,26 @@ class account_analytic_balance(report_sxw.rml_parse):
|
||||||
self.acc_data_dict[account_id] = ids
|
self.acc_data_dict[account_id] = ids
|
||||||
else:
|
else:
|
||||||
ids = self.acc_data_dict[account_id]
|
ids = self.acc_data_dict[account_id]
|
||||||
|
|
||||||
|
query_params = (tuple(ids), date1, date2)
|
||||||
if option == "credit" :
|
if option == "credit" :
|
||||||
self.cr.execute("SELECT -sum(amount) FROM account_analytic_line \
|
self.cr.execute("SELECT -sum(amount) FROM account_analytic_line \
|
||||||
WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount<0",
|
WHERE account_id in %s AND date>=%s AND date<=%s AND amount<0",query_params)
|
||||||
(ids,date1, date2))
|
|
||||||
elif option == "debit" :
|
elif option == "debit" :
|
||||||
self.cr.execute("SELECT sum(amount) FROM account_analytic_line \
|
self.cr.execute("SELECT sum(amount) FROM account_analytic_line \
|
||||||
WHERE account_id =ANY(%s)\
|
WHERE account_id in %s\
|
||||||
AND date>=%s AND date<=%s AND amount>0",
|
AND date>=%s AND date<=%s AND amount>0",query_params)
|
||||||
(ids,date1, date2))
|
|
||||||
elif option == "quantity" :
|
elif option == "quantity" :
|
||||||
self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line \
|
self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line \
|
||||||
WHERE account_id =ANY(%s)\
|
WHERE account_id in %s\
|
||||||
AND date>=%s AND date<=%s",
|
AND date>=%s AND date<=%s",query_params)
|
||||||
(ids,date1, date2))
|
|
||||||
return self.cr.fetchone()[0] or 0.0
|
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):
|
def _move_sum_balance(self, account_id, date1, date2):
|
||||||
debit = self._move_sum(account_id, date1, date2, 'debit')
|
debit = self._move_sum(account_id, date1, date2, 'debit')
|
||||||
credit = self._move_sum(account_id, date1, date2, 'credit')
|
credit = self._move_sum(account_id, date1, date2, 'credit')
|
||||||
return (debit-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):
|
def _sum_all(self, accounts, date1, date2, option):
|
||||||
ids = map(lambda x: x['id'], accounts)
|
ids = map(lambda x: x['id'], accounts)
|
||||||
if not len(ids):
|
if not len(ids):
|
||||||
|
@ -174,68 +132,25 @@ class account_analytic_balance(report_sxw.rml_parse):
|
||||||
self.acc_sum_list = ids2
|
self.acc_sum_list = ids2
|
||||||
else:
|
else:
|
||||||
ids2 = self.acc_sum_list
|
ids2 = self.acc_sum_list
|
||||||
|
query_params = (tuple(ids2), date1, date2)
|
||||||
if option == "debit" :
|
if option == "debit" :
|
||||||
self.cr.execute("SELECT sum(amount) FROM account_analytic_line \
|
self.cr.execute("SELECT sum(amount) FROM account_analytic_line \
|
||||||
WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount>0",
|
WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount>0",query_params)
|
||||||
(ids,date1, date2,))
|
|
||||||
elif option == "credit" :
|
elif option == "credit" :
|
||||||
self.cr.execute("SELECT -sum(amount) FROM account_analytic_line \
|
self.cr.execute("SELECT -sum(amount) FROM account_analytic_line \
|
||||||
WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount<0",
|
WHERE account_id =ANY(%s) AND date>=%s AND date<=%s AND amount<0",query_params)
|
||||||
(ids,date1, date2,))
|
|
||||||
elif option == "quantity" :
|
elif option == "quantity" :
|
||||||
self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line \
|
self.cr.execute("SELECT sum(unit_amount) FROM account_analytic_line \
|
||||||
WHERE account_id =ANY(%s)AND date>=%s AND date<=%s",
|
WHERE account_id =ANY(%s)AND date>=%s AND date<=%s",query_params)
|
||||||
(ids,date1, date2,))
|
|
||||||
return self.cr.fetchone()[0] or 0.0
|
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):
|
def _sum_balance(self, accounts, date1, date2):
|
||||||
debit = self._sum_all(accounts, date1, date2, 'debit') or 0.0
|
debit = self._sum_all(accounts, date1, date2, 'debit') or 0.0
|
||||||
credit = self._sum_all(accounts, date1, date2, 'credit') or 0.0
|
credit = self._sum_all(accounts, date1, date2, 'credit') or 0.0
|
||||||
return (debit-credit)
|
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',
|
report_sxw.report_sxw('report.account.analytic.account.balance',
|
||||||
'account.analytic.account', 'addons/account/project/report/analytic_balance.rml',
|
'account.analytic.account', 'addons/account/project/report/analytic_balance.rml',
|
||||||
|
|
|
@ -77,41 +77,6 @@ class account_analytic_analytic_check(report_sxw.rml_parse):
|
||||||
|
|
||||||
return res
|
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):
|
def _gen_deb(self, date1, date2):
|
||||||
return self.sum_gen_deb
|
return self.sum_gen_deb
|
||||||
|
|
||||||
|
|
|
@ -93,15 +93,14 @@ class account_analytic_cost_ledger(report_sxw.rml_parse):
|
||||||
ids = map(lambda x: x.id, accounts)
|
ids = map(lambda x: x.id, accounts)
|
||||||
if not len(ids):
|
if not len(ids):
|
||||||
return 0.0
|
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
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_credit(self, accounts, date1, date2):
|
def _sum_credit(self, accounts, date1, date2):
|
||||||
ids = map(lambda x: x.id, accounts)
|
ids = map(lambda x: x.id, accounts)
|
||||||
if not len(ids):
|
if not len(ids):
|
||||||
return 0.0
|
return 0.0
|
||||||
ids = map(lambda x: x.id, accounts)
|
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,))
|
||||||
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,))
|
|
||||||
return self.cr.fetchone()[0] or 0.0
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_balance(self, accounts, date1, date2):
|
def _sum_balance(self, accounts, date1, date2):
|
||||||
|
|
|
@ -38,12 +38,17 @@ class account_inverted_analytic_balance(report_sxw.rml_parse):
|
||||||
|
|
||||||
def _lines_g(self, accounts, date1, date2):
|
def _lines_g(self, accounts, date1, date2):
|
||||||
ids = map(lambda x: x.id, accounts)
|
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 \
|
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 \
|
WHERE (aal.general_account_id=aa.id) "
|
||||||
GROUP BY aal.general_account_id, aa.name, aa.code, aal.code, aa.id ORDER BY aal.code", (ids,date1,date2,))
|
"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()
|
res = self.cr.dictfetchall()
|
||||||
|
|
||||||
for r in res:
|
for r in res:
|
||||||
if r['balance'] > 0:
|
if r['balance'] > 0:
|
||||||
r['debit'] = r['balance']
|
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):
|
def _lines_a(self, accounts, general_account_id, date1, date2):
|
||||||
ids = map(lambda x: x.id, accounts)
|
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 \
|
self.cr.execute("SELECT sum(aal.amount) AS balance, "
|
||||||
FROM account_analytic_line AS aal, account_analytic_account AS aaa \
|
"sum(aal.unit_amount) AS quantity, "
|
||||||
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 \
|
"aaa.code AS code, aaa.name AS name, account_id \
|
||||||
GROUP BY aal.account_id, general_account_id, aaa.code, aaa.name ORDER BY aal.account_id", (ids,general_account_id, date1, date2,))
|
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()
|
res = self.cr.dictfetchall()
|
||||||
|
|
||||||
aaa_obj = self.pool.get('account.analytic.account')
|
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)
|
ids = map(lambda x: x.id, accounts)
|
||||||
self.cr.execute("SELECT sum(amount) \
|
self.cr.execute("SELECT sum(amount) \
|
||||||
FROM account_analytic_line \
|
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
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_credit(self, accounts, date1, date2):
|
def _sum_credit(self, accounts, date1, date2):
|
||||||
ids = map(lambda x: x.id, accounts)
|
ids = map(lambda x: x.id, accounts)
|
||||||
self.cr.execute("SELECT -sum(amount) \
|
self.cr.execute("SELECT -sum(amount) \
|
||||||
FROM account_analytic_line \
|
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
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_balance(self, accounts, date1, date2):
|
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)
|
ids = map(lambda x: x.id, accounts)
|
||||||
self.cr.execute("SELECT sum(unit_amount) \
|
self.cr.execute("SELECT sum(unit_amount) \
|
||||||
FROM account_analytic_line \
|
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
|
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)
|
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)
|
||||||
|
|
|
@ -52,9 +52,9 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse):
|
||||||
WHERE (aal.account_id=%s) AND (aal.date>=%s) \
|
WHERE (aal.account_id=%s) AND (aal.date>=%s) \
|
||||||
AND (aal.date<=%s) AND (aal.general_account_id=aa.id) \
|
AND (aal.date<=%s) AND (aal.general_account_id=aa.id) \
|
||||||
AND aa.active \
|
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",
|
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()
|
res = self.cr.dictfetchall()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@ -79,9 +79,9 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse):
|
||||||
account_analytic_journal AS aaj \
|
account_analytic_journal AS aaj \
|
||||||
WHERE (aal.general_account_id=%s) AND (aal.account_id=%s) \
|
WHERE (aal.general_account_id=%s) AND (aal.account_id=%s) \
|
||||||
AND (aal.date>=%s) AND (aal.date<=%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",
|
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()
|
res = self.cr.dictfetchall()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
|
@ -80,13 +80,13 @@ class aged_trial_report(rml_parse.rml_parse):
|
||||||
self.cr.execute("""SELECT partner_id, SUM(debit-credit)
|
self.cr.execute("""SELECT partner_id, SUM(debit-credit)
|
||||||
FROM account_move_line AS line, account_account
|
FROM account_move_line AS line, account_account
|
||||||
WHERE (line.account_id = account_account.id)
|
WHERE (line.account_id = account_account.id)
|
||||||
AND (account_account.type =ANY(%s))
|
AND (account_account.type IN %s)
|
||||||
AND (partner_id =ANY (%s))
|
AND (partner_id IN %s)
|
||||||
AND ((reconcile_id IS NULL)
|
AND ((reconcile_id IS NULL)
|
||||||
OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))
|
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.company_id = %s)
|
||||||
AND account_account.active
|
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()
|
t = self.cr.fetchall()
|
||||||
for i in t:
|
for i in t:
|
||||||
totals[i[0]] = i[1]
|
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)
|
self.cr.execute("""SELECT partner_id, SUM(debit-credit)
|
||||||
FROM account_move_line AS line, account_account
|
FROM account_move_line AS line, account_account
|
||||||
WHERE (line.account_id=account_account.id)
|
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 (COALESCE(date_maturity,date) < %s)
|
||||||
AND (partner_id =ANY (%s))
|
AND (partner_id IN %s)
|
||||||
AND ((reconcile_id IS NULL)
|
AND ((reconcile_id IS NULL)
|
||||||
OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))
|
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.company_id = %s)
|
||||||
AND account_account.active
|
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()
|
t = self.cr.fetchall()
|
||||||
for i in t:
|
for i in t:
|
||||||
future_past[i[0]] = i[1]
|
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)
|
self.cr.execute("""SELECT partner_id, SUM(debit-credit)
|
||||||
FROM account_move_line AS line, account_account
|
FROM account_move_line AS line, account_account
|
||||||
WHERE (line.account_id=account_account.id)
|
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 (COALESCE(date_maturity,date) > %s)
|
||||||
AND (partner_id =ANY (%s))
|
AND (partner_id IN %s)
|
||||||
AND ((reconcile_id IS NULL)
|
AND ((reconcile_id IS NULL)
|
||||||
OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))
|
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.company_id = %s)
|
||||||
AND account_account.active
|
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()
|
t = self.cr.fetchall()
|
||||||
for i in t:
|
for i in t:
|
||||||
future_past[i[0]] = i[1]
|
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)
|
self.cr.execute("""SELECT partner_id, SUM(debit-credit)
|
||||||
FROM account_move_line AS line, account_account
|
FROM account_move_line AS line, account_account
|
||||||
WHERE (line.account_id=account_account.id)
|
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 (COALESCE(date_maturity,date) BETWEEN %s AND %s)
|
||||||
AND (partner_id =ANY (%s))
|
AND (partner_id IN %s)
|
||||||
AND ((reconcile_id IS NULL)
|
AND ((reconcile_id IS NULL)
|
||||||
OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))
|
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.company_id = %s)
|
||||||
AND account_account.active
|
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()
|
t = self.cr.fetchall()
|
||||||
d = {}
|
d = {}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
from operator import itemgetter
|
||||||
import pooler
|
import pooler
|
||||||
import time
|
import time
|
||||||
from report import report_sxw
|
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):
|
def set_context(self, objects, data, ids, report_type = None):
|
||||||
super(journal_print, self).set_context(objects, data, ids, report_type)
|
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()
|
res = self.cr.fetchall()
|
||||||
self.period_ids = map(lambda x:x[0],res)
|
self.period_ids, self.journal_ids = zip(*res)
|
||||||
self.journal_ids = map(lambda x:x[1],res)
|
|
||||||
|
|
||||||
# returns a list of period objs
|
# returns a list of period objs
|
||||||
def periods(self, journal_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)
|
periods.append(data.period_id.id)
|
||||||
for period in periods:
|
for period in periods:
|
||||||
period_data = self.pool.get('account.period').browse(self.cr, self.uid, period)
|
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 = self.cr.dictfetchall()
|
||||||
res[0].update({'period_name':period_data.name})
|
res[0].update({'period_name':period_data.name})
|
||||||
res[0].update({'pid':period})
|
res[0].update({'pid':period})
|
||||||
|
@ -82,45 +91,60 @@ class journal_print(report_sxw.rml_parse):
|
||||||
return lines_data
|
return lines_data
|
||||||
if not self.journal_ids:
|
if not self.journal_ids:
|
||||||
return []
|
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,))
|
print " self.journal_ids >>. " , 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()
|
res = self.cr.dictfetchall()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _sum_debit_period(self, period_id,journal_id=None):
|
def _sum_debit_period(self, period_id,journal_id=None):
|
||||||
if type(journal_id)==type([]):
|
journals = journal_id or self.journal_ids
|
||||||
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,))
|
if not journals:
|
||||||
return self.cr.fetchone()[0] or 0.0
|
|
||||||
if not self.journal_ids:
|
|
||||||
return 0.0
|
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
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_credit_period(self, period_id,journal_id=None):
|
def _sum_credit_period(self, period_id,journal_id=None):
|
||||||
if type(journal_id)==type([]):
|
journals = journal_id or self.journal_ids
|
||||||
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,))
|
if not journals:
|
||||||
return self.cr.fetchone()[0] or 0.0
|
|
||||||
if not self.journal_ids:
|
|
||||||
return 0.0
|
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
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_debit(self,period_id=None,journal_id=None):
|
def _sum_debit(self,period_id=None,journal_id=None):
|
||||||
if type(period_id)==type([]):
|
journals = journal_id or self.journal_ids
|
||||||
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,))
|
periods = period_id or self.period_ids
|
||||||
return self.cr.fetchone()[0] or 0.0
|
if not (journals and periods):
|
||||||
if not self.journal_ids or not self.period_ids:
|
|
||||||
return 0.0
|
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
|
return self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
def _sum_credit(self,period_id=None,journal_id=None):
|
def _sum_credit(self,period_id=None,journal_id=None):
|
||||||
if type(period_id)==type([]):
|
periods = period_id or self.period_ids
|
||||||
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,))
|
journals = journal_id or self.journal_ids
|
||||||
return self.cr.fetchone()[0] or 0.0
|
if not (periods and journals):
|
||||||
if not self.journal_ids or not self.period_ids:
|
|
||||||
return 0.0
|
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
|
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', '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)
|
report_sxw.report_sxw('report.account.general.journal.wiz', 'account.journal.period', 'addons/account/report/wizard_general_journal.rml', parser=journal_print, header=False)
|
||||||
|
|
|
@ -87,14 +87,15 @@ class general_ledger(rml_parse.rml_parse):
|
||||||
#periods = form['periods'][0][2]
|
#periods = form['periods'][0][2]
|
||||||
if not periods:
|
if not periods:
|
||||||
sql = """
|
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:
|
else:
|
||||||
periods_id = ','.join(map(str, periods))
|
|
||||||
sql = """
|
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()
|
res = self.cr.dictfetchall()
|
||||||
borne_min = res[0]['start_date']
|
borne_min = res[0]['start_date']
|
||||||
borne_max = res[0]['stop_date']
|
borne_max = res[0]['stop_date']
|
||||||
|
@ -105,15 +106,22 @@ class general_ledger(rml_parse.rml_parse):
|
||||||
periods = form['periods']
|
periods = form['periods']
|
||||||
#periods = form['periods'][0][2]
|
#periods = form['periods'][0][2]
|
||||||
if not periods:
|
if not periods:
|
||||||
sql = """
|
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:
|
else:
|
||||||
periods_id = ','.join(map(str, periods))
|
|
||||||
sql = """
|
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()
|
res = self.cr.dictfetchall()
|
||||||
period_min = res[0]['start_date']
|
period_min = res[0]['start_date']
|
||||||
period_max = res[0]['stop_date']
|
period_max = res[0]['stop_date']
|
||||||
|
@ -196,8 +204,12 @@ class general_ledger(rml_parse.rml_parse):
|
||||||
else:
|
else:
|
||||||
## We will now compute solde initiaux
|
## We will now compute solde initiaux
|
||||||
for move in res:
|
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'] + "'"
|
SOLDEINIT = "SELECT SUM(l.debit) AS sum_debit,"\
|
||||||
self.cr.execute(SOLDEINIT)
|
" 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()
|
resultat = self.cr.dictfetchall()
|
||||||
if resultat[0] :
|
if resultat[0] :
|
||||||
if resultat[0]['sum_debit'] == None:
|
if resultat[0]['sum_debit'] == None:
|
||||||
|
@ -322,7 +334,8 @@ class general_ledger(rml_parse.rml_parse):
|
||||||
return 0.0
|
return 0.0
|
||||||
self.cr.execute("SELECT sum(debit) "\
|
self.cr.execute("SELECT sum(debit) "\
|
||||||
"FROM account_move_line l "\
|
"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
|
sum_debit = self.cr.fetchone()[0] or 0.0
|
||||||
return sum_debit
|
return sum_debit
|
||||||
|
|
||||||
|
@ -331,7 +344,8 @@ class general_ledger(rml_parse.rml_parse):
|
||||||
return 0.0
|
return 0.0
|
||||||
self.cr.execute("SELECT sum(credit) "\
|
self.cr.execute("SELECT sum(credit) "\
|
||||||
"FROM account_move_line l "\
|
"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
|
## Add solde init to the result
|
||||||
#
|
#
|
||||||
sum_credit = self.cr.fetchone()[0] or 0.0
|
sum_credit = self.cr.fetchone()[0] or 0.0
|
||||||
|
@ -342,7 +356,8 @@ class general_ledger(rml_parse.rml_parse):
|
||||||
return 0.0
|
return 0.0
|
||||||
self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\
|
self.cr.execute("SELECT (sum(debit) - sum(credit)) as tot_solde "\
|
||||||
"FROM account_move_line l "\
|
"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
|
sum_solde = self.cr.fetchone()[0] or 0.0
|
||||||
return sum_solde
|
return sum_solde
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@ class partner_balance(report_sxw.rml_parse):
|
||||||
def __init__(self, cr, uid, name, context):
|
def __init__(self, cr, uid, name, context):
|
||||||
super(partner_balance, self).__init__(cr, uid, name, context=context)
|
super(partner_balance, self).__init__(cr, uid, name, context=context)
|
||||||
self.date_lst = []
|
self.date_lst = []
|
||||||
self.date_lst_string = ''
|
|
||||||
self.account_ids = ''
|
self.account_ids = ''
|
||||||
self.localcontext.update( {
|
self.localcontext.update( {
|
||||||
'time': time,
|
'time': time,
|
||||||
|
@ -166,28 +165,24 @@ class partner_balance(report_sxw.rml_parse):
|
||||||
|
|
||||||
self.transform_both_into_date_array(data)
|
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
|
## Compute Code
|
||||||
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||||
#
|
#
|
||||||
if (data['form']['result_selection'] == 'customer' ):
|
if (data['form']['result_selection'] == 'customer' ):
|
||||||
self.ACCOUNT_TYPE = ['receivable']
|
self.ACCOUNT_TYPE = ('receivable',)
|
||||||
elif (data['form']['result_selection'] == 'supplier'):
|
elif (data['form']['result_selection'] == 'supplier'):
|
||||||
self.ACCOUNT_TYPE = ['payable']
|
self.ACCOUNT_TYPE = ('payable',)
|
||||||
else:
|
else:
|
||||||
self.ACCOUNT_TYPE = ['payable','receivable']
|
self.ACCOUNT_TYPE = ('payable','receivable')
|
||||||
#
|
#
|
||||||
self.cr.execute("SELECT a.id " \
|
self.cr.execute("SELECT a.id " \
|
||||||
"FROM account_account a " \
|
"FROM account_account a " \
|
||||||
"LEFT JOIN account_account_type t " \
|
"LEFT JOIN account_account_type t " \
|
||||||
"ON (a.type = t.code) " \
|
"ON (a.type = t.code) " \
|
||||||
"WHERE a.company_id = %s " \
|
"WHERE a.company_id = %s " \
|
||||||
"AND a.type =ANY(%s) "\
|
"AND a.type IN %s " \
|
||||||
"AND a.active", (data['form']['company_id'],self.ACCOUNT_TYPE,))
|
"AND a.active", (data['form']['company_id'],self.ACCOUNT_TYPE))
|
||||||
self.account_ids = [a for (a,) in self.cr.fetchall()]
|
self.account_ids = [a for (a,) in self.cr.fetchall()]
|
||||||
|
|
||||||
super(partner_balance, self).set_context(objects, data, ids, report_type)
|
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')
|
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||||
full_account = []
|
full_account = []
|
||||||
result_tmp = 0.0
|
result_tmp = 0.0
|
||||||
if self.date_lst_string:
|
if self.date_lst:
|
||||||
self.cr.execute(
|
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, " \
|
"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) " \
|
"CASE WHEN sum(debit) > sum(credit) " \
|
||||||
|
@ -211,16 +206,17 @@ class partner_balance(report_sxw.rml_parse):
|
||||||
"(SELECT sum(debit-credit) " \
|
"(SELECT sum(debit-credit) " \
|
||||||
"FROM account_move_line l " \
|
"FROM account_move_line l " \
|
||||||
"WHERE partner_id = p.id " \
|
"WHERE partner_id = p.id " \
|
||||||
"AND l.date IN (" + self.date_lst_string + ") " \
|
"AND l.date IN %s " \
|
||||||
"AND blocked = TRUE " \
|
"AND blocked = TRUE " \
|
||||||
") AS enlitige " \
|
") AS enlitige " \
|
||||||
"FROM account_move_line l LEFT JOIN res_partner p ON (l.partner_id=p.id) " \
|
"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)" \
|
"JOIN account_account ac ON (l.account_id = ac.id)" \
|
||||||
"WHERE ac.type =ANY(%s) "
|
"WHERE ac.type IN %s " \
|
||||||
"AND l.date IN (" + self.date_lst_string + ") " \
|
"AND l.date IN %s " \
|
||||||
"AND ac.company_id = %s" \
|
"AND ac.company_id = %s " \
|
||||||
"GROUP BY p.id, p.ref, p.name,l.account_id,ac.name,ac.code " \
|
"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()
|
res = self.cr.dictfetchall()
|
||||||
for r in res:
|
for r in res:
|
||||||
full_account.append(r)
|
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')
|
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||||
result_tmp = 0.0
|
result_tmp = 0.0
|
||||||
temp_res = 0.0
|
temp_res = 0.0
|
||||||
if self.date_lst_string:
|
if self.date_lst:
|
||||||
self.cr.execute(
|
self.cr.execute(
|
||||||
"SELECT sum(debit) " \
|
"SELECT sum(debit) " \
|
||||||
"FROM account_move_line AS l " \
|
"FROM account_move_line AS l " \
|
||||||
"WHERE l.account_id =ANY(%s)" \
|
"WHERE l.account_id IN %s" \
|
||||||
"AND l.date IN (" + self.date_lst_string + ")" ,(self.account_ids,))
|
"AND l.date IN %s",
|
||||||
|
(tuple(self.account_ids), tuple(self.date_lst)))
|
||||||
temp_res = float(self.cr.fetchone()[0] or 0.0)
|
temp_res = float(self.cr.fetchone()[0] or 0.0)
|
||||||
result_tmp = result_tmp + temp_res
|
result_tmp = result_tmp + temp_res
|
||||||
|
|
||||||
|
@ -371,12 +368,13 @@ class partner_balance(report_sxw.rml_parse):
|
||||||
|
|
||||||
result_tmp = 0.0
|
result_tmp = 0.0
|
||||||
temp_res = 0.0
|
temp_res = 0.0
|
||||||
if self.date_lst_string:
|
if self.date_lst:
|
||||||
self.cr.execute(
|
self.cr.execute(
|
||||||
"SELECT sum(credit) " \
|
"SELECT sum(credit) " \
|
||||||
"FROM account_move_line AS l " \
|
"FROM account_move_line AS l " \
|
||||||
"WHERE l.account_id =ANY(%s)" \
|
"WHERE l.account_id IN %s" \
|
||||||
"AND l.date IN (" + self.date_lst_string + ")" ,(self.account_ids,))
|
"AND l.date IN %s",
|
||||||
|
(tuple(self.account_ids), tuple(self.date_lst),))
|
||||||
temp_res = float(self.cr.fetchone()[0] or 0.0)
|
temp_res = float(self.cr.fetchone()[0] or 0.0)
|
||||||
result_tmp = result_tmp + temp_res
|
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')
|
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||||
result_tmp = 0.0
|
result_tmp = 0.0
|
||||||
temp_res = 0.0
|
temp_res = 0.0
|
||||||
if self.date_lst_string:
|
if self.date_lst:
|
||||||
self.cr.execute(
|
self.cr.execute(
|
||||||
"SELECT sum(debit-credit) " \
|
"SELECT sum(debit-credit) " \
|
||||||
"FROM account_move_line AS l " \
|
"FROM account_move_line AS l " \
|
||||||
"WHERE l.account_id =ANY(%s)" \
|
"WHERE l.account_id IN %s" \
|
||||||
"AND l.date IN (" + self.date_lst_string + ")"\
|
"AND l.date IN %s " \
|
||||||
"AND l.blocked=TRUE " ,(self.account_ids,))
|
"AND l.blocked=TRUE ",
|
||||||
|
(tuple(self.account_ids), tuple(self.date_lst),))
|
||||||
temp_res = float(self.cr.fetchone()[0] or 0.0)
|
temp_res = float(self.cr.fetchone()[0] or 0.0)
|
||||||
result_tmp = result_tmp + temp_res
|
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')
|
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
|
||||||
result_tmp = 0.0
|
result_tmp = 0.0
|
||||||
a = 0.0
|
a = 0.0
|
||||||
if self.date_lst_string:
|
if self.date_lst:
|
||||||
self.cr.execute(
|
self.cr.execute(
|
||||||
"SELECT CASE WHEN sum(debit) > sum(credit) " \
|
"SELECT CASE WHEN sum(debit) > sum(credit) " \
|
||||||
"THEN sum(debit) - sum(credit) " \
|
"THEN sum(debit) - sum(credit) " \
|
||||||
"ELSE 0 " \
|
"ELSE 0 " \
|
||||||
"END " \
|
"END " \
|
||||||
"FROM account_move_line AS l " \
|
"FROM account_move_line AS l " \
|
||||||
"WHERE l.account_id =ANY(%s)" \
|
"WHERE l.account_id IN %s" \
|
||||||
"AND l.date IN (" + self.date_lst_string + ")" \
|
"AND l.date IN %s " \
|
||||||
"GROUP BY l.partner_id",(self.account_ids,))
|
"GROUP BY l.partner_id",
|
||||||
|
(tuple(self.account_ids), tuple(self.date_lst),))
|
||||||
a = self.cr.fetchone()[0]
|
a = self.cr.fetchone()[0]
|
||||||
|
|
||||||
if self.cr.fetchone() != None:
|
if self.cr.fetchone() != None:
|
||||||
|
@ -433,16 +433,17 @@ class partner_balance(report_sxw.rml_parse):
|
||||||
|
|
||||||
result_tmp = 0.0
|
result_tmp = 0.0
|
||||||
a = 0.0
|
a = 0.0
|
||||||
if self.date_lst_string:
|
if self.date_lst:
|
||||||
self.cr.execute(
|
self.cr.execute(
|
||||||
"SELECT CASE WHEN sum(debit) < sum(credit) " \
|
"SELECT CASE WHEN sum(debit) < sum(credit) " \
|
||||||
"THEN sum(credit) - sum(debit) " \
|
"THEN sum(credit) - sum(debit) " \
|
||||||
"ELSE 0 " \
|
"ELSE 0 " \
|
||||||
"END " \
|
"END " \
|
||||||
"FROM account_move_line AS l " \
|
"FROM account_move_line AS l " \
|
||||||
"WHERE l.account_id =ANY(%s)" \
|
"WHERE l.account_id IN %s" \
|
||||||
"AND l.date IN (" + self.date_lst_string + ")" \
|
"AND l.date IN %s " \
|
||||||
"GROUP BY l.partner_id",(self.account_ids,))
|
"GROUP BY l.partner_id",
|
||||||
|
(tuple(self.account_ids), tuple(self.date_lst),))
|
||||||
a = self.cr.fetchone()[0] or 0.0
|
a = self.cr.fetchone()[0] or 0.0
|
||||||
|
|
||||||
if self.cr.fetchone() != None:
|
if self.cr.fetchone() != None:
|
||||||
|
|
|
@ -28,7 +28,6 @@ from report import report_sxw
|
||||||
class tax_report(rml_parse.rml_parse):
|
class tax_report(rml_parse.rml_parse):
|
||||||
_name = 'report.account.vat.declaration'
|
_name = 'report.account.vat.declaration'
|
||||||
def __init__(self, cr, uid, name, context={}):
|
def __init__(self, cr, uid, name, context={}):
|
||||||
print "tax______init", name, context
|
|
||||||
super(tax_report, self).__init__(cr, uid, name, context=context)
|
super(tax_report, self).__init__(cr, uid, name, context=context)
|
||||||
self.localcontext.update({
|
self.localcontext.update({
|
||||||
'time': time,
|
'time': time,
|
||||||
|
@ -86,9 +85,10 @@ class tax_report(rml_parse.rml_parse):
|
||||||
def _get_period(self, period_id, context={}):
|
def _get_period(self, period_id, context={}):
|
||||||
return self.pool.get('account.period').browse(self.cr, self.uid, period_id, context=context).name
|
return self.pool.get('account.period').browse(self.cr, self.uid, period_id, context=context).name
|
||||||
|
|
||||||
def _get_general(self, tax_code_id,period_list ,company_id, based_on, context={}):
|
def _get_general(self, tax_code_id, period_list ,company_id, based_on, context={}):
|
||||||
res=[]
|
res=[]
|
||||||
obj_account = self.pool.get('account.account')
|
obj_account = self.pool.get('account.account')
|
||||||
|
periods_ids = tuple(period_list)
|
||||||
if based_on == 'payments':
|
if based_on == 'payments':
|
||||||
self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \
|
self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \
|
||||||
SUM(line.debit) AS debit, \
|
SUM(line.debit) AS debit, \
|
||||||
|
@ -107,11 +107,11 @@ class tax_report(rml_parse.rml_parse):
|
||||||
AND line.account_id = account.id \
|
AND line.account_id = account.id \
|
||||||
AND account.company_id = %s \
|
AND account.company_id = %s \
|
||||||
AND move.id = line.move_id \
|
AND move.id = line.move_id \
|
||||||
AND line.period_id =ANY(%s) \
|
AND line.period_id IN %s \
|
||||||
AND ((invoice.state = %s) \
|
AND ((invoice.state = %s) \
|
||||||
OR (invoice.id IS NULL)) \
|
OR (invoice.id IS NULL)) \
|
||||||
GROUP BY account.id,account.name,account.code', ('draft', tax_code_id,
|
GROUP BY account.id,account.name,account.code', ('draft', tax_code_id,
|
||||||
company_id, period_list, 'paid',))
|
company_id, periods_ids, 'paid',))
|
||||||
|
|
||||||
else :
|
else :
|
||||||
self.cr.execute('SELECT SUM(line.tax_amount) AS tax_amount, \
|
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.tax_code_id = %s \
|
||||||
AND line.account_id = account.id \
|
AND line.account_id = account.id \
|
||||||
AND account.company_id = %s \
|
AND account.company_id = %s \
|
||||||
AND line.period_id =ANY(%s)\
|
AND line.period_id IN %s\
|
||||||
AND account.active \
|
AND account.active \
|
||||||
GROUP BY account.id,account.name,account.code', ('draft', tax_code_id,
|
GROUP BY account.id,account.name,account.code', ('draft', tax_code_id,
|
||||||
company_id, period_list,))
|
company_id, periods_ids,))
|
||||||
res = self.cr.dictfetchall()
|
res = self.cr.dictfetchall()
|
||||||
|
|
||||||
#AND line.period_id IN ('+ period_sql_list +') \
|
#AND line.period_id IN ('+ period_sql_list +') \
|
||||||
|
|
|
@ -117,7 +117,7 @@ class account_balance_report(osv.osv_memory):
|
||||||
context = {}
|
context = {}
|
||||||
sql = """
|
sql = """
|
||||||
SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """
|
SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """
|
||||||
cr.execute(sql,(data['form']['date_from'],))
|
cr.execute(sql, (data['form']['date_from'],))
|
||||||
res = cr.dictfetchall()
|
res = cr.dictfetchall()
|
||||||
if res:
|
if res:
|
||||||
|
|
||||||
|
|
|
@ -160,10 +160,10 @@ class account_fiscalyear_close(osv.osv_memory):
|
||||||
'WHERE b.account_id = %s ' \
|
'WHERE b.account_id = %s ' \
|
||||||
'AND b.reconcile_id is NOT NULL ' \
|
'AND b.reconcile_id is NOT NULL ' \
|
||||||
'AND a.reconcile_id = b.reconcile_id ' \
|
'AND a.reconcile_id = b.reconcile_id ' \
|
||||||
'AND b.period_id =ANY(%s)'\
|
'AND b.period_id IN %s'\
|
||||||
'AND a.period_id =ANY(%s)' \
|
'AND a.period_id IN %s' \
|
||||||
'ORDER BY id ' \
|
'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()
|
result = cr.dictfetchall()
|
||||||
if not result:
|
if not result:
|
||||||
break
|
break
|
||||||
|
|
|
@ -96,7 +96,7 @@ class account_general_ledger_report(osv.osv_memory):
|
||||||
context = {}
|
context = {}
|
||||||
sql = """
|
sql = """
|
||||||
SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """
|
SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """
|
||||||
cr.execute(sql,(data['form']['date_from'],))
|
cr.execute(sql, (data['form']['date_from'],))
|
||||||
res = cr.dictfetchall()
|
res = cr.dictfetchall()
|
||||||
if res:
|
if res:
|
||||||
if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']):
|
if (data['form']['date_to'] > res[0]['date_stop'] or data['form']['date_to'] < res[0]['date_start']):
|
||||||
|
|
|
@ -37,16 +37,7 @@ class account_open_closed_fiscalyear(osv.osv_memory):
|
||||||
period_journal = data_fyear.end_journal_period_id
|
period_journal = data_fyear.end_journal_period_id
|
||||||
ids_move = self.pool.get('account.move').search(cr,uid,[('journal_id','=',period_journal.journal_id.id),('period_id','=',period_journal.period_id.id)])
|
ids_move = self.pool.get('account.move').search(cr,uid,[('journal_id','=',period_journal.journal_id.id),('period_id','=',period_journal.period_id.id)])
|
||||||
if ids_move:
|
if ids_move:
|
||||||
cr.execute('delete from account_move where id =ANY(%s)',(ids_move,))
|
cr.execute('delete from account_move where id IN %s', (tuple(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))
|
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
account_open_closed_fiscalyear()
|
account_open_closed_fiscalyear()
|
||||||
|
|
|
@ -72,7 +72,6 @@ class account_partner_balance(osv.osv_memory):
|
||||||
'model': 'res.partner',
|
'model': 'res.partner',
|
||||||
'form': self.read(cr, uid, ids, [])[0],
|
'form': self.read(cr, uid, ids, [])[0],
|
||||||
}
|
}
|
||||||
|
|
||||||
if data['form']['state'] == 'bydate' :
|
if data['form']['state'] == 'bydate' :
|
||||||
return self._check_date(cr, uid, data, context)
|
return self._check_date(cr, uid, data, context)
|
||||||
if data['form']['state'] == 'byperiod':
|
if data['form']['state'] == 'byperiod':
|
||||||
|
@ -89,7 +88,7 @@ class account_partner_balance(osv.osv_memory):
|
||||||
def _check_date(self, cr, uid, data, context):
|
def _check_date(self, cr, uid, data, context):
|
||||||
sql = """
|
sql = """
|
||||||
SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """
|
SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """
|
||||||
cr.execute(sql,(data['form']['date1'],))
|
cr.execute(sql, (data['form']['date1'],))
|
||||||
res = cr.dictfetchall()
|
res = cr.dictfetchall()
|
||||||
if res:
|
if res:
|
||||||
if (data['form']['date2'] > res[0]['date_stop'] or data['form']['date2'] < res[0]['date_start']):
|
if (data['form']['date2'] > res[0]['date_stop'] or data['form']['date2'] < res[0]['date_start']):
|
||||||
|
|
|
@ -112,7 +112,7 @@ class account_partner_ledger(osv.osv_memory):
|
||||||
context = {}
|
context = {}
|
||||||
sql = """
|
sql = """
|
||||||
SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """
|
SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where %s between f.date_start and f.date_stop """
|
||||||
cr.execute(sql,(data['form']['date1'],))
|
cr.execute(sql, (data['form']['date1'],))
|
||||||
res = cr.dictfetchall()
|
res = cr.dictfetchall()
|
||||||
if res:
|
if res:
|
||||||
if (data['form']['date2'] > res[0]['date_stop'] or data['form']['date2'] < res[0]['date_start']):
|
if (data['form']['date2'] > res[0]['date_stop'] or data['form']['date2'] < res[0]['date_start']):
|
||||||
|
|
|
@ -32,31 +32,29 @@ class account_analytic_account(osv.osv):
|
||||||
|
|
||||||
def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context={}):
|
def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context={}):
|
||||||
res = {}
|
res = {}
|
||||||
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
|
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
|
||||||
if ids2:
|
if parent_ids:
|
||||||
acc_set = ",".join(map(str, ids2))
|
|
||||||
cr.execute("select account_analytic_line.account_id, COALESCE(sum(amount_currency),0.0) \
|
cr.execute("select account_analytic_line.account_id, COALESCE(sum(amount_currency),0.0) \
|
||||||
from account_analytic_line \
|
from account_analytic_line \
|
||||||
join account_analytic_journal \
|
join account_analytic_journal \
|
||||||
on account_analytic_line.journal_id = account_analytic_journal.id \
|
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' \
|
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():
|
for account_id, sum in cr.fetchall():
|
||||||
res[account_id] = round(sum,2)
|
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={}):
|
def _ca_to_invoice_calc(self, cr, uid, ids, name, arg, context={}):
|
||||||
res = {}
|
res = {}
|
||||||
res2 = {}
|
res2 = {}
|
||||||
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
|
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
|
||||||
if ids2:
|
if parent_ids:
|
||||||
# Amount uninvoiced hours to invoice at sale price
|
# Amount uninvoiced hours to invoice at sale price
|
||||||
# Warning
|
# Warning
|
||||||
# This computation doesn't take care of pricelist !
|
# This computation doesn't take care of pricelist !
|
||||||
# Just consider list_price
|
# Just consider list_price
|
||||||
acc_set = ",".join(map(str, ids2))
|
|
||||||
cr.execute("""SELECT account_analytic_account.id, \
|
cr.execute("""SELECT account_analytic_account.id, \
|
||||||
COALESCE(sum (product_template.list_price * \
|
COALESCE(sum (product_template.list_price * \
|
||||||
account_analytic_line.unit_amount * \
|
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 \
|
on account_analytic_account.id = account_analytic_line.account_id \
|
||||||
JOIN hr_timesheet_invoice_factor \
|
JOIN hr_timesheet_invoice_factor \
|
||||||
on hr_timesheet_invoice_factor.id = account_analytic_account.to_invoice \
|
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.invoice_id is null \
|
||||||
AND account_analytic_line.to_invoice IS NOT NULL \
|
AND account_analytic_line.to_invoice IS NOT NULL \
|
||||||
and account_analytic_journal.type in ('purchase','general') \
|
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():
|
for account_id, sum in cr.fetchall():
|
||||||
res[account_id] = round(sum,2)
|
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={}):
|
def _hours_qtt_non_invoiced_calc (self, cr, uid, ids, name, arg, context={}):
|
||||||
res = {}
|
res = {}
|
||||||
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
|
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
|
||||||
if ids2:
|
if parent_ids:
|
||||||
cr.execute("select account_analytic_line.account_id, COALESCE(sum(unit_amount),0.0) \
|
cr.execute("select account_analytic_line.account_id, COALESCE(sum(unit_amount),0.0) \
|
||||||
from account_analytic_line \
|
from account_analytic_line \
|
||||||
join account_analytic_journal \
|
join account_analytic_journal \
|
||||||
on account_analytic_line.journal_id = account_analytic_journal.id \
|
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 account_analytic_journal.type='general' \
|
||||||
and invoice_id is null \
|
and invoice_id is null \
|
||||||
AND to_invoice IS NOT 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():
|
for account_id, sum in cr.fetchall():
|
||||||
res[account_id] = round(sum,2)
|
res[account_id] = round(sum,2)
|
||||||
for obj_id in ids:
|
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={}):
|
def _hours_quantity_calc(self, cr, uid, ids, name, arg, context={}):
|
||||||
res = {}
|
res = {}
|
||||||
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
|
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
|
||||||
if ids2:
|
if parent_ids:
|
||||||
cr.execute("select account_analytic_line.account_id,COALESCE(SUM(unit_amount),0.0) \
|
cr.execute("select account_analytic_line.account_id,COALESCE(SUM(unit_amount),0.0) \
|
||||||
from account_analytic_line \
|
from account_analytic_line \
|
||||||
join account_analytic_journal \
|
join account_analytic_journal \
|
||||||
on account_analytic_line.journal_id = account_analytic_journal.id \
|
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 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()
|
ff = cr.fetchall()
|
||||||
for account_id, sum in ff:
|
for account_id, sum in ff:
|
||||||
res[account_id] = round(sum,2)
|
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={}):
|
def _total_cost_calc(self, cr, uid, ids, name, arg, context={}):
|
||||||
res = {}
|
res = {}
|
||||||
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
|
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
|
||||||
if ids2:
|
if parent_ids:
|
||||||
acc_set = ",".join(map(str, ids2))
|
|
||||||
cr.execute("""select account_analytic_line.account_id,COALESCE(sum(amount_currency),0.0) \
|
cr.execute("""select account_analytic_line.account_id,COALESCE(sum(amount_currency),0.0) \
|
||||||
|
|
||||||
from account_analytic_line \
|
from account_analytic_line \
|
||||||
join account_analytic_journal \
|
join account_analytic_journal \
|
||||||
on account_analytic_line.journal_id = account_analytic_journal.id \
|
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 \
|
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():
|
for account_id, sum in cr.fetchall():
|
||||||
res[account_id] = round(sum,2)
|
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 !
|
# TODO Take care of pricelist and purchase !
|
||||||
def _ca_theorical_calc(self, cr, uid, ids, name, arg, context={}):
|
def _ca_theorical_calc(self, cr, uid, ids, name, arg, context={}):
|
||||||
res = {}
|
res = {}
|
||||||
res2 = {}
|
res2 = {}
|
||||||
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
|
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
|
||||||
# Warning
|
# Warning
|
||||||
# This computation doesn't take care of pricelist !
|
# This computation doesn't take care of pricelist !
|
||||||
# Just consider list_price
|
# Just consider list_price
|
||||||
if ids2:
|
if parent_ids:
|
||||||
cr.execute("""select account_analytic_line.account_id as account_id, \
|
cr.execute("""select account_analytic_line.account_id as account_id, \
|
||||||
COALESCE(sum((account_analytic_line.unit_amount * pt.list_price) \
|
COALESCE(sum((account_analytic_line.unit_amount * pt.list_price) \
|
||||||
- (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) \
|
on (a.id=account_analytic_line.account_id) \
|
||||||
join hr_timesheet_invoice_factor hr \
|
join hr_timesheet_invoice_factor hr \
|
||||||
on (hr.id=a.to_invoice) \
|
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 a.to_invoice IS NOT NULL \
|
||||||
and account_analytic_journal.type in ('purchase','general')
|
and account_analytic_journal.type in ('purchase','general')
|
||||||
GROUP BY account_analytic_line.account_id""",(ids2,))
|
GROUP BY account_analytic_line.account_id""",(parent_ids,))
|
||||||
for account_id, sum in cr.fetchall():
|
for account_id, sum in cr.fetchall():
|
||||||
res2[account_id] = round(sum,2)
|
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={}):
|
def _last_worked_date_calc (self, cr, uid, ids, name, arg, context={}):
|
||||||
res = {}
|
res = {}
|
||||||
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
|
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
|
||||||
if ids2:
|
if parent_ids:
|
||||||
cr.execute("select account_analytic_line.account_id, max(date) \
|
cr.execute("select account_analytic_line.account_id, max(date) \
|
||||||
from account_analytic_line \
|
from account_analytic_line \
|
||||||
where account_id =ANY(%s) \
|
where account_id IN %s \
|
||||||
and invoice_id is null \
|
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():
|
for account_id, sum in cr.fetchall():
|
||||||
res[account_id] = sum
|
res[account_id] = sum
|
||||||
for obj_id in ids:
|
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={}):
|
def _last_invoice_date_calc (self, cr, uid, ids, name, arg, context={}):
|
||||||
res = {}
|
res = {}
|
||||||
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
|
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
|
||||||
if ids2:
|
if parent_ids:
|
||||||
cr.execute ("select account_analytic_line.account_id, \
|
cr.execute ("select account_analytic_line.account_id, \
|
||||||
date(max(account_invoice.date_invoice)) \
|
date(max(account_invoice.date_invoice)) \
|
||||||
from account_analytic_line \
|
from account_analytic_line \
|
||||||
join account_invoice \
|
join account_invoice \
|
||||||
on account_analytic_line.invoice_id = account_invoice.id \
|
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 \
|
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():
|
for account_id, sum in cr.fetchall():
|
||||||
res[account_id] = sum
|
res[account_id] = sum
|
||||||
for obj_id in ids:
|
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={}):
|
def _last_worked_invoiced_date_calc (self, cr, uid, ids, name, arg, context={}):
|
||||||
res = {}
|
res = {}
|
||||||
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
|
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
|
||||||
if ids2:
|
if parent_ids:
|
||||||
cr.execute("select account_analytic_line.account_id, max(date) \
|
cr.execute("select account_analytic_line.account_id, max(date) \
|
||||||
from account_analytic_line \
|
from account_analytic_line \
|
||||||
where account_id =ANY(%s) \
|
where account_id IN %s \
|
||||||
and invoice_id is not null \
|
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():
|
for account_id, sum in cr.fetchall():
|
||||||
res[account_id] = sum
|
res[account_id] = sum
|
||||||
for obj_id in ids:
|
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):
|
def _month(self, cr, uid, ids, name, arg, context=None):
|
||||||
res = {}
|
res = {}
|
||||||
for id in ids:
|
for id in ids:
|
||||||
ids2 = self.search(cr, uid, [('parent_id', 'child_of', [id])])
|
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
|
||||||
if ids2:
|
if parent_ids:
|
||||||
cr.execute('SELECT DISTINCT(month_id) FROM account_analytic_analysis_summary_month ' \
|
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()]
|
res[id] = [int(id * 1000000 + int(x[0])) for x in cr.fetchall()]
|
||||||
else:
|
else:
|
||||||
res[id] = []
|
res[id] = []
|
||||||
|
@ -360,10 +357,10 @@ class account_analytic_account(osv.osv):
|
||||||
cr.execute('SELECT MAX(id) FROM res_users')
|
cr.execute('SELECT MAX(id) FROM res_users')
|
||||||
max_user = cr.fetchone()[0]
|
max_user = cr.fetchone()[0]
|
||||||
for id in ids:
|
for id in ids:
|
||||||
ids2 = self.search(cr, uid, [('parent_id', 'child_of', [id])])
|
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
|
||||||
if ids2:
|
if parent_ids:
|
||||||
cr.execute('SELECT DISTINCT("user") FROM account_analytic_analysis_summary_user ' \
|
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()]
|
res[id] = [int((id * max_user) + x[0]) for x in cr.fetchall()]
|
||||||
else:
|
else:
|
||||||
res[id] = []
|
res[id] = []
|
||||||
|
@ -405,12 +402,12 @@ class account_analytic_account_summary_user(osv.osv):
|
||||||
max_user = cr.fetchone()[0]
|
max_user = cr.fetchone()[0]
|
||||||
account_ids = [int(str(x/max_user - (x%max_user == 0 and 1 or 0))) for x in ids]
|
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]
|
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)])
|
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', account_ids)]))
|
||||||
if account_ids2:
|
if parent_ids:
|
||||||
cr.execute('SELECT id, unit_amount ' \
|
cr.execute('SELECT id, unit_amount ' \
|
||||||
'FROM account_analytic_analysis_summary_user ' \
|
'FROM account_analytic_analysis_summary_user ' \
|
||||||
'WHERE account_id =ANY(%s) ' \
|
'WHERE account_id IN %s ' \
|
||||||
'AND "user" =ANY(%s)',(account_ids2, user_ids,))
|
'AND "user" IN %s',(parent_ids, user_ids,))
|
||||||
for sum_id, unit_amount in cr.fetchall():
|
for sum_id, unit_amount in cr.fetchall():
|
||||||
res[sum_id] = unit_amount
|
res[sum_id] = unit_amount
|
||||||
for obj_id in ids:
|
for obj_id in ids:
|
||||||
|
@ -570,12 +567,12 @@ class account_analytic_account_summary_month(osv.osv):
|
||||||
account_obj = self.pool.get('account.analytic.account')
|
account_obj = self.pool.get('account.analytic.account')
|
||||||
account_ids = [int(str(int(x))[:-6]) for x in ids]
|
account_ids = [int(str(int(x))[:-6]) for x in ids]
|
||||||
month_ids = [int(str(int(x))[-6:]) for x in ids]
|
month_ids = [int(str(int(x))[-6:]) for x in ids]
|
||||||
account_ids2 = account_obj.search(cr, uid, [('parent_id', 'child_of', account_ids)])
|
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', account_ids)]))
|
||||||
if account_ids2:
|
if parent_ids:
|
||||||
cr.execute('SELECT id, unit_amount ' \
|
cr.execute('SELECT id, unit_amount ' \
|
||||||
'FROM account_analytic_analysis_summary_month ' \
|
'FROM account_analytic_analysis_summary_month ' \
|
||||||
'WHERE account_id =ANY(%s) ' \
|
'WHERE account_id IN %s ' \
|
||||||
'AND month_id =ANY(%s) ',(account_ids2, month_ids,))
|
'AND month_id IN %s ',(parent_ids, month_ids,))
|
||||||
for sum_id, unit_amount in cr.fetchall():
|
for sum_id, unit_amount in cr.fetchall():
|
||||||
res[sum_id] = unit_amount
|
res[sum_id] = unit_amount
|
||||||
for obj_id in ids:
|
for obj_id in ids:
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
from operator import itemgetter
|
||||||
from osv import fields, osv
|
from osv import fields, osv
|
||||||
from tools.translate import _
|
from tools.translate import _
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class account_move_line(osv.osv):
|
||||||
WHERE move_line_id = ml.id
|
WHERE move_line_id = ml.id
|
||||||
AND po.state != 'cancel') as amount
|
AND po.state != 'cancel') as amount
|
||||||
FROM account_move_line ml
|
FROM account_move_line ml
|
||||||
WHERE id =ANY(%s)""" ,(ids,))
|
WHERE id IN %s""", (tuple(ids),))
|
||||||
r=dict(cr.fetchall())
|
r=dict(cr.fetchall())
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
@ -58,8 +58,10 @@ class account_move_line(osv.osv):
|
||||||
END - coalesce(sum(pl.amount_currency), 0)
|
END - coalesce(sum(pl.amount_currency), 0)
|
||||||
FROM payment_line pl
|
FROM payment_line pl
|
||||||
INNER JOIN payment_order po ON (pl.order_id = po.id)
|
INNER JOIN payment_order po ON (pl.order_id = po.id)
|
||||||
WHERE move_line_id = l.id AND po.state != 'cancel')''' \
|
WHERE move_line_id = l.id
|
||||||
+ x[1] + str(x[2])+' ',args))
|
AND po.state != 'cancel'
|
||||||
|
) %(operator)s %%s ''' % {'operator': x[1]}, args))
|
||||||
|
sql_args = tuple(map(itemgetter(2), args))
|
||||||
|
|
||||||
cr.execute(('''select id
|
cr.execute(('''select id
|
||||||
from account_move_line l
|
from account_move_line l
|
||||||
|
@ -68,7 +70,7 @@ class account_move_line(osv.osv):
|
||||||
where type=%s and active)
|
where type=%s and active)
|
||||||
and reconcile_id is null
|
and reconcile_id is null
|
||||||
and credit > 0
|
and credit > 0
|
||||||
and ''' + where + ' and ' + query), ('payable',) )
|
and ''' + where + ' and ' + query), ('payable',)+sql_args )
|
||||||
|
|
||||||
res = cr.fetchall()
|
res = cr.fetchall()
|
||||||
if not len(res):
|
if not len(res):
|
||||||
|
|
|
@ -66,7 +66,6 @@ class payment_mode(osv.osv):
|
||||||
where pm.id = %s """, [payment_code])
|
where pm.id = %s """, [payment_code])
|
||||||
return [x[0] for x in cr.fetchall()]
|
return [x[0] for x in cr.fetchall()]
|
||||||
|
|
||||||
|
|
||||||
payment_mode()
|
payment_mode()
|
||||||
|
|
||||||
|
|
||||||
|
@ -151,19 +150,9 @@ class payment_line(osv.osv):
|
||||||
_name = 'payment.line'
|
_name = 'payment.line'
|
||||||
_description = '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):
|
def translate(self, orig):
|
||||||
return {
|
return {
|
||||||
# "to_pay": "credit",
|
|
||||||
"due_date": "date_maturity",
|
"due_date": "date_maturity",
|
||||||
"reference": "ref"}.get(orig, orig)
|
"reference": "ref"}.get(orig, orig)
|
||||||
|
|
||||||
|
@ -225,8 +214,8 @@ class payment_line(osv.osv):
|
||||||
from account_move_line ml
|
from account_move_line ml
|
||||||
inner join payment_line pl
|
inner join payment_line pl
|
||||||
on (ml.id = pl.move_line_id)
|
on (ml.id = pl.move_line_id)
|
||||||
where pl.id =ANY(%s)""",
|
where pl.id IN %%s"""% self.translate(name),
|
||||||
(self.translate(name),ids,))
|
(tuple(ids),))
|
||||||
res = dict(cr.fetchall())
|
res = dict(cr.fetchall())
|
||||||
|
|
||||||
if name == 'partner_id':
|
if name == 'partner_id':
|
||||||
|
@ -245,61 +234,6 @@ class payment_line(osv.osv):
|
||||||
res.setdefault(id, (False, ""))
|
res.setdefault(id, (False, ""))
|
||||||
return res
|
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):
|
def _amount(self, cursor, user, ids, name, args, context=None):
|
||||||
if not ids:
|
if not ids:
|
||||||
return {}
|
return {}
|
||||||
|
@ -335,15 +269,6 @@ class payment_line(osv.osv):
|
||||||
else:
|
else:
|
||||||
return self.pool.get('res.currency').search(cr, uid, [('rate','=',1.0)])[0]
|
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):
|
def _get_ml_inv_ref(self, cr, uid, ids, *a):
|
||||||
res={}
|
res={}
|
||||||
for id in self.browse(cr, uid, ids):
|
for id in self.browse(cr, uid, ids):
|
||||||
|
@ -378,11 +303,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.'),
|
'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),
|
'amount_currency': fields.float('Amount in Partner Currency', digits=(16,2),
|
||||||
required=True, help='Payment amount in the partner currency'),
|
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),
|
'currency': fields.many2one('res.currency','Partner Currency',required=True),
|
||||||
'company_currency': fields.many2one('res.currency','Company Currency',readonly=True),
|
'company_currency': fields.many2one('res.currency','Company Currency',readonly=True),
|
||||||
'bank_id': fields.many2one('res.partner.bank', 'Destination Bank account'),
|
'bank_id': fields.many2one('res.partner.bank', 'Destination Bank account'),
|
||||||
|
@ -392,21 +312,12 @@ class payment_line(osv.osv):
|
||||||
'amount': fields.function(_amount, string='Amount in Company Currency',
|
'amount': fields.function(_amount, string='Amount in Company Currency',
|
||||||
method=True, type='float',
|
method=True, type='float',
|
||||||
help='Payment amount in the company currency'),
|
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",
|
'ml_date_created': fields.function(_get_ml_created_date, string="Effective Date",
|
||||||
method=True, type='date',help="Invoice 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_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.'),
|
'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_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.'),
|
'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"),
|
'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),
|
'create_date': fields.datetime('Created' ,readonly=True),
|
||||||
'state': fields.selection([('normal','Free'), ('structured','Structured')], 'Communication Type', required=True)
|
'state': fields.selection([('normal','Free'), ('structured','Structured')], 'Communication Type', required=True)
|
||||||
|
|
|
@ -440,7 +440,7 @@ class account_voucher(osv.osv):
|
||||||
def action_number(self, cr, uid, ids, *args):
|
def action_number(self, cr, uid, ids, *args):
|
||||||
cr.execute('SELECT id, type, number, move_id, reference ' \
|
cr.execute('SELECT id, type, number, move_id, reference ' \
|
||||||
'FROM account_voucher ' \
|
'FROM account_voucher ' \
|
||||||
'WHERE id =ANY(%s)',(ids,))
|
'WHERE id IN %s',(tuple(ids),))
|
||||||
for (id, invtype, number, move_id, reference) in cr.fetchall():
|
for (id, invtype, number, move_id, reference) in cr.fetchall():
|
||||||
if not number:
|
if not number:
|
||||||
number = self.pool.get('ir.sequence').get(cr, uid, invtype)
|
number = self.pool.get('ir.sequence').get(cr, uid, invtype)
|
||||||
|
|
|
@ -33,10 +33,10 @@ class account_analytic_account(osv.osv):
|
||||||
_name = 'account.analytic.account'
|
_name = 'account.analytic.account'
|
||||||
_description = '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
|
# Handle multi-currency on each level of analytic account
|
||||||
# This is a refactoring of _balance_calc computation
|
# 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())
|
currency= dict(cr.fetchall())
|
||||||
res_currency= self.pool.get('res.currency')
|
res_currency= self.pool.get('res.currency')
|
||||||
for id in ids:
|
for id in ids:
|
||||||
|
@ -61,13 +61,11 @@ class account_analytic_account(osv.osv):
|
||||||
|
|
||||||
def _credit_calc(self, cr, uid, ids, name, arg, context={}):
|
def _credit_calc(self, cr, uid, ids, name, arg, context={}):
|
||||||
res = {}
|
res = {}
|
||||||
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
|
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
|
||||||
acc_set = ",".join(map(str, ids2))
|
|
||||||
|
|
||||||
for i in ids:
|
for i in ids:
|
||||||
res.setdefault(i,0.0)
|
res.setdefault(i,0.0)
|
||||||
|
|
||||||
if not ids2:
|
if not parent_ids:
|
||||||
return res
|
return res
|
||||||
|
|
||||||
where_date = ''
|
where_date = ''
|
||||||
|
@ -75,19 +73,17 @@ class account_analytic_account(osv.osv):
|
||||||
where_date += " AND l.date >= '" + context['from_date'] + "'"
|
where_date += " AND l.date >= '" + context['from_date'] + "'"
|
||||||
if context.get('to_date',False):
|
if context.get('to_date',False):
|
||||||
where_date += " AND l.date <= '" + context['to_date'] + "'"
|
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())
|
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={}):
|
def _debit_calc(self, cr, uid, ids, name, arg, context={}):
|
||||||
res = {}
|
res = {}
|
||||||
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
|
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
|
||||||
acc_set = ",".join(map(str, ids2))
|
|
||||||
|
|
||||||
for i in ids:
|
for i in ids:
|
||||||
res.setdefault(i,0.0)
|
res.setdefault(i,0.0)
|
||||||
|
|
||||||
if not ids2:
|
if not parent_ids:
|
||||||
return res
|
return res
|
||||||
|
|
||||||
where_date = ''
|
where_date = ''
|
||||||
|
@ -95,19 +91,17 @@ class account_analytic_account(osv.osv):
|
||||||
where_date += " AND l.date >= '" + context['from_date'] + "'"
|
where_date += " AND l.date >= '" + context['from_date'] + "'"
|
||||||
if context.get('to_date',False):
|
if context.get('to_date',False):
|
||||||
where_date += " AND l.date <= '" + context['to_date'] + "'"
|
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())
|
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={}):
|
def _balance_calc(self, cr, uid, ids, name, arg, context={}):
|
||||||
res = {}
|
res = {}
|
||||||
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
|
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
|
||||||
acc_set = ",".join(map(str, ids2))
|
|
||||||
|
|
||||||
for i in ids:
|
for i in ids:
|
||||||
res.setdefault(i,0.0)
|
res.setdefault(i,0.0)
|
||||||
|
|
||||||
if not ids2:
|
if not parent_ids:
|
||||||
return res
|
return res
|
||||||
|
|
||||||
where_date = ''
|
where_date = ''
|
||||||
|
@ -115,23 +109,22 @@ class account_analytic_account(osv.osv):
|
||||||
where_date += " AND l.date >= '" + context['from_date'] + "'"
|
where_date += " AND l.date >= '" + context['from_date'] + "'"
|
||||||
if context.get('to_date',False):
|
if context.get('to_date',False):
|
||||||
where_date += " AND l.date <= '" + context['to_date'] + "'"
|
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():
|
for account_id, sum in cr.fetchall():
|
||||||
res[account_id] = sum
|
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={}):
|
def _quantity_calc(self, cr, uid, ids, name, arg, context={}):
|
||||||
#XXX must convert into one uom
|
#XXX must convert into one uom
|
||||||
res = {}
|
res = {}
|
||||||
ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
|
parent_ids = tuple(self.search(cr, uid, [('parent_id', 'child_of', ids)]))
|
||||||
acc_set = ",".join(map(str, ids2))
|
|
||||||
|
|
||||||
for i in ids:
|
for i in ids:
|
||||||
res.setdefault(i,0.0)
|
res.setdefault(i,0.0)
|
||||||
|
|
||||||
if not ids2:
|
if not parent_ids:
|
||||||
return res
|
return res
|
||||||
|
|
||||||
where_date = ''
|
where_date = ''
|
||||||
|
@ -143,13 +136,13 @@ class account_analytic_account(osv.osv):
|
||||||
cr.execute('SELECT a.id, COALESCE(SUM(l.unit_amount), 0) \
|
cr.execute('SELECT a.id, COALESCE(SUM(l.unit_amount), 0) \
|
||||||
FROM account_analytic_account a \
|
FROM account_analytic_account a \
|
||||||
LEFT JOIN account_analytic_line l ON (a.id = l.account_id ' + where_date + ') \
|
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():
|
for account_id, sum in cr.fetchall():
|
||||||
res[account_id] = sum
|
res[account_id] = sum
|
||||||
|
|
||||||
for id in ids:
|
for id in ids:
|
||||||
if id not in ids2:
|
if id not in parent_ids:
|
||||||
continue
|
continue
|
||||||
for child in self.search(cr, uid, [('parent_id', 'child_of', [id])]):
|
for child in self.search(cr, uid, [('parent_id', 'child_of', [id])]):
|
||||||
if child != id:
|
if child != id:
|
||||||
|
|
|
@ -98,9 +98,15 @@ class auction_dates(osv.osv):
|
||||||
#TODO: convert this query to tiny API
|
#TODO: convert this query to tiny API
|
||||||
lots_obj = self.pool.get('auction.lots')
|
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 =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'))
|
||||||
nbr = cr.fetchone()[0]
|
nbr = cr.fetchone()[0]
|
||||||
ach_uids = {}
|
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)
|
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 =ANY(%s) and obj_price>0',(ids,))
|
||||||
ids2 = [x[0] for x in cr.fetchall()]
|
ids2 = [x[0] for x in cr.fetchall()]
|
||||||
|
@ -115,7 +121,9 @@ auction_dates()
|
||||||
# Deposits
|
# Deposits
|
||||||
#----------------------------------------------------------
|
#----------------------------------------------------------
|
||||||
def _inv_uniq(cr, ids):
|
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():
|
for datas in cr.fetchall():
|
||||||
cr.execute('select count(*) from auction_deposit where name=%s', (datas[0],))
|
cr.execute('select count(*) from auction_deposit where name=%s', (datas[0],))
|
||||||
if cr.fetchone()[0]>1:
|
if cr.fetchone()[0]>1:
|
||||||
|
@ -231,7 +239,9 @@ def _type_get(self, cr, uid,ids):
|
||||||
# Lots
|
# Lots
|
||||||
#----------------------------------------------------------
|
#----------------------------------------------------------
|
||||||
def _inv_constraint(cr, ids):
|
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():
|
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]))
|
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:
|
if cr.fetchone()[0]>1:
|
||||||
|
|
|
@ -28,19 +28,8 @@ class auction_objects(report_sxw.rml_parse):
|
||||||
super(auction_objects, self).__init__(cr, uid, name, context=context)
|
super(auction_objects, self).__init__(cr, uid, name, context=context)
|
||||||
self.localcontext.update({
|
self.localcontext.update({
|
||||||
'time': time,
|
'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)
|
report_sxw.report_sxw('report.auction.objects', 'auction.lots', 'addons/auction/report/auction_objects.rml', parser=auction_objects)
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,10 @@ class auction_total_rml(report_sxw.rml_parse):
|
||||||
for lot_id in objects:
|
for lot_id in objects:
|
||||||
auc_lot_ids.append(lot_id.id)
|
auc_lot_ids.append(lot_id.id)
|
||||||
self.total_obj=auc_lot_ids
|
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()
|
auc_date_ids = self.cr.fetchall()
|
||||||
auct_dat=[]
|
auct_dat=[]
|
||||||
for ad_id in auc_date_ids:
|
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):
|
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()
|
res = self.cr.fetchone()
|
||||||
return res[0]
|
return res[0]
|
||||||
def sold_item(self, object_id):
|
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()
|
res = self.cr.fetchone()
|
||||||
return str(res[0])
|
return str(res[0])
|
||||||
|
|
||||||
|
|
||||||
def sum_buyer(self, auction_id):
|
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()
|
res = self.cr.fetchone()
|
||||||
return str(res[0])
|
return str(res[0])
|
||||||
|
|
||||||
|
|
||||||
def sum_seller(self, auction_id):
|
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()
|
res = self.cr.fetchone()
|
||||||
return res[0]
|
return res[0]
|
||||||
|
|
||||||
def sum_adj(self, auction_id):
|
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()
|
res = self.cr.fetchone()
|
||||||
return str(res[0])
|
return str(res[0])
|
||||||
|
|
||||||
def count_take(self, auction_id):
|
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()
|
res = self.cr.fetchone()
|
||||||
return str(res[0])
|
return str(res[0])
|
||||||
|
|
||||||
def chek_paid(self, auction_id):
|
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()
|
res = self.cr.fetchone()
|
||||||
return str(res[0])
|
return str(res[0])
|
||||||
def check_paid_seller(self,auction_id):
|
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()
|
res = self.cr.fetchone()
|
||||||
return str(res[0]) or 0.0
|
return str(res[0]) or 0.0
|
||||||
|
|
||||||
def sum_credit(self,auction_id):
|
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()
|
res = self.cr.fetchone()
|
||||||
return str(res[0])
|
return str(res[0])
|
||||||
|
|
||||||
def sum_debit_buyer(self,auction_id):
|
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()
|
res = self.cr.fetchone()
|
||||||
return str(res[0] or 0)
|
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):
|
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()
|
res = self.cr.fetchone()
|
||||||
return str(res[0] or 0)
|
return str(res[0] or 0)
|
||||||
|
|
||||||
def sum_minadj(self, auction_id):
|
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()
|
res = self.cr.fetchone()
|
||||||
return str(res[0]) or 0
|
return str(res[0]) or 0
|
||||||
|
|
||||||
def sum_maxadj(self, auction_id):
|
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()
|
res = self.cr.fetchone()
|
||||||
return str(res[0]) or 0
|
return str(res[0]) or 0
|
||||||
|
|
||||||
def sum_buyer_paid(self, auction_id):
|
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()
|
res = self.cr.fetchone()
|
||||||
return str(res[0])
|
return str(res[0])
|
||||||
|
|
||||||
def count_comm(self, auction_id):
|
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()
|
res = self.cr.fetchone()
|
||||||
return str(res[0])
|
return str(res[0])
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,8 @@ class buyer_list(report_sxw.rml_parse):
|
||||||
for lot_id in objects:
|
for lot_id in objects:
|
||||||
auc_lot_ids.append(lot_id.id)
|
auc_lot_ids.append(lot_id.id)
|
||||||
self.auc_lot_ids=auc_lot_ids
|
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()
|
auc_date_ids = self.cr.fetchall()
|
||||||
auct_dat=[]
|
auct_dat=[]
|
||||||
for ad_id in auc_date_ids:
|
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'])]))
|
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, '\
|
||||||
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],))
|
'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()
|
res = self.cr.dictfetchall()
|
||||||
for r in res:
|
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_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_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']
|
self.sum_buyer_price_val = self.sum_buyer_price_val + r['to_pay']
|
||||||
|
|
|
@ -126,7 +126,7 @@ class auction_catalog(report_rml):
|
||||||
for test in ab:
|
for test in ab:
|
||||||
if test.has_key('auction_id'):
|
if test.has_key('auction_id'):
|
||||||
auction_ids.append(test['auction_id'][0])
|
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()
|
res = cr.dictfetchall()
|
||||||
for cat in res:
|
for cat in res:
|
||||||
product =doc.createElement('product')
|
product =doc.createElement('product')
|
||||||
|
|
|
@ -466,7 +466,7 @@ class crm_case_section(osv.osv):
|
||||||
level = 100
|
level = 100
|
||||||
|
|
||||||
while len(ids):
|
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()))
|
ids = filter(None, map(lambda x: x[0], cr.fetchall()))
|
||||||
if not level:
|
if not level:
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -69,7 +69,7 @@ class report_custom(report_int):
|
||||||
|
|
||||||
cr.execute('select probability, planned_revenue, planned_cost, user_id,\
|
cr.execute('select probability, planned_revenue, planned_cost, user_id,\
|
||||||
res_users.name as name from crm_case left join res_users on \
|
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()
|
res = cr.dictfetchall()
|
||||||
for row in res:
|
for row in res:
|
||||||
|
|
|
@ -52,7 +52,6 @@ class email_template_mailbox(osv.osv):
|
||||||
for attid in values['attachments_ids']:
|
for attid in values['attachments_ids']:
|
||||||
attachment = self.pool.get('ir.attachment').browse(cr, uid, attid, context)#,['datas_fname','datas'])
|
attachment = self.pool.get('ir.attachment').browse(cr, uid, attid, context)#,['datas_fname','datas'])
|
||||||
payload[attachment.datas_fname] = attachment.datas
|
payload[attachment.datas_fname] = attachment.datas
|
||||||
print "233333333333333"
|
|
||||||
result = account_obj.send_mail(cr, uid,
|
result = account_obj.send_mail(cr, uid,
|
||||||
[values['account_id'][0]],
|
[values['account_id'][0]],
|
||||||
{'To':values.get('email_to', u'') or u'', 'CC':values.get('email_cc', u'') or u'', 'BCC':values.get('email_bcc', u'') or u''},
|
{'To':values.get('email_to', u'') or u'', 'CC':values.get('email_cc', u'') or u'', 'BCC':values.get('email_bcc', u'') or u''},
|
||||||
|
|
|
@ -168,7 +168,6 @@ class email_template_send_wizard(osv.osv_memory):
|
||||||
mail_ids = []
|
mail_ids = []
|
||||||
template = self._get_template(cr, uid, context)
|
template = self._get_template(cr, uid, context)
|
||||||
for id in context['src_rec_ids']:
|
for id in context['src_rec_ids']:
|
||||||
print "@22222222222222222222222",ids
|
|
||||||
screen_vals = self.read(cr, uid, ids[0], [],context)
|
screen_vals = self.read(cr, uid, ids[0], [],context)
|
||||||
account = self.pool.get('email_template.account').read(cr, uid, screen_vals['from'], context=context)
|
account = self.pool.get('email_template.account').read(cr, uid, screen_vals['from'], context=context)
|
||||||
vals = {
|
vals = {
|
||||||
|
|
|
@ -37,7 +37,7 @@ class hr_employee_category(osv.osv):
|
||||||
def _check_recursion(self, cr, uid, ids):
|
def _check_recursion(self, cr, uid, ids):
|
||||||
level = 100
|
level = 100
|
||||||
while len(ids):
|
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()))
|
ids = filter(None, map(lambda x:x[0], cr.fetchall()))
|
||||||
if not level:
|
if not level:
|
||||||
return False
|
return False
|
||||||
|
@ -130,7 +130,7 @@ class hr_employee(osv.osv):
|
||||||
def _check_recursion(self, cr, uid, ids):
|
def _check_recursion(self, cr, uid, ids):
|
||||||
level = 100
|
level = 100
|
||||||
while len(ids):
|
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()))
|
ids = filter(None, map(lambda x:x[0], cr.fetchall()))
|
||||||
if not level:
|
if not level:
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -61,7 +61,7 @@ class hr_department(osv.osv):
|
||||||
def _check_recursion(self, cr, uid, ids):
|
def _check_recursion(self, cr, uid, ids):
|
||||||
level = 100
|
level = 100
|
||||||
while len(ids):
|
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()))
|
ids = filter(None, map(lambda x:x[0], cr.fetchall()))
|
||||||
if not level:
|
if not level:
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -104,7 +104,7 @@ class hr_employee(osv.osv):
|
||||||
LEFT JOIN hr_attendance \
|
LEFT JOIN hr_attendance \
|
||||||
ON (hr_attendance.employee_id = foo.employee_id \
|
ON (hr_attendance.employee_id = foo.employee_id \
|
||||||
AND hr_attendance.name = foo.name) \
|
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():
|
for res in cr.fetchall():
|
||||||
result[res[1]] = res[0] == 'sign_in' and 'present' or 'absent'
|
result[res[1]] = res[0] == 'sign_in' and 'present' or 'absent'
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -44,7 +44,7 @@ class hr_attendance_error(osv.osv_memory):
|
||||||
data_error = self.read(cr, uid, ids)[0]
|
data_error = self.read(cr, uid, ids)[0]
|
||||||
date_from = data_error['init_date']
|
date_from = data_error['init_date']
|
||||||
date_to = data_error['end_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()]
|
attendance_ids = [x[0] for x in cr.fetchall()]
|
||||||
if not attendance_ids:
|
if not attendance_ids:
|
||||||
raise osv.except_osv(_('No Data Available'), _('No records found for your selection!'))
|
raise osv.except_osv(_('No Data Available'), _('No records found for your selection!'))
|
||||||
|
|
|
@ -38,7 +38,7 @@ class hr_expense_expense(osv.osv):
|
||||||
return super(hr_expense_expense, self).copy(cr, uid, id, default, context)
|
return super(hr_expense_expense, self).copy(cr, uid, id, default, context)
|
||||||
|
|
||||||
def _amount(self, cr, uid, ids, field_name, arg, 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())
|
res = dict(cr.fetchall())
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ class hr_expense_line(osv.osv):
|
||||||
def _amount(self, cr, uid, ids, field_name, arg, context):
|
def _amount(self, cr, uid, ids, field_name, arg, context):
|
||||||
if not len(ids):
|
if not len(ids):
|
||||||
return {}
|
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())
|
res = dict(cr.fetchall())
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ class hr_timesheet_invoice_create(osv.osv_memory):
|
||||||
if obj_acc.invoice_id and obj_acc.invoice_id.state !='cancel':
|
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,))
|
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()
|
account_ids = cr.fetchall()
|
||||||
return [x[0] for x in account_ids]
|
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) " \
|
cr.execute("SELECT product_id, to_invoice, sum(unit_amount) " \
|
||||||
"FROM account_analytic_line as line " \
|
"FROM account_analytic_line as line " \
|
||||||
"WHERE account_id = %s " \
|
"WHERE account_id = %s " \
|
||||||
"AND id =ANY(%s) AND to_invoice IS NOT NULL " \
|
"AND id IN %s AND to_invoice IS NOT NULL " \
|
||||||
"GROUP BY product_id,to_invoice", (account.id,context['active_ids'],))
|
"GROUP BY product_id,to_invoice", (account.id,tuple(context['active_ids']),))
|
||||||
|
|
||||||
for product_id,factor_id,qty in cr.fetchall():
|
for product_id,factor_id,qty in cr.fetchall():
|
||||||
product = pool.get('product.product').browse(cr, uid, product_id, context2)
|
product = pool.get('product.product').browse(cr, uid, product_id, context2)
|
||||||
|
@ -159,7 +159,7 @@ class hr_timesheet_invoice_create(osv.osv_memory):
|
||||||
#
|
#
|
||||||
# Compute for lines
|
# Compute for lines
|
||||||
#
|
#
|
||||||
cr.execute("SELECT * FROM account_analytic_line WHERE account_id = %s and id = ANY (%s) AND product_id=%s and to_invoice=%s", (account.id, data['ids'], product_id, factor_id))
|
cr.execute("SELECT * FROM account_analytic_line WHERE account_id = %s and id in %s AND product_id=%s and to_invoice=%s", (account.id, tuple(data['ids']), product_id, factor_id))
|
||||||
|
|
||||||
line_ids = cr.dictfetchall()
|
line_ids = cr.dictfetchall()
|
||||||
note = []
|
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))
|
curr_line['note'] = "\n".join(map(lambda x: unicode(x) or '',note))
|
||||||
pool.get('account.invoice.line').create(cr, uid, curr_line)
|
pool.get('account.invoice.line').create(cr, uid, curr_line)
|
||||||
cr.execute("update account_analytic_line set invoice_id=%s WHERE account_id = %s and id =ANY(%s)" ,(last_invoice, account.id,data['ids']))
|
cr.execute("update account_analytic_line set invoice_id=%s WHERE account_id = %s and id in %s" ,(last_invoice, account.id,tuple(data['ids'])))
|
||||||
|
|
||||||
self.pool.get('account.invoice').button_reset_taxes(cr, uid, [last_invoice], context)
|
self.pool.get('account.invoice').button_reset_taxes(cr, uid, [last_invoice], context)
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ class hr_timesheet_sheet(osv.osv):
|
||||||
LEFT JOIN hr_timesheet_sheet_sheet_day AS day \
|
LEFT JOIN hr_timesheet_sheet_sheet_day AS day \
|
||||||
ON (sheet.id = day.sheet_id \
|
ON (sheet.id = day.sheet_id \
|
||||||
AND day.name = sheet.date_current) \
|
AND day.name = sheet.date_current) \
|
||||||
WHERE sheet.id =ANY(%s)',(ids,))
|
WHERE sheet.id IN %s',(tuple(ids),))
|
||||||
for record in cr.fetchall():
|
for record in cr.fetchall():
|
||||||
res[record[0]] = {}
|
res[record[0]] = {}
|
||||||
res[record[0]]['total_attendance_day'] = record[1]
|
res[record[0]]['total_attendance_day'] = record[1]
|
||||||
|
@ -118,7 +118,7 @@ class hr_timesheet_sheet(osv.osv):
|
||||||
FROM hr_timesheet_sheet_sheet s \
|
FROM hr_timesheet_sheet_sheet s \
|
||||||
LEFT JOIN hr_timesheet_sheet_sheet_day d \
|
LEFT JOIN hr_timesheet_sheet_sheet_day d \
|
||||||
ON (s.id = d.sheet_id) \
|
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():
|
for record in cr.fetchall():
|
||||||
res[record[0]] = {}
|
res[record[0]] = {}
|
||||||
res[record[0]]['total_attendance'] = record[1]
|
res[record[0]]['total_attendance'] = record[1]
|
||||||
|
@ -368,7 +368,7 @@ class hr_timesheet_line(osv.osv):
|
||||||
ON (s.date_to >= al.date \
|
ON (s.date_to >= al.date \
|
||||||
AND s.date_from <= al.date \
|
AND s.date_from <= al.date \
|
||||||
AND s.user_id = al.user_id) \
|
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())
|
res = dict(cursor.fetchall())
|
||||||
sheet_names = {}
|
sheet_names = {}
|
||||||
for sheet_id, name in sheet_obj.name_get(cursor, user, res.values(),
|
for sheet_id, name in sheet_obj.name_get(cursor, user, res.values(),
|
||||||
|
@ -487,7 +487,7 @@ class hr_attendance(osv.osv):
|
||||||
ON (s.date_to >= date_trunc('day',a.name) \
|
ON (s.date_to >= date_trunc('day',a.name) \
|
||||||
AND s.date_from <= a.name \
|
AND s.date_from <= a.name \
|
||||||
AND s.user_id = r.user_id) \
|
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())
|
res = dict(cursor.fetchall())
|
||||||
sheet_names = {}
|
sheet_names = {}
|
||||||
for sheet_id, name in sheet_obj.name_get(cursor, user, res.values(),
|
for sheet_id, name in sheet_obj.name_get(cursor, user, res.values(),
|
||||||
|
|
|
@ -66,11 +66,11 @@ class idea_idea(osv.osv):
|
||||||
|
|
||||||
sql = """SELECT i.id, avg(v.score::integer)
|
sql = """SELECT i.id, avg(v.score::integer)
|
||||||
FROM idea_idea i LEFT OUTER JOIN idea_vote v ON i.id = v.idea_id
|
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
|
GROUP BY i.id
|
||||||
"""
|
"""
|
||||||
|
|
||||||
cr.execute(sql, (ids,))
|
cr.execute(sql, (tuple(ids),))
|
||||||
return dict(cr.fetchall())
|
return dict(cr.fetchall())
|
||||||
|
|
||||||
def _vote_count(self, cr, uid, ids, name, arg, context=None):
|
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)
|
sql = """SELECT i.id, COUNT(1)
|
||||||
FROM idea_idea i LEFT OUTER JOIN idea_vote v ON i.id = v.idea_id
|
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
|
GROUP BY i.id
|
||||||
"""
|
"""
|
||||||
|
|
||||||
cr.execute(sql, (ids,))
|
cr.execute(sql, (tuple(ids),))
|
||||||
return dict(cr.fetchall())
|
return dict(cr.fetchall())
|
||||||
|
|
||||||
def _comment_count(self, cr, uid, ids, name, arg, context=None):
|
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)
|
sql = """SELECT i.id, COUNT(1)
|
||||||
FROM idea_idea i LEFT OUTER JOIN idea_comment c ON i.id = c.idea_id
|
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
|
GROUP BY i.id
|
||||||
"""
|
"""
|
||||||
|
|
||||||
cr.execute(sql, (ids,))
|
cr.execute(sql, (tuple(ids),))
|
||||||
return dict(cr.fetchall())
|
return dict(cr.fetchall())
|
||||||
|
|
||||||
def _vote_read(self, cr, uid, ids, name, arg, context = None):
|
def _vote_read(self, cr, uid, ids, name, arg, context = None):
|
||||||
|
|
|
@ -81,7 +81,7 @@ class partner_vat(osv.osv_memory):
|
||||||
break
|
break
|
||||||
if not go_ahead:
|
if not go_ahead:
|
||||||
continue
|
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()
|
line_info = cursor.fetchall()
|
||||||
if not line_info:
|
if not line_info:
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -71,7 +71,7 @@ def _reconstruct_invoice_ref(cursor, user, reference, context):
|
||||||
cursor.execute('SELECT l.id ' \
|
cursor.execute('SELECT l.id ' \
|
||||||
'FROM account_move_line l, account_invoice i ' \
|
'FROM account_move_line l, account_invoice i ' \
|
||||||
'WHERE l.move_id = i.move_id AND l.reconcile_id is NULL ' \
|
'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 = []
|
inv_line = []
|
||||||
for id_line in cursor.fetchall():
|
for id_line in cursor.fetchall():
|
||||||
inv_line.append(id_line[0])
|
inv_line.append(id_line[0])
|
||||||
|
|
|
@ -40,12 +40,12 @@ class lunch_cashbox_clean(osv.osv_memory):
|
||||||
cashmove_ref = self.pool.get('lunch.cashmove')
|
cashmove_ref = self.pool.get('lunch.cashmove')
|
||||||
|
|
||||||
cr.execute("select user_cashmove, box,sum(amount) from lunch_cashmove \
|
cr.execute("select user_cashmove, box,sum(amount) from lunch_cashmove \
|
||||||
where active = 't' and box in (%s) group by user_cashmove, \
|
where active = 't' and box IN (%s) group by user_cashmove, \
|
||||||
box" % ','.join(map(str, data)))
|
box" , (tuple(data),))
|
||||||
res = cr.fetchall()
|
res = cr.fetchall()
|
||||||
|
|
||||||
cr.execute("update lunch_cashmove set active = 'f' where active= 't' \
|
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:
|
for (user_id, box_id, amount) in res:
|
||||||
cashmove_ref.create(cr, uid, {'name': 'Summary for user' + str(user_id),
|
cashmove_ref.create(cr, uid, {'name': 'Summary for user' + str(user_id),
|
||||||
|
|
|
@ -150,7 +150,7 @@ class membership_line(osv.osv):
|
||||||
)
|
)
|
||||||
JOIN account_invoice ai ON (
|
JOIN account_invoice ai ON (
|
||||||
ai.id = ail.invoice_id)
|
ai.id = ail.invoice_id)
|
||||||
WHERE ml.id =ANY(%s)''',(ids,))
|
WHERE ml.id IN %s''',(tuple(ids),))
|
||||||
res = cr.fetchall()
|
res = cr.fetchall()
|
||||||
for r in res:
|
for r in res:
|
||||||
if r[0] and r[0] < 0:
|
if r[0] and r[0] < 0:
|
||||||
|
@ -412,7 +412,7 @@ class Partner(osv.osv):
|
||||||
def _check_recursion(self, cr, uid, ids):
|
def _check_recursion(self, cr, uid, ids):
|
||||||
level = 100
|
level = 100
|
||||||
while len(ids):
|
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()))
|
ids = filter(None, map(lambda x:x[0], cr.fetchall()))
|
||||||
if not level:
|
if not level:
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -43,7 +43,7 @@ class membership_invoice(osv.osv_memory):
|
||||||
cr.execute('''
|
cr.execute('''
|
||||||
SELECT partner_id, id, type
|
SELECT partner_id, id, type
|
||||||
FROM res_partner_address
|
FROM res_partner_address
|
||||||
WHERE partner_id =ANY(%s)''',(partner_ids,))
|
WHERE partner_id IN %s''',(tuple(partner_ids),))
|
||||||
fetchal = cr.fetchall()
|
fetchal = cr.fetchall()
|
||||||
if not fetchal:
|
if not fetchal:
|
||||||
raise osv.except_osv(_('Error !'), _('No Address defined for this partner'))
|
raise osv.except_osv(_('Error !'), _('No Address defined for this partner'))
|
||||||
|
|
|
@ -223,7 +223,7 @@ class mrp_bom(osv.osv):
|
||||||
def _check_recursion(self, cr, uid, ids):
|
def _check_recursion(self, cr, uid, ids):
|
||||||
level = 100
|
level = 100
|
||||||
while len(ids):
|
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()))
|
ids = filter(None, map(lambda x:x[0], cr.fetchall()))
|
||||||
if not level:
|
if not level:
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -104,7 +104,7 @@ class report_custom(report_int):
|
||||||
"WHERE mrp_production_workcenter_line.production_id=mrp_production.id "\
|
"WHERE mrp_production_workcenter_line.production_id=mrp_production.id "\
|
||||||
"AND mrp_production_workcenter_line.workcenter_id=mrp_workcenter.id "\
|
"AND mrp_production_workcenter_line.workcenter_id=mrp_workcenter.id "\
|
||||||
"AND mrp_production.state NOT IN ('cancel','done') "\
|
"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()
|
res = cr.dictfetchone()
|
||||||
if not res['stop']:
|
if not res['stop']:
|
||||||
res['stop'] = time.strftime('%Y-%m-%d %H:%M:%S')
|
res['stop'] = time.strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
@ -135,8 +135,8 @@ class report_custom(report_int):
|
||||||
# select workcenters
|
# select workcenters
|
||||||
cr.execute(
|
cr.execute(
|
||||||
"SELECT mw.id, rs.name FROM mrp_workcenter mw, resource_resource rs " \
|
"SELECT mw.id, rs.name FROM mrp_workcenter mw, resource_resource rs " \
|
||||||
"WHERE mw.id=ANY(%s) and mw.resource_id=rs.id " \
|
"WHERE mw.id IN %s and mw.resource_id=rs.id " \
|
||||||
"ORDER BY mw.id" ,(ids,))
|
"ORDER BY mw.id" ,(tuple(ids),))
|
||||||
workcenters = cr.dictfetchall()
|
workcenters = cr.dictfetchall()
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
|
|
|
@ -96,7 +96,7 @@ class pos_order(osv.osv):
|
||||||
) AS amount
|
) AS amount
|
||||||
FROM pos_order p
|
FROM pos_order p
|
||||||
LEFT OUTER JOIN pos_order_line l ON (p.id=l.order_id)
|
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())
|
res = dict(cr.fetchall())
|
||||||
for rec in self.browse(cr, uid, ids, context):
|
for rec in self.browse(cr, uid, ids, context):
|
||||||
if rec.partner_id \
|
if rec.partner_id \
|
||||||
|
|
|
@ -37,12 +37,11 @@ class pos_sales_user_today(report_sxw.rml_parse):
|
||||||
def _get_data(self,form):
|
def _get_data(self,form):
|
||||||
data={}
|
data={}
|
||||||
ids = form['user_id']
|
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 " \
|
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 " \
|
"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 " \
|
"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()
|
data = self.cr.dictfetchall()
|
||||||
return data
|
return data
|
||||||
|
|
|
@ -219,7 +219,7 @@ class product_category(osv.osv):
|
||||||
def _check_recursion(self, cr, uid, ids):
|
def _check_recursion(self, cr, uid, ids):
|
||||||
level = 100
|
level = 100
|
||||||
while len(ids):
|
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()))
|
ids = filter(None, map(lambda x:x[0], cr.fetchall()))
|
||||||
if not level:
|
if not level:
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -92,10 +92,10 @@ class project(osv.osv):
|
||||||
FROM
|
FROM
|
||||||
project_task
|
project_task
|
||||||
WHERE
|
WHERE
|
||||||
project_id =ANY(%s) AND
|
project_id IN %s AND
|
||||||
state<>'cancelled'
|
state<>'cancelled'
|
||||||
GROUP BY
|
GROUP BY
|
||||||
project_id''',(ids2,))
|
project_id''',(tuple(ids2),))
|
||||||
progress = dict(map(lambda x: (x[0], (x[1], x[2], x[3])), cr.fetchall()))
|
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):
|
for project in self.browse(cr, uid, ids, context=context):
|
||||||
s = [0.0, 0.0, 0.0]
|
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)
|
res = super(project, self).copy(cr, uid, id, default, context)
|
||||||
ids = self.search(cr, uid, [('parent_id','child_of', [res])])
|
ids = self.search(cr, uid, [('parent_id','child_of', [res])])
|
||||||
if ids:
|
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
|
return res
|
||||||
|
|
||||||
def duplicate_template(self, cr, uid, ids, context={}):
|
def duplicate_template(self, cr, uid, ids, context={}):
|
||||||
|
@ -272,7 +272,7 @@ class task(osv.osv):
|
||||||
# Compute: effective_hours, total_hours, progress
|
# Compute: effective_hours, total_hours, progress
|
||||||
def _hours_get(self, cr, uid, ids, field_names, args, context=None):
|
def _hours_get(self, cr, uid, ids, field_names, args, context=None):
|
||||||
res = {}
|
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())
|
hours = dict(cr.fetchall())
|
||||||
for task in self.browse(cr, uid, ids, context=context):
|
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)}
|
res[task.id] = {'effective_hours': hours.get(task.id, 0.0), 'total_hours': task.remaining_hours + hours.get(task.id, 0.0)}
|
||||||
|
|
|
@ -116,7 +116,7 @@ class purchase_order(osv.osv):
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
stock_picking p on (p.id=m.picking_id)
|
stock_picking p on (p.id=m.picking_id)
|
||||||
WHERE
|
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():
|
for oid,nbr,state in cr.fetchall():
|
||||||
if state=='cancel':
|
if state=='cancel':
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -114,7 +114,7 @@ class sale_order(osv.osv):
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
mrp_procurement mp on (mp.move_id=m.id)
|
mrp_procurement mp on (mp.move_id=m.id)
|
||||||
WHERE
|
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():
|
for oid, nbr, mp_state in cr.fetchall():
|
||||||
if mp_state == 'cancel':
|
if mp_state == 'cancel':
|
||||||
continue
|
continue
|
||||||
|
@ -322,7 +322,7 @@ class sale_order(osv.osv):
|
||||||
def action_cancel_draft(self, cr, uid, ids, *args):
|
def action_cancel_draft(self, cr, uid, ids, *args):
|
||||||
if not len(ids):
|
if not len(ids):
|
||||||
return False
|
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())
|
line_ids = map(lambda x: x[0], cr.fetchall())
|
||||||
self.write(cr, uid, ids, {'state': 'draft', 'invoice_ids': [], 'shipped': 0})
|
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, [])]})
|
self.pool.get('sale.order.line').write(cr, uid, line_ids, {'invoiced': False, 'state': 'draft', 'invoice_lines': [(6, 0, [])]})
|
||||||
|
|
|
@ -26,13 +26,13 @@ import time
|
||||||
def compute_burndown(cr, uid, tasks_id, date_start, date_stop):
|
def compute_burndown(cr, uid, tasks_id, date_start, date_stop):
|
||||||
latest = False
|
latest = False
|
||||||
if len(tasks_id):
|
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()
|
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()
|
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 += cr.fetchall()
|
||||||
tasks2.sort()
|
tasks2.sort()
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -43,9 +43,9 @@ class external_pdf(render):
|
||||||
def burndown_chart(cr, uid, tasks_id, date_start, date_stop):
|
def burndown_chart(cr, uid, tasks_id, date_start, date_stop):
|
||||||
latest = False
|
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()
|
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()
|
tasks2 = cr.fetchall()
|
||||||
current_date = date_start
|
current_date = date_start
|
||||||
total = 0
|
total = 0
|
||||||
|
@ -72,14 +72,14 @@ class report_tasks(report_int):
|
||||||
io = StringIO.StringIO()
|
io = StringIO.StringIO()
|
||||||
|
|
||||||
if 'date_start' not in datas:
|
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]
|
dt = cr.fetchone()[0]
|
||||||
if dt:
|
if dt:
|
||||||
datas['date_start'] = dt[:10]
|
datas['date_start'] = dt[:10]
|
||||||
else:
|
else:
|
||||||
datas['date_start'] = time.strftime('%Y-%m-%d')
|
datas['date_start'] = time.strftime('%Y-%m-%d')
|
||||||
if 'date_stop' not in datas:
|
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()
|
res = cr.fetchone()
|
||||||
datas['date_stop'] = (res[0] and res[0][:10]) or time.strftime('%Y-%m-%d')
|
datas['date_stop'] = (res[0] and res[0][:10]) or time.strftime('%Y-%m-%d')
|
||||||
if res[1] and datas['date_stop']<res[1]:
|
if res[1] and datas['date_stop']<res[1]:
|
||||||
|
|
|
@ -72,9 +72,9 @@ class report_stock(report_int):
|
||||||
cr.execute("select sum(r.product_qty * u.factor), r.date_planned, r.product_id "
|
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) "
|
"from stock_move r left join product_uom u on (r.product_uom=u.id) "
|
||||||
"where state in %s"
|
"where state in %s"
|
||||||
"and location_id=ANY(%s)"
|
"and location_id IN %s"
|
||||||
"and product_id=ANY(%s)"
|
"and product_id IN %s"
|
||||||
"group by date_planned,product_id",(('confirmed','assigned','waiting'),loc_ids ,product_ids,))
|
"group by date_planned,product_id",(('confirmed','assigned','waiting'),tuple(loc_ids) ,tuple(product_ids),))
|
||||||
for (qty, dt, prod_id) in cr.fetchall():
|
for (qty, dt, prod_id) in cr.fetchall():
|
||||||
if dt<=dt_from:
|
if dt<=dt_from:
|
||||||
dt= (datetime.now() + relativedelta(days=1)).strftime('%Y-%m-%d')
|
dt= (datetime.now() + relativedelta(days=1)).strftime('%Y-%m-%d')
|
||||||
|
@ -86,9 +86,9 @@ class report_stock(report_int):
|
||||||
cr.execute("select sum(r.product_qty * u.factor), r.date_planned, r.product_id "
|
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) "
|
"from stock_move r left join product_uom u on (r.product_uom=u.id) "
|
||||||
"where state in %s"
|
"where state in %s"
|
||||||
"and location_dest_id=ANY(%s)"
|
"and location_dest_id IN %s"
|
||||||
"and product_id=ANY(%s)"
|
"and product_id IN %s"
|
||||||
"group by date_planned,product_id",(('confirmed','assigned','waiting'),loc_ids ,product_ids,))
|
"group by date_planned,product_id",(('confirmed','assigned','waiting'),tuple(loc_ids) ,tuple(product_ids),))
|
||||||
|
|
||||||
for (qty, dt, prod_id) in cr.fetchall():
|
for (qty, dt, prod_id) in cr.fetchall():
|
||||||
if dt<=dt_from:
|
if dt<=dt_from:
|
||||||
|
|
|
@ -1092,7 +1092,7 @@ class stock_production_lot(osv.osv):
|
||||||
from
|
from
|
||||||
stock_report_prodlots
|
stock_report_prodlots
|
||||||
where
|
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()))
|
res.update(dict(cr.fetchall()))
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@ -1104,8 +1104,8 @@ class stock_production_lot(osv.osv):
|
||||||
from
|
from
|
||||||
stock_report_prodlots
|
stock_report_prodlots
|
||||||
where
|
where
|
||||||
location_id =ANY(%s) group by prodlot_id
|
location_id IN %s group by prodlot_id
|
||||||
having sum(name) '''+ str(args[0][1]) + str(args[0][2]),(locations,))
|
having sum(name) '''+ str(args[0][1]) + str(args[0][2]),(tuple(locations),))
|
||||||
res = cr.fetchall()
|
res = cr.fetchall()
|
||||||
ids = [('id', 'in', map(lambda x: x[0], res))]
|
ids = [('id', 'in', map(lambda x: x[0], res))]
|
||||||
return ids
|
return ids
|
||||||
|
|
|
@ -211,8 +211,8 @@ class survey_question(osv.osv):
|
||||||
return {}
|
return {}
|
||||||
val = {}
|
val = {}
|
||||||
cr.execute("select question_id, count(id) as Total_response from \
|
cr.execute("select question_id, count(id) as Total_response from \
|
||||||
survey_response_line where state='done' and question_id in (%s)\
|
survey_response_line where state='done' and question_id IN %s\
|
||||||
group by question_id" % ",".join(map(str, map(int, ids))))
|
group by question_id" ,(tuple(ids),))
|
||||||
ids1 = copy.deepcopy(ids)
|
ids1 = copy.deepcopy(ids)
|
||||||
for rec in cr.fetchall():
|
for rec in cr.fetchall():
|
||||||
ids1.remove(rec[0])
|
ids1.remove(rec[0])
|
||||||
|
|
|
@ -39,8 +39,8 @@ class wiki_make_index(osv.osv_memory):
|
||||||
|
|
||||||
for index_obj in self.browse(cr, uid, ids):
|
for index_obj in self.browse(cr, uid, ids):
|
||||||
wiki_pool = self.pool.get('wiki.wiki')
|
wiki_pool = self.pool.get('wiki.wiki')
|
||||||
cr.execute("Select id, section from wiki_wiki where id = ANY(%s) \
|
cr.execute("Select id, section from wiki_wiki where id IN %s \
|
||||||
order by section ", (data,))
|
order by section ", (tuple(data),))
|
||||||
lst0 = cr.fetchall()
|
lst0 = cr.fetchall()
|
||||||
lst = []
|
lst = []
|
||||||
s_ids = {}
|
s_ids = {}
|
||||||
|
|
Loading…
Reference in New Issue