[IMP] account_financial_report: adapt the wizards to multicompany
parent
fb9198e609
commit
ebe7d52f6f
|
@ -97,6 +97,7 @@ Contributors
|
||||||
* Akim Juillerat <akim.juillerat@camptocamp.com>
|
* Akim Juillerat <akim.juillerat@camptocamp.com>
|
||||||
* Alexis de Lattre <alexis@via.ecp.fr>
|
* Alexis de Lattre <alexis@via.ecp.fr>
|
||||||
* Mihai Fekete <feketemihai@gmail.com>
|
* Mihai Fekete <feketemihai@gmail.com>
|
||||||
|
* Miquel Raïch <miquel.raich@eficent.com>
|
||||||
|
|
||||||
Much of the work in this module was done at a sprint in Sorrento, Italy in
|
Much of the work in this module was done at a sprint in Sorrento, Italy in
|
||||||
April 2016.
|
April 2016.
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
{
|
{
|
||||||
'name': 'Account Financial Reports',
|
'name': 'Account Financial Reports',
|
||||||
'version': '11.0.2.3.1',
|
'version': '11.0.2.4.0',
|
||||||
'category': 'Reporting',
|
'category': 'Reporting',
|
||||||
'summary': 'OCA Financial Reports',
|
'summary': 'OCA Financial Reports',
|
||||||
'author': 'Camptocamp SA,'
|
'author': 'Camptocamp SA,'
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
* Akim Juillerat <akim.juillerat@camptocamp.com>
|
* Akim Juillerat <akim.juillerat@camptocamp.com>
|
||||||
* Alexis de Lattre <alexis@via.ecp.fr>
|
* Alexis de Lattre <alexis@via.ecp.fr>
|
||||||
* Mihai Fekete <feketemihai@gmail.com>
|
* Mihai Fekete <feketemihai@gmail.com>
|
||||||
|
* Miquel Raïch <miquel.raich@eficent.com>
|
||||||
|
|
||||||
Much of the work in this module was done at a sprint in Sorrento, Italy in
|
Much of the work in this module was done at a sprint in Sorrento, Italy in
|
||||||
April 2016.
|
April 2016.
|
||||||
|
|
|
@ -48,22 +48,27 @@ class TestVATReport(common.TransactionCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestVATReport, self).setUp()
|
super(TestVATReport, self).setUp()
|
||||||
self.date_from = time.strftime('%Y-%m-01'),
|
self.date_from = time.strftime('%Y-%m-01')
|
||||||
self.date_to = time.strftime('%Y-%m-28'),
|
self.date_to = time.strftime('%Y-%m-28')
|
||||||
|
self.company = self.env.ref('base.main_company')
|
||||||
self.receivable_account = self.env['account.account'].search([
|
self.receivable_account = self.env['account.account'].search([
|
||||||
|
('company_id', '=', self.company.id),
|
||||||
('user_type_id.name', '=', 'Receivable')
|
('user_type_id.name', '=', 'Receivable')
|
||||||
], limit=1)
|
], limit=1)
|
||||||
self.income_account = self.env['account.account'].search([
|
self.income_account = self.env['account.account'].search([
|
||||||
|
('company_id', '=', self.company.id),
|
||||||
('user_type_id.name', '=', 'Income')
|
('user_type_id.name', '=', 'Income')
|
||||||
], limit=1)
|
], limit=1)
|
||||||
self.tax_account = self.env['account.account'].search([
|
self.tax_account = self.env['account.account'].search([
|
||||||
|
('company_id', '=', self.company.id),
|
||||||
('user_type_id',
|
('user_type_id',
|
||||||
'=',
|
'=',
|
||||||
self.env.ref(
|
self.env.ref(
|
||||||
'account.data_account_type_non_current_liabilities').id
|
'account.data_account_type_non_current_liabilities').id)
|
||||||
)], limit=1)
|
], limit=1)
|
||||||
self.bank_journal = self.env['account.journal'].search(
|
self.bank_journal = self.env['account.journal'].search([
|
||||||
[('type', '=', 'bank')], limit=1)
|
('type', '=', 'bank'), ('company_id', '=', self.company.id)
|
||||||
|
], limit=1)
|
||||||
self.tax_tag_01 = self.env['account.account.tag'].create({
|
self.tax_tag_01 = self.env['account.account.tag'].create({
|
||||||
'name': 'Tag 01',
|
'name': 'Tag 01',
|
||||||
'applicability': 'taxes'
|
'applicability': 'taxes'
|
||||||
|
@ -90,6 +95,7 @@ class TestVATReport(common.TransactionCase):
|
||||||
'amount_type': 'percent',
|
'amount_type': 'percent',
|
||||||
'type_tax_use': 'sale',
|
'type_tax_use': 'sale',
|
||||||
'account_id': self.tax_account.id,
|
'account_id': self.tax_account.id,
|
||||||
|
'company_id': self.company.id,
|
||||||
'refund_account_id': self.tax_account.id,
|
'refund_account_id': self.tax_account.id,
|
||||||
'tax_group_id': self.tax_group_10.id,
|
'tax_group_id': self.tax_group_10.id,
|
||||||
'tag_ids': [(6, 0, [self.tax_tag_01.id, self.tax_tag_02.id])]
|
'tag_ids': [(6, 0, [self.tax_tag_01.id, self.tax_tag_02.id])]
|
||||||
|
@ -102,6 +108,7 @@ class TestVATReport(common.TransactionCase):
|
||||||
'type_tax_use': 'sale',
|
'type_tax_use': 'sale',
|
||||||
'tax_exigibility': 'on_payment',
|
'tax_exigibility': 'on_payment',
|
||||||
'account_id': self.tax_account.id,
|
'account_id': self.tax_account.id,
|
||||||
|
'company_id': self.company.id,
|
||||||
'refund_account_id': self.tax_account.id,
|
'refund_account_id': self.tax_account.id,
|
||||||
'cash_basis_account': self.tax_account.id,
|
'cash_basis_account': self.tax_account.id,
|
||||||
'tax_group_id': self.tax_group_20.id,
|
'tax_group_id': self.tax_group_20.id,
|
||||||
|
@ -111,6 +118,7 @@ class TestVATReport(common.TransactionCase):
|
||||||
invoice = self.env['account.invoice'].create({
|
invoice = self.env['account.invoice'].create({
|
||||||
'partner_id': self.env.ref('base.res_partner_2').id,
|
'partner_id': self.env.ref('base.res_partner_2').id,
|
||||||
'account_id': self.receivable_account.id,
|
'account_id': self.receivable_account.id,
|
||||||
|
'company_id': self.company.id,
|
||||||
'date_invoice': time.strftime('%Y-%m-03'),
|
'date_invoice': time.strftime('%Y-%m-03'),
|
||||||
'type': 'out_invoice',
|
'type': 'out_invoice',
|
||||||
})
|
})
|
||||||
|
@ -130,6 +138,7 @@ class TestVATReport(common.TransactionCase):
|
||||||
self.cbinvoice = self.env['account.invoice'].create({
|
self.cbinvoice = self.env['account.invoice'].create({
|
||||||
'partner_id': self.env.ref('base.res_partner_2').id,
|
'partner_id': self.env.ref('base.res_partner_2').id,
|
||||||
'account_id': self.receivable_account.id,
|
'account_id': self.receivable_account.id,
|
||||||
|
'company_id': self.company.id,
|
||||||
'date_invoice': time.strftime('%Y-%m-05'),
|
'date_invoice': time.strftime('%Y-%m-05'),
|
||||||
'type': 'out_invoice',
|
'type': 'out_invoice',
|
||||||
})
|
})
|
||||||
|
@ -147,13 +156,12 @@ class TestVATReport(common.TransactionCase):
|
||||||
self.cbinvoice.action_invoice_open()
|
self.cbinvoice.action_invoice_open()
|
||||||
|
|
||||||
def _get_report_lines(self):
|
def _get_report_lines(self):
|
||||||
company = self.env.ref('base.main_company')
|
|
||||||
self.cbinvoice.pay_and_reconcile(
|
self.cbinvoice.pay_and_reconcile(
|
||||||
self.bank_journal.id, 300, time.strftime('%Y-%m-10'))
|
self.bank_journal.id, 300, time.strftime('%Y-%m-10'))
|
||||||
vat_report = self.env['report_vat_report'].create({
|
vat_report = self.env['report_vat_report'].create({
|
||||||
'date_from': self.date_from,
|
'date_from': self.date_from,
|
||||||
'date_to': self.date_to,
|
'date_to': self.date_to,
|
||||||
'company_id': company.id,
|
'company_id': self.company.id,
|
||||||
'based_on': 'taxtags',
|
'based_on': 'taxtags',
|
||||||
'tax_detail': True,
|
'tax_detail': True,
|
||||||
})
|
})
|
||||||
|
@ -238,11 +246,10 @@ class TestVATReport(common.TransactionCase):
|
||||||
self.assertEqual(lines['tax_group_20'].tax, 50)
|
self.assertEqual(lines['tax_group_20'].tax, 50)
|
||||||
|
|
||||||
def test_get_report_html(self):
|
def test_get_report_html(self):
|
||||||
company = self.env.ref('base.main_company')
|
|
||||||
vat_report = self.env['report_vat_report'].create({
|
vat_report = self.env['report_vat_report'].create({
|
||||||
'date_from': self.date_from,
|
'date_from': self.date_from,
|
||||||
'date_to': self.date_to,
|
'date_to': self.date_to,
|
||||||
'company_id': company.id,
|
'company_id': self.company.id,
|
||||||
'tax_detail': True,
|
'tax_detail': True,
|
||||||
})
|
})
|
||||||
vat_report.compute_data_for_report()
|
vat_report.compute_data_for_report()
|
||||||
|
|
|
@ -17,6 +17,7 @@ class AgedPartnerBalanceWizard(models.TransientModel):
|
||||||
company_id = fields.Many2one(
|
company_id = fields.Many2one(
|
||||||
comodel_name='res.company',
|
comodel_name='res.company',
|
||||||
default=lambda self: self.env.user.company_id,
|
default=lambda self: self.env.user.company_id,
|
||||||
|
required=True,
|
||||||
string='Company'
|
string='Company'
|
||||||
)
|
)
|
||||||
date_at = fields.Date(required=True,
|
date_at = fields.Date(required=True,
|
||||||
|
@ -38,11 +39,22 @@ class AgedPartnerBalanceWizard(models.TransientModel):
|
||||||
)
|
)
|
||||||
show_move_line_details = fields.Boolean()
|
show_move_line_details = fields.Boolean()
|
||||||
|
|
||||||
|
@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)
|
||||||
|
if self.company_id and self.account_ids:
|
||||||
|
self.account_ids = self.account_ids.filtered(
|
||||||
|
lambda a: a.company_id == self.company_id)
|
||||||
|
|
||||||
@api.onchange('receivable_accounts_only', 'payable_accounts_only')
|
@api.onchange('receivable_accounts_only', 'payable_accounts_only')
|
||||||
def onchange_type_accounts_only(self):
|
def onchange_type_accounts_only(self):
|
||||||
"""Handle receivable/payable accounts only change."""
|
"""Handle receivable/payable accounts only change."""
|
||||||
if self.receivable_accounts_only or self.payable_accounts_only:
|
if self.receivable_accounts_only or self.payable_accounts_only:
|
||||||
domain = []
|
domain = [('company_id', '=', self.company_id.id)]
|
||||||
if self.receivable_accounts_only and 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:
|
elif self.receivable_accounts_only:
|
||||||
|
|
|
@ -21,15 +21,21 @@
|
||||||
</group>
|
</group>
|
||||||
<group name="partner_filter" col="1">
|
<group name="partner_filter" col="1">
|
||||||
<label for="partner_ids"/>
|
<label for="partner_ids"/>
|
||||||
<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}"
|
||||||
|
domain="['|',('company_id','=',company_id), ('company_id','=',False)]"/>
|
||||||
</group>
|
</group>
|
||||||
<group name="account_filter" col="4">
|
<group name="account_filter" col="4">
|
||||||
<label for="account_ids" colspan="4"/>
|
<label for="account_ids" colspan="4"/>
|
||||||
<field name="receivable_accounts_only"/>
|
<field name="receivable_accounts_only"/>
|
||||||
<field name="payable_accounts_only"/>
|
<field name="payable_accounts_only"/>
|
||||||
<field name="account_ids" nolabel="1" widget="many2many_tags" options="{'no_create': True}" colspan="4"/>
|
<field name="account_ids" nolabel="1"
|
||||||
|
widget="many2many_tags"
|
||||||
|
options="{'no_create': True}"
|
||||||
|
domain="[('company_id','=',company_id)]"
|
||||||
|
colspan="4"/>
|
||||||
</group>
|
</group>
|
||||||
<field name="account_ids" nolabel="1" options="{'no_create': True}"/>
|
|
||||||
<footer>
|
<footer>
|
||||||
<button name="button_export_html" string="View"
|
<button name="button_export_html" string="View"
|
||||||
type="object" default_focus="1" class="oe_highlight"/>
|
type="object" default_focus="1" class="oe_highlight"/>
|
||||||
|
|
|
@ -7,9 +7,10 @@
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# 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.tools.safe_eval import safe_eval
|
from odoo.tools.safe_eval import safe_eval
|
||||||
from odoo.tools import pycompat
|
from odoo.tools import pycompat
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
class GeneralLedgerReportWizard(models.TransientModel):
|
class GeneralLedgerReportWizard(models.TransientModel):
|
||||||
|
@ -21,6 +22,7 @@ class GeneralLedgerReportWizard(models.TransientModel):
|
||||||
company_id = fields.Many2one(
|
company_id = fields.Many2one(
|
||||||
comodel_name='res.company',
|
comodel_name='res.company',
|
||||||
default=lambda self: self.env.user.company_id,
|
default=lambda self: self.env.user.company_id,
|
||||||
|
required=True,
|
||||||
string='Company'
|
string='Company'
|
||||||
)
|
)
|
||||||
date_range_id = fields.Many2one(
|
date_range_id = fields.Many2one(
|
||||||
|
@ -98,6 +100,19 @@ class GeneralLedgerReportWizard(models.TransientModel):
|
||||||
('company_id', '=', self.company_id.id)
|
('company_id', '=', self.company_id.id)
|
||||||
])
|
])
|
||||||
self.not_only_one_unaffected_earnings_account = count != 1
|
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:
|
||||||
|
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)
|
||||||
|
if self.company_id and self.account_ids:
|
||||||
|
self.account_ids = self.account_ids.filtered(
|
||||||
|
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)
|
||||||
|
|
||||||
@api.onchange('date_range_id')
|
@api.onchange('date_range_id')
|
||||||
def onchange_date_range_id(self):
|
def onchange_date_range_id(self):
|
||||||
|
@ -105,11 +120,21 @@ class GeneralLedgerReportWizard(models.TransientModel):
|
||||||
self.date_from = self.date_range_id.date_start
|
self.date_from = self.date_range_id.date_start
|
||||||
self.date_to = self.date_range_id.date_end
|
self.date_to = self.date_range_id.date_end
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
@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:
|
||||||
|
raise ValidationError(
|
||||||
|
_('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):
|
def onchange_type_accounts_only(self):
|
||||||
"""Handle receivable/payable accounts only change."""
|
"""Handle receivable/payable accounts only change."""
|
||||||
if self.receivable_accounts_only or self.payable_accounts_only:
|
if self.receivable_accounts_only or self.payable_accounts_only:
|
||||||
domain = []
|
domain = [('company_id', '=', self.company_id.id)]
|
||||||
if self.receivable_accounts_only and 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:
|
elif self.receivable_accounts_only:
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
<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="filters">
|
||||||
<group name="date_range">
|
<group name="date_range">
|
||||||
<field name="date_range_id" domain="['|',('company_id','=',company_id), ('company_id','=',False)]"/>
|
<field name="date_range_id"
|
||||||
|
domain="['|',('company_id','=',company_id), ('company_id','=',False)]"/>
|
||||||
<field name="date_from"/>
|
<field name="date_from"/>
|
||||||
<field name="date_to"/>
|
<field name="date_to"/>
|
||||||
<field name="fy_start_date" invisible="1"/>
|
<field name="fy_start_date" invisible="1"/>
|
||||||
|
@ -32,13 +33,23 @@
|
||||||
<field name="receivable_accounts_only"/>
|
<field name="receivable_accounts_only"/>
|
||||||
<field name="payable_accounts_only"/>
|
<field name="payable_accounts_only"/>
|
||||||
</group>
|
</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}"
|
||||||
|
domain="[('company_id','=',company_id)]"/>
|
||||||
</page>
|
</page>
|
||||||
<page string="Filter partners">
|
<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"
|
||||||
|
domain="['|',('company_id','=',company_id), ('company_id','=',False)]"
|
||||||
|
options="{'no_create': True}"/>
|
||||||
</page>
|
</page>
|
||||||
<page string="Filter cost centers" 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"/>
|
<field name="cost_center_ids" nolabel="1"
|
||||||
|
options="{'no_create': True}"
|
||||||
|
domain="[('company_id','=',company_id)]"
|
||||||
|
groups="analytic.group_analytic_accounting"/>
|
||||||
</page>
|
</page>
|
||||||
<page string="Filter analytic tags">
|
<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}"/>
|
||||||
|
|
|
@ -17,6 +17,7 @@ class OpenItemsReportWizard(models.TransientModel):
|
||||||
company_id = fields.Many2one(
|
company_id = fields.Many2one(
|
||||||
comodel_name='res.company',
|
comodel_name='res.company',
|
||||||
default=lambda self: self.env.user.company_id,
|
default=lambda self: self.env.user.company_id,
|
||||||
|
required=True,
|
||||||
string='Company'
|
string='Company'
|
||||||
)
|
)
|
||||||
date_at = fields.Date(required=True,
|
date_at = fields.Date(required=True,
|
||||||
|
@ -51,11 +52,22 @@ class OpenItemsReportWizard(models.TransientModel):
|
||||||
'will display initial and final balance in that currency.'
|
'will display initial and final balance in that currency.'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@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)
|
||||||
|
if self.company_id and self.account_ids:
|
||||||
|
self.account_ids = self.account_ids.filtered(
|
||||||
|
lambda a: a.company_id == self.company_id)
|
||||||
|
|
||||||
@api.onchange('receivable_accounts_only', 'payable_accounts_only')
|
@api.onchange('receivable_accounts_only', 'payable_accounts_only')
|
||||||
def onchange_type_accounts_only(self):
|
def onchange_type_accounts_only(self):
|
||||||
"""Handle receivable/payable accounts only change."""
|
"""Handle receivable/payable accounts only change."""
|
||||||
if self.receivable_accounts_only or self.payable_accounts_only:
|
if self.receivable_accounts_only or self.payable_accounts_only:
|
||||||
domain = []
|
domain = [('company_id', '=', self.company_id.id)]
|
||||||
if self.receivable_accounts_only and 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:
|
elif self.receivable_accounts_only:
|
||||||
|
|
|
@ -22,13 +22,21 @@
|
||||||
</group>
|
</group>
|
||||||
<group name="partner_filter" col="1">
|
<group name="partner_filter" col="1">
|
||||||
<label for="partner_ids"/>
|
<label for="partner_ids"/>
|
||||||
<field name="partner_ids" nolabel="1" widget="many2many_tags" options="{'no_create': True}"/>
|
<field name="partner_ids"
|
||||||
|
nolabel="1"
|
||||||
|
domain="['|',('company_id','=',company_id), ('company_id','=',False)]"
|
||||||
|
widget="many2many_tags"
|
||||||
|
options="{'no_create': True}"/>
|
||||||
</group>
|
</group>
|
||||||
<group name="account_filter" col="4">
|
<group name="account_filter" col="4">
|
||||||
<label for="account_ids" colspan="4"/>
|
|
||||||
<field name="receivable_accounts_only"/>
|
<field name="receivable_accounts_only"/>
|
||||||
<field name="payable_accounts_only"/>
|
<field name="payable_accounts_only"/>
|
||||||
<field name="account_ids" nolabel="1" widget="many2many_tags" options="{'no_create': True}" colspan="4"/>
|
<field name="account_ids"
|
||||||
|
nolabel="1"
|
||||||
|
widget="many2many_tags"
|
||||||
|
domain="[('company_id','=',company_id)]"
|
||||||
|
options="{'no_create': True}"
|
||||||
|
colspan="4"/>
|
||||||
</group>
|
</group>
|
||||||
<footer>
|
<footer>
|
||||||
<button name="button_export_html" string="View"
|
<button name="button_export_html" string="View"
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
from odoo import api, fields, models, _
|
from odoo import api, fields, models, _
|
||||||
from odoo.tools.safe_eval import safe_eval
|
from odoo.tools.safe_eval import safe_eval
|
||||||
from odoo.tools import pycompat
|
from odoo.tools import pycompat
|
||||||
from odoo.exceptions import UserError
|
from odoo.exceptions import UserError, ValidationError
|
||||||
|
|
||||||
|
|
||||||
class TrialBalanceReportWizard(models.TransientModel):
|
class TrialBalanceReportWizard(models.TransientModel):
|
||||||
|
@ -19,6 +19,7 @@ class TrialBalanceReportWizard(models.TransientModel):
|
||||||
company_id = fields.Many2one(
|
company_id = fields.Many2one(
|
||||||
comodel_name='res.company',
|
comodel_name='res.company',
|
||||||
default=lambda self: self.env.user.company_id,
|
default=lambda self: self.env.user.company_id,
|
||||||
|
required=True,
|
||||||
string='Company'
|
string='Company'
|
||||||
)
|
)
|
||||||
date_range_id = fields.Many2one(
|
date_range_id = fields.Many2one(
|
||||||
|
@ -107,6 +108,16 @@ class TrialBalanceReportWizard(models.TransientModel):
|
||||||
('company_id', '=', self.company_id.id)
|
('company_id', '=', self.company_id.id)
|
||||||
])
|
])
|
||||||
self.not_only_one_unaffected_earnings_account = count != 1
|
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:
|
||||||
|
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)
|
||||||
|
if self.company_id and self.account_ids:
|
||||||
|
self.account_ids = self.account_ids.filtered(
|
||||||
|
lambda a: a.company_id == self.company_id)
|
||||||
|
|
||||||
@api.onchange('date_range_id')
|
@api.onchange('date_range_id')
|
||||||
def onchange_date_range_id(self):
|
def onchange_date_range_id(self):
|
||||||
|
@ -114,11 +125,21 @@ class TrialBalanceReportWizard(models.TransientModel):
|
||||||
self.date_from = self.date_range_id.date_start
|
self.date_from = self.date_range_id.date_start
|
||||||
self.date_to = self.date_range_id.date_end
|
self.date_to = self.date_range_id.date_end
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
@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:
|
||||||
|
raise ValidationError(
|
||||||
|
_('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):
|
def onchange_type_accounts_only(self):
|
||||||
"""Handle receivable/payable accounts only change."""
|
"""Handle receivable/payable accounts only change."""
|
||||||
if self.receivable_accounts_only or self.payable_accounts_only:
|
if self.receivable_accounts_only or self.payable_accounts_only:
|
||||||
domain = []
|
domain = [('company_id', '=', self.company_id.id)]
|
||||||
if self.receivable_accounts_only and 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:
|
elif self.receivable_accounts_only:
|
||||||
|
|
|
@ -30,17 +30,31 @@
|
||||||
</group>
|
</group>
|
||||||
<group name="partner_filter" attrs="{'invisible':[('show_partner_details','!=',True)]}" col="1">
|
<group name="partner_filter" attrs="{'invisible':[('show_partner_details','!=',True)]}" col="1">
|
||||||
<label for="partner_ids"/>
|
<label for="partner_ids"/>
|
||||||
<field name="partner_ids" nolabel="1" widget="many2many_tags" options="{'no_create': True}"/>
|
<field name="partner_ids"
|
||||||
|
nolabel="1"
|
||||||
|
domain="['|',('company_id','=',company_id), ('company_id','=',False)]"
|
||||||
|
widget="many2many_tags"
|
||||||
|
options="{'no_create': True}"/>
|
||||||
</group>
|
</group>
|
||||||
<label for="journal_ids"/>
|
<label for="journal_ids"/>
|
||||||
<field name="journal_ids" widget="many2many_tags" nolabel="1" options="{'no_create': True}"/>
|
<field name="journal_ids"
|
||||||
|
widget="many2many_tags"
|
||||||
|
domain="[('company_id','=',company_id)]"
|
||||||
|
nolabel="1"
|
||||||
|
options="{'no_create': True}"
|
||||||
|
/>
|
||||||
<group attrs="{'invisible':[('show_partner_details','!=',True)]}"/>
|
<group attrs="{'invisible':[('show_partner_details','!=',True)]}"/>
|
||||||
<div/>
|
<div/>
|
||||||
<group name="account_filter" col="4">
|
<group name="account_filter" col="4">
|
||||||
<label for="account_ids" colspan="4"/>
|
<label for="account_ids" colspan="4"/>
|
||||||
<field name="receivable_accounts_only"/>
|
<field name="receivable_accounts_only"/>
|
||||||
<field name="payable_accounts_only"/>
|
<field name="payable_accounts_only"/>
|
||||||
<field name="account_ids" nolabel="1" widget="many2many_tags" options="{'no_create': True}" colspan="4"/>
|
<field name="account_ids"
|
||||||
|
nolabel="1"
|
||||||
|
widget="many2many_tags"
|
||||||
|
domain="[('company_id','=',company_id)]"
|
||||||
|
options="{'no_create': True}"
|
||||||
|
colspan="4"/>
|
||||||
</group>
|
</group>
|
||||||
</div>
|
</div>
|
||||||
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', False)]}">
|
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', False)]}">
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
# Copyright 2018 Forest and Biomass Romania
|
# Copyright 2018 Forest and Biomass Romania
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# 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.tools.safe_eval import safe_eval
|
from odoo.tools.safe_eval import safe_eval
|
||||||
from odoo.tools import pycompat
|
from odoo.tools import pycompat
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
class VATReportWizard(models.TransientModel):
|
class VATReportWizard(models.TransientModel):
|
||||||
|
@ -12,6 +13,7 @@ class VATReportWizard(models.TransientModel):
|
||||||
company_id = fields.Many2one(
|
company_id = fields.Many2one(
|
||||||
comodel_name='res.company',
|
comodel_name='res.company',
|
||||||
default=lambda self: self.env.user.company_id,
|
default=lambda self: self.env.user.company_id,
|
||||||
|
required=True,
|
||||||
string='Company'
|
string='Company'
|
||||||
)
|
)
|
||||||
date_range_id = fields.Many2one(
|
date_range_id = fields.Many2one(
|
||||||
|
@ -27,12 +29,28 @@ class VATReportWizard(models.TransientModel):
|
||||||
default='taxtags')
|
default='taxtags')
|
||||||
tax_detail = fields.Boolean('Detail Taxes')
|
tax_detail = fields.Boolean('Detail Taxes')
|
||||||
|
|
||||||
|
@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:
|
||||||
|
self.date_range_id = False
|
||||||
|
|
||||||
@api.onchange('date_range_id')
|
@api.onchange('date_range_id')
|
||||||
def onchange_date_range_id(self):
|
def onchange_date_range_id(self):
|
||||||
"""Handle date range change."""
|
"""Handle date range change."""
|
||||||
self.date_from = self.date_range_id.date_start
|
self.date_from = self.date_range_id.date_start
|
||||||
self.date_to = self.date_range_id.date_end
|
self.date_to = self.date_range_id.date_end
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
@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:
|
||||||
|
raise ValidationError(
|
||||||
|
_('The Company in the Vat Report Wizard and in '
|
||||||
|
'Date Range must be the same.'))
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def button_export_html(self):
|
def button_export_html(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
|
|
Loading…
Reference in New Issue