[IMP] stock_account: Adapt tests to work with/without demo data

This commit is contained in:
Yannick Tivisse
2019-11-05 16:18:10 +01:00
parent 583c717fea
commit 9fd98d0e03
3 changed files with 29 additions and 24 deletions
@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<!-- Used in other modules for the tests, NOT in this one -->
<record forcecreate="True" id="property_stock_valuation_account_id" model="ir.property">
<field name="name">property_stock_valuation_account_id</field>
<field name="fields_id" search="[('model','=','product.category'),('name','=','property_stock_valuation_account_id')]"/>
<field eval="'account.account,'+str(ref('stk'))" model="account.account" name="value"/>
<field name="company_id" ref="base.main_company"/>
</record>
<record forcecreate="True" id="property_stock_valuation_journal_id" model="ir.property">
<field name="name">property_stock_valuation_journal</field>
<field name="fields_id" search="[('model','=','product.category'),('name','=','property_stock_journal')]"/>
<field eval="'account.journal,'+str(ref('miscellaneous_journal'))" model="account.journal" name="value"/>
<field name="company_id" ref="base.main_company"/>
</record>
</data>
</odoo>
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.account.tests.account_test_classes import AccountingTestCase
class StockAccountMinimalTest(AccountingTestCase):
@classmethod
def setUpClass(cls):
super(StockAccountMinimalTest, cls).setUpClass()
# Properties: Stock valuation account and journal
cls.env['ir.property'].create([{
'name': 'property_stock_valuation_account_id',
'fields_id': cls.env['ir.model.fields'].search([('model', '=', 'product.category'), ('name', '=', 'property_stock_valuation_account_id')], limit=1).id,
'value': 'account.account,%s' % (cls.stk.id),
'company_id': cls.env.company.id,
}, {
'name': 'property_stock_valuation_journal',
'fields_id': cls.env['ir.model.fields'].search([('model', '=', 'product.category'), ('name', '=', 'property_stock_journal')], limit=1).id,
'value': 'account.journal,%s' % (cls.miscellaneous_journal.id),
'company_id': cls.env.company.id,
}])
@@ -2,10 +2,10 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.account.tests.account_test_classes import AccountingTestCase
from odoo.addons.stock_account.tests.stock_account_minimal_test import StockAccountMinimalTest
from odoo import fields
class ValuationReconciliationTestCase(AccountingTestCase):
class ValuationReconciliationTestCase(StockAccountMinimalTest):
""" Base class for tests checking interim accounts reconciliation works
in anglosaxon accounting. It sets up everything we need in the tests, and is
extended in both sale_stock and purchase modules to run the 'true' tests.
@@ -139,4 +139,6 @@ class ValuationReconciliationTestCase(AccountingTestCase):
# entries get automatically reconciled (and you cannot modify a reconciled entry).
# So, we have to make sure that "today"'s rate will always be the last rate we
# created in order to ensure complete control of the test.
self.env.ref('base.rateUSDbis').unlink()
rateUSDbis = self.env.ref('base.rateUSDbis', raise_if_not_found=False)
if rateUSDbis:
rateUSDbis.unlink()