Since #96791 the currency is reset to USD when starting a test to be less dependant of demo data when starting tests. Unfortunatelly, some l10n_modules will add account.move.line demo data leading to an error: You cannot change the currency of the company since some journal items already exist An initial solution would be to delete the existing account.move.line cls.env['account.move.line'].search([('company_id', '=', company.id)]).unlink() This is only possible passing some context flags in order to disable some checks existing = cls.env['account.move.line'].search([('company_id', '=', company.id)]) existing = existing.with_context(dynamic_unlink=True, force_delete=True) existing.unlink() Actually, unlinking account.move.line also creates other ones. existing = cls.env['account.move.line'].search([('company_id', '=', company.id)]) existing = existing.with_context(dynamic_unlink=True, force_delete=True) existing.unlink() existing = cls.env['account.move.line'].search([('company_id', '=', company.id)]) existing = existing.with_context(dynamic_unlink=True, force_delete=True) existing.unlink() Finally, it looks easier to bypass all business logic leading to the proposed solution. closes odoo/odoo#98736 Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo.tests import tagged
|
|
|
|
from odoo.addons.product.tests.common import ProductCommon
|
|
|
|
|
|
@tagged('post_install', '-at_install')
|
|
class TestProduct(ProductCommon):
|
|
|
|
def test_common(self):
|
|
self.assertEqual(self.consumable_product.type, 'consu')
|
|
self.assertEqual(self.service_product.type, 'service')
|
|
|
|
account_module = self.env['ir.module.module']._get('account')
|
|
if account_module.state == 'installed':
|
|
self.assertFalse(self.consumable_product.taxes_id)
|
|
self.assertFalse(self.service_product.taxes_id)
|
|
|
|
self.assertFalse(self.pricelist.item_ids)
|
|
self.assertEqual(
|
|
self.env['product.pricelist'].search([]),
|
|
self.pricelist,
|
|
)
|
|
self.assertEqual(
|
|
self.env['res.partner'].search([]).property_product_pricelist,
|
|
self.pricelist,
|
|
)
|
|
self.assertEqual(self.pricelist.currency_id.name, 'USD')
|
|
self.assertEqual(self.pricelist.discount_policy, 'with_discount')
|