[FIX] account_financial_report: Refactor tests
Use core account test base, helping to ensure we have the correct accounting environment setup. If any of the localization modules are loaded, this will make this tests be skipped, instead of simply failing TT28423pull/868/head
parent
f23450bbed
commit
436a6e028d
|
@ -7,45 +7,34 @@ import time
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
from odoo import api, fields
|
from odoo import api, fields
|
||||||
from odoo.tests import common
|
|
||||||
|
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
|
||||||
|
|
||||||
|
|
||||||
class TestGeneralLedgerReport(common.TransactionCase):
|
class TestGeneralLedgerReport(AccountTestInvoicingCommon):
|
||||||
def setUp(self):
|
@classmethod
|
||||||
super(TestGeneralLedgerReport, self).setUp()
|
def setUpClass(cls, chart_template_ref=None):
|
||||||
self.env.user.company_id = self.env.ref("base.main_company").id
|
super().setUpClass(chart_template_ref=chart_template_ref)
|
||||||
self.before_previous_fy_year = fields.Date.from_string("2014-05-05")
|
cls.before_previous_fy_year = fields.Date.from_string("2014-05-05")
|
||||||
self.previous_fy_date_start = fields.Date.from_string("2015-01-01")
|
cls.previous_fy_date_start = fields.Date.from_string("2015-01-01")
|
||||||
self.previous_fy_date_end = fields.Date.from_string("2015-12-31")
|
cls.previous_fy_date_end = fields.Date.from_string("2015-12-31")
|
||||||
self.fy_date_start = fields.Date.from_string("2016-01-01")
|
cls.fy_date_start = fields.Date.from_string("2016-01-01")
|
||||||
self.fy_date_end = fields.Date.from_string("2016-12-31")
|
cls.fy_date_end = fields.Date.from_string("2016-12-31")
|
||||||
|
# Get accounts
|
||||||
self.receivable_account = self.env["account.account"].search(
|
cls.receivable_account = cls.company_data["default_account_receivable"]
|
||||||
[
|
cls.income_account = cls.company_data["default_account_revenue"]
|
||||||
("user_type_id.name", "=", "Receivable"),
|
cls.unaffected_account = cls.env["account.account"].search(
|
||||||
("company_id", "=", self.env.user.company_id.id),
|
|
||||||
],
|
|
||||||
limit=1,
|
|
||||||
)
|
|
||||||
self.income_account = self.env["account.account"].search(
|
|
||||||
[
|
|
||||||
("user_type_id.name", "=", "Income"),
|
|
||||||
("company_id", "=", self.env.user.company_id.id),
|
|
||||||
],
|
|
||||||
limit=1,
|
|
||||||
)
|
|
||||||
self.unaffected_account = self.env["account.account"].search(
|
|
||||||
[
|
[
|
||||||
(
|
(
|
||||||
"user_type_id",
|
"user_type_id",
|
||||||
"=",
|
"=",
|
||||||
self.env.ref("account.data_unaffected_earnings").id,
|
cls.env.ref("account.data_unaffected_earnings").id,
|
||||||
),
|
),
|
||||||
("company_id", "=", self.env.user.company_id.id),
|
("company_id", "=", cls.env.user.company_id.id),
|
||||||
],
|
],
|
||||||
limit=1,
|
limit=1,
|
||||||
)
|
)
|
||||||
self.partner = self.env.ref("base.res_partner_12")
|
cls.partner = cls.env.ref("base.res_partner_12")
|
||||||
|
|
||||||
def _add_move(
|
def _add_move(
|
||||||
self,
|
self,
|
||||||
|
@ -104,7 +93,7 @@ class TestGeneralLedgerReport(common.TransactionCase):
|
||||||
centralize = True
|
centralize = True
|
||||||
if with_partners:
|
if with_partners:
|
||||||
centralize = False
|
centralize = False
|
||||||
company = self.env.ref("base.main_company")
|
company = self.env.user.company_id
|
||||||
general_ledger = self.env["general.ledger.report.wizard"].create(
|
general_ledger = self.env["general.ledger.report.wizard"].create(
|
||||||
{
|
{
|
||||||
"date_from": self.fy_date_start,
|
"date_from": self.fy_date_start,
|
||||||
|
@ -685,7 +674,7 @@ class TestGeneralLedgerReport(common.TransactionCase):
|
||||||
self.assertEqual(wizard._default_partners(), expected_list)
|
self.assertEqual(wizard._default_partners(), expected_list)
|
||||||
|
|
||||||
def test_validate_date(self):
|
def test_validate_date(self):
|
||||||
company_id = self.env.ref("base.main_company")
|
company_id = self.env.user.company_id
|
||||||
company_id.write({"fiscalyear_last_day": 31, "fiscalyear_last_month": "12"})
|
company_id.write({"fiscalyear_last_day": 31, "fiscalyear_last_month": "12"})
|
||||||
user = self.env.ref("base.user_root").with_context(company_id=company_id.id)
|
user = self.env.ref("base.user_root").with_context(company_id=company_id.id)
|
||||||
wizard = self.env["general.ledger.report.wizard"].with_context(user=user.id)
|
wizard = self.env["general.ledger.report.wizard"].with_context(user=user.id)
|
||||||
|
|
|
@ -7,93 +7,46 @@ from datetime import datetime
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
|
|
||||||
from odoo.fields import Date
|
from odoo.fields import Date
|
||||||
from odoo.tests.common import Form, TransactionCase
|
from odoo.tests.common import Form
|
||||||
|
|
||||||
|
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
|
||||||
|
|
||||||
|
|
||||||
class TestJournalReport(TransactionCase):
|
class TestJournalReport(AccountTestInvoicingCommon):
|
||||||
def setUp(self):
|
@classmethod
|
||||||
super(TestJournalReport, self).setUp()
|
def setUpClass(cls, chart_template_ref=None):
|
||||||
self.env.user.company_id = self.env.ref("base.main_company").id
|
super().setUpClass(chart_template_ref=chart_template_ref)
|
||||||
self.AccountObj = self.env["account.account"]
|
cls.AccountObj = cls.env["account.account"]
|
||||||
self.InvoiceObj = self.env["account.move"]
|
cls.InvoiceObj = cls.env["account.move"]
|
||||||
self.JournalObj = self.env["account.journal"]
|
cls.JournalObj = cls.env["account.journal"]
|
||||||
self.MoveObj = self.env["account.move"]
|
cls.MoveObj = cls.env["account.move"]
|
||||||
self.TaxObj = self.env["account.tax"]
|
cls.TaxObj = cls.env["account.tax"]
|
||||||
|
cls.JournalLedgerReportWizard = cls.env["journal.ledger.report.wizard"]
|
||||||
self.JournalLedgerReportWizard = self.env["journal.ledger.report.wizard"]
|
cls.JournalLedgerReport = cls.env[
|
||||||
self.JournalLedgerReport = self.env[
|
|
||||||
"report.account_financial_report.journal_ledger"
|
"report.account_financial_report.journal_ledger"
|
||||||
]
|
]
|
||||||
self.company = self.env.ref("base.main_company")
|
cls.company = cls.company_data["company"]
|
||||||
self.company.account_sale_tax_id = False
|
cls.company.account_sale_tax_id = False
|
||||||
self.company.account_purchase_tax_id = False
|
cls.company.account_purchase_tax_id = False
|
||||||
|
|
||||||
today = datetime.today()
|
today = datetime.today()
|
||||||
last_year = today - relativedelta(years=1)
|
last_year = today - relativedelta(years=1)
|
||||||
|
cls.previous_fy_date_start = Date.to_string(last_year.replace(month=1, day=1))
|
||||||
self.previous_fy_date_start = Date.to_string(last_year.replace(month=1, day=1))
|
cls.previous_fy_date_end = Date.to_string(last_year.replace(month=12, day=31))
|
||||||
self.previous_fy_date_end = Date.to_string(last_year.replace(month=12, day=31))
|
cls.fy_date_start = Date.to_string(today.replace(month=1, day=1))
|
||||||
self.fy_date_start = Date.to_string(today.replace(month=1, day=1))
|
cls.fy_date_end = Date.to_string(today.replace(month=12, day=31))
|
||||||
self.fy_date_end = Date.to_string(today.replace(month=12, day=31))
|
cls.receivable_account = cls.company_data["default_account_receivable"]
|
||||||
|
cls.income_account = cls.company_data["default_account_revenue"]
|
||||||
self.receivable_account = self.AccountObj.search(
|
cls.expense_account = cls.company_data["default_account_expense"]
|
||||||
[
|
cls.payable_account = cls.company_data["default_account_payable"]
|
||||||
("user_type_id.name", "=", "Receivable"),
|
cls.journal_sale = cls.company_data["default_journal_sale"]
|
||||||
("company_id", "=", self.env.user.company_id.id),
|
cls.journal_purchase = cls.company_data["default_journal_purchase"]
|
||||||
],
|
cls.tax_15_s = cls.company_data["default_tax_sale"]
|
||||||
limit=1,
|
cls.tax_15_s.sequence = 30
|
||||||
)
|
cls.tax_15_s.amount = 15.0
|
||||||
self.income_account = self.AccountObj.search(
|
cls.tax_15_s.amount_type = "percent"
|
||||||
[
|
cls.tax_15_s.include_base_amount = False
|
||||||
("user_type_id.name", "=", "Income"),
|
cls.tax_15_s.type_tax_use = "sale"
|
||||||
("company_id", "=", self.env.user.company_id.id),
|
cls.tax_20_s = cls.tax_15_s.copy(
|
||||||
],
|
|
||||||
limit=1,
|
|
||||||
)
|
|
||||||
self.expense_account = self.AccountObj.search(
|
|
||||||
[
|
|
||||||
("user_type_id.name", "=", "Expenses"),
|
|
||||||
("company_id", "=", self.env.user.company_id.id),
|
|
||||||
],
|
|
||||||
limit=1,
|
|
||||||
)
|
|
||||||
self.payable_account = self.AccountObj.search(
|
|
||||||
[
|
|
||||||
("user_type_id.name", "=", "Payable"),
|
|
||||||
("company_id", "=", self.env.user.company_id.id),
|
|
||||||
],
|
|
||||||
limit=1,
|
|
||||||
)
|
|
||||||
|
|
||||||
self.journal_sale = self.JournalObj.create(
|
|
||||||
{
|
|
||||||
"name": "Test journal sale",
|
|
||||||
"code": "TST-JRNL-S",
|
|
||||||
"type": "sale",
|
|
||||||
"company_id": self.company.id,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
self.journal_purchase = self.JournalObj.create(
|
|
||||||
{
|
|
||||||
"name": "Test journal purchase",
|
|
||||||
"code": "TST-JRNL-P",
|
|
||||||
"type": "purchase",
|
|
||||||
"company_id": self.company.id,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
self.tax_15_s = self.TaxObj.create(
|
|
||||||
{
|
|
||||||
"sequence": 30,
|
|
||||||
"name": "Tax 15.0% (Percentage of Price)",
|
|
||||||
"amount": 15.0,
|
|
||||||
"amount_type": "percent",
|
|
||||||
"include_base_amount": False,
|
|
||||||
"type_tax_use": "sale",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
self.tax_20_s = self.TaxObj.create(
|
|
||||||
{
|
{
|
||||||
"sequence": 30,
|
"sequence": 30,
|
||||||
"name": "Tax 20.0% (Percentage of Price)",
|
"name": "Tax 20.0% (Percentage of Price)",
|
||||||
|
@ -103,19 +56,13 @@ class TestJournalReport(TransactionCase):
|
||||||
"type_tax_use": "sale",
|
"type_tax_use": "sale",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
cls.tax_15_p = cls.company_data["default_tax_purchase"]
|
||||||
self.tax_15_p = self.TaxObj.create(
|
cls.tax_15_p.sequence = 30
|
||||||
{
|
cls.tax_15_p.amount = 15.0
|
||||||
"sequence": 30,
|
cls.tax_15_p.amount_type = "percent"
|
||||||
"name": "Tax 15.0% (Percentage of Price)",
|
cls.tax_15_p.include_base_amount = False
|
||||||
"amount": 15.0,
|
cls.tax_15_p.type_tax_use = "purchase"
|
||||||
"amount_type": "percent",
|
cls.tax_20_p = cls.tax_15_p.copy(
|
||||||
"include_base_amount": False,
|
|
||||||
"type_tax_use": "purchase",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
self.tax_20_p = self.TaxObj.create(
|
|
||||||
{
|
{
|
||||||
"sequence": 30,
|
"sequence": 30,
|
||||||
"name": "Tax 20.0% (Percentage of Price)",
|
"name": "Tax 20.0% (Percentage of Price)",
|
||||||
|
@ -125,8 +72,7 @@ class TestJournalReport(TransactionCase):
|
||||||
"type_tax_use": "purchase",
|
"type_tax_use": "purchase",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
cls.partner_2 = cls.env.ref("base.res_partner_2")
|
||||||
self.partner_2 = self.env.ref("base.res_partner_2")
|
|
||||||
|
|
||||||
def _add_move(
|
def _add_move(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -2,12 +2,15 @@
|
||||||
# Copyright 2016 Camptocamp SA
|
# Copyright 2016 Camptocamp SA
|
||||||
# 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.tests.common import TransactionCase
|
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
|
||||||
|
|
||||||
|
|
||||||
class TestOpenItems(TransactionCase):
|
class TestOpenItems(AccountTestInvoicingCommon):
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls, chart_template_ref=None):
|
||||||
|
super().setUpClass(chart_template_ref=chart_template_ref)
|
||||||
|
|
||||||
def test_partner_filter(self):
|
def test_partner_filter(self):
|
||||||
self.env.user.company_id = self.env.ref("base.main_company").id
|
|
||||||
partner_1 = self.env.ref("base.res_partner_1")
|
partner_1 = self.env.ref("base.res_partner_1")
|
||||||
partner_2 = self.env.ref("base.res_partner_2")
|
partner_2 = self.env.ref("base.res_partner_2")
|
||||||
partner_3 = self.env.ref("base.res_partner_3")
|
partner_3 = self.env.ref("base.res_partner_3")
|
||||||
|
|
|
@ -3,85 +3,79 @@
|
||||||
# Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com)
|
# Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com)
|
||||||
# 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.tests import common
|
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
|
||||||
|
|
||||||
|
|
||||||
class TestTrialBalanceReport(common.TransactionCase):
|
class TestTrialBalanceReport(AccountTestInvoicingCommon):
|
||||||
def setUp(self):
|
@classmethod
|
||||||
super(TestTrialBalanceReport, self).setUp()
|
def setUpClass(cls, chart_template_ref=None):
|
||||||
self.env.user.company_id = self.env.ref("base.main_company").id
|
super().setUpClass(chart_template_ref=chart_template_ref)
|
||||||
group_obj = self.env["account.group"]
|
|
||||||
# Remove previous account groups and related invoices to avoid conflicts
|
# Remove previous account groups and related invoices to avoid conflicts
|
||||||
group_obj.search([("code_prefix_start", "in", ["1", "2", "11"])]).unlink()
|
group_obj = cls.env["account.group"]
|
||||||
self.group1 = group_obj.create({"code_prefix_start": "1", "name": "Group 1"})
|
cls.group1 = group_obj.create({"code_prefix_start": "1", "name": "Group 1"})
|
||||||
self.group11 = group_obj.create(
|
cls.group11 = group_obj.create(
|
||||||
{"code_prefix_start": "11", "name": "Group 11", "parent_id": self.group1.id}
|
{"code_prefix_start": "11", "name": "Group 11", "parent_id": cls.group1.id}
|
||||||
)
|
)
|
||||||
self.group2 = group_obj.create({"code_prefix_start": "2", "name": "Group 2"})
|
cls.group2 = group_obj.create({"code_prefix_start": "2", "name": "Group 2"})
|
||||||
self.account100 = self._create_account_account(
|
# Set accounts
|
||||||
{
|
cls.account100 = cls.company_data["default_account_receivable"]
|
||||||
"code": "100",
|
cls.account100.group_id = cls.group1.id
|
||||||
"name": "Account 100",
|
cls.account110 = cls.env["account.account"].search(
|
||||||
"group_id": self.group1.id,
|
|
||||||
"user_type_id": self.env.ref("account.data_account_type_receivable").id,
|
|
||||||
"reconcile": True,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
self.account110 = self.env["account.account"].search(
|
|
||||||
[
|
[
|
||||||
(
|
(
|
||||||
"user_type_id",
|
"user_type_id",
|
||||||
"=",
|
"=",
|
||||||
self.env.ref("account.data_unaffected_earnings").id,
|
cls.env.ref("account.data_unaffected_earnings").id,
|
||||||
),
|
),
|
||||||
("company_id", "=", self.env.user.company_id.id),
|
|
||||||
],
|
],
|
||||||
limit=1,
|
limit=1,
|
||||||
)
|
)
|
||||||
self.account200 = self._create_account_account(
|
cls.account200 = cls._create_account_account(
|
||||||
|
cls,
|
||||||
{
|
{
|
||||||
"code": "200",
|
"code": "200",
|
||||||
"name": "Account 200",
|
"name": "Account 200",
|
||||||
"group_id": self.group2.id,
|
"group_id": cls.group2.id,
|
||||||
"user_type_id": self.env.ref(
|
"user_type_id": cls.env.ref(
|
||||||
"account.data_account_type_other_income"
|
"account.data_account_type_other_income"
|
||||||
).id,
|
).id,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
self.account300 = self._create_account_account(
|
cls.account300 = cls._create_account_account(
|
||||||
|
cls,
|
||||||
{
|
{
|
||||||
"code": "300",
|
"code": "300",
|
||||||
"name": "Account 300",
|
"name": "Account 300",
|
||||||
"user_type_id": self.env.ref(
|
"user_type_id": cls.env.ref(
|
||||||
"account.data_account_type_other_income"
|
"account.data_account_type_other_income"
|
||||||
).id,
|
).id,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
self.account301 = self._create_account_account(
|
cls.account301 = cls._create_account_account(
|
||||||
|
cls,
|
||||||
{
|
{
|
||||||
"code": "301",
|
"code": "301",
|
||||||
"name": "Account 301",
|
"name": "Account 301",
|
||||||
"group_id": self.group2.id,
|
"group_id": cls.group2.id,
|
||||||
"user_type_id": self.env.ref(
|
"user_type_id": cls.env.ref(
|
||||||
"account.data_account_type_other_income"
|
"account.data_account_type_other_income"
|
||||||
).id,
|
).id,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
self.previous_fy_date_start = "2015-01-01"
|
cls.previous_fy_date_start = "2015-01-01"
|
||||||
self.previous_fy_date_end = "2015-12-31"
|
cls.previous_fy_date_end = "2015-12-31"
|
||||||
self.fy_date_start = "2016-01-01"
|
cls.fy_date_start = "2016-01-01"
|
||||||
self.fy_date_end = "2016-12-31"
|
cls.fy_date_end = "2016-12-31"
|
||||||
self.date_start = "2016-01-01"
|
cls.date_start = "2016-01-01"
|
||||||
self.date_end = "2016-12-31"
|
cls.date_end = "2016-12-31"
|
||||||
self.partner = self.env.ref("base.res_partner_12")
|
cls.partner = cls.env.ref("base.res_partner_12")
|
||||||
self.unaffected_account = self.env["account.account"].search(
|
cls.unaffected_account = cls.env["account.account"].search(
|
||||||
[
|
[
|
||||||
(
|
(
|
||||||
"user_type_id",
|
"user_type_id",
|
||||||
"=",
|
"=",
|
||||||
self.env.ref("account.data_unaffected_earnings").id,
|
cls.env.ref("account.data_unaffected_earnings").id,
|
||||||
),
|
),
|
||||||
("company_id", "=", self.env.user.company_id.id),
|
|
||||||
],
|
],
|
||||||
limit=1,
|
limit=1,
|
||||||
)
|
)
|
||||||
|
@ -166,7 +160,7 @@ class TestTrialBalanceReport(common.TransactionCase):
|
||||||
move.action_post()
|
move.action_post()
|
||||||
|
|
||||||
def _get_report_lines(self, with_partners=False, hierarchy_on="computed"):
|
def _get_report_lines(self, with_partners=False, hierarchy_on="computed"):
|
||||||
company = self.env.ref("base.main_company")
|
company = self.env.user.company_id
|
||||||
trial_balance = self.env["trial.balance.report.wizard"].create(
|
trial_balance = self.env["trial.balance.report.wizard"].create(
|
||||||
{
|
{
|
||||||
"date_from": self.date_start,
|
"date_from": self.date_start,
|
||||||
|
@ -694,7 +688,7 @@ class TestTrialBalanceReport(common.TransactionCase):
|
||||||
move = self.env["account.move"].create(move_vals)
|
move = self.env["account.move"].create(move_vals)
|
||||||
move.action_post()
|
move.action_post()
|
||||||
# Generate the trial balance line
|
# Generate the trial balance line
|
||||||
company = self.env.ref("base.main_company")
|
company = self.env.user.company_id
|
||||||
trial_balance = self.env["trial.balance.report.wizard"].create(
|
trial_balance = self.env["trial.balance.report.wizard"].create(
|
||||||
{
|
{
|
||||||
"date_from": self.date_start,
|
"date_from": self.date_start,
|
||||||
|
|
|
@ -5,81 +5,103 @@
|
||||||
import time
|
import time
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
from odoo.tests import common
|
from odoo import fields
|
||||||
|
from odoo.tests.common import Form
|
||||||
|
|
||||||
|
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
|
||||||
|
|
||||||
|
|
||||||
class TestVATReport(common.TransactionCase):
|
class TestVATReport(AccountTestInvoicingCommon):
|
||||||
def setUp(self):
|
@classmethod
|
||||||
super(TestVATReport, self).setUp()
|
def init_invoice(
|
||||||
self.env.user.company_id = self.env.ref("base.main_company").id
|
cls,
|
||||||
self.date_from = time.strftime("%Y-%m-01")
|
move_type,
|
||||||
self.date_to = time.strftime("%Y-%m-28")
|
name=None,
|
||||||
self.company = self.env.ref("base.main_company")
|
partner=None,
|
||||||
self.receivable_account = self.env["account.account"].search(
|
invoice_date=None,
|
||||||
[
|
post=False,
|
||||||
("company_id", "=", self.company.id),
|
lines=None,
|
||||||
("user_type_id.name", "=", "Receivable"),
|
taxes=None,
|
||||||
],
|
):
|
||||||
limit=1,
|
move_form = Form(
|
||||||
|
cls.env["account.move"].with_context(default_move_type=move_type)
|
||||||
)
|
)
|
||||||
self.income_account = self.env["account.account"].search(
|
move_form.invoice_date = invoice_date or fields.Date.from_string("2019-01-01")
|
||||||
|
move_form.partner_id = partner or cls.partner_a
|
||||||
|
move_form.name = name or "Test"
|
||||||
|
lines = lines or []
|
||||||
|
for line in lines:
|
||||||
|
with move_form.invoice_line_ids.new() as line_form:
|
||||||
|
line_form.product_id = line[0]
|
||||||
|
line_form.name = "Test"
|
||||||
|
line_form.account_id = line[1]
|
||||||
|
line_form.quantity = line[2]
|
||||||
|
line_form.price_unit = line[3]
|
||||||
|
if taxes:
|
||||||
|
line_form.tax_ids.clear()
|
||||||
|
line_form.tax_ids.add(taxes)
|
||||||
|
rslt = move_form.save()
|
||||||
|
if post:
|
||||||
|
rslt.action_post()
|
||||||
|
return rslt
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls, chart_template_ref=None):
|
||||||
|
super().setUpClass(chart_template_ref=chart_template_ref)
|
||||||
|
cls.date_from = time.strftime("%Y-%m-01")
|
||||||
|
cls.date_to = time.strftime("%Y-%m-28")
|
||||||
|
cls.company = cls.env.user.company_id
|
||||||
|
cls.company.country_id = cls.env.ref("base.us").id
|
||||||
|
cls.receivable_account = cls.company_data["default_account_receivable"]
|
||||||
|
cls.income_account = cls.company_data["default_account_revenue"]
|
||||||
|
cls.expense_account = cls.company_data["default_account_expense"]
|
||||||
|
cls.tax_account = cls.env["account.account"].search(
|
||||||
[
|
[
|
||||||
("company_id", "=", self.company.id),
|
("company_id", "=", cls.company.id),
|
||||||
("user_type_id.name", "=", "Income"),
|
|
||||||
],
|
|
||||||
limit=1,
|
|
||||||
)
|
|
||||||
self.tax_account = self.env["account.account"].search(
|
|
||||||
[
|
|
||||||
("company_id", "=", self.company.id),
|
|
||||||
(
|
(
|
||||||
"user_type_id",
|
"user_type_id",
|
||||||
"=",
|
"=",
|
||||||
self.env.ref(
|
cls.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(
|
cls.bank_journal = cls.company_data["default_journal_bank"]
|
||||||
[("type", "=", "bank"), ("company_id", "=", self.company.id)], limit=1
|
cls.tax_tag_01 = cls.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",
|
||||||
"country_id": self.company.country_id.id,
|
"country_id": cls.company.country_id.id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.tax_tag_02 = self.env["account.account.tag"].create(
|
cls.tax_tag_02 = cls.env["account.account.tag"].create(
|
||||||
{
|
{
|
||||||
"name": "Tag 02",
|
"name": "Tag 02",
|
||||||
"applicability": "taxes",
|
"applicability": "taxes",
|
||||||
"country_id": self.company.country_id.id,
|
"country_id": cls.company.country_id.id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.tax_tag_03 = self.env["account.account.tag"].create(
|
cls.tax_tag_03 = cls.env["account.account.tag"].create(
|
||||||
{
|
{
|
||||||
"name": "Tag 03",
|
"name": "Tag 03",
|
||||||
"applicability": "taxes",
|
"applicability": "taxes",
|
||||||
"country_id": self.company.country_id.id,
|
"country_id": cls.company.country_id.id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.tax_group_10 = self.env["account.tax.group"].create(
|
cls.tax_group_10 = cls.env["account.tax.group"].create(
|
||||||
{"name": "Tax 10%", "sequence": 1}
|
{"name": "Tax 10%", "sequence": 1}
|
||||||
)
|
)
|
||||||
self.tax_group_20 = self.env["account.tax.group"].create(
|
cls.tax_group_20 = cls.env["account.tax.group"].create(
|
||||||
{"name": "Tax 20%", "sequence": 2}
|
{"name": "Tax 20%", "sequence": 2}
|
||||||
)
|
)
|
||||||
self.tax_10 = self.env["account.tax"].create(
|
cls.tax_10 = cls.env["account.tax"].create(
|
||||||
{
|
{
|
||||||
"name": "Tax 10.0%",
|
"name": "Tax 10.0%",
|
||||||
"amount": 10.0,
|
"amount": 10.0,
|
||||||
"amount_type": "percent",
|
"amount_type": "percent",
|
||||||
"type_tax_use": "sale",
|
"type_tax_use": "sale",
|
||||||
"company_id": self.company.id,
|
"company_id": cls.company.id,
|
||||||
"tax_group_id": self.tax_group_10.id,
|
"tax_group_id": cls.tax_group_10.id,
|
||||||
"invoice_repartition_line_ids": [
|
"invoice_repartition_line_ids": [
|
||||||
(0, 0, {"factor_percent": 100, "repartition_type": "base"}),
|
(0, 0, {"factor_percent": 100, "repartition_type": "base"}),
|
||||||
(
|
(
|
||||||
|
@ -88,10 +110,8 @@ class TestVATReport(common.TransactionCase):
|
||||||
{
|
{
|
||||||
"factor_percent": 100,
|
"factor_percent": 100,
|
||||||
"repartition_type": "tax",
|
"repartition_type": "tax",
|
||||||
"account_id": self.tax_account.id,
|
"account_id": cls.tax_account.id,
|
||||||
"tag_ids": [
|
"tag_ids": [(6, 0, [cls.tax_tag_01.id, cls.tax_tag_02.id])],
|
||||||
(6, 0, [self.tax_tag_01.id, self.tax_tag_02.id])
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -103,22 +123,22 @@ class TestVATReport(common.TransactionCase):
|
||||||
{
|
{
|
||||||
"factor_percent": 100,
|
"factor_percent": 100,
|
||||||
"repartition_type": "tax",
|
"repartition_type": "tax",
|
||||||
"account_id": self.tax_account.id,
|
"account_id": cls.tax_account.id,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.tax_20 = self.env["account.tax"].create(
|
cls.tax_20 = cls.env["account.tax"].create(
|
||||||
{
|
{
|
||||||
"sequence": 30,
|
"sequence": 30,
|
||||||
"name": "Tax 20.0%",
|
"name": "Tax 20.0%",
|
||||||
"amount": 20.0,
|
"amount": 20.0,
|
||||||
"amount_type": "percent",
|
"amount_type": "percent",
|
||||||
"type_tax_use": "sale",
|
"type_tax_use": "sale",
|
||||||
"company_id": self.company.id,
|
"company_id": cls.company.id,
|
||||||
"cash_basis_transition_account_id": self.tax_account.id,
|
"cash_basis_transition_account_id": cls.tax_account.id,
|
||||||
"tax_group_id": self.tax_group_20.id,
|
"tax_group_id": cls.tax_group_20.id,
|
||||||
"invoice_repartition_line_ids": [
|
"invoice_repartition_line_ids": [
|
||||||
(0, 0, {"factor_percent": 100, "repartition_type": "base"}),
|
(0, 0, {"factor_percent": 100, "repartition_type": "base"}),
|
||||||
(
|
(
|
||||||
|
@ -127,10 +147,8 @@ class TestVATReport(common.TransactionCase):
|
||||||
{
|
{
|
||||||
"factor_percent": 100,
|
"factor_percent": 100,
|
||||||
"repartition_type": "tax",
|
"repartition_type": "tax",
|
||||||
"account_id": self.tax_account.id,
|
"account_id": cls.tax_account.id,
|
||||||
"tag_ids": [
|
"tag_ids": [(6, 0, [cls.tax_tag_02.id, cls.tax_tag_03.id])],
|
||||||
(6, 0, [self.tax_tag_02.id, self.tax_tag_03.id])
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -142,40 +160,39 @@ class TestVATReport(common.TransactionCase):
|
||||||
{
|
{
|
||||||
"factor_percent": 100,
|
"factor_percent": 100,
|
||||||
"repartition_type": "tax",
|
"repartition_type": "tax",
|
||||||
"account_id": self.tax_account.id,
|
"account_id": cls.tax_account.id,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
cls.init_invoice(
|
||||||
move_form = common.Form(
|
"out_invoice",
|
||||||
self.env["account.move"].with_context(default_move_type="out_invoice")
|
name="Test invoice 1",
|
||||||
|
partner=cls.env.ref("base.res_partner_2"),
|
||||||
|
invoice_date=time.strftime("%Y-%m-03"),
|
||||||
|
post=True,
|
||||||
|
lines=[
|
||||||
|
(cls.env.ref("product.product_product_4"), cls.income_account, 1, 100.0)
|
||||||
|
],
|
||||||
|
taxes=cls.tax_10,
|
||||||
)
|
)
|
||||||
move_form.partner_id = self.env.ref("base.res_partner_2")
|
cls.init_invoice(
|
||||||
move_form.invoice_date = time.strftime("%Y-%m-03")
|
"out_invoice",
|
||||||
with move_form.invoice_line_ids.new() as line_form:
|
name="Test invoice 2",
|
||||||
line_form.product_id = self.env.ref("product.product_product_4")
|
partner=cls.env.ref("base.res_partner_2"),
|
||||||
line_form.quantity = 1.0
|
invoice_date=time.strftime("%Y-%m-04"),
|
||||||
line_form.price_unit = 100.0
|
post=True,
|
||||||
line_form.account_id = self.income_account
|
lines=[
|
||||||
line_form.tax_ids.add(self.tax_10)
|
(
|
||||||
invoice = move_form.save()
|
cls.env.ref("product.product_product_4"),
|
||||||
invoice.action_post()
|
cls.income_account,
|
||||||
|
1,
|
||||||
move_form = common.Form(
|
250.0,
|
||||||
self.env["account.move"].with_context(default_move_type="out_invoice")
|
),
|
||||||
|
],
|
||||||
|
taxes=cls.tax_20,
|
||||||
)
|
)
|
||||||
move_form.partner_id = self.env.ref("base.res_partner_2")
|
|
||||||
move_form.invoice_date = time.strftime("%Y-%m-04")
|
|
||||||
with move_form.invoice_line_ids.new() as line_form:
|
|
||||||
line_form.product_id = self.env.ref("product.product_product_4")
|
|
||||||
line_form.quantity = 1.0
|
|
||||||
line_form.price_unit = 250.0
|
|
||||||
line_form.account_id = self.income_account
|
|
||||||
line_form.tax_ids.add(self.tax_20)
|
|
||||||
invoice = move_form.save()
|
|
||||||
invoice.action_post()
|
|
||||||
|
|
||||||
def _get_report_lines(self, taxgroups=False):
|
def _get_report_lines(self, taxgroups=False):
|
||||||
based_on = "taxtags"
|
based_on = "taxtags"
|
||||||
|
|
Loading…
Reference in New Issue