Browse Source

[IMP] account_financial_report: open_items

* added option "show_partner_details"
pull/660/head
Joan Sisquella 5 years ago
parent
commit
2477566483
  1. 19
      account_financial_report/report/open_items.py
  2. 9
      account_financial_report/report/open_items_xlsx.py
  3. 5
      account_financial_report/report/templates/general_ledger.xml
  4. 35
      account_financial_report/report/templates/open_items.xml
  5. 5
      account_financial_report/wizard/open_items_wizard.py
  6. 1
      account_financial_report/wizard/open_items_wizard_view.xml

19
account_financial_report/report/open_items.py

@ -259,6 +259,19 @@ class OpenItemsReport(models.AbstractModel):
'amount_residual'] 'amount_residual']
return total_amount return total_amount
@api.model
def _get_open_items_no_partners(self, open_items_move_lines_data):
new_open_items = {}
for acc_id in open_items_move_lines_data.keys():
new_open_items[acc_id] = {}
move_lines = []
for prt_id in open_items_move_lines_data[acc_id]:
for move_line in open_items_move_lines_data[acc_id][prt_id]:
move_lines += [move_line]
move_lines = sorted(move_lines, key=lambda k: (k['date']))
new_open_items[acc_id] = move_lines
return new_open_items
@api.multi @api.multi
def _get_report_values(self, docids, data): def _get_report_values(self, docids, data):
wizard_id = data['wizard_id'] wizard_id = data['wizard_id']
@ -270,6 +283,7 @@ class OpenItemsReport(models.AbstractModel):
date_at_object = datetime.strptime(date_at, '%Y-%m-%d').date() date_at_object = datetime.strptime(date_at, '%Y-%m-%d').date()
date_from = data['date_from'] date_from = data['date_from']
target_move = data['target_move'] target_move = data['target_move']
show_partner_details = data['show_partner_details']
move_lines_data, partners_data, journals_data, accounts_data, \ move_lines_data, partners_data, journals_data, accounts_data, \
open_items_move_lines_data = self._get_data( open_items_move_lines_data = self._get_data(
@ -277,11 +291,16 @@ class OpenItemsReport(models.AbstractModel):
target_move, company_id, date_from) target_move, company_id, date_from)
total_amount = self._calculate_amounts(open_items_move_lines_data) total_amount = self._calculate_amounts(open_items_move_lines_data)
if not show_partner_details:
open_items_move_lines_data = self._get_open_items_no_partners(
open_items_move_lines_data
)
return{ return{
'doc_ids': [wizard_id], 'doc_ids': [wizard_id],
'doc_model': 'open.items.report.wizard', 'doc_model': 'open.items.report.wizard',
'docs': self.env['open.items.report.wizard'].browse(wizard_id), 'docs': self.env['open.items.report.wizard'].browse(wizard_id),
'foreign_currency': data['foreign_currency'], 'foreign_currency': data['foreign_currency'],
'show_partner_details': data['show_partner_details'],
'company_name': company.display_name, 'company_name': company.display_name,
'currency_name': company.currency_id.name, 'currency_name': company.currency_id.name,
'date_at': date_at_object.strftime("%d/%m/%Y"), 'date_at': date_at_object.strftime("%d/%m/%Y"),

9
account_financial_report/report/open_items_xlsx.py

@ -93,6 +93,7 @@ class OpenItemsXslx(models.AbstractModel):
accounts_data = res_data['accounts_data'] accounts_data = res_data['accounts_data']
partners_data = res_data['partners_data'] partners_data = res_data['partners_data']
total_amount = res_data['total_amount'] total_amount = res_data['total_amount']
show_partner_details = res_data['show_partner_details']
for account_id in Open_items.keys(): for account_id in Open_items.keys():
# Write account title # Write account title
self.write_array_title(accounts_data[account_id]['code'] + ' - ' + self.write_array_title(accounts_data[account_id]['code'] + ' - ' +
@ -100,6 +101,7 @@ class OpenItemsXslx(models.AbstractModel):
# For each partner # For each partner
if Open_items[account_id]: if Open_items[account_id]:
if show_partner_details:
for partner_id in Open_items[account_id]: for partner_id in Open_items[account_id]:
type_object = 'partner' type_object = 'partner'
# Write partner title # Write partner title
@ -119,6 +121,13 @@ class OpenItemsXslx(models.AbstractModel):
# Line break # Line break
self.row_pos += 1 self.row_pos += 1
else:
# Display array header for move lines
self.write_array_header()
# Display account move lines
for line in Open_items[account_id]:
self.write_line_from_dict(line)
# Display ending balance line for account # Display ending balance line for account
type_object = 'account' type_object = 'account'

5
account_financial_report/report/templates/general_ledger.xml

@ -68,6 +68,8 @@
<t t-set="type" t-value='"partner_type"'/> <t t-set="type" t-value='"partner_type"'/>
</t> </t>
</div>
</t>
<!-- Display account footer --> <!-- Display account footer -->
<t t-if="not filter_partner_ids"> <t t-if="not filter_partner_ids">
<t t-call="account_financial_report.report_general_ledger_ending_cumul"> <t t-call="account_financial_report.report_general_ledger_ending_cumul">
@ -75,9 +77,6 @@
<t t-set="type" t-value='"account_type"'/> <t t-set="type" t-value='"account_type"'/>
</t> </t>
</t> </t>
</div>
</t>
</t> </t>
</div> </div>
</t> </t>

35
account_financial_report/report/templates/open_items.xml

@ -25,7 +25,6 @@
<t t-call="account_financial_report.report_open_items_filters"/> <t t-call="account_financial_report.report_open_items_filters"/>
<t t-foreach="Open_Items.keys()" t-as="account_id"> <t t-foreach="Open_Items.keys()" t-as="account_id">
<div class="page_break">
<!-- Display account header --> <!-- Display account header -->
<div class="act_as_table list_table" style="margin-top: 10px;" /> <div class="act_as_table list_table" style="margin-top: 10px;" />
<div class="account_title" <div class="account_title"
@ -34,34 +33,45 @@
- -
<span t-esc="accounts_data[account_id]['name']"/> <span t-esc="accounts_data[account_id]['name']"/>
</div> </div>
<t t-if="not show_partner_details">
<div class="act_as_table data_table" style="width: 100%;">
<t t-call="account_financial_report.report_open_items_lines_header"/>
<!-- Display account move lines -->
<t t-foreach="Open_Items[account_id]" t-as="line" >
<t t-call="account_financial_report.report_open_items_lines"/>
</t>
</div>
</t>
<t t-if="show_partner_details">
<div class="page_break">
<!-- Display account partners --> <!-- Display account partners -->
<t t-foreach="Open_Items[account_id]" t-as="partner_id" > <t t-foreach="Open_Items[account_id]" t-as="partner_id" >
<div class="page_break">
<!-- Display partner header -->
<div class="act_as_caption account_title"> <div class="act_as_caption account_title">
<span t-esc="partners_data[partner_id]['name']"/> <span t-esc="partners_data[partner_id]['name']"/>
</div> </div>
<div class="act_as_table data_table" style="width: 100%;">
<!-- Display partner header -->
<t t-call="account_financial_report.report_open_items_lines_header"/>
<!-- Display partner move lines --> <!-- Display partner move lines -->
<t t-foreach="Open_Items[account_id][partner_id]" t-as="line" >
<t t-call="account_financial_report.report_open_items_lines"/> <t t-call="account_financial_report.report_open_items_lines"/>
<!-- Display partner footer -->
</t>
</div>
<t t-call="account_financial_report.report_open_items_ending_cumul"> <t t-call="account_financial_report.report_open_items_ending_cumul">
<t t-set="account_or_partner_id" t-value="partners_data[partner_id]"/> <t t-set="account_or_partner_id" t-value="partners_data[partner_id]"/>
<t t-set="currency_id" t-value="accounts_data[account_id]['currency_name']"/> <t t-set="currency_id" t-value="accounts_data[account_id]['currency_name']"/>
<t t-set="type" t-value='"partner_type"'/> <t t-set="type" t-value='"partner_type"'/>
</t> </t>
</t>
</div> </div>
</t> </t>
<!-- Display account footer --> <!-- Display account footer -->
<t t-call="account_financial_report.report_open_items_ending_cumul"> <t t-call="account_financial_report.report_open_items_ending_cumul">
<t t-set="account_or_partner_id" t-value="accounts_data[account_id]"/> <t t-set="account_or_partner_id" t-value="accounts_data[account_id]"/>
<t t-set="currency_id" t-value="accounts_data[account_id]['currency_name']"/> <t t-set="currency_id" t-value="accounts_data[account_id]['currency_name']"/>
<t t-set="type" t-value='"account_type"'/> <t t-set="type" t-value='"account_type"'/>
</t> </t>
</div>
</t> </t>
</div> </div>
</template> </template>
@ -89,8 +99,7 @@
</div> </div>
</template> </template>
<template id="account_financial_report.report_open_items_lines">
<div class="act_as_table data_table" style="width: 100%;">
<template id="account_financial_report.report_open_items_lines_header">
<!-- Display table headers for lines --> <!-- Display table headers for lines -->
<div class="act_as_thead"> <div class="act_as_thead">
<div class="act_as_row labels"> <div class="act_as_row labels">
@ -127,9 +136,9 @@
</t> </t>
</div> </div>
</div> </div>
</template>
<!-- Display each lines -->
<t t-foreach="Open_Items[account_id][partner_id]" t-as="line" >
<template id="account_financial_report.report_open_items_lines">
<!-- # lines or centralized lines --> <!-- # lines or centralized lines -->
<div class="act_as_row lines"> <div class="act_as_row lines">
<!--## date--> <!--## date-->
@ -202,8 +211,6 @@
</t> </t>
</t> </t>
</div> </div>
</t>
</div>
</template> </template>
<template id="account_financial_report.report_open_items_ending_cumul"> <template id="account_financial_report.report_open_items_ending_cumul">

5
account_financial_report/wizard/open_items_wizard.py

@ -53,6 +53,10 @@ class OpenItemsReportWizard(models.TransientModel):
'will display initial and final balance in that currency.', 'will display initial and final balance in that currency.',
default=lambda self: self._default_foreign_currency(), default=lambda self: self._default_foreign_currency(),
) )
show_partner_details = fields.Boolean(
string='Show Partner Details',
default=True,
)
def _default_foreign_currency(self): def _default_foreign_currency(self):
return self.env.user.has_group('base.group_multi_currency') return self.env.user.has_group('base.group_multi_currency')
@ -135,6 +139,7 @@ class OpenItemsReportWizard(models.TransientModel):
'only_posted_moves': self.target_move == 'posted', 'only_posted_moves': self.target_move == 'posted',
'hide_account_at_0': self.hide_account_at_0, 'hide_account_at_0': self.hide_account_at_0,
'foreign_currency': self.foreign_currency, 'foreign_currency': self.foreign_currency,
'show_partner_details': self.show_partner_details,
'company_id': self.company_id.id, 'company_id': self.company_id.id,
'target_move': self.target_move, 'target_move': self.target_move,
'account_ids': self.account_ids.ids, 'account_ids': self.account_ids.ids,

1
account_financial_report/wizard/open_items_wizard_view.xml

@ -17,6 +17,7 @@
</group> </group>
<group name="other_filters"> <group name="other_filters">
<field name="target_move" widget="radio"/> <field name="target_move" widget="radio"/>
<field name="show_partner_details"/>
<field name="hide_account_at_0"/> <field name="hide_account_at_0"/>
<field name="foreign_currency"/> <field name="foreign_currency"/>
</group> </group>

Loading…
Cancel
Save