add an option in partner balance for non-zero only

This options exists in the partner balance from the account module. It
was not there in the webkit module though. The naming is the same as
from the odoo module.

A very old commit message for the webkit report mentions this
functionality but apparently it is not there.

By default all partners are shown as before. This option works for both
PDF and XLS reports.
pull/203/head
Leonardo Pistone 2016-05-31 17:49:06 +02:00
parent 129adaf283
commit 518988dc65
3 changed files with 32 additions and 11 deletions

View File

@ -36,7 +36,8 @@ class CommonPartnerBalanceReportHeaderWebkit(CommonBalanceReportHeaderWebkit,
def _get_account_partners_details(self, account_by_ids, main_filter,
target_move, start, stop,
initial_balance_mode,
partner_filter_ids=False):
partner_filter_ids=False,
display_partner='all'):
res = {}
filter_from = False
if main_filter in ('filter_period', 'filter_no', 'filter_opening'):
@ -80,6 +81,11 @@ class CommonPartnerBalanceReportHeaderWebkit(CommonBalanceReportHeaderWebkit,
get('init_balance', 0.0) + \
details[partner_id].get('debit', 0.0) - \
details[partner_id].get('credit', 0.0)
if display_partner == 'non-zero_balance':
details = {k: v
for k, v in details.iteritems()
if abs(v['balance']) > 0.0001}
res[account_id] = details
return res
@ -201,7 +207,9 @@ class CommonPartnerBalanceReportHeaderWebkit(CommonBalanceReportHeaderWebkit,
partner_details_by_ids = self._get_account_partners_details(
accounts_by_ids, details_filter,
target_move, start, stop, initial_balance_mode,
partner_filter_ids=partner_filter_ids)
partner_filter_ids=partner_filter_ids,
display_partner=data['form']['display_partner']
)
for account_id in account_ids:
accounts_details_by_ids[account_id][
@ -263,7 +271,8 @@ class CommonPartnerBalanceReportHeaderWebkit(CommonBalanceReportHeaderWebkit,
partner_details_by_ids = self._get_account_partners_details(
accounts_by_ids, main_filter, target_move, start, stop,
initial_balance_mode, partner_filter_ids=partner_ids)
initial_balance_mode, partner_filter_ids=partner_ids,
display_partner=data['form']['display_partner'])
comparison_params = []
comp_accounts_by_ids = []

View File

@ -14,21 +14,31 @@ class AccountPartnerBalanceWizard(models.TransientModel):
_description = "Partner Balance Report"
result_selection = fields.Selection(
[('customer', 'Receivable Accounts'),
[
('customer', 'Receivable Accounts'),
('supplier', 'Payable Accounts'),
('customer_supplier', 'Receivable and Payable Accounts')],
('customer_supplier', 'Receivable and Payable Accounts')
],
"Partner's", required=True, default='customer_supplier')
partner_ids = fields.Many2many(
'res.partner', string='Filter on partner',
help="Only selected partners will be printed. "
"Leave empty to print all partners.")
# same field in the module account
display_partner = fields.Selection(
[
('non-zero_balance', 'With balance is not equal to 0'),
('all', 'All Partners')
], 'Display Partners', default='all')
@api.multi
def pre_print_report(self, data):
self.ensure_one()
data = super(AccountPartnerBalanceWizard, self).pre_print_report(data)
vals = self.read(['result_selection', 'partner_ids'])[0]
vals = self.read(['result_selection', 'partner_ids',
'display_partner'])[0]
data['form'].update(vals)
return data

View File

@ -22,6 +22,8 @@
<field name="target_move" position="after">
<newline/>
<field name="result_selection" colspan="4"/>
<newline/>
<field name="display_partner" colspan="4"/>
</field>
<page name="filters" position="after">
<page string="Accounts Filters" name="accounts">