Skip to content

Commit

Permalink
[IMP] Print aged partner balance on a selection of partners
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] authored and Stefan Rijnhart committed Jul 2, 2014
1 parent 8457e36 commit dbc3b68
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
16 changes: 14 additions & 2 deletions addons/account/report/account_aged_partner_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,23 @@ def set_context(self, objects, data, ids, report_type=None):
self.ACCOUNT_TYPE = ['payable']
else:
self.ACCOUNT_TYPE = ['payable','receivable']
self.partner_ids = ids if data.get('model') == 'res.partner' else False
return super(aged_trial_report, self).set_context(objects, data, ids, report_type=report_type)

def _get_lines(self, form):
res = []
move_state = ['draft','posted']
if self.target_move == 'posted':
move_state = ['posted']
query_params = [
tuple(move_state), tuple(self.ACCOUNT_TYPE),
self.date_from, self.date_from]
if self.partner_ids:
partner_query = ' AND res_partner.id IN %s '
query_params.append(tuple(self.partner_ids))
else:
partner_query = ''

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\
Expand All @@ -76,8 +86,8 @@ def _get_lines(self, form):
OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date >= %s::timestamp + \'1day\'::interval )))\
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,))
AND ' + self.query + partner_query + ' \
ORDER BY res_partner.name', tuple(query_params))
partners = self.cr.dictfetchall()
## mise a 0 du total
for i in range(7):
Expand Down Expand Up @@ -236,6 +246,8 @@ def _get_lines(self, form):
return res

def _get_lines_with_out_partner(self, form):
if self.partner_ids:
return []
res = []
move_state = ['draft','posted']
if self.target_move == 'posted':
Expand Down
4 changes: 2 additions & 2 deletions addons/account/wizard/account_report_aged_partner_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def _print_report(self, cr, uid, ids, data, context=None):
context = {}

data = self.pre_print_report(cr, uid, ids, data, context=context)
data['ids'] = context.get('active_ids', [])
data['model'] = context.get('active_model', 'ir.ui.menu')
data['form'].update(self.read(cr, uid, ids, ['period_length', 'direction_selection'])[0])

period_length = data['form']['period_length']
Expand Down Expand Up @@ -78,8 +80,6 @@ def _print_report(self, cr, uid, ids, data, context=None):
}
start = stop + relativedelta(days=1)
data['form'].update(res)
if data.get('form',False):
data['ids']=[data['form'].get('chart_account_id',False)]
return {
'type': 'ir.actions.report.xml',
'report_name': 'account.aged_trial_balance',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@
<field name="target">new</field>
</record>

<record model="ir.values" id="ir_values_account_aged_partner_balance">
<field name="key2" eval="'client_print_multi'"/>
<field name="model" eval="'res.partner'"/>
<field name="name">Print Aged Partner Balance</field>
<field name="value" eval="'ir.actions.act_window,%d'%action_account_aged_balance_view"/>
</record>

<menuitem icon="STOCK_PRINT"
name="Aged Partner Balance"
action="action_account_aged_balance_view"
Expand Down

0 comments on commit dbc3b68

Please sign in to comment.