[IMP] account_financial_report: black, isort
This commit is contained in:
@@ -5,28 +5,25 @@ from odoo import models
|
||||
|
||||
|
||||
class AbstractWizard(models.AbstractModel):
|
||||
_name = 'account_financial_report_abstract_wizard'
|
||||
_description = 'Abstract Wizard'
|
||||
_name = "account_financial_report_abstract_wizard"
|
||||
_description = "Abstract Wizard"
|
||||
|
||||
def _get_partner_ids_domain(self):
|
||||
return [
|
||||
'&',
|
||||
'|',
|
||||
('company_id', '=', self.company_id.id),
|
||||
('company_id', '=', False),
|
||||
'|',
|
||||
('parent_id', '=', False),
|
||||
('is_company', '=', True),
|
||||
"&",
|
||||
"|",
|
||||
("company_id", "=", self.company_id.id),
|
||||
("company_id", "=", False),
|
||||
"|",
|
||||
("parent_id", "=", False),
|
||||
("is_company", "=", True),
|
||||
]
|
||||
|
||||
def _default_partners(self):
|
||||
context = self.env.context
|
||||
if (
|
||||
context.get('active_ids') and
|
||||
context.get('active_model') == 'res.partner'
|
||||
):
|
||||
partners = self.env['res.partner'].browse(context['active_ids'])
|
||||
corp_partners = partners.filtered('parent_id')
|
||||
if context.get("active_ids") and context.get("active_model") == "res.partner":
|
||||
partners = self.env["res.partner"].browse(context["active_ids"])
|
||||
corp_partners = partners.filtered("parent_id")
|
||||
partners -= corp_partners
|
||||
partners |= corp_partners.mapped('commercial_partner_id')
|
||||
partners |= corp_partners.mapped("commercial_partner_id")
|
||||
return partners.ids
|
||||
|
||||
@@ -9,114 +9,115 @@ from odoo import api, fields, models
|
||||
class AgedPartnerBalanceWizard(models.TransientModel):
|
||||
"""Aged partner balance report wizard."""
|
||||
|
||||
_name = 'aged.partner.balance.report.wizard'
|
||||
_description = 'Aged Partner Balance Wizard'
|
||||
_inherit = 'account_financial_report_abstract_wizard'
|
||||
_name = "aged.partner.balance.report.wizard"
|
||||
_description = "Aged Partner Balance Wizard"
|
||||
_inherit = "account_financial_report_abstract_wizard"
|
||||
|
||||
company_id = fields.Many2one(
|
||||
comodel_name='res.company',
|
||||
comodel_name="res.company",
|
||||
default=lambda self: self.env.user.company_id,
|
||||
required=False,
|
||||
string='Company'
|
||||
string="Company",
|
||||
)
|
||||
date_at = fields.Date(required=True, default=fields.Date.context_today)
|
||||
target_move = fields.Selection(
|
||||
[("posted", "All Posted Entries"), ("all", "All Entries")],
|
||||
string="Target Moves",
|
||||
required=True,
|
||||
default="all",
|
||||
)
|
||||
date_at = fields.Date(required=True,
|
||||
default=fields.Date.context_today)
|
||||
target_move = fields.Selection([('posted', 'All Posted Entries'),
|
||||
('all', 'All Entries')],
|
||||
string='Target Moves',
|
||||
required=True,
|
||||
default='all')
|
||||
account_ids = fields.Many2many(
|
||||
comodel_name='account.account',
|
||||
string='Filter accounts',
|
||||
comodel_name="account.account", string="Filter accounts",
|
||||
)
|
||||
receivable_accounts_only = fields.Boolean()
|
||||
payable_accounts_only = fields.Boolean()
|
||||
partner_ids = fields.Many2many(
|
||||
comodel_name='res.partner',
|
||||
string='Filter partners',
|
||||
comodel_name="res.partner", string="Filter partners",
|
||||
)
|
||||
show_move_line_details = fields.Boolean()
|
||||
|
||||
@api.onchange('company_id')
|
||||
@api.onchange("company_id")
|
||||
def onchange_company_id(self):
|
||||
"""Handle company change."""
|
||||
if self.company_id and self.partner_ids:
|
||||
self.partner_ids = self.partner_ids.filtered(
|
||||
lambda p: p.company_id == self.company_id or
|
||||
not p.company_id)
|
||||
lambda p: p.company_id == self.company_id or not p.company_id
|
||||
)
|
||||
if self.company_id and self.account_ids:
|
||||
if self.receivable_accounts_only or self.payable_accounts_only:
|
||||
self.onchange_type_accounts_only()
|
||||
else:
|
||||
self.account_ids = self.account_ids.filtered(
|
||||
lambda a: a.company_id == self.company_id)
|
||||
res = {'domain': {'account_ids': [],
|
||||
'partner_ids': []}}
|
||||
lambda a: a.company_id == self.company_id
|
||||
)
|
||||
res = {"domain": {"account_ids": [], "partner_ids": []}}
|
||||
if not self.company_id:
|
||||
return res
|
||||
else:
|
||||
res['domain']['account_ids'] += [
|
||||
('company_id', '=', self.company_id.id)]
|
||||
res['domain']['partner_ids'] += self._get_partner_ids_domain()
|
||||
res["domain"]["account_ids"] += [("company_id", "=", self.company_id.id)]
|
||||
res["domain"]["partner_ids"] += self._get_partner_ids_domain()
|
||||
return res
|
||||
|
||||
@api.onchange('receivable_accounts_only', 'payable_accounts_only')
|
||||
@api.onchange("receivable_accounts_only", "payable_accounts_only")
|
||||
def onchange_type_accounts_only(self):
|
||||
"""Handle receivable/payable accounts only change."""
|
||||
domain = [('company_id', '=', self.company_id.id)]
|
||||
domain = [("company_id", "=", self.company_id.id)]
|
||||
if self.receivable_accounts_only or self.payable_accounts_only:
|
||||
if self.receivable_accounts_only and self.payable_accounts_only:
|
||||
domain += [('internal_type', 'in', ('receivable', 'payable'))]
|
||||
domain += [("internal_type", "in", ("receivable", "payable"))]
|
||||
elif self.receivable_accounts_only:
|
||||
domain += [('internal_type', '=', 'receivable')]
|
||||
domain += [("internal_type", "=", "receivable")]
|
||||
elif self.payable_accounts_only:
|
||||
domain += [('internal_type', '=', 'payable')]
|
||||
domain += [("internal_type", "=", "payable")]
|
||||
elif not self.receivable_accounts_only and not self.payable_accounts_only:
|
||||
domain += [('reconcile', '=', True)]
|
||||
self.account_ids = self.env['account.account'].search(domain)
|
||||
domain += [("reconcile", "=", True)]
|
||||
self.account_ids = self.env["account.account"].search(domain)
|
||||
|
||||
@api.multi
|
||||
def _print_report(self, report_type):
|
||||
self.ensure_one()
|
||||
data = self._prepare_report_aged_partner_balance()
|
||||
if report_type == 'xlsx':
|
||||
report_name = 'a_f_r.report_aged_partner_balance_xlsx'
|
||||
if report_type == "xlsx":
|
||||
report_name = "a_f_r.report_aged_partner_balance_xlsx"
|
||||
else:
|
||||
report_name = 'account_financial_report.aged_partner_balance'
|
||||
return self.env['ir.actions.report'].search(
|
||||
[('report_name', '=', report_name),
|
||||
('report_type', '=', report_type)], limit=1).report_action(
|
||||
self, data=data)
|
||||
report_name = "account_financial_report.aged_partner_balance"
|
||||
return (
|
||||
self.env["ir.actions.report"]
|
||||
.search(
|
||||
[("report_name", "=", report_name), ("report_type", "=", report_type)],
|
||||
limit=1,
|
||||
)
|
||||
.report_action(self, data=data)
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def button_export_html(self):
|
||||
self.ensure_one()
|
||||
report_type = 'qweb-html'
|
||||
report_type = "qweb-html"
|
||||
return self._export(report_type)
|
||||
|
||||
@api.multi
|
||||
def button_export_pdf(self):
|
||||
self.ensure_one()
|
||||
report_type = 'qweb-pdf'
|
||||
report_type = "qweb-pdf"
|
||||
return self._export(report_type)
|
||||
|
||||
@api.multi
|
||||
def button_export_xlsx(self):
|
||||
self.ensure_one()
|
||||
report_type = 'xlsx'
|
||||
report_type = "xlsx"
|
||||
return self._export(report_type)
|
||||
|
||||
def _prepare_report_aged_partner_balance(self):
|
||||
self.ensure_one()
|
||||
return {
|
||||
'wizard_id': self.id,
|
||||
'date_at': self.date_at,
|
||||
'only_posted_moves': self.target_move == 'posted',
|
||||
'company_id': self.company_id.id,
|
||||
'account_ids': self.account_ids.ids,
|
||||
'partner_ids': self.partner_ids.ids,
|
||||
'show_move_line_details': self.show_move_line_details,
|
||||
"wizard_id": self.id,
|
||||
"date_at": self.date_at,
|
||||
"only_posted_moves": self.target_move == "posted",
|
||||
"company_id": self.company_id.id,
|
||||
"account_ids": self.account_ids.ids,
|
||||
"partner_ids": self.partner_ids.ids,
|
||||
"show_move_line_details": self.show_move_line_details,
|
||||
}
|
||||
|
||||
def _export(self, report_type):
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
|
||||
<!-- AGED PARTNER BALANCE -->
|
||||
<record id="aged_partner_balance_wizard" model="ir.ui.view">
|
||||
<field name="name">Aged Partner Balance</field>
|
||||
@@ -8,52 +7,75 @@
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<group name="main_info">
|
||||
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
|
||||
<field
|
||||
name="company_id"
|
||||
options="{'no_create': True}"
|
||||
groups="base.group_multi_company"
|
||||
/>
|
||||
</group>
|
||||
<group name="filters">
|
||||
<group name="date_range">
|
||||
<field name="date_at"/>
|
||||
<field name="date_at" />
|
||||
</group>
|
||||
<group name="other_filters">
|
||||
<field name="target_move" widget="radio"/>
|
||||
<field name="show_move_line_details"/>
|
||||
<field name="target_move" widget="radio" />
|
||||
<field name="show_move_line_details" />
|
||||
</group>
|
||||
</group>
|
||||
<group name="partner_filter" col="1">
|
||||
<label for="partner_ids"/>
|
||||
<field name="partner_ids" nolabel="1"
|
||||
widget="many2many_tags"
|
||||
options="{'no_create': True}"/>
|
||||
<label for="partner_ids" />
|
||||
<field
|
||||
name="partner_ids"
|
||||
nolabel="1"
|
||||
widget="many2many_tags"
|
||||
options="{'no_create': True}"
|
||||
/>
|
||||
</group>
|
||||
<group name="account_filter" col="4">
|
||||
<label for="account_ids" colspan="4"/>
|
||||
<field name="receivable_accounts_only"/>
|
||||
<field name="payable_accounts_only"/>
|
||||
<field name="account_ids" nolabel="1"
|
||||
widget="many2many_tags"
|
||||
options="{'no_create': True}"
|
||||
colspan="4"/>
|
||||
<label for="account_ids" colspan="4" />
|
||||
<field name="receivable_accounts_only" />
|
||||
<field name="payable_accounts_only" />
|
||||
<field
|
||||
name="account_ids"
|
||||
nolabel="1"
|
||||
widget="many2many_tags"
|
||||
options="{'no_create': True}"
|
||||
colspan="4"
|
||||
/>
|
||||
</group>
|
||||
<footer>
|
||||
<button name="button_export_html" string="View"
|
||||
type="object" default_focus="1" class="oe_highlight"/>
|
||||
<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"/>
|
||||
<button
|
||||
name="button_export_pdf"
|
||||
string="Export PDF"
|
||||
type="object"
|
||||
/>
|
||||
or
|
||||
<button name="button_export_xlsx" string="Export XLSX" type="object"/>
|
||||
<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_aged_partner_balance_wizard"
|
||||
name="Aged Partner Balance"
|
||||
res_model="aged.partner.balance.report.wizard"
|
||||
view_type="form"
|
||||
view_mode="form"
|
||||
view_id="aged_partner_balance_wizard"
|
||||
target="new" />
|
||||
|
||||
<act_window
|
||||
id="action_aged_partner_balance_wizard"
|
||||
name="Aged Partner Balance"
|
||||
res_model="aged.partner.balance.report.wizard"
|
||||
view_type="form"
|
||||
view_mode="form"
|
||||
view_id="aged_partner_balance_wizard"
|
||||
target="new"
|
||||
/>
|
||||
</odoo>
|
||||
|
||||
@@ -7,83 +7,72 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import ValidationError
|
||||
import time
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class GeneralLedgerReportWizard(models.TransientModel):
|
||||
"""General ledger report wizard."""
|
||||
|
||||
_name = "general.ledger.report.wizard"
|
||||
_description = "General Ledger Report Wizard"
|
||||
_inherit = 'account_financial_report_abstract_wizard'
|
||||
_inherit = "account_financial_report_abstract_wizard"
|
||||
|
||||
company_id = fields.Many2one(
|
||||
comodel_name='res.company',
|
||||
comodel_name="res.company",
|
||||
default=lambda self: self.env.user.company_id,
|
||||
required=False,
|
||||
string='Company'
|
||||
string="Company",
|
||||
)
|
||||
date_range_id = fields.Many2one(
|
||||
comodel_name='date.range',
|
||||
string='Date range'
|
||||
date_range_id = fields.Many2one(comodel_name="date.range", string="Date range")
|
||||
date_from = fields.Date(required=True, default=lambda self: self._init_date_from())
|
||||
date_to = fields.Date(required=True, default=fields.Date.context_today)
|
||||
fy_start_date = fields.Date(compute="_compute_fy_start_date")
|
||||
target_move = fields.Selection(
|
||||
[("posted", "All Posted Entries"), ("all", "All Entries")],
|
||||
string="Target Moves",
|
||||
required=True,
|
||||
default="all",
|
||||
)
|
||||
date_from = fields.Date(required=True,
|
||||
default=lambda self: self._init_date_from())
|
||||
date_to = fields.Date(required=True,
|
||||
default=fields.Date.context_today)
|
||||
fy_start_date = fields.Date(compute='_compute_fy_start_date')
|
||||
target_move = fields.Selection([('posted', 'All Posted Entries'),
|
||||
('all', 'All Entries')],
|
||||
string='Target Moves',
|
||||
required=True,
|
||||
default='all')
|
||||
account_ids = fields.Many2many(
|
||||
comodel_name='account.account',
|
||||
string='Filter accounts',
|
||||
comodel_name="account.account", string="Filter accounts",
|
||||
)
|
||||
centralize = fields.Boolean(string='Activate centralization',
|
||||
default=True)
|
||||
centralize = fields.Boolean(string="Activate centralization", default=True)
|
||||
hide_account_at_0 = fields.Boolean(
|
||||
string='Hide account ending balance at 0',
|
||||
help='Use this filter to hide an account or a partner '
|
||||
'with an ending balance at 0. '
|
||||
'If partners are filtered, '
|
||||
'debits and credits totals will not match the trial balance.'
|
||||
)
|
||||
show_analytic_tags = fields.Boolean(
|
||||
string='Show analytic tags',
|
||||
string="Hide account ending balance at 0",
|
||||
help="Use this filter to hide an account or a partner "
|
||||
"with an ending balance at 0. "
|
||||
"If partners are filtered, "
|
||||
"debits and credits totals will not match the trial balance.",
|
||||
)
|
||||
show_analytic_tags = fields.Boolean(string="Show analytic tags",)
|
||||
receivable_accounts_only = fields.Boolean()
|
||||
payable_accounts_only = fields.Boolean()
|
||||
partner_ids = fields.Many2many(
|
||||
comodel_name='res.partner',
|
||||
string='Filter partners',
|
||||
comodel_name="res.partner",
|
||||
string="Filter partners",
|
||||
default=lambda self: self._default_partners(),
|
||||
)
|
||||
analytic_tag_ids = fields.Many2many(
|
||||
comodel_name='account.analytic.tag',
|
||||
string='Filter analytic tags',
|
||||
comodel_name="account.analytic.tag", string="Filter analytic tags",
|
||||
)
|
||||
account_journal_ids = fields.Many2many(
|
||||
comodel_name='account.journal',
|
||||
string='Filter journals',
|
||||
comodel_name="account.journal", string="Filter journals",
|
||||
)
|
||||
cost_center_ids = fields.Many2many(
|
||||
comodel_name='account.analytic.account',
|
||||
string='Filter cost centers',
|
||||
comodel_name="account.analytic.account", string="Filter cost centers",
|
||||
)
|
||||
|
||||
not_only_one_unaffected_earnings_account = fields.Boolean(
|
||||
readonly=True,
|
||||
string='Not only one unaffected earnings account'
|
||||
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.',
|
||||
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.",
|
||||
default=lambda self: self._default_foreign_currency(),
|
||||
)
|
||||
|
||||
@@ -95,73 +84,87 @@ class GeneralLedgerReportWizard(models.TransientModel):
|
||||
last_fsc_month = self.env.user.company_id.fiscalyear_last_month
|
||||
last_fsc_day = self.env.user.company_id.fiscalyear_last_day
|
||||
|
||||
if cur_month < last_fsc_month \
|
||||
or cur_month == last_fsc_month and cur_day <= last_fsc_day:
|
||||
return time.strftime('%Y-01-01')
|
||||
if (
|
||||
cur_month < last_fsc_month
|
||||
or cur_month == last_fsc_month
|
||||
and cur_day <= last_fsc_day
|
||||
):
|
||||
return time.strftime("%Y-01-01")
|
||||
|
||||
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")
|
||||
|
||||
@api.depends('date_from')
|
||||
@api.depends("date_from")
|
||||
def _compute_fy_start_date(self):
|
||||
for wiz in self.filtered('date_from'):
|
||||
for wiz in self.filtered("date_from"):
|
||||
date = fields.Datetime.from_string(wiz.date_from)
|
||||
res = self.company_id.compute_fiscalyear_dates(date)
|
||||
wiz.fy_start_date = fields.Date.to_string(res['date_from'])
|
||||
wiz.fy_start_date = fields.Date.to_string(res["date_from"])
|
||||
|
||||
@api.onchange('company_id')
|
||||
@api.onchange("company_id")
|
||||
def onchange_company_id(self):
|
||||
"""Handle company change."""
|
||||
account_type = self.env.ref('account.data_unaffected_earnings')
|
||||
count = self.env['account.account'].search_count(
|
||||
account_type = self.env.ref("account.data_unaffected_earnings")
|
||||
count = self.env["account.account"].search_count(
|
||||
[
|
||||
('user_type_id', '=', account_type.id),
|
||||
('company_id', '=', self.company_id.id)
|
||||
])
|
||||
("user_type_id", "=", account_type.id),
|
||||
("company_id", "=", self.company_id.id),
|
||||
]
|
||||
)
|
||||
self.not_only_one_unaffected_earnings_account = count != 1
|
||||
if self.company_id and self.date_range_id.company_id and \
|
||||
self.date_range_id.company_id != self.company_id:
|
||||
if (
|
||||
self.company_id
|
||||
and self.date_range_id.company_id
|
||||
and self.date_range_id.company_id != self.company_id
|
||||
):
|
||||
self.date_range_id = False
|
||||
if self.company_id and self.account_journal_ids:
|
||||
self.account_journal_ids = self.account_journal_ids.filtered(
|
||||
lambda p: p.company_id == self.company_id or
|
||||
not p.company_id)
|
||||
lambda p: p.company_id == self.company_id or not p.company_id
|
||||
)
|
||||
if self.company_id and self.partner_ids:
|
||||
self.partner_ids = self.partner_ids.filtered(
|
||||
lambda p: p.company_id == self.company_id or
|
||||
not p.company_id)
|
||||
lambda p: p.company_id == self.company_id or not p.company_id
|
||||
)
|
||||
if self.company_id and self.account_ids:
|
||||
if self.receivable_accounts_only or self.payable_accounts_only:
|
||||
self.onchange_type_accounts_only()
|
||||
else:
|
||||
self.account_ids = self.account_ids.filtered(
|
||||
lambda a: a.company_id == self.company_id)
|
||||
lambda a: a.company_id == self.company_id
|
||||
)
|
||||
if self.company_id and self.cost_center_ids:
|
||||
self.cost_center_ids = self.cost_center_ids.filtered(
|
||||
lambda c: c.company_id == self.company_id)
|
||||
res = {'domain': {'account_ids': [],
|
||||
'partner_ids': [],
|
||||
'account_journal_ids': [],
|
||||
'cost_center_ids': [],
|
||||
'date_range_id': []
|
||||
}
|
||||
}
|
||||
lambda c: c.company_id == self.company_id
|
||||
)
|
||||
res = {
|
||||
"domain": {
|
||||
"account_ids": [],
|
||||
"partner_ids": [],
|
||||
"account_journal_ids": [],
|
||||
"cost_center_ids": [],
|
||||
"date_range_id": [],
|
||||
}
|
||||
}
|
||||
if not self.company_id:
|
||||
return res
|
||||
else:
|
||||
res['domain']['account_ids'] += [
|
||||
('company_id', '=', self.company_id.id)]
|
||||
res['domain']['account_journal_ids'] += [
|
||||
('company_id', '=', self.company_id.id)]
|
||||
res['domain']['partner_ids'] += self._get_partner_ids_domain()
|
||||
res['domain']['cost_center_ids'] += [
|
||||
('company_id', '=', self.company_id.id)]
|
||||
res['domain']['date_range_id'] += [
|
||||
'|', ('company_id', '=', self.company_id.id),
|
||||
('company_id', '=', False)]
|
||||
res["domain"]["account_ids"] += [("company_id", "=", self.company_id.id)]
|
||||
res["domain"]["account_journal_ids"] += [
|
||||
("company_id", "=", self.company_id.id)
|
||||
]
|
||||
res["domain"]["partner_ids"] += self._get_partner_ids_domain()
|
||||
res["domain"]["cost_center_ids"] += [
|
||||
("company_id", "=", self.company_id.id)
|
||||
]
|
||||
res["domain"]["date_range_id"] += [
|
||||
"|",
|
||||
("company_id", "=", self.company_id.id),
|
||||
("company_id", "=", False),
|
||||
]
|
||||
return res
|
||||
|
||||
@api.onchange('date_range_id')
|
||||
@api.onchange("date_range_id")
|
||||
def onchange_date_range_id(self):
|
||||
"""Handle date range change."""
|
||||
if self.date_range_id:
|
||||
@@ -169,31 +172,37 @@ class GeneralLedgerReportWizard(models.TransientModel):
|
||||
self.date_to = self.date_range_id.date_end
|
||||
|
||||
@api.multi
|
||||
@api.constrains('company_id', 'date_range_id')
|
||||
@api.constrains("company_id", "date_range_id")
|
||||
def _check_company_id_date_range_id(self):
|
||||
for rec in self.sudo():
|
||||
if rec.company_id and rec.date_range_id.company_id and\
|
||||
rec.company_id != rec.date_range_id.company_id:
|
||||
if (
|
||||
rec.company_id
|
||||
and rec.date_range_id.company_id
|
||||
and rec.company_id != rec.date_range_id.company_id
|
||||
):
|
||||
raise ValidationError(
|
||||
_('The Company in the General Ledger Report Wizard and in '
|
||||
'Date Range must be the same.'))
|
||||
_(
|
||||
"The Company in the General Ledger Report Wizard and in "
|
||||
"Date Range must be the same."
|
||||
)
|
||||
)
|
||||
|
||||
@api.onchange('receivable_accounts_only', 'payable_accounts_only')
|
||||
@api.onchange("receivable_accounts_only", "payable_accounts_only")
|
||||
def onchange_type_accounts_only(self):
|
||||
"""Handle receivable/payable accounts only change."""
|
||||
if self.receivable_accounts_only or self.payable_accounts_only:
|
||||
domain = [('company_id', '=', self.company_id.id)]
|
||||
domain = [("company_id", "=", self.company_id.id)]
|
||||
if self.receivable_accounts_only and self.payable_accounts_only:
|
||||
domain += [('internal_type', 'in', ('receivable', 'payable'))]
|
||||
domain += [("internal_type", "in", ("receivable", "payable"))]
|
||||
elif self.receivable_accounts_only:
|
||||
domain += [('internal_type', '=', 'receivable')]
|
||||
domain += [("internal_type", "=", "receivable")]
|
||||
elif self.payable_accounts_only:
|
||||
domain += [('internal_type', '=', 'payable')]
|
||||
self.account_ids = self.env['account.account'].search(domain)
|
||||
domain += [("internal_type", "=", "payable")]
|
||||
self.account_ids = self.env["account.account"].search(domain)
|
||||
else:
|
||||
self.account_ids = None
|
||||
|
||||
@api.onchange('partner_ids')
|
||||
@api.onchange("partner_ids")
|
||||
def onchange_partner_ids(self):
|
||||
"""Handle partners change."""
|
||||
if self.partner_ids:
|
||||
@@ -202,73 +211,77 @@ class GeneralLedgerReportWizard(models.TransientModel):
|
||||
self.receivable_accounts_only = self.payable_accounts_only = False
|
||||
|
||||
@api.multi
|
||||
@api.depends('company_id')
|
||||
@api.depends("company_id")
|
||||
def _compute_unaffected_earnings_account(self):
|
||||
account_type = self.env.ref('account.data_unaffected_earnings')
|
||||
account_type = self.env.ref("account.data_unaffected_earnings")
|
||||
for record in self:
|
||||
record.unaffected_earnings_account = self.env[
|
||||
'account.account'].search(
|
||||
record.unaffected_earnings_account = self.env["account.account"].search(
|
||||
[
|
||||
('user_type_id', '=', account_type.id),
|
||||
('company_id', '=', record.company_id.id)
|
||||
])
|
||||
("user_type_id", "=", account_type.id),
|
||||
("company_id", "=", record.company_id.id),
|
||||
]
|
||||
)
|
||||
|
||||
unaffected_earnings_account = fields.Many2one(
|
||||
comodel_name='account.account',
|
||||
compute='_compute_unaffected_earnings_account',
|
||||
store=True
|
||||
comodel_name="account.account",
|
||||
compute="_compute_unaffected_earnings_account",
|
||||
store=True,
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def _print_report(self, report_type):
|
||||
self.ensure_one()
|
||||
data = self._prepare_report_general_ledger()
|
||||
if report_type == 'xlsx':
|
||||
report_name = 'a_f_r.report_general_ledger_xlsx'
|
||||
if report_type == "xlsx":
|
||||
report_name = "a_f_r.report_general_ledger_xlsx"
|
||||
else:
|
||||
report_name = 'account_financial_report.general_ledger'
|
||||
return self.env['ir.actions.report'].search(
|
||||
[('report_name', '=', report_name),
|
||||
('report_type', '=', report_type)], limit=1).report_action(
|
||||
self, data=data)
|
||||
report_name = "account_financial_report.general_ledger"
|
||||
return (
|
||||
self.env["ir.actions.report"]
|
||||
.search(
|
||||
[("report_name", "=", report_name), ("report_type", "=", report_type)],
|
||||
limit=1,
|
||||
)
|
||||
.report_action(self, data=data)
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def button_export_html(self):
|
||||
self.ensure_one()
|
||||
report_type = 'qweb-html'
|
||||
report_type = "qweb-html"
|
||||
return self._export(report_type)
|
||||
|
||||
@api.multi
|
||||
def button_export_pdf(self):
|
||||
self.ensure_one()
|
||||
report_type = 'qweb-pdf'
|
||||
report_type = "qweb-pdf"
|
||||
return self._export(report_type)
|
||||
|
||||
@api.multi
|
||||
def button_export_xlsx(self):
|
||||
self.ensure_one()
|
||||
report_type = 'xlsx'
|
||||
report_type = "xlsx"
|
||||
return self._export(report_type)
|
||||
|
||||
def _prepare_report_general_ledger(self):
|
||||
self.ensure_one()
|
||||
return {
|
||||
'wizard_id': self.id,
|
||||
'date_from': self.date_from,
|
||||
'date_to': self.date_to,
|
||||
'only_posted_moves': self.target_move == 'posted',
|
||||
'hide_account_at_0': self.hide_account_at_0,
|
||||
'foreign_currency': self.foreign_currency,
|
||||
'show_analytic_tags': self.show_analytic_tags,
|
||||
'company_id': self.company_id.id,
|
||||
'account_ids': self.account_ids.ids,
|
||||
'partner_ids': self.partner_ids.ids,
|
||||
'cost_center_ids': self.cost_center_ids.ids,
|
||||
'analytic_tag_ids': self.analytic_tag_ids.ids,
|
||||
'journal_ids': self.account_journal_ids.ids,
|
||||
'centralize': self.centralize,
|
||||
'fy_start_date': self.fy_start_date,
|
||||
'unaffected_earnings_account': self.unaffected_earnings_account.id,
|
||||
"wizard_id": self.id,
|
||||
"date_from": self.date_from,
|
||||
"date_to": self.date_to,
|
||||
"only_posted_moves": self.target_move == "posted",
|
||||
"hide_account_at_0": self.hide_account_at_0,
|
||||
"foreign_currency": self.foreign_currency,
|
||||
"show_analytic_tags": self.show_analytic_tags,
|
||||
"company_id": self.company_id.id,
|
||||
"account_ids": self.account_ids.ids,
|
||||
"partner_ids": self.partner_ids.ids,
|
||||
"cost_center_ids": self.cost_center_ids.ids,
|
||||
"analytic_tag_ids": self.analytic_tag_ids.ids,
|
||||
"journal_ids": self.account_journal_ids.ids,
|
||||
"centralize": self.centralize,
|
||||
"fy_start_date": self.fy_start_date,
|
||||
"unaffected_earnings_account": self.unaffected_earnings_account.id,
|
||||
}
|
||||
|
||||
def _export(self, report_type):
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
|
||||
<!-- GENERAL LEDGER -->
|
||||
<record id="general_ledger_wizard" model="ir.ui.view">
|
||||
<field name="name">General Ledger</field>
|
||||
@@ -8,95 +7,141 @@
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<group name="main_info">
|
||||
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
|
||||
<field
|
||||
name="company_id"
|
||||
options="{'no_create': True}"
|
||||
groups="base.group_multi_company"
|
||||
/>
|
||||
</group>
|
||||
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', True)]}">
|
||||
<div
|
||||
attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', True)]}"
|
||||
>
|
||||
<group name="filters">
|
||||
<group name="date_range">
|
||||
<field name="date_range_id"/>
|
||||
<field name="date_from"/>
|
||||
<field name="date_to"/>
|
||||
<field name="fy_start_date" invisible="1"/>
|
||||
<field name="date_range_id" />
|
||||
<field name="date_from" />
|
||||
<field name="date_to" />
|
||||
<field name="fy_start_date" invisible="1" />
|
||||
</group>
|
||||
<group name="other_filters">
|
||||
<field name="target_move" widget="radio"/>
|
||||
<field name="centralize"/>
|
||||
<field name="hide_account_at_0"/>
|
||||
<field name="foreign_currency"/>
|
||||
<field name="show_analytic_tags"/>
|
||||
<field name="target_move" widget="radio" />
|
||||
<field name="centralize" />
|
||||
<field name="hide_account_at_0" />
|
||||
<field name="foreign_currency" />
|
||||
<field name="show_analytic_tags" />
|
||||
</group>
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="Filter accounts">
|
||||
<group col="4">
|
||||
<field name="receivable_accounts_only"/>
|
||||
<field name="payable_accounts_only"/>
|
||||
<field name="receivable_accounts_only" />
|
||||
<field name="payable_accounts_only" />
|
||||
</group>
|
||||
<field name="account_ids"
|
||||
nolabel="1"
|
||||
widget="many2many_tags"
|
||||
options="{'no_create': True}"/>
|
||||
<field
|
||||
name="account_ids"
|
||||
nolabel="1"
|
||||
widget="many2many_tags"
|
||||
options="{'no_create': True}"
|
||||
/>
|
||||
</page>
|
||||
<page string="Filter partners">
|
||||
<field name="partner_ids" nolabel="1"
|
||||
widget="many2many_tags"
|
||||
options="{'no_create': True}"/>
|
||||
<field
|
||||
name="partner_ids"
|
||||
nolabel="1"
|
||||
widget="many2many_tags"
|
||||
options="{'no_create': True}"
|
||||
/>
|
||||
</page>
|
||||
<page string="Filter cost centers" groups="analytic.group_analytic_accounting">
|
||||
<field name="cost_center_ids" nolabel="1"
|
||||
options="{'no_create': True}"
|
||||
groups="analytic.group_analytic_accounting"/>
|
||||
<page
|
||||
string="Filter cost centers"
|
||||
groups="analytic.group_analytic_accounting"
|
||||
>
|
||||
<field
|
||||
name="cost_center_ids"
|
||||
nolabel="1"
|
||||
options="{'no_create': True}"
|
||||
groups="analytic.group_analytic_accounting"
|
||||
/>
|
||||
</page>
|
||||
<page string="Filter analytic tags">
|
||||
<field name="analytic_tag_ids" widget="many2many_tags" nolabel="1" options="{'no_create': True}"/>
|
||||
<field
|
||||
name="analytic_tag_ids"
|
||||
widget="many2many_tags"
|
||||
nolabel="1"
|
||||
options="{'no_create': True}"
|
||||
/>
|
||||
</page>
|
||||
</notebook>
|
||||
</div>
|
||||
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', False)]}">
|
||||
<field name="not_only_one_unaffected_earnings_account" invisible="1"/>
|
||||
<group/>
|
||||
<h4>General Ledger can be computed only if selected company have only one unaffected earnings account.</h4>
|
||||
<group/>
|
||||
<div
|
||||
attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', False)]}"
|
||||
>
|
||||
<field
|
||||
name="not_only_one_unaffected_earnings_account"
|
||||
invisible="1"
|
||||
/>
|
||||
<group />
|
||||
<h4
|
||||
>General Ledger can be computed only if selected company have only one unaffected earnings account.</h4>
|
||||
<group />
|
||||
</div>
|
||||
<footer>
|
||||
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', True)]}">
|
||||
<button name="button_export_html" string="View"
|
||||
type="object" default_focus="1" class="oe_highlight"/>
|
||||
<div
|
||||
attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', True)]}"
|
||||
>
|
||||
<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"/>
|
||||
<button
|
||||
name="button_export_pdf"
|
||||
string="Export PDF"
|
||||
type="object"
|
||||
/>
|
||||
or
|
||||
<button name="button_export_xlsx" string="Export XLSX" type="object"/>
|
||||
<button
|
||||
name="button_export_xlsx"
|
||||
string="Export XLSX"
|
||||
type="object"
|
||||
/>
|
||||
or
|
||||
<button string="Cancel" class="oe_link" special="cancel" />
|
||||
</div>
|
||||
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', False)]}">
|
||||
<div
|
||||
attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', False)]}"
|
||||
>
|
||||
<button string="Cancel" class="oe_link" special="cancel" />
|
||||
</div>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<act_window id="action_general_ledger_wizard"
|
||||
name="General Ledger"
|
||||
res_model="general.ledger.report.wizard"
|
||||
view_type="form"
|
||||
view_mode="form"
|
||||
view_id="general_ledger_wizard"
|
||||
target="new" />
|
||||
|
||||
<act_window
|
||||
id="action_general_ledger_wizard"
|
||||
name="General Ledger"
|
||||
res_model="general.ledger.report.wizard"
|
||||
view_type="form"
|
||||
view_mode="form"
|
||||
view_id="general_ledger_wizard"
|
||||
target="new"
|
||||
/>
|
||||
<!--Add to res.partner action-->
|
||||
<act_window id="act_action_general_ledger_wizard_partner_relation"
|
||||
name="General Ledger"
|
||||
res_model="general.ledger.report.wizard"
|
||||
src_model="res.partner"
|
||||
view_mode="form"
|
||||
context="{
|
||||
<act_window
|
||||
id="act_action_general_ledger_wizard_partner_relation"
|
||||
name="General Ledger"
|
||||
res_model="general.ledger.report.wizard"
|
||||
src_model="res.partner"
|
||||
view_mode="form"
|
||||
context="{
|
||||
'default_receivable_accounts_only':1,
|
||||
'default_payable_accounts_only':1,
|
||||
}"
|
||||
groups="account.group_account_manager"
|
||||
key2="client_action_multi"
|
||||
target="new" />
|
||||
|
||||
groups="account.group_account_manager"
|
||||
key2="client_action_multi"
|
||||
target="new"
|
||||
/>
|
||||
</odoo>
|
||||
|
||||
@@ -1,133 +1,121 @@
|
||||
# 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 import _, api, fields, models
|
||||
|
||||
|
||||
class JournalLedgerReportWizard(models.TransientModel):
|
||||
"""Journal Ledger report wizard."""
|
||||
|
||||
_name = 'journal.ledger.report.wizard'
|
||||
_name = "journal.ledger.report.wizard"
|
||||
_description = "Journal Ledger Report Wizard"
|
||||
|
||||
company_id = fields.Many2one(
|
||||
comodel_name='res.company',
|
||||
comodel_name="res.company",
|
||||
default=lambda self: self.env.user.company_id,
|
||||
string='Company',
|
||||
string="Company",
|
||||
required=False,
|
||||
ondelete='cascade',
|
||||
)
|
||||
date_range_id = fields.Many2one(
|
||||
comodel_name='date.range',
|
||||
string='Date range',
|
||||
)
|
||||
date_from = fields.Date(
|
||||
string="Start date",
|
||||
required=True
|
||||
)
|
||||
date_to = fields.Date(
|
||||
string="End date",
|
||||
required=True
|
||||
ondelete="cascade",
|
||||
)
|
||||
date_range_id = fields.Many2one(comodel_name="date.range", string="Date range",)
|
||||
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",
|
||||
required=False,
|
||||
comodel_name="account.journal", string="Journals", required=False,
|
||||
)
|
||||
move_target = fields.Selection(
|
||||
selection='_get_move_targets',
|
||||
default='all',
|
||||
required=True,
|
||||
selection="_get_move_targets", default="all", required=True,
|
||||
)
|
||||
foreign_currency = fields.Boolean()
|
||||
sort_option = fields.Selection(
|
||||
selection='_get_sort_options',
|
||||
selection="_get_sort_options",
|
||||
string="Sort entries by",
|
||||
default='move_name',
|
||||
default="move_name",
|
||||
required=True,
|
||||
)
|
||||
group_option = fields.Selection(
|
||||
selection='_get_group_options',
|
||||
selection="_get_group_options",
|
||||
string="Group entries by",
|
||||
default='journal',
|
||||
default="journal",
|
||||
required=True,
|
||||
)
|
||||
with_account_name = fields.Boolean(
|
||||
default=False,
|
||||
)
|
||||
with_account_name = fields.Boolean(default=False,)
|
||||
|
||||
@api.model
|
||||
def _get_move_targets(self):
|
||||
return [
|
||||
('all', _("All")),
|
||||
('posted', _("Posted")),
|
||||
('draft', _("Not Posted"))
|
||||
]
|
||||
return [("all", _("All")), ("posted", _("Posted")), ("draft", _("Not Posted"))]
|
||||
|
||||
@api.model
|
||||
def _get_sort_options(self):
|
||||
return [
|
||||
('move_name', _("Entry number")),
|
||||
('date', _("Date")),
|
||||
("move_name", _("Entry number")),
|
||||
("date", _("Date")),
|
||||
]
|
||||
|
||||
@api.model
|
||||
def _get_group_options(self):
|
||||
return [
|
||||
('journal', _("Journal")),
|
||||
('none', _("No group")),
|
||||
("journal", _("Journal")),
|
||||
("none", _("No group")),
|
||||
]
|
||||
|
||||
@api.onchange('date_range_id')
|
||||
@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.onchange('company_id')
|
||||
@api.onchange("company_id")
|
||||
def onchange_company_id(self):
|
||||
"""Handle company change."""
|
||||
if self.company_id and self.date_range_id.company_id and \
|
||||
self.date_range_id.company_id != self.company_id:
|
||||
if (
|
||||
self.company_id
|
||||
and self.date_range_id.company_id
|
||||
and self.date_range_id.company_id != self.company_id
|
||||
):
|
||||
self.date_range_id = False
|
||||
if self.company_id and self.journal_ids:
|
||||
self.journal_ids = self.journal_ids.filtered(
|
||||
lambda p: p.company_id == self.company_id or not p.company_id)
|
||||
res = {'domain': {'journal_ids': []}}
|
||||
lambda p: p.company_id == self.company_id or not p.company_id
|
||||
)
|
||||
res = {"domain": {"journal_ids": []}}
|
||||
if not self.company_id:
|
||||
return res
|
||||
else:
|
||||
res['domain']['journal_ids'] += [
|
||||
('company_id', '=', self.company_id.id)]
|
||||
res["domain"]["journal_ids"] += [("company_id", "=", self.company_id.id)]
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
def _print_report(self, report_type):
|
||||
self.ensure_one()
|
||||
data = self._prepare_report_journal_ledger()
|
||||
if report_type == 'xlsx':
|
||||
report_name = 'a_f_r.report_journal_ledger_xlsx'
|
||||
if report_type == "xlsx":
|
||||
report_name = "a_f_r.report_journal_ledger_xlsx"
|
||||
else:
|
||||
report_name = 'account_financial_report.journal_ledger'
|
||||
return self.env['ir.actions.report'].search(
|
||||
[('report_name', '=', report_name),
|
||||
('report_type', '=', report_type)], limit=1).report_action(
|
||||
self, data=data)
|
||||
report_name = "account_financial_report.journal_ledger"
|
||||
return (
|
||||
self.env["ir.actions.report"]
|
||||
.search(
|
||||
[("report_name", "=", report_name), ("report_type", "=", report_type)],
|
||||
limit=1,
|
||||
)
|
||||
.report_action(self, data=data)
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def button_export_html(self):
|
||||
self.ensure_one()
|
||||
report_type = 'qweb-html'
|
||||
report_type = "qweb-html"
|
||||
return self._export(report_type)
|
||||
|
||||
@api.multi
|
||||
def button_export_pdf(self):
|
||||
report_type = 'qweb-pdf'
|
||||
report_type = "qweb-pdf"
|
||||
return self._export(report_type)
|
||||
|
||||
@api.multi
|
||||
def button_export_xlsx(self):
|
||||
self.ensure_one()
|
||||
report_type = 'xlsx'
|
||||
report_type = "xlsx"
|
||||
return self._export(report_type)
|
||||
|
||||
@api.multi
|
||||
@@ -136,19 +124,20 @@ class JournalLedgerReportWizard(models.TransientModel):
|
||||
journals = self.journal_ids
|
||||
if not journals:
|
||||
# Not selecting a journal means that we'll display all journals
|
||||
journals = self.env['account.journal'].search(
|
||||
[('company_id', '=', self.company_id.id)])
|
||||
journals = self.env["account.journal"].search(
|
||||
[("company_id", "=", self.company_id.id)]
|
||||
)
|
||||
return {
|
||||
'wizard_id': self.id,
|
||||
'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': journals.ids,
|
||||
'sort_option': self.sort_option,
|
||||
'group_option': self.group_option,
|
||||
'with_account_name': self.with_account_name,
|
||||
"wizard_id": self.id,
|
||||
"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": journals.ids,
|
||||
"sort_option": self.sort_option,
|
||||
"group_option": self.group_option,
|
||||
"with_account_name": self.with_account_name,
|
||||
}
|
||||
|
||||
def _export(self, report_type):
|
||||
@@ -158,26 +147,25 @@ class JournalLedgerReportWizard(models.TransientModel):
|
||||
|
||||
@api.model
|
||||
def _get_ml_tax_description(
|
||||
self, move_line_data, tax_line_data, move_line_taxes_data):
|
||||
taxes_description = ''
|
||||
if move_line_data['tax_line_id']:
|
||||
taxes_description = tax_line_data['description'] or \
|
||||
tax_line_data['name']
|
||||
self, move_line_data, tax_line_data, move_line_taxes_data
|
||||
):
|
||||
taxes_description = ""
|
||||
if move_line_data["tax_line_id"]:
|
||||
taxes_description = tax_line_data["description"] or tax_line_data["name"]
|
||||
elif move_line_taxes_data:
|
||||
tax_names = []
|
||||
for tax_key in move_line_taxes_data:
|
||||
tax = move_line_taxes_data[tax_key]
|
||||
tax_names.append(
|
||||
tax['description'] or tax['name'])
|
||||
taxes_description = ','.join(tax_names)
|
||||
tax_names.append(tax["description"] or tax["name"])
|
||||
taxes_description = ",".join(tax_names)
|
||||
return taxes_description
|
||||
|
||||
@api.model
|
||||
def _get_partner_name(self, partner_id, partner_data):
|
||||
if str(partner_id) in partner_data.keys():
|
||||
return partner_data[str(partner_id)]['name']
|
||||
return partner_data[str(partner_id)]["name"]
|
||||
else:
|
||||
return ''
|
||||
return ""
|
||||
|
||||
@api.model
|
||||
def _get_atr_from_dict(self, obj_id, data, key):
|
||||
|
||||
@@ -1,66 +1,76 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?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"/>
|
||||
<field name="company_id" groups="base.group_multi_company" />
|
||||
</group>
|
||||
|
||||
<separator string="Periods"/>
|
||||
<separator string="Periods" />
|
||||
<group>
|
||||
<group>
|
||||
<field name="date_range_id"/>
|
||||
<field name="date_from"/>
|
||||
<field name="date_to"/>
|
||||
<field name="date_range_id" />
|
||||
<field name="date_from" />
|
||||
<field name="date_to" />
|
||||
</group>
|
||||
<group/>
|
||||
<group />
|
||||
</group>
|
||||
|
||||
<separator string="Options"/>
|
||||
<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"/>
|
||||
<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 />
|
||||
</group>
|
||||
|
||||
<separator string="Journals"/>
|
||||
<separator string="Journals" />
|
||||
<group>
|
||||
<field name="journal_ids" widget="many2many_tags"/>
|
||||
<field name="journal_ids" widget="many2many_tags" />
|
||||
</group>
|
||||
|
||||
<footer>
|
||||
<button name="button_export_html" string="View"
|
||||
type="object" default_focus="1" class="oe_highlight"/>
|
||||
<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"/>
|
||||
<button
|
||||
name="button_export_pdf"
|
||||
string="Export PDF"
|
||||
type="object"
|
||||
/>
|
||||
or
|
||||
<button name="button_export_xlsx" string="Export XLSX" type="object"/>
|
||||
<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" />
|
||||
|
||||
<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>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# Copyright 2016 Camptocamp SA
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import models, fields, api
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class OpenItemsReportWizard(models.TransientModel):
|
||||
@@ -11,134 +11,138 @@ class OpenItemsReportWizard(models.TransientModel):
|
||||
|
||||
_name = "open.items.report.wizard"
|
||||
_description = "Open Items Report Wizard"
|
||||
_inherit = 'account_financial_report_abstract_wizard'
|
||||
_inherit = "account_financial_report_abstract_wizard"
|
||||
|
||||
company_id = fields.Many2one(
|
||||
comodel_name='res.company',
|
||||
comodel_name="res.company",
|
||||
default=lambda self: self.env.user.company_id,
|
||||
required=False,
|
||||
string='Company'
|
||||
string="Company",
|
||||
)
|
||||
date_at = fields.Date(required=True, default=fields.Date.context_today)
|
||||
date_from = fields.Date(string="Date From")
|
||||
target_move = fields.Selection(
|
||||
[("posted", "All Posted Entries"), ("all", "All Entries")],
|
||||
string="Target Moves",
|
||||
required=True,
|
||||
default="all",
|
||||
)
|
||||
date_at = fields.Date(required=True,
|
||||
default=fields.Date.context_today)
|
||||
date_from = fields.Date(string='Date From')
|
||||
target_move = fields.Selection([('posted', 'All Posted Entries'),
|
||||
('all', 'All Entries')],
|
||||
string='Target Moves',
|
||||
required=True,
|
||||
default='all')
|
||||
account_ids = fields.Many2many(
|
||||
comodel_name='account.account',
|
||||
string='Filter accounts',
|
||||
domain=[('reconcile', '=', True)],
|
||||
comodel_name="account.account",
|
||||
string="Filter accounts",
|
||||
domain=[("reconcile", "=", True)],
|
||||
)
|
||||
hide_account_at_0 = fields.Boolean(
|
||||
string='Hide account ending balance at 0', default=True,
|
||||
help='Use this filter to hide an account or a partner '
|
||||
'with an ending balance at 0. '
|
||||
'If partners are filtered, '
|
||||
'debits and credits totals will not match the trial balance.'
|
||||
string="Hide account ending balance at 0",
|
||||
default=True,
|
||||
help="Use this filter to hide an account or a partner "
|
||||
"with an ending balance at 0. "
|
||||
"If partners are filtered, "
|
||||
"debits and credits totals will not match the trial balance.",
|
||||
)
|
||||
receivable_accounts_only = fields.Boolean()
|
||||
payable_accounts_only = fields.Boolean()
|
||||
partner_ids = fields.Many2many(
|
||||
comodel_name='res.partner',
|
||||
string='Filter partners',
|
||||
comodel_name="res.partner",
|
||||
string="Filter partners",
|
||||
default=lambda self: self._default_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.',
|
||||
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.",
|
||||
default=lambda self: self._default_foreign_currency(),
|
||||
)
|
||||
|
||||
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")
|
||||
|
||||
@api.onchange('company_id')
|
||||
@api.onchange("company_id")
|
||||
def onchange_company_id(self):
|
||||
"""Handle company change."""
|
||||
if self.company_id and self.partner_ids:
|
||||
self.partner_ids = self.partner_ids.filtered(
|
||||
lambda p: p.company_id == self.company_id or
|
||||
not p.company_id)
|
||||
lambda p: p.company_id == self.company_id or not p.company_id
|
||||
)
|
||||
if self.company_id and self.account_ids:
|
||||
if self.receivable_accounts_only or self.payable_accounts_only:
|
||||
self.onchange_type_accounts_only()
|
||||
else:
|
||||
self.account_ids = self.account_ids.filtered(
|
||||
lambda a: a.company_id == self.company_id)
|
||||
res = {'domain': {'account_ids': [],
|
||||
'partner_ids': []}}
|
||||
lambda a: a.company_id == self.company_id
|
||||
)
|
||||
res = {"domain": {"account_ids": [], "partner_ids": []}}
|
||||
if not self.company_id:
|
||||
return res
|
||||
else:
|
||||
res['domain']['account_ids'] += [
|
||||
('company_id', '=', self.company_id.id)]
|
||||
res['domain']['partner_ids'] += self._get_partner_ids_domain()
|
||||
res["domain"]["account_ids"] += [("company_id", "=", self.company_id.id)]
|
||||
res["domain"]["partner_ids"] += self._get_partner_ids_domain()
|
||||
return res
|
||||
|
||||
@api.onchange('receivable_accounts_only', 'payable_accounts_only')
|
||||
@api.onchange("receivable_accounts_only", "payable_accounts_only")
|
||||
def onchange_type_accounts_only(self):
|
||||
"""Handle receivable/payable accounts only change."""
|
||||
domain = [('company_id', '=', self.company_id.id)]
|
||||
domain = [("company_id", "=", self.company_id.id)]
|
||||
if self.receivable_accounts_only or self.payable_accounts_only:
|
||||
if self.receivable_accounts_only and self.payable_accounts_only:
|
||||
domain += [('internal_type', 'in', ('receivable', 'payable'))]
|
||||
domain += [("internal_type", "in", ("receivable", "payable"))]
|
||||
elif self.receivable_accounts_only:
|
||||
domain += [('internal_type', '=', 'receivable')]
|
||||
domain += [("internal_type", "=", "receivable")]
|
||||
elif self.payable_accounts_only:
|
||||
domain += [('internal_type', '=', 'payable')]
|
||||
domain += [("internal_type", "=", "payable")]
|
||||
elif not self.receivable_accounts_only and not self.payable_accounts_only:
|
||||
domain += [('reconcile', '=', True)]
|
||||
self.account_ids = self.env['account.account'].search(domain)
|
||||
domain += [("reconcile", "=", True)]
|
||||
self.account_ids = self.env["account.account"].search(domain)
|
||||
|
||||
@api.multi
|
||||
def _print_report(self, report_type):
|
||||
self.ensure_one()
|
||||
data = self._prepare_report_open_items()
|
||||
if report_type == 'xlsx':
|
||||
report_name = 'a_f_r.report_open_items_xlsx'
|
||||
if report_type == "xlsx":
|
||||
report_name = "a_f_r.report_open_items_xlsx"
|
||||
else:
|
||||
report_name = 'account_financial_report.open_items'
|
||||
return self.env['ir.actions.report'].search(
|
||||
[('report_name', '=', report_name),
|
||||
('report_type', '=', report_type)], limit=1).report_action(
|
||||
self, data=data)
|
||||
report_name = "account_financial_report.open_items"
|
||||
return (
|
||||
self.env["ir.actions.report"]
|
||||
.search(
|
||||
[("report_name", "=", report_name), ("report_type", "=", report_type)],
|
||||
limit=1,
|
||||
)
|
||||
.report_action(self, data=data)
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def button_export_html(self):
|
||||
self.ensure_one()
|
||||
report_type = 'qweb-html'
|
||||
report_type = "qweb-html"
|
||||
return self._export(report_type)
|
||||
|
||||
@api.multi
|
||||
def button_export_pdf(self):
|
||||
self.ensure_one()
|
||||
report_type = 'qweb-pdf'
|
||||
report_type = "qweb-pdf"
|
||||
return self._export(report_type)
|
||||
|
||||
@api.multi
|
||||
def button_export_xlsx(self):
|
||||
self.ensure_one()
|
||||
report_type = 'xlsx'
|
||||
report_type = "xlsx"
|
||||
return self._export(report_type)
|
||||
|
||||
def _prepare_report_open_items(self):
|
||||
self.ensure_one()
|
||||
return {
|
||||
'wizard_id': self.id,
|
||||
'date_at': fields.Date.to_string(self.date_at),
|
||||
'date_from': self.date_from or False,
|
||||
'only_posted_moves': self.target_move == 'posted',
|
||||
'hide_account_at_0': self.hide_account_at_0,
|
||||
'foreign_currency': self.foreign_currency,
|
||||
'company_id': self.company_id.id,
|
||||
'target_move': self.target_move,
|
||||
'account_ids': self.account_ids.ids,
|
||||
'partner_ids': self.partner_ids.ids or [],
|
||||
"wizard_id": self.id,
|
||||
"date_at": fields.Date.to_string(self.date_at),
|
||||
"date_from": self.date_from or False,
|
||||
"only_posted_moves": self.target_move == "posted",
|
||||
"hide_account_at_0": self.hide_account_at_0,
|
||||
"foreign_currency": self.foreign_currency,
|
||||
"company_id": self.company_id.id,
|
||||
"target_move": self.target_move,
|
||||
"account_ids": self.account_ids.ids,
|
||||
"partner_ids": self.partner_ids.ids or [],
|
||||
}
|
||||
|
||||
def _export(self, report_type):
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
|
||||
<!-- OPEN ITEMS -->
|
||||
<record id="open_items_wizard" model="ir.ui.view">
|
||||
<field name="name">Open Items</field>
|
||||
@@ -8,69 +7,91 @@
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<group name="main_info">
|
||||
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
|
||||
<field
|
||||
name="company_id"
|
||||
options="{'no_create': True}"
|
||||
groups="base.group_multi_company"
|
||||
/>
|
||||
</group>
|
||||
<group name="filters">
|
||||
<group name="date_range">
|
||||
<field name="date_at"/>
|
||||
<field name="date_from"/>
|
||||
<field name="date_at" />
|
||||
<field name="date_from" />
|
||||
</group>
|
||||
<group name="other_filters">
|
||||
<field name="target_move" widget="radio"/>
|
||||
<field name="hide_account_at_0"/>
|
||||
<field name="foreign_currency"/>
|
||||
<field name="target_move" widget="radio" />
|
||||
<field name="hide_account_at_0" />
|
||||
<field name="foreign_currency" />
|
||||
</group>
|
||||
</group>
|
||||
<group name="partner_filter" col="1">
|
||||
<label for="partner_ids"/>
|
||||
<field name="partner_ids"
|
||||
nolabel="1"
|
||||
widget="many2many_tags"
|
||||
options="{'no_create': True}"/>
|
||||
<label for="partner_ids" />
|
||||
<field
|
||||
name="partner_ids"
|
||||
nolabel="1"
|
||||
widget="many2many_tags"
|
||||
options="{'no_create': True}"
|
||||
/>
|
||||
</group>
|
||||
<group name="account_filter" col="4">
|
||||
<field name="receivable_accounts_only"/>
|
||||
<field name="payable_accounts_only"/>
|
||||
<field name="account_ids"
|
||||
nolabel="1"
|
||||
widget="many2many_tags"
|
||||
options="{'no_create': True}"
|
||||
colspan="4"/>
|
||||
<field name="receivable_accounts_only" />
|
||||
<field name="payable_accounts_only" />
|
||||
<field
|
||||
name="account_ids"
|
||||
nolabel="1"
|
||||
widget="many2many_tags"
|
||||
options="{'no_create': True}"
|
||||
colspan="4"
|
||||
/>
|
||||
</group>
|
||||
<footer>
|
||||
<button name="button_export_html" string="View"
|
||||
type="object" default_focus="1" class="oe_highlight"/>
|
||||
<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"/>
|
||||
<button
|
||||
name="button_export_pdf"
|
||||
string="Export PDF"
|
||||
type="object"
|
||||
/>
|
||||
or
|
||||
<button name="button_export_xlsx" string="Export XLSX" type="object"/>
|
||||
<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_open_items_wizard"
|
||||
name="Open Items"
|
||||
res_model="open.items.report.wizard"
|
||||
view_type="form"
|
||||
view_mode="form"
|
||||
view_id="open_items_wizard"
|
||||
target="new" />
|
||||
|
||||
<act_window
|
||||
id="action_open_items_wizard"
|
||||
name="Open Items"
|
||||
res_model="open.items.report.wizard"
|
||||
view_type="form"
|
||||
view_mode="form"
|
||||
view_id="open_items_wizard"
|
||||
target="new"
|
||||
/>
|
||||
<!--Add to res.partner action-->
|
||||
<act_window id="act_action_open_items_wizard_partner_relation"
|
||||
name="Open Items Partner"
|
||||
res_model="open.items.report.wizard"
|
||||
src_model="res.partner"
|
||||
view_mode="form"
|
||||
context="{
|
||||
<act_window
|
||||
id="act_action_open_items_wizard_partner_relation"
|
||||
name="Open Items Partner"
|
||||
res_model="open.items.report.wizard"
|
||||
src_model="res.partner"
|
||||
view_mode="form"
|
||||
context="{
|
||||
'default_receivable_accounts_only':1,
|
||||
'default_payable_accounts_only':1,
|
||||
}"
|
||||
groups="account.group_account_manager"
|
||||
key2="client_action_multi"
|
||||
target="new" />
|
||||
|
||||
groups="account.group_account_manager"
|
||||
key2="client_action_multi"
|
||||
target="new"
|
||||
/>
|
||||
</odoo>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# Copyright 2018 Eficent Business and IT Consuting Services, S.L.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
|
||||
|
||||
@@ -13,246 +13,260 @@ class TrialBalanceReportWizard(models.TransientModel):
|
||||
|
||||
_name = "trial.balance.report.wizard"
|
||||
_description = "Trial Balance Report Wizard"
|
||||
_inherit = 'account_financial_report_abstract_wizard'
|
||||
_inherit = "account_financial_report_abstract_wizard"
|
||||
|
||||
company_id = fields.Many2one(
|
||||
comodel_name='res.company',
|
||||
comodel_name="res.company",
|
||||
default=lambda self: self.env.user.company_id,
|
||||
required=False,
|
||||
string='Company'
|
||||
)
|
||||
date_range_id = fields.Many2one(
|
||||
comodel_name='date.range',
|
||||
string='Date range'
|
||||
string="Company",
|
||||
)
|
||||
date_range_id = fields.Many2one(comodel_name="date.range", string="Date range")
|
||||
date_from = fields.Date(required=True)
|
||||
date_to = fields.Date(required=True)
|
||||
fy_start_date = fields.Date(compute='_compute_fy_start_date')
|
||||
target_move = fields.Selection([('posted', 'All Posted Entries'),
|
||||
('all', 'All Entries')],
|
||||
string='Target Moves',
|
||||
required=True,
|
||||
default='all')
|
||||
hierarchy_on = fields.Selection(
|
||||
[('computed', 'Computed Accounts'),
|
||||
('relation', 'Child Accounts'),
|
||||
('none', 'No hierarchy')],
|
||||
string='Hierarchy On',
|
||||
fy_start_date = fields.Date(compute="_compute_fy_start_date")
|
||||
target_move = fields.Selection(
|
||||
[("posted", "All Posted Entries"), ("all", "All Entries")],
|
||||
string="Target Moves",
|
||||
required=True,
|
||||
default='none',
|
||||
default="all",
|
||||
)
|
||||
hierarchy_on = fields.Selection(
|
||||
[
|
||||
("computed", "Computed Accounts"),
|
||||
("relation", "Child Accounts"),
|
||||
("none", "No hierarchy"),
|
||||
],
|
||||
string="Hierarchy On",
|
||||
required=True,
|
||||
default="none",
|
||||
help="""Computed Accounts: Use when the account group have codes
|
||||
that represent prefixes of the actual accounts.\n
|
||||
Child Accounts: Use when your account groups are hierarchical.\n
|
||||
No hierarchy: Use to display just the accounts, without any grouping.
|
||||
""",
|
||||
)
|
||||
limit_hierarchy_level = fields.Boolean('Limit hierarchy levels')
|
||||
show_hierarchy_level = fields.Integer('Hierarchy Levels to display',
|
||||
default=1)
|
||||
limit_hierarchy_level = fields.Boolean("Limit hierarchy levels")
|
||||
show_hierarchy_level = fields.Integer("Hierarchy Levels to display", default=1)
|
||||
hide_parent_hierarchy_level = fields.Boolean(
|
||||
'Do not display parent levels', default=False)
|
||||
"Do not display parent levels", default=False
|
||||
)
|
||||
account_ids = fields.Many2many(
|
||||
comodel_name='account.account',
|
||||
string='Filter accounts',
|
||||
comodel_name="account.account", string="Filter accounts",
|
||||
)
|
||||
hide_account_at_0 = fields.Boolean(
|
||||
string='Hide accounts at 0', default=True,
|
||||
help='When this option is enabled, the trial balance will '
|
||||
'not display accounts that have initial balance = '
|
||||
'debit = credit = end balance = 0',
|
||||
string="Hide accounts at 0",
|
||||
default=True,
|
||||
help="When this option is enabled, the trial balance will "
|
||||
"not display accounts that have initial balance = "
|
||||
"debit = credit = end balance = 0",
|
||||
)
|
||||
receivable_accounts_only = fields.Boolean()
|
||||
payable_accounts_only = fields.Boolean()
|
||||
show_partner_details = fields.Boolean()
|
||||
partner_ids = fields.Many2many(
|
||||
comodel_name='res.partner',
|
||||
string='Filter partners',
|
||||
)
|
||||
journal_ids = fields.Many2many(
|
||||
comodel_name="account.journal",
|
||||
comodel_name="res.partner", string="Filter partners",
|
||||
)
|
||||
journal_ids = fields.Many2many(comodel_name="account.journal",)
|
||||
|
||||
not_only_one_unaffected_earnings_account = fields.Boolean(
|
||||
readonly=True,
|
||||
string='Not only one unaffected earnings account'
|
||||
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.'
|
||||
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.multi
|
||||
@api.constrains('hierarchy_on', 'show_hierarchy_level')
|
||||
@api.constrains("hierarchy_on", "show_hierarchy_level")
|
||||
def _check_show_hierarchy_level(self):
|
||||
for rec in self:
|
||||
if rec.hierarchy_on != 'none' and rec.show_hierarchy_level <= 0:
|
||||
raise UserError(_('The hierarchy level to filter on must be '
|
||||
'greater than 0.'))
|
||||
if rec.hierarchy_on != "none" and rec.show_hierarchy_level <= 0:
|
||||
raise UserError(
|
||||
_("The hierarchy level to filter on must be " "greater than 0.")
|
||||
)
|
||||
|
||||
@api.depends('date_from')
|
||||
@api.depends("date_from")
|
||||
def _compute_fy_start_date(self):
|
||||
for wiz in self.filtered('date_from'):
|
||||
for wiz in self.filtered("date_from"):
|
||||
date = fields.Datetime.from_string(wiz.date_from)
|
||||
res = self.company_id.compute_fiscalyear_dates(date)
|
||||
wiz.fy_start_date = fields.Date.to_string(res['date_from'])
|
||||
wiz.fy_start_date = fields.Date.to_string(res["date_from"])
|
||||
|
||||
@api.onchange('company_id')
|
||||
@api.onchange("company_id")
|
||||
def onchange_company_id(self):
|
||||
"""Handle company change."""
|
||||
account_type = self.env.ref('account.data_unaffected_earnings')
|
||||
count = self.env['account.account'].search_count(
|
||||
account_type = self.env.ref("account.data_unaffected_earnings")
|
||||
count = self.env["account.account"].search_count(
|
||||
[
|
||||
('user_type_id', '=', account_type.id),
|
||||
('company_id', '=', self.company_id.id)
|
||||
])
|
||||
("user_type_id", "=", account_type.id),
|
||||
("company_id", "=", self.company_id.id),
|
||||
]
|
||||
)
|
||||
self.not_only_one_unaffected_earnings_account = count != 1
|
||||
if self.company_id and self.date_range_id.company_id and \
|
||||
self.date_range_id.company_id != self.company_id:
|
||||
if (
|
||||
self.company_id
|
||||
and self.date_range_id.company_id
|
||||
and self.date_range_id.company_id != self.company_id
|
||||
):
|
||||
self.date_range_id = False
|
||||
if self.company_id and self.partner_ids:
|
||||
self.partner_ids = self.partner_ids.filtered(
|
||||
lambda p: p.company_id == self.company_id or
|
||||
not p.company_id)
|
||||
lambda p: p.company_id == self.company_id or not p.company_id
|
||||
)
|
||||
if self.company_id and self.journal_ids:
|
||||
self.journal_ids = self.journal_ids.filtered(
|
||||
lambda a: a.company_id == self.company_id)
|
||||
lambda a: a.company_id == self.company_id
|
||||
)
|
||||
if self.company_id and self.account_ids:
|
||||
if self.receivable_accounts_only or self.payable_accounts_only:
|
||||
self.onchange_type_accounts_only()
|
||||
else:
|
||||
self.account_ids = self.account_ids.filtered(
|
||||
lambda a: a.company_id == self.company_id)
|
||||
res = {'domain': {'account_ids': [],
|
||||
'partner_ids': [],
|
||||
'date_range_id': [],
|
||||
'journal_ids': [],
|
||||
}
|
||||
}
|
||||
lambda a: a.company_id == self.company_id
|
||||
)
|
||||
res = {
|
||||
"domain": {
|
||||
"account_ids": [],
|
||||
"partner_ids": [],
|
||||
"date_range_id": [],
|
||||
"journal_ids": [],
|
||||
}
|
||||
}
|
||||
if not self.company_id:
|
||||
return res
|
||||
else:
|
||||
res['domain']['account_ids'] += [
|
||||
('company_id', '=', self.company_id.id)]
|
||||
res['domain']['partner_ids'] += self._get_partner_ids_domain()
|
||||
res['domain']['date_range_id'] += [
|
||||
'|', ('company_id', '=', self.company_id.id),
|
||||
('company_id', '=', False)]
|
||||
res['domain']['journal_ids'] += [
|
||||
('company_id', '=', self.company_id.id)]
|
||||
res["domain"]["account_ids"] += [("company_id", "=", self.company_id.id)]
|
||||
res["domain"]["partner_ids"] += self._get_partner_ids_domain()
|
||||
res["domain"]["date_range_id"] += [
|
||||
"|",
|
||||
("company_id", "=", self.company_id.id),
|
||||
("company_id", "=", False),
|
||||
]
|
||||
res["domain"]["journal_ids"] += [("company_id", "=", self.company_id.id)]
|
||||
return res
|
||||
|
||||
@api.onchange('date_range_id')
|
||||
@api.onchange("date_range_id")
|
||||
def onchange_date_range_id(self):
|
||||
"""Handle date range change."""
|
||||
self.date_from = self.date_range_id.date_start
|
||||
self.date_to = self.date_range_id.date_end
|
||||
|
||||
@api.multi
|
||||
@api.constrains('company_id', 'date_range_id')
|
||||
@api.constrains("company_id", "date_range_id")
|
||||
def _check_company_id_date_range_id(self):
|
||||
for rec in self.sudo():
|
||||
if rec.company_id and rec.date_range_id.company_id and\
|
||||
rec.company_id != rec.date_range_id.company_id:
|
||||
if (
|
||||
rec.company_id
|
||||
and rec.date_range_id.company_id
|
||||
and rec.company_id != rec.date_range_id.company_id
|
||||
):
|
||||
raise ValidationError(
|
||||
_('The Company in the Trial Balance Report Wizard and in '
|
||||
'Date Range must be the same.'))
|
||||
_(
|
||||
"The Company in the Trial Balance Report Wizard and in "
|
||||
"Date Range must be the same."
|
||||
)
|
||||
)
|
||||
|
||||
@api.onchange('receivable_accounts_only', 'payable_accounts_only')
|
||||
@api.onchange("receivable_accounts_only", "payable_accounts_only")
|
||||
def onchange_type_accounts_only(self):
|
||||
"""Handle receivable/payable accounts only change."""
|
||||
if self.receivable_accounts_only or self.payable_accounts_only:
|
||||
domain = [('company_id', '=', self.company_id.id)]
|
||||
domain = [("company_id", "=", self.company_id.id)]
|
||||
if self.receivable_accounts_only and self.payable_accounts_only:
|
||||
domain += [('internal_type', 'in', ('receivable', 'payable'))]
|
||||
domain += [("internal_type", "in", ("receivable", "payable"))]
|
||||
elif self.receivable_accounts_only:
|
||||
domain += [('internal_type', '=', 'receivable')]
|
||||
domain += [("internal_type", "=", "receivable")]
|
||||
elif self.payable_accounts_only:
|
||||
domain += [('internal_type', '=', 'payable')]
|
||||
self.account_ids = self.env['account.account'].search(domain)
|
||||
domain += [("internal_type", "=", "payable")]
|
||||
self.account_ids = self.env["account.account"].search(domain)
|
||||
else:
|
||||
self.account_ids = None
|
||||
|
||||
@api.onchange('show_partner_details')
|
||||
@api.onchange("show_partner_details")
|
||||
def onchange_show_partner_details(self):
|
||||
"""Handle partners change."""
|
||||
if self.show_partner_details:
|
||||
self.receivable_accounts_only = self.payable_accounts_only = True
|
||||
else:
|
||||
self.receivable_accounts_only = self.\
|
||||
payable_accounts_only = False
|
||||
self.receivable_accounts_only = self.payable_accounts_only = False
|
||||
|
||||
@api.multi
|
||||
@api.depends('company_id')
|
||||
@api.depends("company_id")
|
||||
def _compute_unaffected_earnings_account(self):
|
||||
account_type = self.env.ref('account.data_unaffected_earnings')
|
||||
account_type = self.env.ref("account.data_unaffected_earnings")
|
||||
for record in self:
|
||||
record.unaffected_earnings_account = self.env[
|
||||
'account.account'].search(
|
||||
record.unaffected_earnings_account = self.env["account.account"].search(
|
||||
[
|
||||
('user_type_id', '=', account_type.id),
|
||||
('company_id', '=', record.company_id.id)
|
||||
])
|
||||
("user_type_id", "=", account_type.id),
|
||||
("company_id", "=", record.company_id.id),
|
||||
]
|
||||
)
|
||||
|
||||
unaffected_earnings_account = fields.Many2one(
|
||||
comodel_name='account.account',
|
||||
compute='_compute_unaffected_earnings_account',
|
||||
store=True
|
||||
comodel_name="account.account",
|
||||
compute="_compute_unaffected_earnings_account",
|
||||
store=True,
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def _print_report(self, report_type):
|
||||
self.ensure_one()
|
||||
data = self._prepare_report_trial_balance()
|
||||
if report_type == 'xlsx':
|
||||
report_name = 'a_f_r.report_trial_balance_xlsx'
|
||||
if report_type == "xlsx":
|
||||
report_name = "a_f_r.report_trial_balance_xlsx"
|
||||
else:
|
||||
report_name = 'account_financial_report.trial_balance'
|
||||
return self.env['ir.actions.report'].search(
|
||||
[('report_name', '=', report_name),
|
||||
('report_type', '=', report_type)], limit=1).report_action(
|
||||
self, data=data)
|
||||
report_name = "account_financial_report.trial_balance"
|
||||
return (
|
||||
self.env["ir.actions.report"]
|
||||
.search(
|
||||
[("report_name", "=", report_name), ("report_type", "=", report_type)],
|
||||
limit=1,
|
||||
)
|
||||
.report_action(self, data=data)
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def button_export_html(self):
|
||||
self.ensure_one()
|
||||
report_type = 'qweb-html'
|
||||
report_type = "qweb-html"
|
||||
return self._export(report_type)
|
||||
|
||||
@api.multi
|
||||
def button_export_pdf(self):
|
||||
self.ensure_one()
|
||||
report_type = 'qweb-pdf'
|
||||
report_type = "qweb-pdf"
|
||||
return self._export(report_type)
|
||||
|
||||
@api.multi
|
||||
def button_export_xlsx(self):
|
||||
self.ensure_one()
|
||||
report_type = 'xlsx'
|
||||
report_type = "xlsx"
|
||||
return self._export(report_type)
|
||||
|
||||
def _prepare_report_trial_balance(self):
|
||||
self.ensure_one()
|
||||
return {
|
||||
'wizard_id': self.id,
|
||||
'date_from': self.date_from,
|
||||
'date_to': self.date_to,
|
||||
'only_posted_moves': self.target_move == 'posted',
|
||||
'hide_account_at_0': self.hide_account_at_0,
|
||||
'foreign_currency': self.foreign_currency,
|
||||
'company_id': self.company_id.id,
|
||||
'account_ids': self.account_ids.ids or [],
|
||||
'partner_ids': self.partner_ids.ids or [],
|
||||
'journal_ids': self.journal_ids.ids or [],
|
||||
'fy_start_date': self.fy_start_date,
|
||||
'hierarchy_on': self.hierarchy_on,
|
||||
'limit_hierarchy_level': self.limit_hierarchy_level,
|
||||
'show_hierarchy_level': self.show_hierarchy_level,
|
||||
'hide_parent_hierarchy_level': self.hide_parent_hierarchy_level,
|
||||
'show_partner_details': self.show_partner_details,
|
||||
'unaffected_earnings_account': self.unaffected_earnings_account.id,
|
||||
"wizard_id": self.id,
|
||||
"date_from": self.date_from,
|
||||
"date_to": self.date_to,
|
||||
"only_posted_moves": self.target_move == "posted",
|
||||
"hide_account_at_0": self.hide_account_at_0,
|
||||
"foreign_currency": self.foreign_currency,
|
||||
"company_id": self.company_id.id,
|
||||
"account_ids": self.account_ids.ids or [],
|
||||
"partner_ids": self.partner_ids.ids or [],
|
||||
"journal_ids": self.journal_ids.ids or [],
|
||||
"fy_start_date": self.fy_start_date,
|
||||
"hierarchy_on": self.hierarchy_on,
|
||||
"limit_hierarchy_level": self.limit_hierarchy_level,
|
||||
"show_hierarchy_level": self.show_hierarchy_level,
|
||||
"hide_parent_hierarchy_level": self.hide_parent_hierarchy_level,
|
||||
"show_partner_details": self.show_partner_details,
|
||||
"unaffected_earnings_account": self.unaffected_earnings_account.id,
|
||||
}
|
||||
|
||||
def _export(self, report_type):
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
|
||||
<!-- TRIAL BALANCE -->
|
||||
<record id="trial_balance_wizard" model="ir.ui.view">
|
||||
<field name="name">Trial Balance</field>
|
||||
@@ -8,84 +7,135 @@
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<group name="main_info">
|
||||
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
|
||||
<field
|
||||
name="company_id"
|
||||
options="{'no_create': True}"
|
||||
groups="base.group_multi_company"
|
||||
/>
|
||||
</group>
|
||||
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', True)]}">
|
||||
<div
|
||||
attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', True)]}"
|
||||
>
|
||||
<group name="filters">
|
||||
<group name="date_range">
|
||||
<field name="date_range_id"/>
|
||||
<field name="date_from"/>
|
||||
<field name="date_to"/>
|
||||
<field name="fy_start_date" invisible="1"/>
|
||||
<field name="date_range_id" />
|
||||
<field name="date_from" />
|
||||
<field name="date_to" />
|
||||
<field name="fy_start_date" invisible="1" />
|
||||
</group>
|
||||
<group name="other_filters">
|
||||
<field name="target_move" widget="radio"/>
|
||||
<field name="hide_account_at_0"/>
|
||||
<field name="show_partner_details"/>
|
||||
<field name="hierarchy_on" widget="radio" attrs="{'invisible':[('show_partner_details','=',True)]}"/>
|
||||
<field name="limit_hierarchy_level" attrs="{'invisible':['|', ('hierarchy_on','in',['none', 'computed']),('show_partner_details','=',True)]}"/>
|
||||
<field name="show_hierarchy_level" attrs="{'invisible':[('limit_hierarchy_level','=', False)]}"/>
|
||||
<field name="hide_parent_hierarchy_level" attrs="{'invisible':[('limit_hierarchy_level','=', False)]}"/>
|
||||
<field name="foreign_currency"/>
|
||||
<field name="target_move" widget="radio" />
|
||||
<field name="hide_account_at_0" />
|
||||
<field name="show_partner_details" />
|
||||
<field
|
||||
name="hierarchy_on"
|
||||
widget="radio"
|
||||
attrs="{'invisible':[('show_partner_details','=',True)]}"
|
||||
/>
|
||||
<field
|
||||
name="limit_hierarchy_level"
|
||||
attrs="{'invisible':['|', ('hierarchy_on','in',['none', 'computed']),('show_partner_details','=',True)]}"
|
||||
/>
|
||||
<field
|
||||
name="show_hierarchy_level"
|
||||
attrs="{'invisible':[('limit_hierarchy_level','=', False)]}"
|
||||
/>
|
||||
<field
|
||||
name="hide_parent_hierarchy_level"
|
||||
attrs="{'invisible':[('limit_hierarchy_level','=', False)]}"
|
||||
/>
|
||||
<field name="foreign_currency" />
|
||||
</group>
|
||||
</group>
|
||||
<group name="partner_filter" attrs="{'invisible':[('show_partner_details','!=',True)]}" col="1">
|
||||
<label for="partner_ids"/>
|
||||
<field name="partner_ids"
|
||||
nolabel="1"
|
||||
widget="many2many_tags"
|
||||
options="{'no_create': True}"/>
|
||||
<group
|
||||
name="partner_filter"
|
||||
attrs="{'invisible':[('show_partner_details','!=',True)]}"
|
||||
col="1"
|
||||
>
|
||||
<label for="partner_ids" />
|
||||
<field
|
||||
name="partner_ids"
|
||||
nolabel="1"
|
||||
widget="many2many_tags"
|
||||
options="{'no_create': True}"
|
||||
/>
|
||||
</group>
|
||||
<label for="journal_ids"/>
|
||||
<field name="journal_ids"
|
||||
widget="many2many_tags"
|
||||
nolabel="1"
|
||||
options="{'no_create': True}"
|
||||
<label for="journal_ids" />
|
||||
<field
|
||||
name="journal_ids"
|
||||
widget="many2many_tags"
|
||||
nolabel="1"
|
||||
options="{'no_create': True}"
|
||||
/>
|
||||
<group attrs="{'invisible':[('show_partner_details','!=',True)]}"/>
|
||||
<div/>
|
||||
<group attrs="{'invisible':[('show_partner_details','!=',True)]}" />
|
||||
<div />
|
||||
<group name="account_filter" col="4">
|
||||
<label for="account_ids" colspan="4"/>
|
||||
<field name="receivable_accounts_only"/>
|
||||
<field name="payable_accounts_only"/>
|
||||
<field name="account_ids"
|
||||
nolabel="1"
|
||||
widget="many2many_tags"
|
||||
options="{'no_create': True}"
|
||||
colspan="4"/>
|
||||
<label for="account_ids" colspan="4" />
|
||||
<field name="receivable_accounts_only" />
|
||||
<field name="payable_accounts_only" />
|
||||
<field
|
||||
name="account_ids"
|
||||
nolabel="1"
|
||||
widget="many2many_tags"
|
||||
options="{'no_create': True}"
|
||||
colspan="4"
|
||||
/>
|
||||
</group>
|
||||
</div>
|
||||
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', False)]}">
|
||||
<field name="not_only_one_unaffected_earnings_account" invisible="1"/>
|
||||
<group/>
|
||||
<h4>Trial Balance can be computed only if selected company have only one unaffected earnings account.</h4>
|
||||
<group/>
|
||||
<div
|
||||
attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', False)]}"
|
||||
>
|
||||
<field
|
||||
name="not_only_one_unaffected_earnings_account"
|
||||
invisible="1"
|
||||
/>
|
||||
<group />
|
||||
<h4
|
||||
>Trial Balance can be computed only if selected company have only one unaffected earnings account.</h4>
|
||||
<group />
|
||||
</div>
|
||||
<footer>
|
||||
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', True)]}">
|
||||
<button name="button_export_html" string="View"
|
||||
type="object" default_focus="1" class="oe_highlight"/>
|
||||
<div
|
||||
attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', True)]}"
|
||||
>
|
||||
<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"/>
|
||||
<button
|
||||
name="button_export_pdf"
|
||||
string="Export PDF"
|
||||
type="object"
|
||||
/>
|
||||
or
|
||||
<button name="button_export_xlsx" string="Export XLSX" type="object"/>
|
||||
<button
|
||||
name="button_export_xlsx"
|
||||
string="Export XLSX"
|
||||
type="object"
|
||||
/>
|
||||
or
|
||||
<button string="Cancel" class="oe_link" special="cancel" />
|
||||
</div>
|
||||
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', False)]}">
|
||||
<div
|
||||
attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', False)]}"
|
||||
>
|
||||
<button string="Cancel" class="oe_link" special="cancel" />
|
||||
</div>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<act_window id="action_trial_balance_wizard"
|
||||
name="Trial Balance"
|
||||
res_model="trial.balance.report.wizard"
|
||||
view_type="form"
|
||||
view_mode="form"
|
||||
view_id="trial_balance_wizard"
|
||||
target="new" />
|
||||
|
||||
<act_window
|
||||
id="action_trial_balance_wizard"
|
||||
name="Trial Balance"
|
||||
res_model="trial.balance.report.wizard"
|
||||
view_type="form"
|
||||
view_mode="form"
|
||||
view_id="trial_balance_wizard"
|
||||
target="new"
|
||||
/>
|
||||
</odoo>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Copyright 2018 Forest and Biomass Romania
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
@@ -10,96 +10,107 @@ class VATReportWizard(models.TransientModel):
|
||||
_description = "VAT Report Wizard"
|
||||
|
||||
company_id = fields.Many2one(
|
||||
comodel_name='res.company',
|
||||
comodel_name="res.company",
|
||||
default=lambda self: self.env.user.company_id,
|
||||
required=False,
|
||||
string='Company'
|
||||
string="Company",
|
||||
)
|
||||
date_range_id = fields.Many2one(
|
||||
comodel_name='date.range',
|
||||
string='Date range'
|
||||
date_range_id = fields.Many2one(comodel_name="date.range", string="Date range")
|
||||
date_from = fields.Date("Start Date", required=True)
|
||||
date_to = fields.Date("End Date", required=True)
|
||||
based_on = fields.Selection(
|
||||
[("taxtags", "Tax Tags"), ("taxgroups", "Tax Groups")],
|
||||
string="Based On",
|
||||
required=True,
|
||||
default="taxtags",
|
||||
)
|
||||
date_from = fields.Date('Start Date', required=True)
|
||||
date_to = fields.Date('End Date', required=True)
|
||||
based_on = fields.Selection([('taxtags', 'Tax Tags'),
|
||||
('taxgroups', 'Tax Groups')],
|
||||
string='Based On',
|
||||
required=True,
|
||||
default='taxtags')
|
||||
tax_detail = fields.Boolean('Detail Taxes')
|
||||
tax_detail = fields.Boolean("Detail Taxes")
|
||||
|
||||
@api.onchange('company_id')
|
||||
@api.onchange("company_id")
|
||||
def onchange_company_id(self):
|
||||
if self.company_id and self.date_range_id.company_id and \
|
||||
self.date_range_id.company_id != self.company_id:
|
||||
if (
|
||||
self.company_id
|
||||
and self.date_range_id.company_id
|
||||
and self.date_range_id.company_id != self.company_id
|
||||
):
|
||||
self.date_range_id = False
|
||||
res = {'domain': {'date_range_id': [],
|
||||
}
|
||||
}
|
||||
res = {"domain": {"date_range_id": [],}}
|
||||
if not self.company_id:
|
||||
return res
|
||||
else:
|
||||
res['domain']['date_range_id'] += [
|
||||
'|', ('company_id', '=', self.company_id.id),
|
||||
('company_id', '=', False)]
|
||||
res["domain"]["date_range_id"] += [
|
||||
"|",
|
||||
("company_id", "=", self.company_id.id),
|
||||
("company_id", "=", False),
|
||||
]
|
||||
return res
|
||||
|
||||
@api.onchange('date_range_id')
|
||||
@api.onchange("date_range_id")
|
||||
def onchange_date_range_id(self):
|
||||
"""Handle date range change."""
|
||||
self.date_from = self.date_range_id.date_start
|
||||
self.date_to = self.date_range_id.date_end
|
||||
|
||||
@api.multi
|
||||
@api.constrains('company_id', 'date_range_id')
|
||||
@api.constrains("company_id", "date_range_id")
|
||||
def _check_company_id_date_range_id(self):
|
||||
for rec in self.sudo():
|
||||
if rec.company_id and rec.date_range_id.company_id and\
|
||||
rec.company_id != rec.date_range_id.company_id:
|
||||
if (
|
||||
rec.company_id
|
||||
and rec.date_range_id.company_id
|
||||
and rec.company_id != rec.date_range_id.company_id
|
||||
):
|
||||
raise ValidationError(
|
||||
_('The Company in the Vat Report Wizard and in '
|
||||
'Date Range must be the same.'))
|
||||
_(
|
||||
"The Company in the Vat Report Wizard and in "
|
||||
"Date Range must be the same."
|
||||
)
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def _print_report(self, report_type):
|
||||
self.ensure_one()
|
||||
data = self._prepare_vat_report()
|
||||
if report_type == 'xlsx':
|
||||
report_name = 'a_f_r.report_vat_report_xlsx'
|
||||
if report_type == "xlsx":
|
||||
report_name = "a_f_r.report_vat_report_xlsx"
|
||||
else:
|
||||
report_name = 'account_financial_report.vat_report'
|
||||
return self.env['ir.actions.report'].search(
|
||||
[('report_name', '=', report_name),
|
||||
('report_type', '=', report_type)], limit=1).report_action(
|
||||
self, data=data)
|
||||
report_name = "account_financial_report.vat_report"
|
||||
return (
|
||||
self.env["ir.actions.report"]
|
||||
.search(
|
||||
[("report_name", "=", report_name), ("report_type", "=", report_type)],
|
||||
limit=1,
|
||||
)
|
||||
.report_action(self, data=data)
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def button_export_html(self):
|
||||
self.ensure_one()
|
||||
report_type = 'qweb-html'
|
||||
report_type = "qweb-html"
|
||||
return self._export(report_type)
|
||||
|
||||
@api.multi
|
||||
def button_export_pdf(self):
|
||||
self.ensure_one()
|
||||
report_type = 'qweb-pdf'
|
||||
report_type = "qweb-pdf"
|
||||
return self._export(report_type)
|
||||
|
||||
@api.multi
|
||||
def button_export_xlsx(self):
|
||||
self.ensure_one()
|
||||
report_type = 'xlsx'
|
||||
report_type = "xlsx"
|
||||
return self._export(report_type)
|
||||
|
||||
def _prepare_vat_report(self):
|
||||
self.ensure_one()
|
||||
return {
|
||||
'wizard_id': self.id,
|
||||
'company_id': self.company_id.id,
|
||||
'date_from': self.date_from,
|
||||
'date_to': self.date_to,
|
||||
'based_on': self.based_on,
|
||||
'tax_detail': self.tax_detail,
|
||||
"wizard_id": self.id,
|
||||
"company_id": self.company_id.id,
|
||||
"date_from": self.date_from,
|
||||
"date_to": self.date_to,
|
||||
"based_on": self.based_on,
|
||||
"tax_detail": self.tax_detail,
|
||||
}
|
||||
|
||||
def _export(self, report_type):
|
||||
|
||||
@@ -1,44 +1,61 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
|
||||
<record id="vat_report_wizard" model="ir.ui.view">
|
||||
<field name="name">vat_report_wizard_view</field>
|
||||
<field name="model">vat.report.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="VAT Report Options">
|
||||
<group name="main_info">
|
||||
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
|
||||
</group>
|
||||
<group name="filters">
|
||||
<group name="date_range">
|
||||
<field name="date_range_id"/>
|
||||
<field name="date_from"/>
|
||||
<field name="date_to"/>
|
||||
<form string="VAT Report Options">
|
||||
<group name="main_info">
|
||||
<field
|
||||
name="company_id"
|
||||
options="{'no_create': True}"
|
||||
groups="base.group_multi_company"
|
||||
/>
|
||||
</group>
|
||||
<group name="other_filters">
|
||||
<field name="based_on" widget="radio"/>
|
||||
<field name="tax_detail"/>
|
||||
<group name="filters">
|
||||
<group name="date_range">
|
||||
<field name="date_range_id" />
|
||||
<field name="date_from" />
|
||||
<field name="date_to" />
|
||||
</group>
|
||||
<group name="other_filters">
|
||||
<field name="based_on" widget="radio" />
|
||||
<field name="tax_detail" />
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
<footer>
|
||||
<button name="button_export_html" string="View"
|
||||
type="object" default_focus="1" class="oe_highlight"/>
|
||||
<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"/>
|
||||
<button
|
||||
name="button_export_pdf"
|
||||
string="Export PDF"
|
||||
type="object"
|
||||
/>
|
||||
or
|
||||
<button name="button_export_xlsx" string="Export XLSX" type="object"/>
|
||||
<button
|
||||
name="button_export_xlsx"
|
||||
string="Export XLSX"
|
||||
type="object"
|
||||
/>
|
||||
or
|
||||
<button string="Cancel" class="oe_link" special="cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<act_window id="action_vat_report_wizard"
|
||||
name="VAT Report"
|
||||
res_model="vat.report.wizard"
|
||||
view_type="form"
|
||||
view_mode="form"
|
||||
view_id="vat_report_wizard"
|
||||
target="new" />
|
||||
<act_window
|
||||
id="action_vat_report_wizard"
|
||||
name="VAT Report"
|
||||
res_model="vat.report.wizard"
|
||||
view_type="form"
|
||||
view_mode="form"
|
||||
view_id="vat_report_wizard"
|
||||
target="new"
|
||||
/>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user