[FIX] account: Make tests demo data independent
Part-of: odoo/odoo#146649
This commit is contained in:
@@ -126,6 +126,8 @@ class AccountBankStatementLine(models.Model):
|
||||
('chart_template', '!=', False),
|
||||
('id', 'in', self.env.registry.populated_models['res.company']),
|
||||
])
|
||||
if not company_ids:
|
||||
return []
|
||||
|
||||
journal_ids = self.env['account.journal'].search([
|
||||
*self.env['account.journal']._check_company_domain(company_ids),
|
||||
|
||||
@@ -24,6 +24,8 @@ class AccountJournal(models.Model):
|
||||
('chart_template', '!=', False),
|
||||
('id', 'in', self.env.registry.populated_models['res.company']),
|
||||
])
|
||||
if not company_ids:
|
||||
return []
|
||||
return [
|
||||
('company_id', populate.cartesian(company_ids.ids)),
|
||||
('type', populate.cartesian(['sale', 'purchase', 'cash', 'bank', 'general'])),
|
||||
|
||||
@@ -212,6 +212,8 @@ class AccountMove(models.Model):
|
||||
('active', '=', True),
|
||||
])
|
||||
|
||||
if not company_ids:
|
||||
return []
|
||||
return [
|
||||
('move_type', populate.randomize(
|
||||
['entry', 'in_invoice', 'out_invoice', 'in_refund', 'out_refund', 'in_receipt', 'out_receipt'],
|
||||
|
||||
@@ -108,6 +108,8 @@ class AccountPayment(models.Model):
|
||||
('chart_template', '!=', False),
|
||||
('id', 'in', self.env.registry.populated_models['res.company']),
|
||||
])
|
||||
if not company_ids:
|
||||
return []
|
||||
return [
|
||||
('company_id', populate.cartesian(company_ids.ids)),
|
||||
('payment_type', populate.cartesian(['inbound', 'outbound'])),
|
||||
|
||||
@@ -29,6 +29,8 @@ class AccountReconcileModel(models.Model):
|
||||
('chart_template', '!=', False),
|
||||
('id', 'in', self.env.registry.populated_models['res.company']),
|
||||
])
|
||||
if not company_ids:
|
||||
return []
|
||||
return [
|
||||
('company_id', populate.cartesian(company_ids.ids)),
|
||||
('rule_type', populate.cartesian(['writeoff_button', 'writeoff_suggestion'])),
|
||||
@@ -96,6 +98,12 @@ class AccountReconcileModelLine(models.Model):
|
||||
company_id = self.env['account.reconcile.model'].browse(values['model_id']).company_id.id
|
||||
return random.choice(search_account_ids(company_id).ids)
|
||||
|
||||
company_ids = self.env['res.company'].search([
|
||||
('chart_template', '!=', False),
|
||||
('id', 'in', self.env.registry.populated_models['res.company']),
|
||||
])
|
||||
if not company_ids:
|
||||
return []
|
||||
return [
|
||||
('model_id', populate.cartesian(self.env.registry.populated_models['account.reconcile.model'])),
|
||||
('amount_type', populate.randomize(['fixed', 'percentage', 'regex'])),
|
||||
|
||||
@@ -29,11 +29,11 @@ registry.category("web_tour.tours").add('account_tax_group', {
|
||||
{
|
||||
content: "Add vendor",
|
||||
trigger: 'div.o_field_widget.o_field_res_partner_many2one[name="partner_id"] div input',
|
||||
run: 'text Azure Interior',
|
||||
run: 'text Account Tax Group Partner',
|
||||
},
|
||||
{
|
||||
content: "Valid vendor",
|
||||
trigger: '.ui-menu-item a:contains("Azure Interior")',
|
||||
trigger: '.ui-menu-item a:contains("Account Tax Group Partner")',
|
||||
},
|
||||
// Add First product
|
||||
{
|
||||
@@ -47,11 +47,11 @@ registry.category("web_tour.tours").add('account_tax_group', {
|
||||
{
|
||||
content: "Type item",
|
||||
trigger: 'div[name="invoice_line_ids"] .o_selected_row .o_list_many2one[name="product_id"] input',
|
||||
run: "text Corner Desk Right Sit",
|
||||
run: "text Account Tax Group Product",
|
||||
},
|
||||
{
|
||||
content: "Valid item",
|
||||
trigger: '.ui-menu-item-wrapper:contains("Corner Desk Right Sit")',
|
||||
trigger: '.ui-menu-item-wrapper:contains("Account Tax Group Product")',
|
||||
},
|
||||
// Save account.move
|
||||
{
|
||||
|
||||
@@ -47,6 +47,7 @@ class AccountTestInvoicingCommon(TransactionCase):
|
||||
@classmethod
|
||||
def setUpClass(cls, chart_template_ref=None):
|
||||
super().setUpClass()
|
||||
cls.env.ref('base.main_company').currency_id = cls.env.ref('base.USD')
|
||||
instantiate_accountman(cls)
|
||||
|
||||
assert 'post_install' in cls.test_tags, 'This test requires a CoA to be installed, it should be tagged "post_install"'
|
||||
|
||||
@@ -135,6 +135,10 @@ class TestFiscalPosition(common.TransactionCase):
|
||||
|
||||
|
||||
def test_20_fp_one_tax_2m(self):
|
||||
self.env.company.country_id = self.env.ref('base.us')
|
||||
self.env['account.tax.group'].create(
|
||||
{'name': 'Test Tax Group', 'company_id': self.env.company.id}
|
||||
)
|
||||
|
||||
self.src_tax = self.env['account.tax'].create({'name': "SRC", 'amount': 0.0})
|
||||
self.dst1_tax = self.env['account.tax'].create({'name': "DST1", 'amount': 0.0})
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import Command
|
||||
import odoo.tests
|
||||
|
||||
from odoo import Command
|
||||
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
|
||||
|
||||
|
||||
@odoo.tests.tagged('post_install_l10n', 'post_install', '-at_install')
|
||||
class TestUi(odoo.tests.HttpCase):
|
||||
class TestUi(AccountTestInvoicingCommon, odoo.tests.HttpCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
@@ -30,6 +32,10 @@ class TestUi(odoo.tests.HttpCase):
|
||||
# hidden and non-required, and don't make the tour crash.
|
||||
# Also remove default taxes from the company and its accounts, to avoid inconsistencies
|
||||
# with empty fiscal country.
|
||||
self.env.ref('base.user_admin').write({
|
||||
'company_id': self.env.company.id,
|
||||
'company_ids': [(4, self.env.company.id)],
|
||||
})
|
||||
self.env.company.write({
|
||||
'country_id': None, # Also resets account_fiscal_country_id
|
||||
'account_sale_tax_id': None,
|
||||
@@ -51,15 +57,25 @@ class TestUi(odoo.tests.HttpCase):
|
||||
self.start_tour("/web", 'account_tour', login="admin")
|
||||
|
||||
def test_01_account_tax_groups_tour(self):
|
||||
product = self.env.ref('product.product_product_5')
|
||||
company_used = self.env.companies.sorted(lambda c: c.id)[0]
|
||||
self.env.ref('base.user_admin').write({
|
||||
'company_id': self.env.company.id,
|
||||
'company_ids': [(4, self.env.company.id)],
|
||||
})
|
||||
self.env['res.partner'].create({
|
||||
'name': 'Account Tax Group Partner',
|
||||
'email': 'azure.Interior24@example.com',
|
||||
})
|
||||
product = self.env['product.product'].create({
|
||||
'name': 'Account Tax Group Product',
|
||||
'standard_price': 600.0,
|
||||
'list_price': 147.0,
|
||||
'detailed_type': 'consu',
|
||||
})
|
||||
new_tax = self.env['account.tax'].create({
|
||||
'name': '10% Tour Tax',
|
||||
'type_tax_use': 'purchase',
|
||||
'amount_type': 'percent',
|
||||
'amount': 10,
|
||||
'company_id': company_used.id,
|
||||
'country_id': company_used.account_fiscal_country_id.id
|
||||
})
|
||||
product.supplier_taxes_id = new_tax
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ class TestPeppolParticipant(TransactionCase):
|
||||
'account_peppol_eas': '9925',
|
||||
'account_peppol_endpoint': '0000000000',
|
||||
'account_peppol_phone_number': '+32483123456',
|
||||
'account_peppol_contact_email': 'yourcompany@test.example.com',
|
||||
}
|
||||
|
||||
@contextmanager
|
||||
|
||||
Reference in New Issue
Block a user