avanzosc team mailing list archive
-
avanzosc team
-
Mailing list archive
-
Message #00520
[Merge] lp:~dani-ds/avanzosc/nayar_account_aged_partner_balance into lp:~avanzosc-security-team/avanzosc/72horas
Daniel Campos (Avanzosc) has proposed merging lp:~dani-ds/avanzosc/nayar_account_aged_partner_balance into lp:~avanzosc-security-team/avanzosc/72horas.
Requested reviews:
Avanzosc_security (avanzosc-security-team)
For more details, see:
https://code.launchpad.net/~dani-ds/avanzosc/nayar_account_aged_partner_balance/+merge/225140
Queda pendiente mirar el parser
--
https://code.launchpad.net/~dani-ds/avanzosc/nayar_account_aged_partner_balance/+merge/225140
Your team Avanzosc_security is requested to review the proposed merge of lp:~dani-ds/avanzosc/nayar_account_aged_partner_balance into lp:~avanzosc-security-team/avanzosc/72horas.
=== modified file 'nayar_account_aged_partner_balance/__init__.py'
--- nayar_account_aged_partner_balance/__init__.py 2014-06-11 10:23:47 +0000
+++ nayar_account_aged_partner_balance/__init__.py 2014-07-01 12:06:03 +0000
@@ -19,6 +19,5 @@
#
##############################################################################
-import report
-import wizard
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+from . import report
+from . import wizard
=== modified file 'nayar_account_aged_partner_balance/__openerp__.py'
--- nayar_account_aged_partner_balance/__openerp__.py 2014-06-11 10:23:47 +0000
+++ nayar_account_aged_partner_balance/__openerp__.py 2014-07-01 12:06:03 +0000
@@ -19,16 +19,13 @@
#
##############################################################################
{
- "name" : "Nayar Account Aged Balance Report",
- "version" : "1.1",
- "author" : "Nayar Systems",
+ "name": "Nayar Account Aged Balance Report",
+ "version": "1.1",
+ "author": "Nayar Systems",
"category": 'Generic Modules/Accounting',
"description": """Aged Account Balanced Report
""",
'website': 'http://www.72horas.net',
- 'init_xml': [],
- "depends" : ["account"],
+ "depends": ["account"],
'installable': True,
- 'active': False,
}
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== modified file 'nayar_account_aged_partner_balance/report/__init__.py'
--- nayar_account_aged_partner_balance/report/__init__.py 2014-06-11 10:23:47 +0000
+++ nayar_account_aged_partner_balance/report/__init__.py 2014-07-01 12:06:03 +0000
@@ -19,6 +19,4 @@
#
##############################################################################
-import account_aged_partner_balance
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
+from . import account_aged_partner_balance
=== modified file 'nayar_account_aged_partner_balance/report/account_aged_partner_balance.py'
--- nayar_account_aged_partner_balance/report/account_aged_partner_balance.py 2014-06-11 10:23:47 +0000
+++ nayar_account_aged_partner_balance/report/account_aged_partner_balance.py 2014-07-01 12:06:03 +0000
@@ -18,61 +18,68 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
-
import time
from report import report_sxw
from common_report_header import common_report_header
from operator import itemgetter
-class aged_trial_report(report_sxw.rml_parse, common_report_header):
+
+class AgedTrialReport(report_sxw.rml_parse, common_report_header):
def __init__(self, cr, uid, name, context):
- super(aged_trial_report, self).__init__(cr, uid, name, context=context)
+ super(AgedTrialReport, self).__init__(cr, uid, name, context=context)
self.total_account = []
self.localcontext.update({
'time': time,
'get_lines_with_out_partner': self._get_lines_with_out_partner,
'get_lines': self._get_lines,
'get_lines_from_elevator': self._get_lines_from_elevator,
- 'get_lines_from_elevator_totals': self._get_lines_from_elevator_totals,
+ 'get_lines_from_elevator_totals':
+ self._get_lines_from_elevator_totals,
'get_total': self._get_total,
'get_direction': self._get_direction,
'get_for_period': self._get_for_period,
'get_company': self._get_company,
'get_currency': self._get_currency,
- 'get_partners':self._get_partners,
+ 'get_partners': self._get_partners,
'get_account': self._get_account,
'get_fiscalyear': self._get_fiscalyear,
'get_target_move': self._get_target_move,
})
def set_context(self, objects, data, ids, report_type=None):
- obj_move = self.pool.get('account.move.line')
+ obj_move = self.pool['account.move.line']
+ user_obj = self.pool['res.users']
ctx = data['form'].get('used_context', {})
ctx.update({'fiscalyear': False, 'all_fiscalyear': True})
- self.query = obj_move._query_get(self.cr, self.uid, obj='l', context=ctx)
- self.direction_selection = data['form'].get('direction_selection', 'past')
+ self.query = obj_move._query_get(
+ self.cr, self.uid, obj='l', context=ctx)
+ self.direction_selection = data['form'].get('direction_selection',
+ 'past')
self.target_move = data['form'].get('target_move', 'all')
- self.date_from = data['form'].get('date_from', time.strftime('%Y-%m-%d'))
- if (data['form']['result_selection'] == 'customer' ):
+ self.date_from = data['form'].get('date_from',
+ time.strftime('%Y-%m-%d'))
+ if (data['form']['result_selection'] == 'customer'):
self.ACCOUNT_TYPE = ['receivable']
elif (data['form']['result_selection'] == 'supplier'):
self.ACCOUNT_TYPE = ['payable']
else:
- self.ACCOUNT_TYPE = ['payable','receivable']
- lang_dict = self.pool.get('res.users').read(self.cr,self.uid,self.uid,['context_lang'])
+ self.ACCOUNT_TYPE = ['payable', 'receivable']
+ lang_dict = user_obj.read(self.cr, self.uid, self.uid,
+ ['context_lang'])
data['lang'] = lang_dict.get('context_lang') or False
- return super(aged_trial_report, self).set_context(objects, data, ids, report_type=report_type)
+ return super(AgedTrialReport, self).set_context(
+ objects, data, ids, report_type=report_type)
def _get_lines_from_elevator(self, form):
- l = []
- move_state = ['draft','posted']
+ move_state = ['draft', 'posted']
if self.target_move == 'posted':
move_state = ['posted']
self.cr.execute('SELECT DISTINCT p.id as id, p.name as name, \
contract_contract.elevator_id AS elevator_id, \
p2.name AS elevator_name \
- FROM res_partner p ,account_move_line AS l, account_account, account_move am, \
+ FROM res_partner p ,account_move_line AS l,\
+ account_account, account_move am, \
contract_contract, res_partner p2 \
WHERE (l.account_id=account_account.id) \
AND (l.move_id=am.id) \
@@ -82,44 +89,49 @@
AND (account_account.type IN %s)\
AND account_account.active\
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 (l.partner_id=p.id)\
AND (l.date <= %s)\
AND ' + self.query + ' \
- order by name', (tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from, self.date_from,))
- elevs = self.cr.dictfetchall()
-
- #Consultar los partners
+ order by name', (tuple(move_state), tuple(self.ACCOUNT_TYPE),
+ self.date_from, self.date_from,))
+ # Consultar los partners
partners = self._get_lines(form)
for p in partners:
- self.cr.execute("select p2.id, p2.name from res_partner p inner join contract_contract c on c.customer_id = p.id inner join res_partner p2 on c.elevator_id = p2.id where p.name = %s",(p['name'],))
+ self.cr.execute("select p2.id, p2.name from res_partner p "
+ "inner join contract_contract c on c.customer_id ="
+ " p.id inner join res_partner p2 on c.elevator_id"
+ " = p2.id where p.name = %s", (p['name'],))
res = self.cr.fetchone()
if res is None:
p['elevator_id'] = None
p['elevator_name'] = 'Sin Ascensorista'
- else:
+ else:
p['elevator_id'] = res[0]
p['elevator_name'] = res[1]
partners = sorted(partners, key=itemgetter('elevator_name'))
-
- #for k,v in elevators.items():
- #l.append(v)
- #p = []
- #print partners
- #print elevators
- #return l
+
+ # for k,v in elevators.items():
+ # l.append(v)
+ # p = []
+ # print partners
+ # print elevators
+ # return l
return partners
def _get_lines_from_elevator_totals(self, form):
l = []
- move_state = ['draft','posted']
+ move_state = ['draft', 'posted']
if self.target_move == 'posted':
move_state = ['posted']
self.cr.execute('SELECT DISTINCT p.id as id, p.name as name, \
contract_contract.elevator_id AS elevator_id, \
p2.name AS elevator_name \
- FROM res_partner p ,account_move_line AS l, account_account, account_move am, \
+ FROM res_partner p ,account_move_line AS l,\
+ account_account, account_move am, \
contract_contract, res_partner p2 \
WHERE (l.account_id=account_account.id) \
AND (l.move_id=am.id) \
@@ -129,29 +141,33 @@
AND (account_account.type IN %s)\
AND account_account.active\
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 (l.partner_id=p.id)\
AND (l.date <= %s)\
AND ' + self.query + ' \
- order by name', (tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from, self.date_from,))
- elevs = self.cr.dictfetchall()
-
- #Consultar los partners
+ order by name', (tuple(move_state), tuple(self.ACCOUNT_TYPE),
+ self.date_from, self.date_from,))
+ # elevs = self.cr.dictfetchall()
+ # Consultar los partners
partners = self._get_lines(form)
for p in partners:
- self.cr.execute("select p2.id, p2.name from res_partner p inner join contract_contract c on c.customer_id = p.id inner join res_partner p2 on c.elevator_id = p2.id where p.name = %s",(p['name'],))
+ self.cr.execute("select p2.id, p2.name from res_partner p"
+ "inner join contract_contract c on c.customer_id ="
+ " p.id inner join res_partner p2 on c.elevator_id"
+ " = p2.id where p.name = %s", (p['name'],))
res = self.cr.fetchone()
if res is None:
p['elevator_id'] = None
p['elevator_name'] = 'Sin Ascensorista'
- else:
+ else:
p['elevator_id'] = res[0]
p['elevator_name'] = res[1]
-
- #Recorremos partners para ir montando elevators
+ # Recorremos partners para ir montando elevators
elevators = {}
for p in partners:
- if elevators.has_key(p['elevator_id']):
+ if (p['elevator_id'] in elevators):
elevators[p['elevator_id']]['direction'] += p['direction']
elevators[p['elevator_id']]['total'] += p['total']
elevators[p['elevator_id']]['0'] += p['0']
@@ -159,62 +175,71 @@
elevators[p['elevator_id']]['2'] += p['2']
elevators[p['elevator_id']]['3'] += p['3']
elevators[p['elevator_id']]['4'] += p['4']
- else: #Elevator nuevo
+ else: # Elevator nuevo
elevators[p['elevator_id']] = p
-
- for k,v in elevators.items():
+ for k, v in elevators.items():
l.append(v)
- #print partners
- #print elevators
+ # print partners
+ # print elevators
l = sorted(l, key=itemgetter('elevator_name'))
return l
-
-
def _get_lines(self, form):
res = []
- move_state = ['draft','posted']
+ move_state = ['draft', 'posted']
if self.target_move == 'posted':
move_state = ['posted']
self.cr.execute('SELECT DISTINCT res_partner.id AS id,\
res_partner.name AS name \
- FROM res_partner,account_move_line AS l, account_account, account_move am\
+ FROM res_partner,account_move_line AS l, account_account,\
+ account_move am\
WHERE (l.account_id=account_account.id) \
AND (l.move_id=am.id) \
AND (am.state IN %s)\
AND (account_account.type IN %s)\
AND account_account.active\
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 (l.partner_id=res_partner.id)\
AND (l.date <= %s)\
AND ' + self.query + ' \
- ORDER BY res_partner.name', (tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from, self.date_from,))
+ ORDER BY res_partner.name', (tuple(move_state),
+ tuple(self.ACCOUNT_TYPE),
+ self.date_from, self.date_from,))
partners = self.cr.dictfetchall()
- ## mise a 0 du total
+ # mise a 0 du total
for i in range(7):
self.total_account.append(0)
- #
# Build a string like (1,2,3) for easy use in SQL query
partner_ids = [x['id'] for x in partners]
if not partner_ids:
return []
- # This dictionary will store the debit-credit for all partners, using partner_id as key.
-
+ # This dictionary will store the debit-credit for all partners, using
+ # partner_id as key.
totals = {}
self.cr.execute('SELECT l.partner_id, SUM(l.debit-l.credit) \
- FROM account_move_line AS l, account_account, account_move am \
- WHERE (l.account_id = account_account.id) AND (l.move_id=am.id) \
+ FROM account_move_line AS l, account_account,\
+ account_move am \
+ WHERE (l.account_id = account_account.id)\
+ AND (l.move_id=am.id) \
AND (am.state IN %s)\
AND (account_account.type IN %s)\
AND (l.partner_id IN %s)\
AND ((l.reconcile_id IS NULL)\
- OR (l.reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\
+ OR (l.reconcile_id IN (SELECT recon.id\
+ FROM account_move_reconcile\
+ AS recon WHERE recon.create_date >\
+ %s )))\
AND ' + self.query + '\
AND account_account.active\
AND (l.date <= %s)\
- GROUP BY l.partner_id ', (tuple(move_state), tuple(self.ACCOUNT_TYPE), tuple(partner_ids), self.date_from, self.date_from,))
+ GROUP BY l.partner_id ', (tuple(move_state),
+ tuple(self.ACCOUNT_TYPE),
+ tuple(partner_ids),
+ self.date_from, self.date_from,))
t = self.cr.fetchall()
for i in t:
totals[i[0]] = i[1]
@@ -223,44 +248,67 @@
future_past = {}
if self.direction_selection == 'future':
self.cr.execute('SELECT l.partner_id, SUM(l.debit-l.credit) \
- FROM account_move_line AS l, account_account, account_move am \
- WHERE (l.account_id=account_account.id) AND (l.move_id=am.id) \
+ FROM account_move_line AS l, account_account,\
+ account_move am \
+ WHERE (l.account_id=account_account.id)\
+ AND (l.move_id=am.id) \
AND (am.state IN %s)\
AND (account_account.type IN %s)\
AND (COALESCE(l.date_maturity, l.date) < %s)\
AND (l.partner_id IN %s)\
AND ((l.reconcile_id IS NULL)\
- OR (l.reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\
- AND '+ self.query + '\
+ OR (l.reconcile_id IN (SELECT recon.id\
+ FROM account_move_reconcile\
+ AS recon WHERE\
+ recon.create_date > %s )))\
+ AND ' + self.query + '\
AND account_account.active\
AND (l.date <= %s)\
- GROUP BY l.partner_id', (tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from, tuple(partner_ids),self.date_from, self.date_from,))
+ GROUP BY l.partner_id', (tuple(move_state),
+ tuple(self.ACCOUNT_TYPE),
+ self.date_from,
+ tuple(partner_ids),
+ self.date_from,
+ self.date_from,))
t = self.cr.fetchall()
for i in t:
future_past[i[0]] = i[1]
- elif self.direction_selection == 'past': # Using elif so people could extend without this breaking
+ elif self.direction_selection == 'past':
+ # Using elif so people could extend without this breaking
self.cr.execute('SELECT l.partner_id, SUM(l.debit-l.credit) \
- FROM account_move_line AS l, account_account, account_move am \
- WHERE (l.account_id=account_account.id) AND (l.move_id=am.id)\
+ FROM account_move_line AS l, account_account,\
+ account_move am \
+ WHERE (l.account_id=account_account.id)\
+ AND (l.move_id=am.id)\
AND (am.state IN %s)\
AND (account_account.type IN %s)\
AND (COALESCE(l.date_maturity,l.date) > %s)\
AND (l.partner_id IN %s)\
AND ((l.reconcile_id IS NULL)\
- OR (l.reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\
- AND '+ self.query + '\
+ OR (l.reconcile_id IN (SELECT recon.id\
+ FROM account_move_reconcile AS\
+ recon WHERE recon.create_date >\
+ %s )))\
+ AND ' + self.query + '\
AND account_account.active\
AND (l.date <= %s)\
- GROUP BY l.partner_id', (tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from, tuple(partner_ids), self.date_from, self.date_from,))
+ GROUP BY l.partner_id', (tuple(move_state),
+ tuple(self.ACCOUNT_TYPE),
+ self.date_from,
+ tuple(partner_ids),
+ self.date_from,
+ self.date_from,))
t = self.cr.fetchall()
for i in t:
future_past[i[0]] = i[1]
-
- # Use one query per period and store results in history (a list variable)
- # Each history will contain: history[1] = {'<partner_id>': <partner_debit-credit>}
+ # Use one query per period and store results in history
+ # (a list variable)
+ # Each history will contain: history[1] =
+ # {'<partner_id>': <partner_debit-credit>}
history = []
for i in range(5):
- args_list = (tuple(move_state), tuple(self.ACCOUNT_TYPE), tuple(partner_ids),self.date_from,)
+ args_list = (tuple(move_state), tuple(self.ACCOUNT_TYPE),
+ tuple(partner_ids), self.date_from,)
dates_query = '(COALESCE(l.date_maturity,l.date)'
if form[str(i)]['start'] and form[str(i)]['stop']:
dates_query += ' BETWEEN %s AND %s)'
@@ -273,13 +321,18 @@
args_list += (form[str(i)]['stop'],)
args_list += (self.date_from,)
self.cr.execute('''SELECT l.partner_id, SUM(l.debit-l.credit)
- FROM account_move_line AS l, account_account, account_move am
- WHERE (l.account_id = account_account.id) AND (l.move_id=am.id)
+ FROM account_move_line AS l, account_account,\
+ account_move am
+ WHERE (l.account_id = account_account.id)\
+ AND (l.move_id=am.id)
AND (am.state IN %s)
AND (account_account.type IN %s)
AND (l.partner_id IN %s)
AND ((l.reconcile_id IS NULL)
- OR (l.reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))
+ OR (l.reconcile_id IN (SELECT recon.id\
+ FROM account_move_reconcile AS\
+ recon WHERE recon.create_date\
+ > %s )))
AND ''' + self.query + '''
AND account_account.active
AND ''' + dates_query + '''
@@ -293,40 +346,51 @@
for partner in partners:
values = {}
- ## If choise selection is in the future
+ # If choise selection is in the future
if self.direction_selection == 'future':
- # Query here is replaced by one query which gets the all the partners their 'before' value
+ # Query here is replaced by one query which gets the all the
+ # partners their 'before' value
before = False
- if future_past.has_key(partner['id']):
- before = [ future_past[partner['id']] ]
- self.total_account[6] = self.total_account[6] + (before and before[0] or 0.0)
+ if (partner['id'] in future_past):
+ before = [future_past[partner['id']]]
+ self.total_account[6] = self.total_account[6] + (before and
+ before[0] or
+ 0.0)
values['direction'] = before and before[0] or 0.0
- elif self.direction_selection == 'past': # Changed this so people could in the future create new direction_selections
- # Query here is replaced by one query which gets the all the partners their 'after' value
+ elif self.direction_selection == 'past':
+ # Changed this so people could in the future create new
+ # direction_selections
+ # Query here is replaced by one query which gets the all the
+ # partners their 'after' value
after = False
- if future_past.has_key(partner['id']): # Making sure this partner actually was found by the query
- after = [ future_past[partner['id']] ]
+ if (partner['id'] in future_past):
+ # Making sure this partner actually was found by the query
+ after = [future_past[partner['id']]]
- self.total_account[6] = self.total_account[6] + (after and after[0] or 0.0)
+ self.total_account[6] = self.total_account[6] + (after and
+ after[0] or
+ 0.0)
values['direction'] = after and after[0] or 0.0
for i in range(5):
during = False
- if history[i].has_key(partner['id']):
- during = [ history[i][partner['id']] ]
+ if (partner['id'] in history[i]):
+ during = [history[i][partner['id']]]
# Ajout du compteur
- self.total_account[(i)] = self.total_account[(i)] + (during and during[0] or 0)
+ self.total_account[(i)] = self.total_account[(i)] + (during and
+ during[0]
+ or 0)
values[str(i)] = during and during[0] or 0.0
total = False
- if totals.has_key( partner['id'] ):
- total = [ totals[partner['id']] ]
+ if (partner['id'] in totals):
+ total = [totals[partner['id']]]
values['total'] = total and total[0] or 0.0
- ## Add for total
- self.total_account[(i+1)] = self.total_account[(i+1)] + (total and total[0] or 0.0)
+ # Add for total
+ self.total_account[(i+1)] = self.total_account[(i+1)] + (total and
+ total[0]
+ or 0.0)
values['name'] = partner['name']
-
res.append(values)
-
total = 0.0
totals = {}
for r in res:
@@ -334,68 +398,93 @@
for i in range(5)+['direction']:
totals.setdefault(str(i), 0.0)
totals[str(i)] += float(r[str(i)] or 0.0)
-
return res
def _get_lines_with_out_partner(self, form):
res = []
- move_state = ['draft','posted']
+ move_state = ['draft', 'posted']
if self.target_move == 'posted':
move_state = ['posted']
- ## mise a 0 du total
+ # mise a 0 du total
for i in range(7):
self.total_account.append(0)
totals = {}
self.cr.execute('SELECT SUM(l.debit-l.credit) \
- FROM account_move_line AS l, account_account, account_move am \
- WHERE (l.account_id = account_account.id) AND (l.move_id=am.id)\
+ FROM account_move_line AS l, account_account,\
+ account_move am \
+ WHERE (l.account_id = account_account.id)\
+ AND (l.move_id=am.id)\
AND (am.state IN %s)\
AND (l.partner_id IS NULL)\
AND (account_account.type IN %s)\
AND ((l.reconcile_id IS NULL) \
- OR (l.reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\
+ OR (l.reconcile_id IN (SELECT recon.id\
+ FROM account_move_reconcile AS\
+ recon WHERE recon.create_date > %s\
+ )))\
AND ' + self.query + '\
AND (l.date <= %s)\
- AND account_account.active ',(tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from, self.date_from,))
+ AND account_account.active ', (tuple(move_state),
+ tuple(self.ACCOUNT_TYPE),
+ self.date_from,
+ self.date_from,))
t = self.cr.fetchall()
for i in t:
totals['Unknown Partner'] = i[0]
future_past = {}
if self.direction_selection == 'future':
self.cr.execute('SELECT SUM(l.debit-l.credit) \
- FROM account_move_line AS l, account_account, account_move am\
- WHERE (l.account_id=account_account.id) AND (l.move_id=am.id)\
+ FROM account_move_line AS l, account_account,\
+ account_move am\
+ WHERE (l.account_id=account_account.id)\
+ AND (l.move_id=am.id)\
AND (am.state IN %s)\
AND (l.partner_id IS NULL)\
AND (account_account.type IN %s)\
AND (COALESCE(l.date_maturity, l.date) < %s)\
AND ((l.reconcile_id IS NULL)\
- OR (l.reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\
- AND '+ self.query + '\
- AND account_account.active ', (tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from, self.date_from))
+ OR (l.reconcile_id IN (SELECT recon.id\
+ FROM account_move_reconcile AS\
+ recon WHERE recon.create_date >\
+ %s )))\
+ AND ' + self.query + '\
+ AND account_account.active', (tuple(move_state),
+ tuple(self.ACCOUNT_TYPE),
+ self.date_from,
+ self.date_from))
t = self.cr.fetchall()
for i in t:
future_past['Unknown Partner'] = i[0]
- elif self.direction_selection == 'past': # Using elif so people could extend without this breaking
+ elif self.direction_selection == 'past': # Using elif so people could
+ # extend without this breaking
self.cr.execute('SELECT SUM(l.debit-l.credit) \
- FROM account_move_line AS l, account_account, account_move am \
- WHERE (l.account_id=account_account.id) AND (l.move_id=am.id)\
- AND (am.state IN %s)\
- AND (l.partner_id IS NULL)\
- AND (account_account.type IN %s)\
- AND (COALESCE(l.date_maturity,l.date) > %s)\
- AND ((l.reconcile_id IS NULL)\
- OR (l.reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\
- AND '+ self.query + '\
- AND account_account.active ', (tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from, self.date_from))
+ FROM account_move_line AS l, account_account,\
+ account_move am \
+ WHERE (l.account_id=account_account.id)\
+ AND (l.move_id=am.id)\
+ AND (am.state IN %s)\
+ AND (l.partner_id IS NULL)\
+ AND (account_account.type IN %s)\
+ AND (COALESCE(l.date_maturity,l.date) > %s)\
+ AND ((l.reconcile_id IS NULL)\
+ OR (l.reconcile_id IN (SELECT recon.id\
+ FROM account_move_reconcile AS\
+ recon WHERE recon.create_date >\
+ %s )))\
+ AND ' + self.query + '\
+ AND account_account.active ', (tuple(move_state),
+ tuple(self.ACCOUNT_TYPE),
+ self.date_from,
+ self.date_from))
t = self.cr.fetchall()
for i in t:
future_past['Unknown Partner'] = i[0]
history = []
for i in range(5):
- args_list = (tuple(move_state), tuple(self.ACCOUNT_TYPE), self.date_from,)
+ args_list = (tuple(move_state), tuple(self.ACCOUNT_TYPE),
+ self.date_from,)
dates_query = '(COALESCE(l.date_maturity,l.date)'
if form[str(i)]['start'] and form[str(i)]['stop']:
dates_query += ' BETWEEN %s AND %s)'
@@ -408,14 +497,19 @@
args_list += (form[str(i)]['stop'],)
args_list += (self.date_from,)
self.cr.execute('SELECT SUM(l.debit-l.credit)\
- FROM account_move_line AS l, account_account, account_move am \
- WHERE (l.account_id = account_account.id) AND (l.move_id=am.id)\
+ FROM account_move_line AS l, account_account,\
+ account_move am \
+ WHERE (l.account_id = account_account.id)\
+ AND (l.move_id=am.id)\
AND (am.state IN %s)\
AND (account_account.type IN %s)\
AND (l.partner_id IS NULL)\
AND ((l.reconcile_id IS NULL)\
- OR (l.reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\
- AND '+ self.query + '\
+ OR (l.reconcile_id IN (SELECT recon.id\
+ FROM account_move_reconcile AS\
+ recon WHERE recon.create_date >\
+ %s )))\
+ AND ' + self.query + '\
AND account_account.active\
AND ' + dates_query + '\
AND (l.date <= %s)\
@@ -429,30 +523,36 @@
values = {}
if self.direction_selection == 'future':
before = False
- if future_past.has_key('Unknown Partner'):
- before = [ future_past['Unknown Partner'] ]
- self.total_account[6] = self.total_account[6] + (before and before[0] or 0.0)
+ if ('Unknown Partner' in future_past):
+ before = [future_past['Unknown Partner']]
+ self.total_account[6] = self.total_account[6] + (before and
+ before[0] or 0.0)
values['direction'] = before and before[0] or 0.0
elif self.direction_selection == 'past':
after = False
- if future_past.has_key('Unknown Partner'):
- after = [ future_past['Unknown Partner'] ]
- self.total_account[6] = self.total_account[6] + (after and after[0] or 0.0)
+ if ('Unknown Partner' in future_past):
+ after = [future_past['Unknown Partner']]
+ self.total_account[6] = self.total_account[6] + (after and after[0]
+ or 0.0)
values['direction'] = after and after[0] or 0.0
for i in range(5):
during = False
- if history[i].has_key('Unknown Partner'):
- during = [ history[i]['Unknown Partner'] ]
- self.total_account[(i)] = self.total_account[(i)] + (during and during[0] or 0)
+ if ('Unknown Partner' in history[i]):
+ during = [history[i]['Unknown Partner']]
+ self.total_account[(i)] = self.total_account[(i)] + (during and
+ during[0] or
+ 0)
values[str(i)] = during and during[0] or 0.0
total = False
- if totals.has_key( 'Unknown Partner' ):
- total = [ totals['Unknown Partner'] ]
+ if ('Unknown Partner' in totals):
+ total = [totals['Unknown Partner']]
values['total'] = total and total[0] or 0.0
- ## Add for total
- self.total_account[(i+1)] = self.total_account[(i+1)] + (total and total[0] or 0.0)
+ # Add for total
+ self.total_account[(i+1)] = self.total_account[(i+1)] + (total and
+ total[0] or
+ 0.0)
values['name'] = 'Unknown Partner'
if values['total']:
@@ -467,19 +567,19 @@
totals[str(i)] += float(r[str(i)] or 0.0)
return res
- def _get_total(self,pos):
- period = self.total_account[int(pos)]
- return period or 0.0
-
- def _get_direction(self,pos):
- period = self.total_account[int(pos)]
- return period or 0.0
-
- def _get_for_period(self,pos):
- period = self.total_account[int(pos)]
- return period or 0.0
-
- def _get_partners(self,data):
+ def _get_total(self, pos):
+ period = self.total_account[int(pos)]
+ return period or 0.0
+
+ def _get_direction(self, pos):
+ period = self.total_account[int(pos)]
+ return period or 0.0
+
+ def _get_for_period(self, pos):
+ period = self.total_account[int(pos)]
+ return period or 0.0
+
+ def _get_partners(self, data):
if data['form']['result_selection'] == 'customer':
return 'Receivable Accounts'
elif data['form']['result_selection'] == 'supplier':
@@ -489,7 +589,6 @@
return ''
report_sxw.report_sxw('report.account.nayar_aged_trial_balance', 'res.partner',
- 'addons/nayar_account_aged_partner_balance/report/account_aged_partner_balance.rml',parser=aged_trial_report, header="internal landscape")
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+ 'addons/nayar_account_aged_partner_balance/report/'
+ 'account_aged_partner_balance.rml',
+ parser=aged_trial_report, header="internal landscape")
=== modified file 'nayar_account_aged_partner_balance/report/common_report_header.py'
--- nayar_account_aged_partner_balance/report/common_report_header.py 2014-06-11 10:23:47 +0000
+++ nayar_account_aged_partner_balance/report/common_report_header.py 2014-07-01 12:06:03 +0000
@@ -20,7 +20,8 @@
##############################################################################
import pooler
-from tools.translate import _
+from openerp.tools.translate import _
+
class common_report_header(object):
@@ -36,7 +37,8 @@
if not (period_id and journal_id):
return 0.0
self.cr.execute('SELECT SUM(debit) FROM account_move_line l '
- 'WHERE period_id IN %s AND journal_id IN %s ' + self.query_get_clause + ' ',
+ 'WHERE period_id IN %s AND journal_id IN %s ' +
+ self.query_get_clause + ' ',
(tuple(period_id), tuple(journal_id)))
return self.cr.fetchone()[0] or 0.0
@@ -52,7 +54,8 @@
if not (period_id and journal_id):
return 0.0
self.cr.execute('SELECT SUM(credit) FROM account_move_line l '
- 'WHERE period_id IN %s AND journal_id IN %s '+ self.query_get_clause+'',
+ 'WHERE period_id IN %s AND journal_id IN %s ' +
+ self.query_get_clause + '',
(tuple(period_id), tuple(journal_id)))
return self.cr.fetchone()[0] or 0.0
@@ -74,18 +77,25 @@
return ''
def get_start_period(self, data):
+ pooler_obj = pooler.get_pool(self.cr.dbname)
if data.get('form', False) and data['form'].get('period_from', False):
- return pooler.get_pool(self.cr.dbname).get('account.period').browse(self.cr,self.uid,data['form']['period_from']).name
+ return pooler_obj.get('account.period').browse(
+ self.cr, self.uid, data['form']['period_from']).name
return ''
def get_end_period(self, data):
+ pooler_obj = pooler.get_pool(self.cr.dbname)
if data.get('form', False) and data['form'].get('period_to', False):
- return pooler.get_pool(self.cr.dbname).get('account.period').browse(self.cr, self.uid, data['form']['period_to']).name
+ return pooler_obj.get('account.period').browse(
+ self.cr, self.uid, data['form']['period_to']).name
return ''
def _get_account(self, data):
- if data.get('form', False) and data['form'].get('chart_account_id', False):
- return pooler.get_pool(self.cr.dbname).get('account.account').browse(self.cr, self.uid, data['form']['chart_account_id']).name
+ pooler_obj = pooler.get_pool(self.cr.dbname)
+ chart_account_id = data['form'].get('chart_account_id', False)
+ if data.get('form', False) and chart_account_id:
+ return pooler_obj.get('account.account').browse(
+ self.cr, self.uid, data['form']['chart_account_id']).name
return ''
def _get_sortby(self, data):
@@ -104,7 +114,8 @@
if not journals:
return 0.0
self.cr.execute('SELECT SUM(debit) FROM account_move_line l '
- 'WHERE period_id=%s AND journal_id IN %s '+ self.query_get_clause +'',
+ 'WHERE period_id=%s AND journal_id IN %s ' +
+ self.query_get_clause + '',
(period_id, tuple(journals)))
return self.cr.fetchone()[0] or 0.0
@@ -114,30 +125,42 @@
if not journals:
return 0.0
self.cr.execute('SELECT SUM(credit) FROM account_move_line l '
- 'WHERE period_id=%s AND journal_id IN %s ' + self.query_get_clause +' ',
+ 'WHERE period_id=%s AND journal_id IN %s ' +
+ self.query_get_clause + ' ',
(period_id, tuple(journals)))
return self.cr.fetchone()[0] or 0.0
def _get_fiscalyear(self, data):
- if data.get('form', False) and data['form'].get('fiscalyear_id', False):
- return pooler.get_pool(self.cr.dbname).get('account.fiscalyear').browse(self.cr, self.uid, data['form']['fiscalyear_id']).name
+ pooler_obj = pooler.get_pool(self.cr.dbname)
+ fiscalyear_id = data['form'].get('fiscalyear_id', False)
+ if data.get('form', False) and fiscalyear_id:
+ return pooler_obj.get('account.fiscalyear').browse(
+ self.cr, self.uid, data['form']['fiscalyear_id']).name
return ''
def _get_company(self, data):
- if data.get('form', False) and data['form'].get('chart_account_id', False):
- return pooler.get_pool(self.cr.dbname).get('account.account').browse(self.cr, self.uid, data['form']['chart_account_id']).company_id.name
+ pooler_obj = pooler.get_pool(self.cr.dbname)
+ chart_account_id = data['form'].get('chart_account_id', False)
+ if data.get('form', False) and chart_account_id:
+ return pooler_obj.get('account.account').browse(
+ self.cr, self.uid, chart_account_id).company_id.name
return ''
def _get_journal(self, data):
codes = []
if data.get('form', False) and data['form'].get('journal_ids', False):
- self.cr.execute('select code from account_journal where id IN %s',(tuple(data['form']['journal_ids']),))
+ self.cr.execute('select code from account_journal where id IN %s',
+ (tuple(data['form']['journal_ids']),))
codes = [x for x, in self.cr.fetchall()]
return codes
def _get_currency(self, data):
- if data.get('form', False) and data['form'].get('chart_account_id', False):
- return pooler.get_pool(self.cr.dbname).get('account.account').browse(self.cr, self.uid, data['form']['chart_account_id']).company_id.currency_id.symbol
+ pooler_obj = pooler.get_pool(self.cr.dbname)
+ chart_account_id = data['form'].get('chart_account_id', False)
+ if data.get('form', False) and chart_account_id:
+ return pooler_obj.get('account.account').browse(
+ self.cr, self.uid,
+ chart_account_id).company_id.currency_id.symbol
return ''
-#vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== modified file 'nayar_account_aged_partner_balance/wizard/__init__.py'
--- nayar_account_aged_partner_balance/wizard/__init__.py 2014-06-11 10:23:47 +0000
+++ nayar_account_aged_partner_balance/wizard/__init__.py 2014-07-01 12:06:03 +0000
@@ -1,1 +1,1 @@
-import account_report_aged_partner_balance
+from . import account_report_aged_partner_balance
=== modified file 'nayar_account_aged_partner_balance/wizard/account_report_aged_partner_balance.py'
--- nayar_account_aged_partner_balance/wizard/account_report_aged_partner_balance.py 2014-06-11 10:23:47 +0000
+++ nayar_account_aged_partner_balance/wizard/account_report_aged_partner_balance.py 2014-07-01 12:06:03 +0000
@@ -19,20 +19,16 @@
#
##############################################################################
-import time
-from datetime import datetime
-from dateutil.relativedelta import relativedelta
-from osv import osv, fields
-from tools.translate import _
-
-class account_aged_trial_balance(osv.osv_memory):
+from openerp.osv import orm
+
+
+class AccountAgedTrialBalance(orm.TransientModel):
_inherit = 'account.aged.trial.balance'
- _description = 'Account Aged Trial balance Report'
def _print_report(self, cr, uid, ids, data, context=None):
- res = super(account_aged_trial_balance,self)._print_report(cr, uid, ids, data, context = context)
- res['report_name'] = 'account.nayar_aged_trial_balance'
- return res
-account_aged_trial_balance()
+ res = super(AccountAgedTrialBalance, self)._print_report(
+ cr, uid, ids, data, context=context)
+ res['report_name'] = 'account.nayar_aged_trial_balance'
+ return res
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
Follow ups