[11.0][IMP] account_financial_report - foreign_currency
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from . import aged_partner_balance_wizard
|
||||
from . import general_ledger_wizard
|
||||
from . import journal_ledger_wizard
|
||||
from . import open_items_wizard
|
||||
from . import trial_balance_wizard
|
||||
from . import vat_report_wizard
|
||||
|
||||
@@ -9,7 +9,7 @@ from odoo.tools.safe_eval import safe_eval
|
||||
from odoo.tools import pycompat
|
||||
|
||||
|
||||
class AgedPartnerBalance(models.TransientModel):
|
||||
class AgedPartnerBalanceWizard(models.TransientModel):
|
||||
"""Aged partner balance report wizard."""
|
||||
|
||||
_name = 'aged.partner.balance.wizard'
|
||||
|
||||
@@ -63,6 +63,12 @@ class GeneralLedgerReportWizard(models.TransientModel):
|
||||
readonly=True,
|
||||
string='Not only one unaffected earnings account'
|
||||
)
|
||||
foreign_currency = fields.Boolean(
|
||||
string='Show foreign currency',
|
||||
help='Display foreign currency for move lines, unless '
|
||||
'account currency is not setup through chart of accounts '
|
||||
'will display initial and final balance in that currency.'
|
||||
)
|
||||
|
||||
@api.depends('date_from')
|
||||
def _compute_fy_start_date(self):
|
||||
@@ -147,6 +153,7 @@ class GeneralLedgerReportWizard(models.TransientModel):
|
||||
'date_to': self.date_to,
|
||||
'only_posted_moves': self.target_move == 'posted',
|
||||
'hide_account_balance_at_0': self.hide_account_balance_at_0,
|
||||
'foreign_currency': self.foreign_currency,
|
||||
'company_id': self.company_id.id,
|
||||
'filter_account_ids': [(6, 0, self.account_ids.ids)],
|
||||
'filter_partner_ids': [(6, 0, self.partner_ids.ids)],
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
<field name="target_move" widget="radio"/>
|
||||
<field name="centralize"/>
|
||||
<field name="hide_account_balance_at_0"/>
|
||||
<field name="foreign_currency"/>
|
||||
</group>
|
||||
</group>
|
||||
<label for="cost_center_ids" groups="analytic.group_analytic_accounting"/>
|
||||
|
||||
142
account_financial_report/wizard/journal_ledger_wizard.py
Normal file
142
account_financial_report/wizard/journal_ledger_wizard.py
Normal file
@@ -0,0 +1,142 @@
|
||||
# Copyright 2017 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.tools.safe_eval import safe_eval
|
||||
from odoo.tools import pycompat
|
||||
|
||||
|
||||
class JournalLedgerReportWizard(models.TransientModel):
|
||||
"""Journal Ledger report wizard."""
|
||||
|
||||
_name = 'journal.ledger.report.wizard'
|
||||
_description = "Journal Ledger Report Wizard"
|
||||
|
||||
company_id = fields.Many2one(
|
||||
comodel_name='res.company',
|
||||
default=lambda self: self.env.user.company_id,
|
||||
string='Company',
|
||||
required=True,
|
||||
ondelete='cascade',
|
||||
)
|
||||
date_range_id = fields.Many2one(
|
||||
comodel_name='date.range',
|
||||
string='Date range',
|
||||
domain="['|', "
|
||||
"('company_id', '=', False),"
|
||||
"('company_id', '=', company_id)]",
|
||||
)
|
||||
date_from = fields.Date(
|
||||
string="Start date",
|
||||
required=True
|
||||
)
|
||||
date_to = fields.Date(
|
||||
string="End date",
|
||||
required=True
|
||||
)
|
||||
journal_ids = fields.Many2many(
|
||||
comodel_name='account.journal',
|
||||
string="Journals",
|
||||
domain="[('company_id', '=', company_id)]",
|
||||
required=True,
|
||||
)
|
||||
move_target = fields.Selection(
|
||||
selection='_get_move_targets',
|
||||
default='all',
|
||||
required=True,
|
||||
)
|
||||
foreign_currency = fields.Boolean()
|
||||
sort_option = fields.Selection(
|
||||
selection='_get_sort_options',
|
||||
string="Sort entries by",
|
||||
default='move_name',
|
||||
required=True,
|
||||
)
|
||||
group_option = fields.Selection(
|
||||
selection='_get_group_options',
|
||||
string="Group entries by",
|
||||
default='journal',
|
||||
required=True,
|
||||
)
|
||||
with_account_name = fields.Boolean(
|
||||
default=False,
|
||||
)
|
||||
|
||||
@api.model
|
||||
def _get_move_targets(self):
|
||||
return [
|
||||
('all', _("All")),
|
||||
('posted', _("Posted")),
|
||||
('draft', _("Not Posted"))
|
||||
]
|
||||
|
||||
@api.model
|
||||
def _get_sort_options(self):
|
||||
return [
|
||||
('move_name', _("Entry number")),
|
||||
('date', _("Date")),
|
||||
]
|
||||
|
||||
@api.model
|
||||
def _get_group_options(self):
|
||||
return [
|
||||
('journal', _("Journal")),
|
||||
('none', _("No group")),
|
||||
]
|
||||
|
||||
@api.onchange('date_range_id')
|
||||
def onchange_date_range_id(self):
|
||||
self.date_from = self.date_range_id.date_start
|
||||
self.date_to = self.date_range_id.date_end
|
||||
|
||||
@api.multi
|
||||
def button_export_html(self):
|
||||
self.ensure_one()
|
||||
action = self.env.ref(
|
||||
'account_financial_report.action_report_journal_ledger')
|
||||
vals = action.read()[0]
|
||||
context1 = vals.get('context', {})
|
||||
if isinstance(context1, pycompat.string_types):
|
||||
context1 = safe_eval(context1)
|
||||
model = self.env['report_journal_ledger']
|
||||
report = model.create(self._prepare_report_journal_ledger())
|
||||
report.compute_data_for_report()
|
||||
context1['active_id'] = report.id
|
||||
context1['active_ids'] = report.ids
|
||||
vals['context'] = context1
|
||||
return vals
|
||||
|
||||
@api.multi
|
||||
def button_export_pdf(self):
|
||||
self.ensure_one()
|
||||
report_type = 'qweb-pdf'
|
||||
return self._export(report_type)
|
||||
|
||||
@api.multi
|
||||
def button_export_xlsx(self):
|
||||
self.ensure_one()
|
||||
report_type = 'xlsx'
|
||||
return self._export(report_type)
|
||||
|
||||
@api.multi
|
||||
def _prepare_report_journal_ledger(self):
|
||||
self.ensure_one()
|
||||
return {
|
||||
'date_from': self.date_from,
|
||||
'date_to': self.date_to,
|
||||
'move_target': self.move_target,
|
||||
'foreign_currency': self.foreign_currency,
|
||||
'company_id': self.company_id.id,
|
||||
'journal_ids': [(6, 0, self.journal_ids.ids)],
|
||||
'sort_option': self.sort_option,
|
||||
'group_option': self.group_option,
|
||||
'with_account_name': self.with_account_name,
|
||||
}
|
||||
|
||||
def _export(self, report_type):
|
||||
"""Default export is PDF."""
|
||||
self.ensure_one()
|
||||
model = self.env['report_journal_ledger']
|
||||
report = model.create(self._prepare_report_journal_ledger())
|
||||
report.compute_data_for_report()
|
||||
return report.print_report(report_type)
|
||||
@@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright 2017 ACSONE SA/NV
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
|
||||
|
||||
<odoo>
|
||||
|
||||
|
||||
<record id="journal_ledger_wizard" model="ir.ui.view">
|
||||
<field name="name">Journal Ledger</field>
|
||||
<field name="model">journal.ledger.report.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<group>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
</group>
|
||||
|
||||
<separator string="Periods"/>
|
||||
<group>
|
||||
<group>
|
||||
<field name="date_range_id"/>
|
||||
<field name="date_from"/>
|
||||
<field name="date_to"/>
|
||||
</group>
|
||||
<group/>
|
||||
</group>
|
||||
|
||||
<separator string="Options"/>
|
||||
<group name="options">
|
||||
<group>
|
||||
<field name="move_target" widget="radio" options="{'horizontal': true}"/>
|
||||
<field name="sort_option"/>
|
||||
<field name="group_option"/>
|
||||
<field name="foreign_currency"/>
|
||||
<field name="with_account_name"/>
|
||||
</group>
|
||||
<group/>
|
||||
</group>
|
||||
|
||||
<separator string="Journals"/>
|
||||
<group>
|
||||
<field name="journal_ids" widget="many2many_tags"/>
|
||||
</group>
|
||||
|
||||
<footer>
|
||||
<button name="button_export_html" string="View"
|
||||
type="object" default_focus="1" class="oe_highlight"/>
|
||||
or
|
||||
<button name="button_export_pdf" string="Export PDF" type="object"/>
|
||||
or
|
||||
<button name="button_export_xlsx" string="Export XLSX" type="object"/>
|
||||
or
|
||||
<button string="Cancel" class="oe_link" special="cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<act_window id="action_journal_ledger_wizard"
|
||||
name="Journal Ledger"
|
||||
res_model="journal.ledger.report.wizard"
|
||||
view_type="form"
|
||||
view_mode="form"
|
||||
view_id="journal_ledger_wizard"
|
||||
target="new" />
|
||||
|
||||
</odoo>
|
||||
@@ -45,6 +45,12 @@ class OpenItemsReportWizard(models.TransientModel):
|
||||
comodel_name='res.partner',
|
||||
string='Filter partners',
|
||||
)
|
||||
foreign_currency = fields.Boolean(
|
||||
string='Show foreign currency',
|
||||
help='Display foreign currency for move lines, unless '
|
||||
'account currency is not setup through chart of accounts '
|
||||
'will display initial and final balance in that currency.'
|
||||
)
|
||||
|
||||
@api.onchange('receivable_accounts_only', 'payable_accounts_only')
|
||||
def onchange_type_accounts_only(self):
|
||||
@@ -97,6 +103,7 @@ class OpenItemsReportWizard(models.TransientModel):
|
||||
'date_at': self.date_at,
|
||||
'only_posted_moves': self.target_move == 'posted',
|
||||
'hide_account_balance_at_0': self.hide_account_balance_at_0,
|
||||
'foreign_currency': self.foreign_currency,
|
||||
'company_id': self.company_id.id,
|
||||
'filter_account_ids': [(6, 0, self.account_ids.ids)],
|
||||
'filter_partner_ids': [(6, 0, self.partner_ids.ids)],
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
<group name="other_filters">
|
||||
<field name="target_move" widget="radio"/>
|
||||
<field name="hide_account_balance_at_0"/>
|
||||
<field name="foreign_currency"/>
|
||||
</group>
|
||||
</group>
|
||||
<label for="partner_ids"/>
|
||||
|
||||
@@ -60,6 +60,13 @@ class TrialBalanceReportWizard(models.TransientModel):
|
||||
string='Not only one unaffected earnings account'
|
||||
)
|
||||
|
||||
foreign_currency = fields.Boolean(
|
||||
string='Show foreign currency',
|
||||
help='Display foreign currency for move lines, unless '
|
||||
'account currency is not setup through chart of accounts '
|
||||
'will display initial and final balance in that currency.'
|
||||
)
|
||||
|
||||
@api.depends('date_from')
|
||||
def _compute_fy_start_date(self):
|
||||
for wiz in self.filtered('date_from'):
|
||||
@@ -146,6 +153,7 @@ class TrialBalanceReportWizard(models.TransientModel):
|
||||
'date_to': self.date_to,
|
||||
'only_posted_moves': self.target_move == 'posted',
|
||||
'hide_account_balance_at_0': self.hide_account_balance_at_0,
|
||||
'foreign_currency': self.foreign_currency,
|
||||
'company_id': self.company_id.id,
|
||||
'filter_account_ids': [(6, 0, self.account_ids.ids)],
|
||||
'filter_partner_ids': [(6, 0, self.partner_ids.ids)],
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
<field name="hide_account_balance_at_0"/>
|
||||
<field name="show_partner_details"/>
|
||||
<field name="hierarchy_on" widget="radio" attrs="{'invisible':[('show_partner_details','=',True)]}"/>
|
||||
<field name="foreign_currency"/>
|
||||
</group>
|
||||
</group>
|
||||
<label for="partner_ids" attrs="{'invisible':[('show_partner_details','!=',True)]}"/>
|
||||
|
||||
Reference in New Issue
Block a user