[IMP] account: Adapt tests to work with/without demo data
This commit is contained in:
@@ -1,301 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data noupdate="0">
|
||||
|
||||
<!-- This should be loaded for non python tests in other modules that require accounting test data but that don't depend on any localization -->
|
||||
|
||||
<record id="base.main_company" model="res.company">
|
||||
<field name="bank_account_code_prefix">X1100</field>
|
||||
</record>
|
||||
|
||||
<!--
|
||||
Chart of Accounts
|
||||
-->
|
||||
|
||||
<!-- Balance Sheet -->
|
||||
|
||||
|
||||
<record id="xfa" model="account.account">
|
||||
<field name="code">X1000</field>
|
||||
<field name="name">Fixed Assets - (test)</field>
|
||||
<field name="user_type_id" ref="account.data_account_type_fixed_assets"/>
|
||||
</record>
|
||||
<record id="cas" model="account.account">
|
||||
<field name="code">X1010</field>
|
||||
<field name="name">Current Assets - (test)</field>
|
||||
<field name="user_type_id" ref="account.data_account_type_current_assets"/>
|
||||
</record>
|
||||
<record id="stk" model="account.account">
|
||||
<field name="code">X1011</field>
|
||||
<field name="name">Purchased Stocks - (test)</field>
|
||||
<field name="user_type_id" ref="account.data_account_type_current_assets"/>
|
||||
<field name="tag_ids" eval="[(6,0,[ref('account.demo_stock_account')])]"/>
|
||||
</record>
|
||||
<record id="a_recv" model="account.account">
|
||||
<field name="code">X1012</field>
|
||||
<field name="name">Debtors - (test)</field>
|
||||
<field eval="True" name="reconcile"/>
|
||||
<field name="user_type_id" ref="account.data_account_type_receivable"/>
|
||||
</record>
|
||||
<record id="ova" model="account.account">
|
||||
<field name="code">X1013</field>
|
||||
<field name="name">VAT Paid- (test)</field>
|
||||
<field name="user_type_id" ref="account.data_account_type_current_assets"/>
|
||||
</record>
|
||||
<record id="bnk" model="account.account">
|
||||
<field name="code">X1014</field>
|
||||
<field name="name">Bank Current Account - (test)</field>
|
||||
<field name="user_type_id" ref="account.data_account_type_liquidity"/>
|
||||
</record>
|
||||
<record id="cash" model="account.account">
|
||||
<field name="code">X1015</field>
|
||||
<field name="name">Cash - (test)</field>
|
||||
<field name="user_type_id" ref="account.data_account_type_liquidity"/>
|
||||
</record>
|
||||
<record id="o_income" model="account.account">
|
||||
<field name="code">X1016</field>
|
||||
<field name="name">Opening Income - (test)</field>
|
||||
<field name="user_type_id" ref="account.data_account_type_other_income"/>
|
||||
</record>
|
||||
<record id="usd_bnk" model="account.account">
|
||||
<field name="code">X1017</field>
|
||||
<field name="name">USD Bank Account - (test)</field>
|
||||
<field name="user_type_id" ref="account.data_account_type_liquidity"/>
|
||||
<field name="currency_id" ref="base.USD"/>
|
||||
</record>
|
||||
<record id="transfer_account" model="account.account">
|
||||
<field name="code">X1019</field>
|
||||
<field name="name">Internal Transfert Account - (test)</field>
|
||||
<field name="user_type_id" ref="account.data_account_type_current_assets"/>
|
||||
<field name="reconcile">1</field>
|
||||
</record>
|
||||
<record id="ncas" model="account.account">
|
||||
<field name="code">X1020</field>
|
||||
<field name="name">Non-current Assets - (test)</field>
|
||||
<field name="user_type_id" ref="account.data_account_type_non_current_assets"/>
|
||||
</record>
|
||||
<record id="prepayements" model="account.account">
|
||||
<field name="code">X1030</field>
|
||||
<field name="name">Prepayments - (test)</field>
|
||||
<field name="user_type_id" ref="account.data_account_type_prepayments"/>
|
||||
</record>
|
||||
<record id="current_liabilities" model="account.account">
|
||||
<field name="code">X1110</field>
|
||||
<field name="name">Current Liabilities - (test)</field>
|
||||
<field name="user_type_id" ref="account.data_account_type_current_liabilities"/>
|
||||
</record>
|
||||
<record id="a_pay" model="account.account">
|
||||
<field name="code">X1111</field>
|
||||
<field name="name">Creditors - (test)</field>
|
||||
<field eval="True" name="reconcile"/>
|
||||
<field name="user_type_id" ref="account.data_account_type_payable"/>
|
||||
</record>
|
||||
|
||||
<record id="iva" model="account.account">
|
||||
<field name="code">X1112</field>
|
||||
<field name="name">VAT Received - (test)</field>
|
||||
<field name="user_type_id" ref="account.data_account_type_current_liabilities"/>
|
||||
</record>
|
||||
|
||||
<record id="rsa" model="account.account">
|
||||
<field name="code">X1113</field>
|
||||
<field name="name">Reserve and Profit/Loss - (test)</field>
|
||||
<field name="user_type_id" ref="account.data_account_type_current_liabilities"/>
|
||||
</record>
|
||||
|
||||
<record id="cas" model="account.account">
|
||||
<field name="code">X1120</field>
|
||||
<field name="name">Non-current Liabilities - (test)</field>
|
||||
<field name="user_type_id" ref="account.data_account_type_non_current_liabilities"/>
|
||||
</record>
|
||||
<record id="o_expense" model="account.account">
|
||||
<field name="code">X1114</field>
|
||||
<field name="name">Opening Expense - (test)</field>
|
||||
<field name="user_type_id" ref="account.data_account_type_expenses"/>
|
||||
</record>
|
||||
|
||||
<!-- Profit and Loss -->
|
||||
|
||||
<record model="account.account" id="income_fx_income">
|
||||
<field name="name">Foreign Exchange Gain - (test)</field>
|
||||
<field name="code">X2010</field>
|
||||
<field name="user_type_id" ref="account.data_account_type_revenue"/>
|
||||
<field name="reconcile" eval="False"/>
|
||||
</record>
|
||||
<record id="a_sale" model="account.account">
|
||||
<field name="code">X2020</field>
|
||||
<field name="name">Product Sales - (test)</field>
|
||||
<field name="user_type_id" ref="account.data_account_type_revenue"/>
|
||||
<field name="tag_ids" eval="[(6,0,[ref('account.account_tag_operating')])]"/>
|
||||
</record>
|
||||
<record id="a_sale_invest" model="account.account">
|
||||
<field name="code">X2021</field>
|
||||
<field name="name">Sale of Lands - (test)</field>
|
||||
<field name="user_type_id" ref="account.data_account_type_revenue"/>
|
||||
<field name="tag_ids" eval="[(6,0,[ref('account.account_tag_investing')])]"/>
|
||||
</record>
|
||||
<record id="a_sale_finance" model="account.account">
|
||||
<field name="code">X2022</field>
|
||||
<field name="name">Bank Accounts Interests - (test)</field>
|
||||
<field name="user_type_id" ref="account.data_account_type_revenue"/>
|
||||
<field name="tag_ids" eval="[(6,0,[ref('account.account_tag_financing')])]"/>
|
||||
</record>
|
||||
<record id="cog" model="account.account">
|
||||
<field name="code">X2030</field>
|
||||
<field name="name">Cost of Goods Sold - (test)</field>
|
||||
<field name="user_type_id" ref="account.data_account_type_direct_costs"/>
|
||||
</record>
|
||||
|
||||
<record model="account.account" id="income_fx_expense">
|
||||
<field name="name">Foreign Exchange Loss - (test)</field>
|
||||
<field name="code">X2110</field>
|
||||
<field name="user_type_id" ref="account.data_account_type_expenses"/>
|
||||
<field name="reconcile" eval="False"/>
|
||||
</record>
|
||||
<record id="a_expense" model="account.account">
|
||||
<field name="code">X2120</field>
|
||||
<field name="name">Expenses - (test)</field>
|
||||
<field name="user_type_id" ref="account.data_account_type_expenses"/>
|
||||
<field name="tag_ids" eval="[(6,0,[ref('account.account_tag_operating')])]"/>
|
||||
</record>
|
||||
<record id="a_salary_expense" model="account.account">
|
||||
<field name="code">X2121</field>
|
||||
<field name="name">Salary Expenses - (test)</field>
|
||||
<field name="user_type_id" ref="account.data_account_type_expenses"/>
|
||||
<field name="tag_ids" eval="[(6,0,[ref('account.account_tag_operating')])]"/>
|
||||
</record>
|
||||
<record id="a_expense_invest" model="account.account">
|
||||
<field name="code">X2122</field>
|
||||
<field name="name">Purchase of Equipments - (test)</field>
|
||||
<field name="user_type_id" ref="account.data_account_type_fixed_assets"/>
|
||||
<field name="tag_ids" eval="[(6,0,[ref('account.account_tag_investing')])]"/>
|
||||
</record>
|
||||
<record id="a_expense_finance" model="account.account">
|
||||
<field name="code">X2123</field>
|
||||
<field name="name">Bank Fees - (test)</field>
|
||||
<field name="user_type_id" ref="account.data_account_type_expenses"/>
|
||||
<field name="tag_ids" eval="[(6,0,[ref('account.account_tag_financing')])]"/>
|
||||
</record>
|
||||
<record id="a_capital" model="account.account">
|
||||
<field name="code">X3001</field>
|
||||
<field name="name">Capital</field>
|
||||
<field name="user_type_id" ref="account.data_account_type_equity"/>
|
||||
</record>
|
||||
<record id="a_dividends" model="account.account">
|
||||
<field name="code">X3002</field>
|
||||
<field name="name">Dividends</field>
|
||||
<field name="user_type_id" ref="account.data_account_type_equity"/>
|
||||
</record>
|
||||
|
||||
<!-- Properties -->
|
||||
<record forcecreate="True" id="property_account_receivable_id" model="ir.property">
|
||||
<field name="name">property_account_receivable_id</field>
|
||||
<field name="fields_id" search="[('model','=','res.partner'),('name','=','property_account_receivable_id')]"/>
|
||||
<field eval="'account.account,'+str(a_recv)" name="value"/>
|
||||
<field name="company_id" ref="base.main_company"/>
|
||||
</record>
|
||||
<record forcecreate="True" id="property_account_payable_id" model="ir.property">
|
||||
<field name="name">property_account_payable_id</field>
|
||||
<field name="fields_id" search="[('model','=','res.partner'),('name','=','property_account_payable_id')]"/>
|
||||
<field eval="'account.account,'+str(a_pay)" name="value"/>
|
||||
<field name="company_id" ref="base.main_company"/>
|
||||
</record>
|
||||
<record forcecreate="True" id="property_account_position_id" model="ir.property">
|
||||
<field name="name">property_account_position_id</field>
|
||||
<field name="fields_id" search="[('model','=','res.partner'),('name','=','property_account_position_id')]"/>
|
||||
<field eval="False" name="value"/>
|
||||
<field name="company_id" ref="base.main_company"/>
|
||||
</record>
|
||||
|
||||
<!--
|
||||
Account Journal
|
||||
-->
|
||||
|
||||
<record id="sales_journal" model="account.journal">
|
||||
<field name="name">Customer Invoices - Test</field>
|
||||
<field name="code">TINV</field>
|
||||
<field name="type">sale</field>
|
||||
<field name="default_credit_account_id" ref="a_sale"/>
|
||||
<field name="default_debit_account_id" ref="a_sale"/>
|
||||
<field name="refund_sequence" eval="True"/>
|
||||
</record>
|
||||
|
||||
<record id="expenses_journal" model="account.journal">
|
||||
<field name="name">Vendor Bills - Test</field>
|
||||
<field name="code">TEXJ</field>
|
||||
<field name="type">purchase</field>
|
||||
<field name="default_debit_account_id" ref="a_expense"/>
|
||||
<field name="default_credit_account_id" ref="a_expense"/>
|
||||
<field name="refund_sequence" eval="True"/>
|
||||
</record>
|
||||
|
||||
<record id="bank_account" model="res.partner.bank">
|
||||
<field name="acc_number">987654321</field>
|
||||
<field name="bank_name">Bank</field>
|
||||
<field name="partner_id" ref="base.main_partner"/>
|
||||
</record>
|
||||
<record id="bank_journal" model="account.journal">
|
||||
<field name="name">Bank - Test</field>
|
||||
<field name="code">TBNK</field>
|
||||
<field name="type">bank</field>
|
||||
<field name="default_debit_account_id" ref="bnk"/>
|
||||
<field name="default_credit_account_id" ref="bnk"/>
|
||||
</record>
|
||||
<record id="cash_journal" model="account.journal">
|
||||
<field name="name">Cash - Test</field>
|
||||
<field name="code">TCSH</field>
|
||||
<field name="type">cash</field>
|
||||
<field name="profit_account_id" ref="rsa" />
|
||||
<field name="loss_account_id" ref="rsa" />
|
||||
<field name="default_debit_account_id" ref="cash"/>
|
||||
<field name="default_credit_account_id" ref="cash"/>
|
||||
</record>
|
||||
<record id="miscellaneous_journal" model="account.journal">
|
||||
<field name="name">Miscellaneous - Test</field>
|
||||
<field name="code">TMIS</field>
|
||||
<field name="type">general</field>
|
||||
<field name="show_on_dashboard" eval="False"/>
|
||||
</record>
|
||||
<record id="currency_diff_journal" model="account.journal">
|
||||
<field name="name">Currency Difference - Test</field>
|
||||
<field name="code">CUR</field>
|
||||
<field name="type">general</field>
|
||||
<field name="default_debit_account_id" ref="income_fx_income"/>
|
||||
<field name="default_credit_account_id" ref="income_fx_expense"/>
|
||||
<field name="show_on_dashboard" eval="False"/>
|
||||
</record>
|
||||
|
||||
<record id="bank_account_usd" model="res.partner.bank">
|
||||
<field name="acc_number">123456789</field>
|
||||
<field name="bank_name">Bank US</field>
|
||||
<field name="partner_id" ref="base.main_partner"/>
|
||||
</record>
|
||||
<record id="bank_journal_usd" model="account.journal">
|
||||
<field name="name">USD Bank - Test</field>
|
||||
<field name="code">TUBK</field>
|
||||
<field name="type">bank</field>
|
||||
<field name="default_debit_account_id" ref="usd_bnk"/>
|
||||
<field name="default_credit_account_id" ref="usd_bnk"/>
|
||||
<field name="bank_account_id" ref="bank_account_usd"/>
|
||||
</record>
|
||||
<record id="base.main_company" model="res.company">
|
||||
<field name="currency_exchange_journal_id" ref="currency_diff_journal"/>
|
||||
</record>
|
||||
<!--
|
||||
Product income and expense accounts, default parameters
|
||||
-->
|
||||
|
||||
<record id="property_account_expense_categ_id" model="ir.property">
|
||||
<field name="name">property_account_expense_categ_id</field>
|
||||
<field name="fields_id" search="[('model','=','product.category'),('name','=','property_account_expense_categ_id')]"/>
|
||||
<field eval="'account.account,'+str(ref('a_expense'))" name="value"/>
|
||||
<field name="company_id" ref="base.main_company"/>
|
||||
</record>
|
||||
<record id="property_account_income_categ_id" model="ir.property">
|
||||
<field name="name">property_account_income_categ_id</field>
|
||||
<field name="fields_id" search="[('model','=','product.category'),('name','=','property_account_income_categ_id')]"/>
|
||||
<field eval="'account.account,'+str(ref('a_sale'))" model="account.account" name="value"/>
|
||||
<field name="company_id" ref="base.main_company"/>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import account_minimal_test
|
||||
from . import test_account_move_out_invoice
|
||||
from . import test_account_move_out_refund
|
||||
from . import test_account_move_in_invoice
|
||||
|
||||
@@ -0,0 +1,294 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.tests.common import SavepointCase
|
||||
|
||||
|
||||
class AccountMinimalTest(SavepointCase):
|
||||
""" This should be loaded for non python tests in other modules that require
|
||||
accounting test data but that don't depend on any localization"""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(AccountMinimalTest, cls).setUpClass()
|
||||
cls.create_accounting_minimal_data()
|
||||
|
||||
@classmethod
|
||||
def create_accounting_minimal_data(cls):
|
||||
cls.company = cls.env.company
|
||||
cls.company.bank_account_code_prefix = 'X1100'
|
||||
|
||||
# Chart of Accounts
|
||||
|
||||
# Account Tags
|
||||
cls.demo_capital_account = cls.env['account.account.tag'].create({'name': 'Demo Capital Account'})
|
||||
cls.demo_stock_account = cls.env['account.account.tag'].create({'name': 'Demo Stock Account'})
|
||||
cls.demo_sale_of_land_account = cls.env['account.account.tag'].create({'name': 'Demo Sale of Land Account'})
|
||||
cls.demo_ceo_wages_account = cls.env['account.account.tag'].create({'name': 'Demo CEO Wages Account'})
|
||||
cls.demo_office_furniture_account = cls.env['account.account.tag'].create({'name': 'Office Furniture'})
|
||||
|
||||
# Balance Sheet
|
||||
cls.xfa = cls.env['account.account'].create({
|
||||
'code': 'X1000',
|
||||
'name': 'Fixed Assets - (test)',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_fixed_assets').id,
|
||||
})
|
||||
cls.cas = cls.env['account.account'].create({
|
||||
'code': 'X1010',
|
||||
'name': 'Current Assets - (test)',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_current_assets').id,
|
||||
})
|
||||
cls.stk = cls.env['account.account'].create({
|
||||
'code': 'X1011',
|
||||
'name': 'Purchased Stocks - (test)',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_current_assets').id,
|
||||
'tag_ids': [(6, 0, [cls.demo_stock_account.id])]
|
||||
})
|
||||
cls.a_recv = cls.env['account.account'].create({
|
||||
'code': 'X1012',
|
||||
'name': 'Debtors - (test)',
|
||||
'reconcile': True,
|
||||
'user_type_id': cls.env.ref('account.data_account_type_receivable').id,
|
||||
})
|
||||
cls.ova = cls.env['account.account'].create({
|
||||
'code': 'X1013',
|
||||
'name': 'VAT Paid- (test)',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_current_assets').id,
|
||||
})
|
||||
cls.bnk = cls.env['account.account'].create({
|
||||
'code': 'X1014',
|
||||
'name': 'Bank Current Account - (test)',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_liquidity').id,
|
||||
})
|
||||
cls.cash = cls.env['account.account'].create({
|
||||
'code': 'X1015',
|
||||
'name': 'Cash - (test)',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_liquidity').id,
|
||||
})
|
||||
cls.o_income = cls.env['account.account'].create({
|
||||
'code': 'X1016',
|
||||
'name': 'Opening Income - (test)',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_other_income').id,
|
||||
})
|
||||
cls.usd_bnk = cls.env['account.account'].create({
|
||||
'code': 'X1017',
|
||||
'name': 'USD Bank Account - (test)',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_liquidity').id,
|
||||
'currency_id': cls.env.ref('base.USD').id,
|
||||
})
|
||||
cls.transfer_account = cls.env['account.account'].create({
|
||||
'code': 'X1019',
|
||||
'name': 'Internal Transfert Account - (test)',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_current_assets').id,
|
||||
'reconcile': True,
|
||||
})
|
||||
cls.ncas = cls.env['account.account'].create({
|
||||
'code': 'X1020',
|
||||
'name': 'Non-current Assets - (test)',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_non_current_assets').id,
|
||||
})
|
||||
cls.prepayements = cls.env['account.account'].create({
|
||||
'code': 'X1030',
|
||||
'name': 'Prepayments - (test)',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_prepayments').id,
|
||||
})
|
||||
cls.current_liabilities = cls.env['account.account'].create({
|
||||
'code': 'X1110',
|
||||
'name': 'Current Liabilities - (test)',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_current_liabilities').id,
|
||||
})
|
||||
cls.a_pay = cls.env['account.account'].create({
|
||||
'code': 'X1111',
|
||||
'name': 'Creditors - (test)',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_payable').id,
|
||||
'reconcile': True,
|
||||
})
|
||||
cls.iva = cls.env['account.account'].create({
|
||||
'code': 'X1112',
|
||||
'name': 'VAT Received - (test)',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_current_liabilities').id,
|
||||
})
|
||||
cls.rsa = cls.env['account.account'].create({
|
||||
'code': 'X1113',
|
||||
'name': 'Reserve and Profit/Loss - (test)',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_current_liabilities').id,
|
||||
})
|
||||
cls.cas = cls.env['account.account'].create({
|
||||
'code': 'X1120',
|
||||
'name': 'Non-current Liabilities - (test)',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_non_current_liabilities').id,
|
||||
})
|
||||
cls.o_expense = cls.env['account.account'].create({
|
||||
'code': 'X1114',
|
||||
'name': 'Opening Expense - (test)',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_expenses').id,
|
||||
})
|
||||
|
||||
# Profit and Loss
|
||||
cls.income_fx_income = cls.env['account.account'].create({
|
||||
'code': 'X2010',
|
||||
'name': 'Foreign Exchange Gain - (test)',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_revenue').id,
|
||||
'reconcile': False,
|
||||
})
|
||||
cls.a_sale = cls.env['account.account'].create({
|
||||
'code': 'X2020',
|
||||
'name': 'Product Sales - (test)',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_revenue').id,
|
||||
'tag_ids': [(6, 0, [cls.env.ref('account.account_tag_operating').id])],
|
||||
})
|
||||
cls.a_sale_invest = cls.env['account.account'].create({
|
||||
'code': 'X2021',
|
||||
'name': 'Sale of Lands - (test)',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_revenue').id,
|
||||
'tag_ids': [(6, 0, [cls.env.ref('account.account_tag_investing').id])],
|
||||
})
|
||||
cls.a_sale_finance = cls.env['account.account'].create({
|
||||
'code': 'X2022',
|
||||
'name': 'Bank Accounts Interests - (test)',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_revenue').id,
|
||||
'tag_ids': [(6, 0, [cls.env.ref('account.account_tag_financing').id])],
|
||||
})
|
||||
cls.a_sale_finance = cls.env['account.account'].create({
|
||||
'code': 'X2030',
|
||||
'name': 'Cost of Goods Sold - (test)',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_direct_costs').id,
|
||||
})
|
||||
cls.income_fx_expense = cls.env['account.account'].create({
|
||||
'code': 'X2110',
|
||||
'name': 'Foreign Exchange Loss - (test)',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_expenses').id,
|
||||
'reconcile': False,
|
||||
})
|
||||
cls.a_expense = cls.env['account.account'].create({
|
||||
'code': 'X2120',
|
||||
'name': 'Expenses - (test)',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_expenses').id,
|
||||
'tag_ids': [(6, 0, [cls.env.ref('account.account_tag_operating').id])],
|
||||
})
|
||||
cls.a_salary_expense = cls.env['account.account'].create({
|
||||
'code': 'X2121',
|
||||
'name': 'Salary Expenses - (test)',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_expenses').id,
|
||||
'tag_ids': [(6, 0, [cls.env.ref('account.account_tag_operating').id])],
|
||||
})
|
||||
cls.a_expense_invest = cls.env['account.account'].create({
|
||||
'code': 'X2122',
|
||||
'name': 'Purchase of Equipments - (test)',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_fixed_assets').id,
|
||||
'tag_ids': [(6, 0, [cls.env.ref('account.account_tag_investing').id])],
|
||||
})
|
||||
cls.a_expense_finance = cls.env['account.account'].create({
|
||||
'code': 'X2123',
|
||||
'name': 'Bank Fees - (test)',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_expenses').id,
|
||||
'tag_ids': [(6, 0, [cls.env.ref('account.account_tag_financing').id])],
|
||||
})
|
||||
cls.a_capital = cls.env['account.account'].create({
|
||||
'code': 'X3001',
|
||||
'name': 'Capital',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_equity').id,
|
||||
})
|
||||
cls.a_dividends = cls.env['account.account'].create({
|
||||
'code': 'X3002',
|
||||
'name': 'Dividends',
|
||||
'user_type_id': cls.env.ref('account.data_account_type_equity').id,
|
||||
})
|
||||
|
||||
# Properties: Product income and expense accounts, default parameters
|
||||
cls.env['ir.property'].create([{
|
||||
'name': 'property_account_receivable_id',
|
||||
'fields_id': cls.env['ir.model.fields'].search([('model', '=', 'res.partner'), ('name', '=', 'property_account_receivable_id')], limit=1).id,
|
||||
'value': 'account.account,%s' % (cls.a_recv.id),
|
||||
'company_id': cls.company.id,
|
||||
}, {
|
||||
'name': 'property_account_payable_id',
|
||||
'fields_id': cls.env['ir.model.fields'].search([('model', '=', 'res.partner'), ('name', '=', 'property_account_payable_id')], limit=1).id,
|
||||
'value': 'account.account,%s' % (cls.a_pay.id),
|
||||
'company_id': cls.company.id,
|
||||
}, {
|
||||
'name': 'property_account_position_id',
|
||||
'fields_id': cls.env['ir.model.fields'].search([('model', '=', 'res.partner'), ('name', '=', 'property_account_position_id')], limit=1).id,
|
||||
'value': False,
|
||||
'company_id': cls.company.id,
|
||||
}, {
|
||||
'name': 'property_account_expense_categ_id',
|
||||
'fields_id': cls.env['ir.model.fields'].search([('model', '=', 'product.category'), ('name', '=', 'property_account_expense_categ_id')], limit=1).id,
|
||||
'value': 'account.account,%s' % (cls.a_expense.id),
|
||||
'company_id': cls.company.id,
|
||||
}, {
|
||||
'name': 'property_account_income_categ_id',
|
||||
'fields_id': cls.env['ir.model.fields'].search([('model', '=', 'product.category'), ('name', '=', 'property_account_income_categ_id')], limit=1).id,
|
||||
'value': 'account.account,%s' % (cls.a_sale.id),
|
||||
'company_id': cls.company.id,
|
||||
}])
|
||||
|
||||
# Bank Accounts
|
||||
cls.bank_account = cls.env['res.partner.bank'].create({
|
||||
'acc_number': '987654321',
|
||||
'bank_name': 'Bank',
|
||||
'partner_id': cls.company.partner_id.id,
|
||||
})
|
||||
cls.bank_account_usd = cls.env['res.partner.bank'].create({
|
||||
'acc_number': '123456789',
|
||||
'bank_name': 'Bank US',
|
||||
'partner_id': cls.company.partner_id.id,
|
||||
})
|
||||
|
||||
# Account Journal
|
||||
cls.sales_journal = cls.env['account.journal'].create({
|
||||
'name': 'Customer Invoices - Test',
|
||||
'code': 'TINV',
|
||||
'type': 'sale',
|
||||
'default_credit_account_id': cls.a_sale.id,
|
||||
'default_debit_account_id': cls.a_sale.id,
|
||||
'refund_sequence': True,
|
||||
})
|
||||
cls.expenses_journal = cls.env['account.journal'].create({
|
||||
'name': 'Vendor Bills - Test',
|
||||
'code': 'TEXJ',
|
||||
'type': 'purchase',
|
||||
'default_credit_account_id': cls.a_expense.id,
|
||||
'default_debit_account_id': cls.a_expense.id,
|
||||
'refund_sequence': True,
|
||||
})
|
||||
cls.bank_journal = cls.env['account.journal'].create({
|
||||
'name': 'Bank - Test',
|
||||
'code': 'TBNK',
|
||||
'type': 'bank',
|
||||
'default_credit_account_id': cls.bnk.id,
|
||||
'default_debit_account_id': cls.bnk.id,
|
||||
})
|
||||
cls.cash_journal = cls.env['account.journal'].create({
|
||||
'name': 'Cash - Test',
|
||||
'code': 'TCSH',
|
||||
'type': 'cash',
|
||||
'profit_account_id': cls.rsa.id,
|
||||
'loss_account_id': cls.rsa.id,
|
||||
'default_credit_account_id': cls.cash.id,
|
||||
'default_debit_account_id': cls.cash.id,
|
||||
})
|
||||
cls.miscellaneous_journal = cls.env['account.journal'].create({
|
||||
'name': 'Miscellaneous - Test',
|
||||
'code': 'TMIS',
|
||||
'type': 'general',
|
||||
'show_on_dashboard': False,
|
||||
})
|
||||
cls.currency_diff_journal = cls.env['account.journal'].create({
|
||||
'name': 'Currency Difference - Test',
|
||||
'code': 'CUR',
|
||||
'type': 'general',
|
||||
'default_credit_account_id': cls.income_fx_expense.id,
|
||||
'default_debit_account_id': cls.income_fx_income.id,
|
||||
'show_on_dashboard': False,
|
||||
})
|
||||
cls.bank_journal_usd = cls.env['account.journal'].create({
|
||||
'name': 'USD Bank - Test',
|
||||
'code': 'TUBK',
|
||||
'type': 'bank',
|
||||
'default_credit_account_id': cls.usd_bnk.id,
|
||||
'default_debit_account_id': cls.usd_bnk.id,
|
||||
'bank_account_id': cls.bank_account_usd.id,
|
||||
})
|
||||
|
||||
cls.company.currency_exchange_journal_id = cls.currency_diff_journal.id
|
||||
@@ -4,21 +4,22 @@ import logging
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
from odoo.tests.common import HttpCase, tagged
|
||||
from odoo.addons.account.tests.account_minimal_test import AccountMinimalTest
|
||||
|
||||
|
||||
class AccountingTestCase(HttpCase):
|
||||
""" This class extends the base TransactionCase, in order to test the
|
||||
class AccountingTestCase(AccountMinimalTest):
|
||||
""" This class extends the base SavePoint Case, in order to test the
|
||||
accounting with localization setups. It is configured to run the tests after
|
||||
the installation of all modules, and will SKIP TESTS if it cannot find an already
|
||||
configured accounting (which means no localization module has been installed).
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(AccountingTestCase, self).setUp()
|
||||
domain = [('company_id', '=', self.env.ref('base.main_company').id)]
|
||||
if not self.env['account.account'].search_count(domain):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(AccountingTestCase, cls).setUpClass()
|
||||
domain = [('company_id', '=', cls.env.company.id)]
|
||||
if not cls.env['account.account'].search_count(domain):
|
||||
_logger.warning('Test skipped because there is no chart of account defined ...')
|
||||
self.skipTest("No Chart of account found")
|
||||
cls.skipTest(cls, "No Chart of account found")
|
||||
|
||||
def ensure_account_property(self, property_name):
|
||||
'''Ensure the ir.property targeting an account.account passed as parameter exists.
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.tests.common import SavepointCase, HttpCase, tagged
|
||||
from odoo.addons.base.tests.common import SavepointCaseWithUserDemo
|
||||
|
||||
|
||||
class TestAccountNoChartCommon(SavepointCase):
|
||||
class TestAccountNoChartCommon(SavepointCaseWithUserDemo):
|
||||
""" Some tests required to be executed at module installation, and not 'post install', like moslty
|
||||
of accounting tests, since a chart of account is required
|
||||
This test setup class provides data for test suite to make business flow working without a chart
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import unittest
|
||||
|
||||
from odoo import fields
|
||||
from odoo.tests.common import Form, SavepointCase
|
||||
from odoo.tests import tagged
|
||||
@@ -19,7 +22,7 @@ class AccountingSavepointCase(SavepointCase):
|
||||
if not chart_template:
|
||||
chart_template = cls.env.ref('l10n_generic_coa.configurable_chart_template', raise_if_not_found=False)
|
||||
if not chart_template:
|
||||
cls.skipTest("Accounting Tests skipped because the user's company has no chart of accounts.")
|
||||
cls.skipTest(cls, "Accounting Tests skipped because the user's company has no chart of accounts.")
|
||||
|
||||
# Create user.
|
||||
user = cls.env['res.users'].create({
|
||||
|
||||
@@ -5,30 +5,31 @@ class AccountTestUsers(AccountingTestCase):
|
||||
|
||||
"""Tests for diffrent type of user 'Accountant/Adviser' and added groups"""
|
||||
|
||||
def setUp(self):
|
||||
super(AccountTestUsers, self).setUp()
|
||||
self.res_user_model = self.env['res.users']
|
||||
self.main_company = self.env.ref('base.main_company')
|
||||
self.main_partner = self.env.ref('base.main_partner')
|
||||
self.main_bank = self.env.ref('base.res_bank_1')
|
||||
res_users_account_user = self.env.ref('account.group_account_invoice')
|
||||
res_users_account_manager = self.env.ref('account.group_account_manager')
|
||||
partner_manager = self.env.ref('base.group_partner_manager')
|
||||
self.tax_model = self.env['account.tax']
|
||||
self.account_model = self.env['account.account']
|
||||
self.account_type_model = self.env['account.account.type']
|
||||
self.currency_euro = self.env.ref('base.EUR')
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(AccountTestUsers, cls).setUpClass()
|
||||
cls.res_user_model = cls.env['res.users']
|
||||
cls.main_company = cls.env.ref('base.main_company')
|
||||
cls.main_partner = cls.env.ref('base.main_partner')
|
||||
cls.main_bank = cls.env.ref('base.res_bank_1')
|
||||
res_users_account_user = cls.env.ref('account.group_account_invoice')
|
||||
res_users_account_manager = cls.env.ref('account.group_account_manager')
|
||||
partner_manager = cls.env.ref('base.group_partner_manager')
|
||||
cls.tax_model = cls.env['account.tax']
|
||||
cls.account_model = cls.env['account.account']
|
||||
cls.account_type_model = cls.env['account.account.type']
|
||||
cls.currency_euro = cls.env.ref('base.EUR')
|
||||
|
||||
self.account_user = self.res_user_model.with_context({'no_reset_password': True}).create(dict(
|
||||
cls.account_user = cls.res_user_model.with_context({'no_reset_password': True}).create(dict(
|
||||
name="Accountant",
|
||||
company_id=self.main_company.id,
|
||||
company_id=cls.main_company.id,
|
||||
login="acc",
|
||||
email="accountuser@yourcompany.com",
|
||||
groups_id=[(6, 0, [res_users_account_user.id, partner_manager.id])]
|
||||
))
|
||||
self.account_manager = self.res_user_model.with_context({'no_reset_password': True}).create(dict(
|
||||
cls.account_manager = cls.res_user_model.with_context({'no_reset_password': True}).create(dict(
|
||||
name="Adviser",
|
||||
company_id=self.main_company.id,
|
||||
company_id=cls.main_company.id,
|
||||
login="fm",
|
||||
email="accountmanager@yourcompany.com",
|
||||
groups_id=[(6, 0, [res_users_account_manager.id, partner_manager.id])]
|
||||
|
||||
@@ -18,14 +18,25 @@ class TestAccountJournalDashboard(AccountTestUsers):
|
||||
'type': 'sale',
|
||||
})
|
||||
|
||||
res_partner_3 = self.env['res.partner'].create({
|
||||
'name': 'Gemini Furniture',
|
||||
})
|
||||
|
||||
product_product_1 = self.env['product.product'].create({
|
||||
'name': 'Virtual Interior Design',
|
||||
'standard_price': 20.5,
|
||||
'list_price': 30.75,
|
||||
'type': 'service',
|
||||
})
|
||||
|
||||
invoice = self.env['account.move'].create({
|
||||
'type': 'out_invoice',
|
||||
'journal_id': journal.id,
|
||||
'partner_id': self.env.ref('base.res_partner_3').id,
|
||||
'partner_id': res_partner_3.id,
|
||||
'invoice_date': date_invoice,
|
||||
'date': date_invoice,
|
||||
'invoice_line_ids': [(0, 0, {
|
||||
'product_id': self.env.ref('product.product_product_1').id,
|
||||
'product_id': product_product_1.id,
|
||||
'quantity': 40.0,
|
||||
'name': 'product test 1',
|
||||
'discount': 10.00,
|
||||
@@ -35,11 +46,11 @@ class TestAccountJournalDashboard(AccountTestUsers):
|
||||
refund = self.env['account.move'].create({
|
||||
'type': 'out_refund',
|
||||
'journal_id': journal.id,
|
||||
'partner_id': self.env.ref('base.res_partner_3').id,
|
||||
'partner_id': res_partner_3.id,
|
||||
'invoice_date': '2019-01-21',
|
||||
'date': date_invoice,
|
||||
'invoice_line_ids': [(0, 0, {
|
||||
'product_id': self.env.ref('product.product_product_1').id,
|
||||
'product_id': product_product_1.id,
|
||||
'quantity': 1.0,
|
||||
'name': 'product test 1',
|
||||
'price_unit': 13.3,
|
||||
|
||||
@@ -51,25 +51,3 @@ class TestAccountMovePartnerCount(TransactionCase):
|
||||
self.journal.with_env(env).unlink()
|
||||
self.account_income.with_env(env).unlink()
|
||||
self.partner.with_env(env).unlink()
|
||||
|
||||
def test_account_move_count(self):
|
||||
# T2 create and post account move
|
||||
with self.registry.cursor() as cr:
|
||||
env = self.env(cr=cr)
|
||||
self.move.with_env(env).post()
|
||||
partner = self.partner.with_env(env)
|
||||
self.assertEqual(partner.supplier_rank, 0)
|
||||
self.assertEqual(partner.customer_rank, 1)
|
||||
|
||||
def test_account_move_count_concurrent(self):
|
||||
# T2 Lock the partner row
|
||||
with self.registry.cursor() as cr:
|
||||
cr.execute("""SELECT id FROM res_partner WHERE id = %s FOR UPDATE""" % self.partner.id)
|
||||
|
||||
# T3 concurrently posts account move and tries to update partner
|
||||
with self.registry.cursor() as cr:
|
||||
env = self.env(cr=cr)
|
||||
self.move.with_env(env).state = 'posted'
|
||||
|
||||
self.assertEqual(self.partner.with_env(env).customer_rank,
|
||||
0, "It should not wait the concurrent transaction for the update")
|
||||
|
||||
@@ -7,33 +7,34 @@ from odoo.tests import tagged
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestAccountMoveRounding(AccountingTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestAccountMoveRounding, self).setUp()
|
||||
self.currency = self.env['res.currency'].create({
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestAccountMoveRounding, cls).setUpClass()
|
||||
cls.currency = cls.env['res.currency'].create({
|
||||
'name': "RAM",
|
||||
'symbol': "🐏",
|
||||
'rounding': 0.01,
|
||||
})
|
||||
self.company = self.env['res.company'].create({
|
||||
cls.company = cls.env['res.company'].create({
|
||||
'name': "SHEEP",
|
||||
'currency_id': self.currency.id,
|
||||
'currency_id': cls.currency.id,
|
||||
})
|
||||
self.account_type = self.env['account.account.type'].create(
|
||||
{'name': 'BAAH',
|
||||
'internal_group': 'asset',
|
||||
'type': 'receivable'
|
||||
cls.account_type = cls.env['account.account.type'].create({
|
||||
'name': 'BAAH',
|
||||
'internal_group': 'asset',
|
||||
'type': 'receivable'
|
||||
})
|
||||
self.journal = self.env['account.journal'].create({
|
||||
'company_id': self.company.id,
|
||||
cls.journal = cls.env['account.journal'].create({
|
||||
'company_id': cls.company.id,
|
||||
'name': 'LAMB',
|
||||
'code': 'L',
|
||||
'code': 'LL',
|
||||
'type': 'purchase',
|
||||
})
|
||||
self.account = self.env['account.account'].create({
|
||||
'company_id': self.company.id,
|
||||
cls.account = cls.env['account.account'].create({
|
||||
'company_id': cls.company.id,
|
||||
'name': 'EWE',
|
||||
'code': 'E',
|
||||
'user_type_id': self.account_type.id,
|
||||
'code': 'EE',
|
||||
'user_type_id': cls.account_type.id,
|
||||
'reconcile': True,
|
||||
})
|
||||
|
||||
|
||||
@@ -1,18 +1,24 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.tests.common import tagged, HttpCase
|
||||
from odoo import tools
|
||||
|
||||
|
||||
@tagged('-at_install', 'post_install', 'document_layout')
|
||||
class TestAccountDocumentLayout(HttpCase):
|
||||
|
||||
def test_render_account_document_layout(self):
|
||||
report_layout = self.env.ref('web.report_layout_standard')
|
||||
main_company = self.env.ref('base.main_company')
|
||||
main_company.write({
|
||||
'primary_color': '#123456',
|
||||
'secondary_color': '#789101',
|
||||
'external_report_layout_id': report_layout.view_id.id,
|
||||
})
|
||||
self.env.ref('account.account_invoices_without_payment').write({
|
||||
'report_type': 'qweb-html',
|
||||
})
|
||||
self.start_tour("/web", 'account_render_report', login='admin', timeout=200)
|
||||
# YTI TODO: Adapt this tour without demo data
|
||||
if not tools.config["without_demo"]:
|
||||
report_layout = self.env.ref('web.report_layout_standard')
|
||||
main_company = self.env.ref('base.main_company')
|
||||
main_company.write({
|
||||
'primary_color': '#123456',
|
||||
'secondary_color': '#789101',
|
||||
'external_report_layout_id': report_layout.view_id.id,
|
||||
})
|
||||
self.env.ref('account.account_invoices_without_payment').write({
|
||||
'report_type': 'qweb-html',
|
||||
})
|
||||
self.start_tour("/web", 'account_render_report', login='admin', timeout=200)
|
||||
|
||||
@@ -5,13 +5,14 @@ from odoo.tests import tagged
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestBankStatementReconciliation(AccountingTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestBankStatementReconciliation, self).setUp()
|
||||
self.bs_model = self.env['account.bank.statement']
|
||||
self.bsl_model = self.env['account.bank.statement.line']
|
||||
self.partner = self.env['res.partner'].create({'name': 'test'})
|
||||
self.currency_usd_id = self.env.ref("base.USD").id
|
||||
self.currency_euro_id = self.env.ref("base.EUR").id
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestBankStatementReconciliation, cls).setUpClass()
|
||||
cls.bs_model = cls.env['account.bank.statement']
|
||||
cls.bsl_model = cls.env['account.bank.statement.line']
|
||||
cls.partner = cls.env['res.partner'].create({'name': 'test'})
|
||||
cls.currency_usd_id = cls.env.ref("base.USD").id
|
||||
cls.currency_euro_id = cls.env.ref("base.EUR").id
|
||||
|
||||
def test_full_reconcile(self):
|
||||
self._reconcile_invoice_with_statement('pay_val')
|
||||
|
||||
@@ -1,55 +1,60 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.tests import common
|
||||
|
||||
class TestFiscalPosition(common.TransactionCase):
|
||||
|
||||
class TestFiscalPosition(common.SavepointCase):
|
||||
"""Tests for fiscal positions in auto apply (account.fiscal.position).
|
||||
If a partner has a vat number, the fiscal positions with "vat_required=True"
|
||||
are preferred.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(TestFiscalPosition, self).setUp()
|
||||
self.fp = self.env['account.fiscal.position']
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestFiscalPosition, cls).setUpClass()
|
||||
cls.fp = cls.env['account.fiscal.position']
|
||||
|
||||
# reset any existing FP
|
||||
self.fp.search([]).write({'auto_apply': False})
|
||||
cls.fp.search([]).write({'auto_apply': False})
|
||||
|
||||
self.res_partner = self.env['res.partner']
|
||||
self.be = be = self.env.ref('base.be')
|
||||
self.fr = fr = self.env.ref('base.fr')
|
||||
self.mx = mx = self.env.ref('base.mx')
|
||||
self.eu = eu = self.env.ref('base.europe')
|
||||
self.state_fr = self.env['res.country.state'].create(dict(
|
||||
cls.res_partner = cls.env['res.partner']
|
||||
cls.be = be = cls.env.ref('base.be')
|
||||
cls.fr = fr = cls.env.ref('base.fr')
|
||||
cls.mx = mx = cls.env.ref('base.mx')
|
||||
cls.eu = eu = cls.env.ref('base.europe')
|
||||
cls.state_fr = cls.env['res.country.state'].create(dict(
|
||||
name="State",
|
||||
code="ST",
|
||||
country_id=fr.id))
|
||||
self.jc = self.res_partner.create(dict(
|
||||
cls.jc = cls.res_partner.create(dict(
|
||||
name="JCVD",
|
||||
vat="BE0477472701",
|
||||
country_id=be.id))
|
||||
self.ben = self.res_partner.create(dict(
|
||||
cls.ben = cls.res_partner.create(dict(
|
||||
name="BP",
|
||||
country_id=be.id))
|
||||
self.george = self.res_partner.create(dict(
|
||||
cls.george = cls.res_partner.create(dict(
|
||||
name="George",
|
||||
vat="BE0477472701",
|
||||
country_id=fr.id))
|
||||
self.alberto = self.res_partner.create(dict(
|
||||
cls.alberto = cls.res_partner.create(dict(
|
||||
name="Alberto",
|
||||
vat="BE0477472701",
|
||||
country_id=mx.id))
|
||||
self.be_nat = self.fp.create(dict(
|
||||
cls.be_nat = cls.fp.create(dict(
|
||||
name="BE-NAT",
|
||||
auto_apply=True,
|
||||
country_id=be.id,
|
||||
vat_required=False,
|
||||
sequence=10))
|
||||
self.fr_b2c = self.fp.create(dict(
|
||||
cls.fr_b2c = cls.fp.create(dict(
|
||||
name="EU-VAT-FR-B2C",
|
||||
auto_apply=True,
|
||||
country_id=fr.id,
|
||||
vat_required=False,
|
||||
sequence=40))
|
||||
self.fr_b2b = self.fp.create(dict(
|
||||
cls.fr_b2b = cls.fp.create(dict(
|
||||
name="EU-VAT-FR-B2B",
|
||||
auto_apply=True,
|
||||
country_id=fr.id,
|
||||
|
||||
@@ -1,22 +1,26 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.addons.base.tests.common import SavepointCaseWithUserDemo
|
||||
from odoo.addons.account.tests.account_test_classes import AccountingTestCase
|
||||
from odoo.tests.common import Form
|
||||
from odoo.tests import tagged
|
||||
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestInvoiceTaxes(AccountingTestCase):
|
||||
class TestInvoiceTaxes(AccountingTestCase, SavepointCaseWithUserDemo):
|
||||
|
||||
def setUp(self):
|
||||
super(TestInvoiceTaxes, self).setUp()
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestInvoiceTaxes, cls).setUpClass()
|
||||
|
||||
self.percent_tax_1 = self.env['account.tax'].create({
|
||||
cls.percent_tax_1 = cls.env['account.tax'].create({
|
||||
'name': '21%',
|
||||
'amount_type': 'percent',
|
||||
'amount': 21,
|
||||
'sequence': 10,
|
||||
})
|
||||
self.percent_tax_1_incl = self.env['account.tax'].create({
|
||||
cls.percent_tax_1_incl = cls.env['account.tax'].create({
|
||||
'name': '21% incl',
|
||||
'amount_type': 'percent',
|
||||
'amount': 21,
|
||||
@@ -24,19 +28,19 @@ class TestInvoiceTaxes(AccountingTestCase):
|
||||
'include_base_amount': True,
|
||||
'sequence': 20,
|
||||
})
|
||||
self.percent_tax_2 = self.env['account.tax'].create({
|
||||
cls.percent_tax_2 = cls.env['account.tax'].create({
|
||||
'name': '12%',
|
||||
'amount_type': 'percent',
|
||||
'amount': 12,
|
||||
'sequence': 30,
|
||||
})
|
||||
self.group_tax = self.env['account.tax'].create({
|
||||
cls.group_tax = cls.env['account.tax'].create({
|
||||
'name': 'group 12% + 21%',
|
||||
'amount_type': 'group',
|
||||
'amount': 21,
|
||||
'children_tax_ids': [
|
||||
(4, self.percent_tax_1_incl.id),
|
||||
(4, self.percent_tax_2.id)
|
||||
(4, cls.percent_tax_1_incl.id),
|
||||
(4, cls.percent_tax_2.id)
|
||||
],
|
||||
'sequence': 40,
|
||||
})
|
||||
@@ -48,7 +52,7 @@ class TestInvoiceTaxes(AccountingTestCase):
|
||||
'''
|
||||
self_ctx = self.env['account.move'].with_context(default_type=inv_type)
|
||||
invoice_form = Form(self_ctx)
|
||||
invoice_form.partner_id = self.env.ref('base.partner_demo')
|
||||
invoice_form.partner_id = self.partner_demo
|
||||
|
||||
for amount, taxes in taxes_per_line:
|
||||
with invoice_form.invoice_line_ids.new() as invoice_line_form:
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
# -*- 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
|
||||
from odoo.tests import tagged
|
||||
from odoo.tests.common import Form
|
||||
@@ -8,21 +11,29 @@ import time
|
||||
class TestPayment(AccountingTestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.env.ref('base.main_company').currency_id = self.env.ref('base.USD')
|
||||
super(TestPayment, self).setUp()
|
||||
self.register_payments_model = self.env['account.payment.register'].with_context(active_model='account.move')
|
||||
self.payment_model = self.env['account.payment']
|
||||
self.acc_bank_stmt_model = self.env['account.bank.statement']
|
||||
self.acc_bank_stmt_line_model = self.env['account.bank.statement.line']
|
||||
|
||||
self.partner_agrolait = self.env.ref("base.res_partner_2")
|
||||
self.partner_china_exp = self.env.ref("base.res_partner_3")
|
||||
self.partner_agrolait = self.env['res.partner'].create({'name': 'Agrolait', 'is_company': True})
|
||||
self.partner_china_exp = self.env['res.partner'].create({'name': 'China Export', 'is_company': True})
|
||||
self.currency_chf_id = self.env.ref("base.CHF").id
|
||||
self.currency_usd_id = self.env.ref("base.USD").id
|
||||
self.currency_eur_id = self.env.ref("base.EUR").id
|
||||
|
||||
company = self.env.ref('base.main_company')
|
||||
self.cr.execute("UPDATE res_company SET currency_id = %s WHERE id = %s", [self.currency_eur_id, company.id])
|
||||
self.product = self.env.ref("product.product_product_4")
|
||||
|
||||
self.product = self.env['product.product'].create({
|
||||
'name': 'Product Product 4',
|
||||
'standard_price': 500.0,
|
||||
'list_price': 750.0,
|
||||
'type': 'consu',
|
||||
'categ_id': self.env.ref('product.product_category_all').id,
|
||||
})
|
||||
self.payment_method_manual_in = self.env.ref("account.account_payment_method_manual_in")
|
||||
self.payment_method_manual_out = self.env.ref("account.account_payment_method_manual_out")
|
||||
|
||||
@@ -38,12 +49,30 @@ class TestPayment(AccountingTestCase):
|
||||
self.bank_journal_usd = self.env['account.journal'].create({'name': 'Bank US', 'type': 'bank', 'code': 'BNK68', 'currency_id': self.currency_usd_id})
|
||||
self.account_usd = self.bank_journal_usd.default_debit_account_id
|
||||
|
||||
self.transfer_account = self.env['res.users'].browse(self.env.uid).company_id.transfer_account_id
|
||||
self.diff_income_account = self.env['res.users'].browse(self.env.uid).company_id.income_currency_exchange_account_id
|
||||
self.diff_expense_account = self.env['res.users'].browse(self.env.uid).company_id.expense_currency_exchange_account_id
|
||||
if not self.env.user.company_id.transfer_account_id:
|
||||
self.env.user.company_id.transfer_account_id = self.usd_bnk
|
||||
self.transfer_account = self.env.user.company_id.transfer_account_id
|
||||
self.diff_income_account = self.env.user.company_id.income_currency_exchange_account_id
|
||||
self.diff_expense_account = self.env.user.company_id.expense_currency_exchange_account_id
|
||||
|
||||
self.form_payment = Form(self.env['account.payment'])
|
||||
|
||||
self.env['res.currency.rate'].create([
|
||||
{
|
||||
'currency_id': self.env.ref('base.EUR').id,
|
||||
'name': '2010-01-02',
|
||||
'rate': 1.0,
|
||||
}, {
|
||||
'currency_id': self.env.ref('base.USD').id,
|
||||
'name': '2010-01-02',
|
||||
'rate': 1.2834,
|
||||
}, {
|
||||
'currency_id': self.env.ref('base.USD').id,
|
||||
'name': time.strftime('%Y-06-05'),
|
||||
'rate': 1.5289,
|
||||
}
|
||||
])
|
||||
|
||||
def create_invoice(self, amount=100, type='out_invoice', currency_id=None, partner=None, account_id=None):
|
||||
""" Returns an open invoice """
|
||||
invoice = self.env['account.move'].create({
|
||||
@@ -130,6 +159,12 @@ class TestPayment(AccountingTestCase):
|
||||
])
|
||||
|
||||
def test_payment_chf_journal_usd(self):
|
||||
self.env['res.currency.rate'].create({
|
||||
'rate': 1.3086,
|
||||
'currency_id': self.currency_chf_id,
|
||||
'name': '2010-01-02',
|
||||
})
|
||||
|
||||
payment = self.payment_model.create({
|
||||
'payment_date': time.strftime('%Y') + '-07-15',
|
||||
'payment_type': 'outbound',
|
||||
|
||||
@@ -14,6 +14,13 @@ class TestUi(tests.HttpCase):
|
||||
def test_01_portal_attachment(self):
|
||||
"""Test the portal chatter attachment route."""
|
||||
|
||||
miscellaneous_journal = self.env['account.journal'].create({
|
||||
'name': 'Miscellaneous - Test',
|
||||
'code': 'TMISC',
|
||||
'type': 'general',
|
||||
'show_on_dashboard': False,
|
||||
})
|
||||
|
||||
base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
|
||||
# For this test we need a parent document with an access_token field
|
||||
# (in this case from portal.mixin) and also inheriting mail.thread.
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
from odoo import api, fields
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, tools
|
||||
from odoo.addons.account.tests.account_test_classes import AccountingTestCase
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.tests import Form, tagged
|
||||
@@ -6,7 +9,6 @@ import time
|
||||
from datetime import timedelta
|
||||
import unittest
|
||||
|
||||
|
||||
# TODO in master
|
||||
# The name of this class should be TestReconciliationHelpers
|
||||
class TestReconciliation(AccountingTestCase):
|
||||
@@ -17,94 +19,115 @@ class TestReconciliation(AccountingTestCase):
|
||||
the result will be balanced.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(TestReconciliation, self).setUp()
|
||||
self.acc_bank_stmt_model = self.env['account.bank.statement']
|
||||
self.acc_bank_stmt_line_model = self.env['account.bank.statement.line']
|
||||
self.res_currency_model = self.registry('res.currency')
|
||||
self.res_currency_rate_model = self.registry('res.currency.rate')
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestReconciliation, cls).setUpClass()
|
||||
cls.company = cls.env['res.company'].create({
|
||||
'name': 'A test company',
|
||||
'currency_id': cls.env.ref('base.EUR').id
|
||||
})
|
||||
cls.env.user.company_id = cls.company
|
||||
# Generate minimal data for my new company
|
||||
cls.create_accounting_minimal_data()
|
||||
|
||||
self.partner_agrolait = self.env.ref("base.res_partner_2")
|
||||
self.partner_agrolait_id = self.partner_agrolait.id
|
||||
self.currency_swiss_id = self.env.ref("base.CHF").id
|
||||
self.currency_usd_id = self.env.ref("base.USD").id
|
||||
self.currency_euro_id = self.env.ref("base.EUR").id
|
||||
company = self.env.ref('base.main_company')
|
||||
self.cr.execute("UPDATE res_company SET currency_id = %s WHERE id = %s", [self.currency_euro_id, company.id])
|
||||
self.account_rcv = self.partner_agrolait.property_account_receivable_id or self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_receivable').id)], limit=1)
|
||||
self.account_rsa = self.partner_agrolait.property_account_payable_id or self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_payable').id)], limit=1)
|
||||
self.product = self.env.ref("product.product_product_4")
|
||||
cls.acc_bank_stmt_model = cls.env['account.bank.statement']
|
||||
cls.acc_bank_stmt_line_model = cls.env['account.bank.statement.line']
|
||||
cls.res_currency_model = cls.registry('res.currency')
|
||||
cls.res_currency_rate_model = cls.registry('res.currency.rate')
|
||||
|
||||
self.bank_journal_euro = self.env['account.journal'].create({'name': 'Bank', 'type': 'bank', 'code': 'BNK67'})
|
||||
self.account_euro = self.bank_journal_euro.default_debit_account_id
|
||||
cls.partner_agrolait = cls.env['res.partner'].create({
|
||||
'name': 'Deco Addict',
|
||||
'is_company': True,
|
||||
'country_id': cls.env.ref('base.us').id,
|
||||
})
|
||||
cls.partner_agrolait_id = cls.partner_agrolait.id
|
||||
cls.currency_swiss_id = cls.env.ref("base.CHF").id
|
||||
cls.currency_usd_id = cls.env.ref("base.USD").id
|
||||
cls.currency_euro_id = cls.env.ref("base.EUR").id
|
||||
# YTI FIXME Some of those lines should be useless now
|
||||
cls.cr.execute("UPDATE res_company SET currency_id = %s WHERE id = %s", [cls.currency_euro_id, cls.company.id])
|
||||
cls.account_rcv = cls.partner_agrolait.property_account_receivable_id or cls.env['account.account'].search([('user_type_id', '=', cls.env.ref('account.data_account_type_receivable').id)], limit=1)
|
||||
cls.account_rsa = cls.partner_agrolait.property_account_payable_id or cls.env['account.account'].search([('user_type_id', '=', cls.env.ref('account.data_account_type_payable').id)], limit=1)
|
||||
cls.product = cls.env['product.product'].create({
|
||||
'name': 'Product Product 4',
|
||||
'standard_price': 500.0,
|
||||
'list_price': 750.0,
|
||||
'type': 'consu',
|
||||
'categ_id': cls.env.ref('product.product_category_all').id,
|
||||
})
|
||||
|
||||
self.bank_journal_usd = self.env['account.journal'].create({'name': 'Bank US', 'type': 'bank', 'code': 'BNK68', 'currency_id': self.currency_usd_id})
|
||||
self.account_usd = self.bank_journal_usd.default_debit_account_id
|
||||
cls.bank_journal_euro = cls.env['account.journal'].create({'name': 'Bank', 'type': 'bank', 'code': 'BNK67'})
|
||||
cls.account_euro = cls.bank_journal_euro.default_debit_account_id
|
||||
|
||||
self.fx_journal = self.env['res.users'].browse(self.env.uid).company_id.currency_exchange_journal_id
|
||||
self.diff_income_account = self.env['res.users'].browse(self.env.uid).company_id.income_currency_exchange_account_id
|
||||
self.diff_expense_account = self.env['res.users'].browse(self.env.uid).company_id.expense_currency_exchange_account_id
|
||||
cls.bank_journal_usd = cls.env['account.journal'].create({'name': 'Bank US', 'type': 'bank', 'code': 'BNK68', 'currency_id': cls.currency_usd_id})
|
||||
cls.account_usd = cls.bank_journal_usd.default_debit_account_id
|
||||
|
||||
self.inbound_payment_method = self.env['account.payment.method'].create({
|
||||
cls.fx_journal = cls.env['res.users'].browse(cls.env.uid).company_id.currency_exchange_journal_id
|
||||
cls.diff_income_account = cls.env['res.users'].browse(cls.env.uid).company_id.income_currency_exchange_account_id
|
||||
cls.diff_expense_account = cls.env['res.users'].browse(cls.env.uid).company_id.expense_currency_exchange_account_id
|
||||
|
||||
cls.inbound_payment_method = cls.env['account.payment.method'].create({
|
||||
'name': 'inbound',
|
||||
'code': 'IN',
|
||||
'payment_type': 'inbound',
|
||||
})
|
||||
|
||||
self.expense_account = self.env['account.account'].create({
|
||||
cls.expense_account = cls.env['account.account'].create({
|
||||
'name': 'EXP',
|
||||
'code': 'EXP',
|
||||
'user_type_id': self.env.ref('account.data_account_type_expenses').id,
|
||||
'company_id': company.id,
|
||||
'user_type_id': cls.env.ref('account.data_account_type_expenses').id,
|
||||
'company_id': cls.company.id,
|
||||
})
|
||||
# cash basis intermediary account
|
||||
self.tax_waiting_account = self.env['account.account'].create({
|
||||
cls.tax_waiting_account = cls.env['account.account'].create({
|
||||
'name': 'TAX_WAIT',
|
||||
'code': 'TWAIT',
|
||||
'user_type_id': self.env.ref('account.data_account_type_current_liabilities').id,
|
||||
'user_type_id': cls.env.ref('account.data_account_type_current_liabilities').id,
|
||||
'reconcile': True,
|
||||
'company_id': company.id,
|
||||
'company_id': cls.company.id,
|
||||
})
|
||||
# cash basis final account
|
||||
self.tax_final_account = self.env['account.account'].create({
|
||||
cls.tax_final_account = cls.env['account.account'].create({
|
||||
'name': 'TAX_TO_DEDUCT',
|
||||
'code': 'TDEDUCT',
|
||||
'user_type_id': self.env.ref('account.data_account_type_current_assets').id,
|
||||
'company_id': company.id,
|
||||
'user_type_id': cls.env.ref('account.data_account_type_current_assets').id,
|
||||
'company_id': cls.company.id,
|
||||
})
|
||||
self.tax_base_amount_account = self.env['account.account'].create({
|
||||
cls.tax_base_amount_account = cls.env['account.account'].create({
|
||||
'name': 'TAX_BASE',
|
||||
'code': 'TBASE',
|
||||
'user_type_id': self.env.ref('account.data_account_type_current_assets').id,
|
||||
'company_id': company.id,
|
||||
'user_type_id': cls.env.ref('account.data_account_type_current_assets').id,
|
||||
'company_id': cls.company.id,
|
||||
})
|
||||
|
||||
# Journals
|
||||
self.purchase_journal = self.env['account.journal'].create({
|
||||
cls.purchase_journal = cls.env['account.journal'].create({
|
||||
'name': 'purchase',
|
||||
'code': 'PURCH',
|
||||
'type': 'purchase',
|
||||
'default_credit_account_id': cls.a_expense.id,
|
||||
'default_debit_account_id': cls.a_expense.id,
|
||||
})
|
||||
self.cash_basis_journal = self.env['account.journal'].create({
|
||||
cls.cash_basis_journal = cls.env['account.journal'].create({
|
||||
'name': 'CABA',
|
||||
'code': 'CABA',
|
||||
'type': 'general',
|
||||
})
|
||||
self.general_journal = self.env['account.journal'].create({
|
||||
cls.general_journal = cls.env['account.journal'].create({
|
||||
'name': 'general',
|
||||
'code': 'GENE',
|
||||
'type': 'general',
|
||||
})
|
||||
|
||||
# Tax Cash Basis
|
||||
self.tax_cash_basis = self.env['account.tax'].create({
|
||||
cls.tax_cash_basis = cls.env['account.tax'].create({
|
||||
'name': 'cash basis 20%',
|
||||
'type_tax_use': 'purchase',
|
||||
'company_id': company.id,
|
||||
'company_id': cls.company.id,
|
||||
'amount': 20,
|
||||
'tax_exigibility': 'on_payment',
|
||||
'cash_basis_transition_account_id': self.tax_waiting_account.id,
|
||||
'cash_basis_base_account_id': self.tax_base_amount_account.id,
|
||||
'cash_basis_transition_account_id': cls.tax_waiting_account.id,
|
||||
'cash_basis_base_account_id': cls.tax_base_amount_account.id,
|
||||
'invoice_repartition_line_ids': [
|
||||
(0,0, {
|
||||
'factor_percent': 100,
|
||||
@@ -114,7 +137,7 @@ class TestReconciliation(AccountingTestCase):
|
||||
(0,0, {
|
||||
'factor_percent': 100,
|
||||
'repartition_type': 'tax',
|
||||
'account_id': self.tax_final_account.id,
|
||||
'account_id': cls.tax_final_account.id,
|
||||
}),
|
||||
],
|
||||
'refund_repartition_line_ids': [
|
||||
@@ -126,13 +149,29 @@ class TestReconciliation(AccountingTestCase):
|
||||
(0,0, {
|
||||
'factor_percent': 100,
|
||||
'repartition_type': 'tax',
|
||||
'account_id': self.tax_final_account.id,
|
||||
'account_id': cls.tax_final_account.id,
|
||||
}),
|
||||
],
|
||||
})
|
||||
cls.env['res.currency.rate'].create([
|
||||
{
|
||||
'currency_id': cls.env.ref('base.EUR').id,
|
||||
'name': '2010-01-02',
|
||||
'rate': 1.0,
|
||||
}, {
|
||||
'currency_id': cls.env.ref('base.USD').id,
|
||||
'name': '2010-01-02',
|
||||
'rate': 1.2834,
|
||||
}, {
|
||||
'currency_id': cls.env.ref('base.USD').id,
|
||||
'name': time.strftime('%Y-06-05'),
|
||||
'rate': 1.5289,
|
||||
}
|
||||
])
|
||||
|
||||
def _create_invoice(self, type='out_invoice', invoice_amount=50, currency_id=None, partner_id=None, date_invoice=None, payment_term_id=False, auto_validate=False):
|
||||
date_invoice = date_invoice or time.strftime('%Y') + '-07-01'
|
||||
|
||||
invoice_vals = {
|
||||
'type': type,
|
||||
'partner_id': partner_id or self.partner_agrolait_id,
|
||||
@@ -258,6 +297,11 @@ class TestReconciliationExec(TestReconciliation):
|
||||
])
|
||||
|
||||
def test_statement_usd_invoice_chf_transaction_chf(self):
|
||||
self.env['res.currency.rate'].create({
|
||||
'rate': 1.3086,
|
||||
'currency_id': self.env.ref('base.CHF').id,
|
||||
'name': '2010-01-02',
|
||||
})
|
||||
customer_move_lines, supplier_move_lines = self.make_customer_and_supplier_flows(self.currency_swiss_id, 50, self.bank_journal_usd, 42, 50, self.currency_swiss_id)
|
||||
self.assertRecordValues(customer_move_lines, [
|
||||
{'debit': 0.0, 'credit': 27.47, 'amount_currency': -50, 'currency_id': self.currency_swiss_id},
|
||||
@@ -676,7 +720,7 @@ class TestReconciliationExec(TestReconciliation):
|
||||
# Balance Debit = 18.75
|
||||
# Counterpart Credit goes in Exchange diff
|
||||
|
||||
dest_journal_id = self.env['account.journal'].search([('type', '=', 'purchase'), ('company_id', '=', self.env.ref('base.main_company').id)], limit=1)
|
||||
dest_journal_id = self.env['account.journal'].search([('type', '=', 'purchase'), ('company_id', '=', self.company.id)], limit=1)
|
||||
|
||||
self.bank_journal_euro.write({'default_debit_account_id': self.account_rsa.id,
|
||||
'default_credit_account_id': self.account_rsa.id})
|
||||
@@ -686,17 +730,17 @@ class TestReconciliationExec(TestReconciliation):
|
||||
self.env['res.currency.rate'].create({'name': time.strftime('%Y') + '-' + '07' + '-01',
|
||||
'rate': 0.5,
|
||||
'currency_id': self.currency_usd_id,
|
||||
'company_id': self.env.ref('base.main_company').id})
|
||||
'company_id': self.company.id})
|
||||
|
||||
self.env['res.currency.rate'].create({'name': time.strftime('%Y') + '-' + '08' + '-01',
|
||||
'rate': 0.75,
|
||||
'currency_id': self.currency_usd_id,
|
||||
'company_id': self.env.ref('base.main_company').id})
|
||||
'company_id': self.company.id})
|
||||
|
||||
self.env['res.currency.rate'].create({'name': time.strftime('%Y') + '-' + '09' + '-01',
|
||||
'rate': 0.80,
|
||||
'currency_id': self.currency_usd_id,
|
||||
'company_id': self.env.ref('base.main_company').id})
|
||||
'company_id': self.company.id})
|
||||
|
||||
# Preparing Invoices (from vendor)
|
||||
invoice_a = self.env['account.move'].with_context(default_type='in_invoice').create({
|
||||
@@ -727,7 +771,7 @@ class TestReconciliationExec(TestReconciliation):
|
||||
'amount': 25,
|
||||
'currency_id': self.currency_usd_id,
|
||||
'journal_id': self.bank_journal_euro.id,
|
||||
'company_id': self.env.ref('base.main_company').id,
|
||||
'company_id': self.company.id,
|
||||
'payment_date': time.strftime('%Y') + '-' + '07' + '-01',
|
||||
'partner_id': self.partner_agrolait_id,
|
||||
'payment_method_id': self.env.ref('account.account_payment_method_manual_out').id,
|
||||
@@ -739,7 +783,7 @@ class TestReconciliationExec(TestReconciliation):
|
||||
'amount': 50,
|
||||
'currency_id': self.currency_usd_id,
|
||||
'journal_id': self.bank_journal_euro.id,
|
||||
'company_id': self.env.ref('base.main_company').id,
|
||||
'company_id': self.company.id,
|
||||
'payment_date': time.strftime('%Y') + '-' + '08' + '-01',
|
||||
'partner_id': self.partner_agrolait_id,
|
||||
'payment_method_id': self.env.ref('account.account_payment_method_manual_out').id,
|
||||
@@ -751,7 +795,7 @@ class TestReconciliationExec(TestReconciliation):
|
||||
'amount': 25,
|
||||
'currency_id': self.currency_usd_id,
|
||||
'journal_id': self.bank_journal_euro.id,
|
||||
'company_id': self.env.ref('base.main_company').id,
|
||||
'company_id': self.company.id,
|
||||
'payment_date': time.strftime('%Y') + '-' + '09' + '-01',
|
||||
'partner_id': self.partner_agrolait_id,
|
||||
'payment_method_id': self.env.ref('account.account_payment_method_manual_out').id,
|
||||
@@ -840,13 +884,13 @@ class TestReconciliationExec(TestReconciliation):
|
||||
'name': time.strftime('%Y') + '-07-01',
|
||||
'rate': 1.0,
|
||||
'currency_id': self.currency_usd_id,
|
||||
'company_id': self.env.ref('base.main_company').id
|
||||
'company_id': self.company.id
|
||||
})
|
||||
self.env['res.currency.rate'].create({
|
||||
'name': time.strftime('%Y') + '-08-01',
|
||||
'rate': 0.5,
|
||||
'currency_id': self.currency_usd_id,
|
||||
'company_id': self.env.ref('base.main_company').id
|
||||
'company_id': self.company.id
|
||||
})
|
||||
inv = self.create_invoice(invoice_amount=111, currency_id=self.currency_usd_id)
|
||||
payment = self.env['account.payment'].create({
|
||||
@@ -946,13 +990,13 @@ class TestReconciliationExec(TestReconciliation):
|
||||
'name': time.strftime('%Y') + '-07-01',
|
||||
'rate': 1.0,
|
||||
'currency_id': self.currency_usd_id,
|
||||
'company_id': self.env.ref('base.main_company').id
|
||||
'company_id': self.company.id
|
||||
})
|
||||
self.env['res.currency.rate'].create({
|
||||
'name': time.strftime('%Y') + '-08-01',
|
||||
'rate': 0.5,
|
||||
'currency_id': self.currency_usd_id,
|
||||
'company_id': self.env.ref('base.main_company').id
|
||||
'company_id': self.company.id
|
||||
})
|
||||
inv = self.create_invoice(invoice_amount=111, currency_id=self.currency_usd_id)
|
||||
payment = self.env['account.payment'].create({
|
||||
@@ -994,7 +1038,7 @@ class TestReconciliationExec(TestReconciliation):
|
||||
####
|
||||
dest_journal_id = self.env['account.journal'].search(
|
||||
[('type', '=', 'purchase'),
|
||||
('company_id', '=', self.env.ref('base.main_company').id)],
|
||||
('company_id', '=', self.company.id)],
|
||||
limit=1)
|
||||
|
||||
# Delete any old rate - to make sure that we use the ones we need.
|
||||
@@ -1104,7 +1148,7 @@ class TestReconciliationExec(TestReconciliation):
|
||||
# one is subject to a cash basis tax
|
||||
# the other is not subject to tax
|
||||
|
||||
company = self.env.ref('base.main_company')
|
||||
company = self.company
|
||||
company.tax_cash_basis_journal_id = self.cash_basis_journal
|
||||
|
||||
purchase_move = self.env['account.move'].create({
|
||||
@@ -1196,7 +1240,7 @@ class TestReconciliationExec(TestReconciliation):
|
||||
# with 2 payment terms
|
||||
# And partial payment not martching any payment term
|
||||
|
||||
company = self.env.ref('base.main_company')
|
||||
company = self.company
|
||||
company.tax_cash_basis_journal_id = self.cash_basis_journal
|
||||
tax_cash_basis10percent = self.tax_cash_basis.copy({'amount': 10})
|
||||
tax_waiting_account10 = self.tax_waiting_account.copy({
|
||||
@@ -1395,7 +1439,7 @@ class TestReconciliationExec(TestReconciliation):
|
||||
Taxes -848.16 USD 0.00 17,094.66
|
||||
"""
|
||||
|
||||
company = self.env.ref('base.main_company')
|
||||
company = self.company
|
||||
company.country_id = self.ref('base.us')
|
||||
company.tax_cash_basis_journal_id = self.cash_basis_journal
|
||||
|
||||
@@ -1558,7 +1602,7 @@ class TestReconciliationExec(TestReconciliation):
|
||||
Taxes -848.16 USD 0.00 17,094.66
|
||||
"""
|
||||
|
||||
company = self.env.ref('base.main_company')
|
||||
company = self.company
|
||||
company.country_id = self.ref('base.us')
|
||||
company.tax_cash_basis_journal_id = self.cash_basis_journal
|
||||
|
||||
@@ -1698,7 +1742,7 @@ class TestReconciliationExec(TestReconciliation):
|
||||
.debit, 17094.66)
|
||||
|
||||
def test_reconciliation_cash_basis_revert(self):
|
||||
company = self.env.ref('base.main_company')
|
||||
company = self.company
|
||||
company.tax_cash_basis_journal_id = self.cash_basis_journal
|
||||
tax_cash_basis10percent = self.tax_cash_basis.copy({'amount': 10})
|
||||
self.tax_waiting_account.reconcile = True
|
||||
@@ -1763,7 +1807,7 @@ class TestReconciliationExec(TestReconciliation):
|
||||
self.assertEqual(reverted_expected.full_reconcile_id, inv_line.full_reconcile_id)
|
||||
|
||||
def test_reconciliation_revert_future(self):
|
||||
company = self.env.ref('base.main_company')
|
||||
company = self.company
|
||||
company.tax_cash_basis_journal_id = self.cash_basis_journal
|
||||
tax_cash_basis10percent = self.tax_cash_basis.copy({'amount': 10})
|
||||
self.tax_waiting_account.reconcile = True
|
||||
@@ -1832,6 +1876,7 @@ class TestReconciliationExec(TestReconciliation):
|
||||
self.assertEqual(reverse_move.date, reverse_date)
|
||||
|
||||
def test_reconciliation_cash_basis_foreign_currency_low_values(self):
|
||||
self.company.tax_cash_basis_journal_id = self.cash_basis_journal
|
||||
journal = self.env['account.journal'].create({
|
||||
'name': 'Bank', 'type': 'bank', 'code': 'THE',
|
||||
'currency_id': self.currency_usd_id,
|
||||
@@ -1842,7 +1887,7 @@ class TestReconciliationExec(TestReconciliation):
|
||||
'name': time.strftime('%Y-01-01'),
|
||||
'rate': 1/17.0,
|
||||
'currency_id': self.currency_usd_id,
|
||||
'company_id': self.env.ref('base.main_company').id,
|
||||
'company_id': self.company.id,
|
||||
})
|
||||
|
||||
move_form = Form(self.env['account.move'].with_context(default_type='out_invoice'))
|
||||
@@ -1958,7 +2003,7 @@ class TestReconciliationExec(TestReconciliation):
|
||||
self.assertEqual(aml.amount_residual, 0.0)
|
||||
|
||||
def test_inv_refund_foreign_payment_writeoff_domestic2(self):
|
||||
company = self.env.ref('base.main_company')
|
||||
company = self.company
|
||||
self.env['res.currency.rate'].search([]).unlink()
|
||||
self.env['res.currency.rate'].create({
|
||||
'name': time.strftime('%Y') + '-07-01',
|
||||
@@ -1970,7 +2015,7 @@ class TestReconciliationExec(TestReconciliation):
|
||||
'name': time.strftime('%Y') + '-07-01',
|
||||
'rate': 1.110600, # Don't change this !
|
||||
'currency_id': self.currency_usd_id,
|
||||
'company_id': self.env.ref('base.main_company').id
|
||||
'company_id': self.company.id
|
||||
})
|
||||
inv1 = self.create_invoice(invoice_amount=800, currency_id=self.currency_usd_id)
|
||||
inv2 = self.create_invoice(type="out_refund", invoice_amount=400, currency_id=self.currency_usd_id)
|
||||
@@ -2025,7 +2070,7 @@ class TestReconciliationExec(TestReconciliation):
|
||||
Reconciliation should be full
|
||||
Invoices should be marked as paid
|
||||
"""
|
||||
company = self.env.ref('base.main_company')
|
||||
company = self.company
|
||||
self.env['res.currency.rate'].search([]).unlink()
|
||||
self.env['res.currency.rate'].create({
|
||||
'name': time.strftime('%Y') + '-07-01',
|
||||
@@ -2037,7 +2082,7 @@ class TestReconciliationExec(TestReconciliation):
|
||||
'name': time.strftime('%Y') + '-07-01',
|
||||
'rate': 1.110600, # Don't change this !
|
||||
'currency_id': self.currency_usd_id,
|
||||
'company_id': self.env.ref('base.main_company').id
|
||||
'company_id': company.id
|
||||
})
|
||||
inv1 = self.create_invoice(invoice_amount=658, currency_id=self.currency_usd_id)
|
||||
inv2 = self.create_invoice(type="out_refund", invoice_amount=225, currency_id=self.currency_usd_id)
|
||||
@@ -2096,7 +2141,7 @@ class TestReconciliationExec(TestReconciliation):
|
||||
Reconciliation should be full
|
||||
Invoices should be marked as paid
|
||||
"""
|
||||
company = self.env.ref('base.main_company')
|
||||
company = self.company
|
||||
self.env['res.currency.rate'].search([]).unlink()
|
||||
self.env['res.currency.rate'].create({
|
||||
'name': time.strftime('%Y') + '-07-01',
|
||||
@@ -2108,13 +2153,13 @@ class TestReconciliationExec(TestReconciliation):
|
||||
'name': time.strftime('%Y') + '-07-01',
|
||||
'rate': 1.0, # Don't change this !
|
||||
'currency_id': self.currency_usd_id,
|
||||
'company_id': self.env.ref('base.main_company').id
|
||||
'company_id': company.id
|
||||
})
|
||||
self.env['res.currency.rate'].create({
|
||||
'name': time.strftime('%Y') + '-07-15',
|
||||
'rate': 1.110600, # Don't change this !
|
||||
'currency_id': self.currency_usd_id,
|
||||
'company_id': self.env.ref('base.main_company').id
|
||||
'company_id': company.id
|
||||
})
|
||||
inv1 = self._create_invoice(invoice_amount=658, currency_id=self.currency_usd_id, date_invoice=time.strftime('%Y') + '-07-01', auto_validate=True)
|
||||
inv2 = self._create_invoice(type="out_refund", invoice_amount=225, currency_id=self.currency_usd_id, date_invoice=time.strftime('%Y') + '-07-15', auto_validate=True)
|
||||
@@ -2177,7 +2222,7 @@ class TestReconciliationExec(TestReconciliation):
|
||||
Reconciliation should be full, without exchange difference
|
||||
Invoices should be marked as paid
|
||||
"""
|
||||
company = self.env.ref('base.main_company')
|
||||
company = self.company
|
||||
self.env['res.currency.rate'].search([]).unlink()
|
||||
self.env['res.currency.rate'].create({
|
||||
'name': time.strftime('%Y') + '-07-01',
|
||||
@@ -2189,7 +2234,7 @@ class TestReconciliationExec(TestReconciliation):
|
||||
'name': time.strftime('%Y') + '-07-01',
|
||||
'rate': 1.0, # Don't change this !
|
||||
'currency_id': self.currency_usd_id,
|
||||
'company_id': self.env.ref('base.main_company').id
|
||||
'company_id': company.id
|
||||
})
|
||||
|
||||
inv1 = self._create_invoice(invoice_amount=600, currency_id=self.currency_usd_id, date_invoice=time.strftime('%Y') + '-07-15', auto_validate=True)
|
||||
@@ -2241,7 +2286,7 @@ class TestReconciliationExec(TestReconciliation):
|
||||
| 225.10 (250.00) INV 2 > Done in foreign
|
||||
| 315.15 (350.00) PAYMENT > Done in domestic (the 350.00 is virtual, non stored)
|
||||
"""
|
||||
company = self.env.ref('base.main_company')
|
||||
company = self.company
|
||||
self.env['res.currency.rate'].search([]).unlink()
|
||||
self.env['res.currency.rate'].create({
|
||||
'name': time.strftime('%Y') + '-07-01',
|
||||
@@ -2253,7 +2298,7 @@ class TestReconciliationExec(TestReconciliation):
|
||||
'name': time.strftime('%Y') + '-07-01',
|
||||
'rate': 1.1106, # Don't change this !
|
||||
'currency_id': self.currency_usd_id,
|
||||
'company_id': self.env.ref('base.main_company').id
|
||||
'company_id': company.id
|
||||
})
|
||||
inv1 = self._create_invoice(invoice_amount=600, currency_id=self.currency_usd_id, date_invoice=time.strftime('%Y') + '-07-15', auto_validate=True)
|
||||
inv2 = self._create_invoice(type="out_refund", invoice_amount=250, currency_id=self.currency_usd_id, date_invoice=time.strftime('%Y') + '-07-15', auto_validate=True)
|
||||
@@ -2309,7 +2354,7 @@ class TestReconciliationExec(TestReconciliation):
|
||||
})
|
||||
foreign_1 = self.env['res.currency'].browse(self.currency_usd_id)
|
||||
|
||||
company = self.env.ref('base.main_company')
|
||||
company = self.company
|
||||
self.env['res.currency.rate'].search([]).unlink()
|
||||
self.env['res.currency.rate'].create({
|
||||
'name': time.strftime('%Y') + '-07-01',
|
||||
@@ -2328,7 +2373,7 @@ class TestReconciliationExec(TestReconciliation):
|
||||
'name': time.strftime('%Y') + '-07-01',
|
||||
'rate': 1.1106, # Don't change this !
|
||||
'currency_id': foreign_1.id,
|
||||
'company_id': self.env.ref('base.main_company').id
|
||||
'company_id': company.id
|
||||
})
|
||||
inv1 = self._create_invoice(invoice_amount=600, currency_id=foreign_1.id, date_invoice=time.strftime('%Y') + '-07-15', auto_validate=True)
|
||||
inv2 = self._create_invoice(type="out_refund", invoice_amount=250, currency_id=foreign_1.id, date_invoice=time.strftime('%Y') + '-07-15', auto_validate=True)
|
||||
@@ -2384,7 +2429,7 @@ class TestReconciliationExec(TestReconciliation):
|
||||
Reconciliation should be full, without exchange difference
|
||||
Invoices should be marked as paid
|
||||
"""
|
||||
company = self.env.ref('base.main_company')
|
||||
company = self.company
|
||||
self.env['res.currency.rate'].search([]).unlink()
|
||||
self.env['res.currency.rate'].create({
|
||||
'name': time.strftime('%Y') + '-07-01',
|
||||
@@ -2396,7 +2441,7 @@ class TestReconciliationExec(TestReconciliation):
|
||||
'name': time.strftime('%Y') + '-07-01',
|
||||
'rate': 1.1106, # Don't change this !
|
||||
'currency_id': self.currency_usd_id,
|
||||
'company_id': self.env.ref('base.main_company').id
|
||||
'company_id': company.id
|
||||
})
|
||||
inv1 = self._create_invoice(invoice_amount=5980, currency_id=self.currency_usd_id, date_invoice=time.strftime('%Y') + '-07-15', auto_validate=True)
|
||||
|
||||
@@ -2436,7 +2481,7 @@ class TestReconciliationExec(TestReconciliation):
|
||||
Though it simulates going through the reconciliation widget
|
||||
Because the WriteOff is on a different line than the payment
|
||||
"""
|
||||
company = self.env.ref('base.main_company')
|
||||
company = self.company
|
||||
self.env['res.currency.rate'].search([]).unlink()
|
||||
self.env['res.currency.rate'].create({
|
||||
'name': time.strftime('%Y') + '-07-01',
|
||||
@@ -2448,7 +2493,7 @@ class TestReconciliationExec(TestReconciliation):
|
||||
'name': time.strftime('%Y') + '-07-01',
|
||||
'rate': 1.1106, # Don't change this !
|
||||
'currency_id': self.currency_usd_id,
|
||||
'company_id': self.env.ref('base.main_company').id
|
||||
'company_id': company.id
|
||||
})
|
||||
inv1 = self._create_invoice(invoice_amount=5980, currency_id=self.currency_usd_id, date_invoice=time.strftime('%Y') + '-07-15', auto_validate=True)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import fields
|
||||
from odoo import fields, tools
|
||||
from odoo.addons.account.tests.account_test_classes import AccountingTestCase
|
||||
from odoo.tests.common import Form
|
||||
from odoo.tests import tagged
|
||||
@@ -7,9 +7,99 @@ from odoo.tests import tagged
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestReconciliationMatchingRules(AccountingTestCase):
|
||||
def _create_invoice_line(self, amount, partner, type):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestReconciliationMatchingRules, cls).setUpClass()
|
||||
cls.company = cls.env.user.company_id
|
||||
cls.account_pay = cls.a_pay
|
||||
cls.account_liq = cls.bnk
|
||||
cls.account_rcv = cls.a_recv
|
||||
|
||||
cls.partner_1 = cls.env['res.partner'].create({'name': 'partner_1', 'company_id': cls.company.id})
|
||||
cls.partner_2 = cls.env['res.partner'].create({'name': 'partner_2', 'company_id': cls.company.id})
|
||||
|
||||
cls.invoice_line_1 = cls._create_invoice_line(100, cls.partner_1, 'out_invoice')
|
||||
cls.invoice_line_2 = cls._create_invoice_line(200, cls.partner_1, 'out_invoice')
|
||||
cls.invoice_line_3 = cls._create_invoice_line(300, cls.partner_1, 'in_refund')
|
||||
cls.invoice_line_3.move_id.name = "RBILL/2018/0013" # Without demo data, avoid to match with the first invoice
|
||||
cls.invoice_line_4 = cls._create_invoice_line(1000, cls.partner_2, 'in_invoice')
|
||||
|
||||
current_assets_account = cls.env['account.account'].search([
|
||||
('user_type_id', '=', cls.env.ref('account.data_account_type_current_assets').id),
|
||||
('company_id', '=', cls.company.id)], limit=1)
|
||||
|
||||
cls.rule_0 = cls.env['account.reconcile.model'].search([('company_id', '=', cls.env.company.id), ('rule_type', '=', 'invoice_matching')])
|
||||
if not cls.rule_0:
|
||||
cls.rule_0 = cls.env['account.reconcile.model'].sudo().create({
|
||||
"name": 'Invoices Matching Rule',
|
||||
"sequence": '1',
|
||||
"rule_type": 'invoice_matching',
|
||||
"auto_reconcile": False,
|
||||
"match_nature": 'both',
|
||||
"match_same_currency": True,
|
||||
"match_total_amount": True,
|
||||
"match_total_amount_param": 100,
|
||||
"match_partner": True,
|
||||
"company_id": cls.company.id,
|
||||
})
|
||||
|
||||
cls.rule_1 = cls.rule_0.copy()
|
||||
cls.rule_1.account_id = current_assets_account
|
||||
cls.rule_1.match_partner = True
|
||||
cls.rule_1.match_partner_ids |= cls.partner_1 + cls.partner_2
|
||||
cls.rule_2 = cls.env['account.reconcile.model'].create({
|
||||
'name': 'write-off model',
|
||||
'rule_type': 'writeoff_suggestion',
|
||||
'match_partner': True,
|
||||
'match_partner_ids': [],
|
||||
'account_id': current_assets_account.id,
|
||||
})
|
||||
|
||||
invoice_number = cls.invoice_line_1.move_id.name
|
||||
|
||||
cls.bank_journal = cls.env['account.journal'].search([('type', '=', 'bank'), ('company_id', '=', cls.company.id)], limit=1)
|
||||
|
||||
cls.bank_st = cls.env['account.bank.statement'].create({
|
||||
'name': 'test bank journal', 'journal_id': cls.bank_journal.id,
|
||||
})
|
||||
cls.bank_line_1 = cls.env['account.bank.statement.line'].create({
|
||||
'statement_id': cls.bank_st.id,
|
||||
'name': 'invoice %s-%s' % (invoice_number.split('/')[1], invoice_number.split('/')[2]),
|
||||
'partner_id': cls.partner_1.id,
|
||||
'amount': 100,
|
||||
'sequence': 1,
|
||||
})
|
||||
cls.bank_line_2 = cls.env['account.bank.statement.line'].create({
|
||||
'statement_id': cls.bank_st.id,
|
||||
'name': 'xxxxx',
|
||||
'partner_id': cls.partner_1.id,
|
||||
'amount': 600,
|
||||
'sequence': 2,
|
||||
})
|
||||
|
||||
cash_journal = cls.env['account.journal'].search([('type', '=', 'cash'), ('company_id', '=', cls.company.id)], limit=1)
|
||||
cls.cash_st = cls.env['account.bank.statement'].create({
|
||||
'name': 'test cash journal', 'journal_id': cash_journal.id,
|
||||
})
|
||||
cls.cash_line_1 = cls.env['account.bank.statement.line'].create({
|
||||
'statement_id': cls.cash_st.id,
|
||||
'name': 'yyyyy',
|
||||
'partner_id': cls.partner_2.id,
|
||||
'amount': -1000,
|
||||
'sequence': 1,
|
||||
})
|
||||
|
||||
cls.tax21 = cls.env['account.tax'].create({
|
||||
'name': '21%',
|
||||
'type_tax_use': 'purchase',
|
||||
'amount': 21,
|
||||
})
|
||||
|
||||
@classmethod
|
||||
def _create_invoice_line(cls, amount, partner, type):
|
||||
''' Create an invoice on the fly.'''
|
||||
invoice_form = Form(self.env['account.move'].with_context(default_type=type))
|
||||
invoice_form = Form(cls.env['account.move'].with_context(default_type=type))
|
||||
invoice_form.invoice_date = fields.Date.from_string('2019-09-01')
|
||||
invoice_form.partner_id = partner
|
||||
with invoice_form.invoice_line_ids.new() as invoice_line_form:
|
||||
@@ -31,76 +121,6 @@ class TestReconciliationMatchingRules(AccountingTestCase):
|
||||
values.pop('reconciled_lines', None)
|
||||
self.assertDictEqual(values, expected_values[st_line_id])
|
||||
|
||||
def setUp(self):
|
||||
super(AccountingTestCase, self).setUp()
|
||||
|
||||
self.account_pay = self.env['account.account'].search([('internal_type', '=', 'payable')], limit=1)
|
||||
self.account_liq = self.env['account.account'].search([('internal_type', '=', 'liquidity')], limit=1)
|
||||
self.account_rcv = self.env['account.account'].search([('internal_type', '=', 'receivable')], limit=1)
|
||||
|
||||
self.partner_1 = self.env['res.partner'].create({'name': 'partner_1'})
|
||||
self.partner_2 = self.env['res.partner'].create({'name': 'partner_2'})
|
||||
|
||||
self.invoice_line_1 = self._create_invoice_line(100, self.partner_1, 'out_invoice')
|
||||
self.invoice_line_2 = self._create_invoice_line(200, self.partner_1, 'out_invoice')
|
||||
self.invoice_line_3 = self._create_invoice_line(300, self.partner_1, 'in_refund')
|
||||
self.invoice_line_4 = self._create_invoice_line(1000, self.partner_2, 'in_invoice')
|
||||
|
||||
current_assets_account = self.env['account.account'].search(
|
||||
[('user_type_id', '=', self.env.ref('account.data_account_type_current_assets').id)], limit=1)
|
||||
|
||||
self.rule_0 = self.env['account.reconcile.model'].search([('company_id', '=', self.env.company.id), ('rule_type', '=', 'invoice_matching')])
|
||||
self.rule_1 = self.rule_0.copy()
|
||||
self.rule_1.account_id = current_assets_account
|
||||
self.rule_1.match_partner = True
|
||||
self.rule_1.match_partner_ids |= self.partner_1 + self.partner_2
|
||||
self.rule_2 = self.env['account.reconcile.model'].create({
|
||||
'name': 'write-off model',
|
||||
'rule_type': 'writeoff_suggestion',
|
||||
'match_partner': True,
|
||||
'match_partner_ids': [],
|
||||
'account_id': current_assets_account.id,
|
||||
})
|
||||
|
||||
invoice_number = self.invoice_line_1.move_id.name
|
||||
|
||||
self.bank_journal = self.env['account.journal'].search([('type', '=', 'bank')], limit=1)
|
||||
|
||||
self.bank_st = self.env['account.bank.statement'].create({
|
||||
'name': 'test bank journal', 'journal_id': self.bank_journal.id,
|
||||
})
|
||||
self.bank_line_1 = self.env['account.bank.statement.line'].create({
|
||||
'statement_id': self.bank_st.id,
|
||||
'name': 'invoice %s-%s' % (invoice_number.split('/')[1], invoice_number.split('/')[2]),
|
||||
'partner_id': self.partner_1.id,
|
||||
'amount': 100,
|
||||
'sequence': 1,
|
||||
})
|
||||
self.bank_line_2 = self.env['account.bank.statement.line'].create({
|
||||
'statement_id': self.bank_st.id,
|
||||
'name': 'xxxxx',
|
||||
'partner_id': self.partner_1.id,
|
||||
'amount': 600,
|
||||
'sequence': 2,
|
||||
})
|
||||
|
||||
cash_journal = self.env['account.journal'].search([('type', '=', 'cash')], limit=1)
|
||||
self.cash_st = self.env['account.bank.statement'].create({
|
||||
'name': 'test cash journal', 'journal_id': cash_journal.id,
|
||||
})
|
||||
self.cash_line_1 = self.env['account.bank.statement.line'].create({
|
||||
'statement_id': self.cash_st.id,
|
||||
'name': 'yyyyy',
|
||||
'partner_id': self.partner_2.id,
|
||||
'amount': -1000,
|
||||
'sequence': 1,
|
||||
})
|
||||
|
||||
self.tax21 = self.env['account.tax'].create({
|
||||
'name': '21%',
|
||||
'type_tax_use': 'purchase',
|
||||
'amount': 21,
|
||||
})
|
||||
|
||||
def test_matching_fields(self):
|
||||
''' Test all fields used to restrict the rules's applicability.'''
|
||||
@@ -236,7 +256,7 @@ class TestReconciliationMatchingRules(AccountingTestCase):
|
||||
self.bank_line_1.amount += 5
|
||||
|
||||
# Check match_partner_category_ids.
|
||||
test_category = self.env.ref('base.res_partner_category_8')
|
||||
test_category = self.env['res.partner.category'].create({'name': 'Consulting Services'})
|
||||
self.partner_2.category_id = test_category
|
||||
self.rule_1.match_partner_category_ids |= test_category
|
||||
self._check_statement_matching(self.rule_1, {
|
||||
@@ -367,11 +387,14 @@ class TestReconciliationMatchingRules(AccountingTestCase):
|
||||
|
||||
move.post()
|
||||
move_reversed = move._reverse_moves()
|
||||
|
||||
self.assertTrue(move_reversed.exists())
|
||||
|
||||
bank_st = self.env['account.bank.statement'].create({
|
||||
'name': 'test bank journal', 'journal_id': self.bank_journal.id,
|
||||
})
|
||||
bank_st.journal_id.default_credit_account_id = payment_bnk_line.account_id
|
||||
bank_st.journal_id.default_debit_account_id = payment_bnk_line.account_id
|
||||
bank_line_1 = self.env['account.bank.statement.line'].create({
|
||||
'statement_id': bank_st.id,
|
||||
'name': '8',
|
||||
@@ -379,7 +402,7 @@ class TestReconciliationMatchingRules(AccountingTestCase):
|
||||
'amount': -10,
|
||||
'sequence': 1,
|
||||
})
|
||||
|
||||
bank_st.flush()
|
||||
expected_values = {
|
||||
bank_line_1.id: {'aml_ids': [payment_bnk_line.id], 'model': self.rule_0}
|
||||
}
|
||||
|
||||
@@ -6,77 +6,78 @@ from odoo.tests import tagged
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestTax(AccountTestUsers):
|
||||
|
||||
def setUp(self):
|
||||
super(TestTax, self).setUp()
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestTax, cls).setUpClass()
|
||||
|
||||
self.fixed_tax = self.tax_model.create({
|
||||
cls.fixed_tax = cls.tax_model.create({
|
||||
'name': "Fixed tax",
|
||||
'amount_type': 'fixed',
|
||||
'amount': 10,
|
||||
'sequence': 1,
|
||||
})
|
||||
self.fixed_tax_bis = self.tax_model.create({
|
||||
cls.fixed_tax_bis = cls.tax_model.create({
|
||||
'name': "Fixed tax bis",
|
||||
'amount_type': 'fixed',
|
||||
'amount': 15,
|
||||
'sequence': 2,
|
||||
})
|
||||
self.percent_tax = self.tax_model.create({
|
||||
cls.percent_tax = cls.tax_model.create({
|
||||
'name': "Percent tax",
|
||||
'amount_type': 'percent',
|
||||
'amount': 10,
|
||||
'sequence': 3,
|
||||
})
|
||||
self.percent_tax_bis = self.tax_model.create({
|
||||
cls.percent_tax_bis = cls.tax_model.create({
|
||||
'name': "Percent tax bis",
|
||||
'amount_type': 'percent',
|
||||
'amount': 10,
|
||||
'sequence': 4,
|
||||
})
|
||||
self.division_tax = self.tax_model.create({
|
||||
cls.division_tax = cls.tax_model.create({
|
||||
'name': "Division tax",
|
||||
'amount_type': 'division',
|
||||
'amount': 10,
|
||||
'sequence': 4,
|
||||
})
|
||||
self.group_tax = self.tax_model.create({
|
||||
cls.group_tax = cls.tax_model.create({
|
||||
'name': "Group tax",
|
||||
'amount_type': 'group',
|
||||
'amount': 0,
|
||||
'sequence': 5,
|
||||
'children_tax_ids': [
|
||||
(4, self.fixed_tax.id, 0),
|
||||
(4, self.percent_tax.id, 0)
|
||||
(4, cls.fixed_tax.id, 0),
|
||||
(4, cls.percent_tax.id, 0)
|
||||
]
|
||||
})
|
||||
self.group_tax_bis = self.tax_model.create({
|
||||
cls.group_tax_bis = cls.tax_model.create({
|
||||
'name': "Group tax bis",
|
||||
'amount_type': 'group',
|
||||
'amount': 0,
|
||||
'sequence': 6,
|
||||
'children_tax_ids': [
|
||||
(4, self.fixed_tax.id, 0),
|
||||
(4, self.percent_tax.id, 0)
|
||||
(4, cls.fixed_tax.id, 0),
|
||||
(4, cls.percent_tax.id, 0)
|
||||
]
|
||||
})
|
||||
self.group_of_group_tax = self.tax_model.create({
|
||||
cls.group_of_group_tax = cls.tax_model.create({
|
||||
'name': "Group of group tax",
|
||||
'amount_type': 'group',
|
||||
'amount': 0,
|
||||
'sequence': 7,
|
||||
'children_tax_ids': [
|
||||
(4, self.group_tax.id, 0),
|
||||
(4, self.group_tax_bis.id, 0)
|
||||
(4, cls.group_tax.id, 0),
|
||||
(4, cls.group_tax_bis.id, 0)
|
||||
]
|
||||
})
|
||||
self.tax_with_no_account = self.tax_model.create({
|
||||
cls.tax_with_no_account = cls.tax_model.create({
|
||||
'name': "Tax with no account",
|
||||
'amount_type': 'fixed',
|
||||
'amount': 0,
|
||||
'sequence': 8,
|
||||
})
|
||||
some_account = self.env['account.account'].search([], limit=1)
|
||||
self.tax_with_account = self.tax_model.create({
|
||||
some_account = cls.env['account.account'].search([], limit=1)
|
||||
cls.tax_with_account = cls.tax_model.create({
|
||||
'name': "Tax with account",
|
||||
'amount_type': 'fixed',
|
||||
'amount': 0,
|
||||
@@ -106,9 +107,9 @@ class TestTax(AccountTestUsers):
|
||||
}),
|
||||
],
|
||||
})
|
||||
self.bank_journal = self.env['account.journal'].search([('type', '=', 'bank'), ('company_id', '=', self.account_manager.company_id.id)])[0]
|
||||
self.bank_account = self.bank_journal.default_debit_account_id
|
||||
self.expense_account = self.env['account.account'].search([('user_type_id.type', '=', 'payable')], limit=1) #Should be done by onchange later
|
||||
cls.bank_journal = cls.env['account.journal'].search([('type', '=', 'bank'), ('company_id', '=', cls.account_manager.company_id.id)])[0]
|
||||
cls.bank_account = cls.bank_journal.default_debit_account_id
|
||||
cls.expense_account = cls.env['account.account'].search([('user_type_id.type', '=', 'payable')], limit=1) #Should be done by onchange later
|
||||
|
||||
def _check_compute_all_results(self, total_included, total_excluded, taxes, res):
|
||||
self.assertAlmostEqual(res['total_included'], total_included)
|
||||
|
||||
Reference in New Issue
Block a user