[IMP] account_voucher: convert yml tests into python

This commit is contained in:
Axay Javiya
2017-11-02 16:18:37 +01:00
committed by Yannick Tivisse
parent 6a943000e8
commit ad70f91daf
7 changed files with 122 additions and 161 deletions
-6
View File
@@ -34,12 +34,6 @@ This module manages:
'security/account_voucher_security.xml',
'data/account_voucher_data.xml',
],
'test' : [
'test/account_voucher_users.yml',
'test/account_voucher_chart.yml',
'test/account_voucher.yml',
'test/sales_receipt.yml',
],
'auto_install': False,
'installable': True,
}
@@ -1,54 +0,0 @@
-
I check the voucher module with user who is accountant.
-
!context
uid: 'res_users_account_voucher_user'
-
In order to check account voucher module in Odoo I create a customer voucher
-
!record {model: account.voucher, id: account_voucher_voucherforaxelor0, view: view_sale_receipt_form}:
voucher_type: sale
account_id: a_cash
amount: 1000.0
company_id: base.main_company
journal_id: sales_journal
name: Voucher for Axelor
narration: Basic Pc
line_ids:
- account_id: a_recv
price_unit: 1000.0
name: Voucher for Axelor
partner_id: base.res_partner_12
date: !eval time.strftime('%Y-%m-%d')
reference: none
-
I check that Initially customer voucher is in the "Draft" state
-
!assert {model: account.voucher, id: account_voucher_voucherforaxelor0}:
- state == 'draft'
-
Now I create a Vendor Voucher
-
!record {model: account.voucher, id: account_voucher_voucheraxelor0}:
voucher_type: purchase
account_id: a_cash
amount: 1000.0
company_id: base.main_company
journal_id: j_cash
name: Voucher Axelor
narration: PC Assemble SC234
line_ids:
- account_id: a_cash
price_unit: 1000.0
name: Voucher Axelor
partner_id: base.res_partner_12
date: !eval time.strftime('%Y-%m-%d')
reference: none
-
I check that Initially vendor voucher is in the "Draft" state
-
!assert {model: account.voucher, id: account_voucher_voucheraxelor0}:
- state == 'draft'
@@ -1,46 +0,0 @@
-
Use voucher accountant user
-
!context
uid: 'res_users_account_voucher_user'
-
Create receivable account
-
!record {model: account.account, id: a_recv}:
code: X1012
name: Debtors - (test)
reconcile: !eval True
user_type_id: account.data_account_type_receivable
-
Create sales account
-
!record {model: account.account, id: a_sale}:
code: X1020
name: Product Sales - (test)
user_type_id: account.data_account_type_revenue
-
Create sales journal
-
!record {model: account.journal, id: sales_journal}:
name: Sales Journal - (test)
code: TSAJ
type: sale
refund_sequence: !eval True
default_debit_account_id: a_sale
default_credit_account_id: a_sale
-
Create cash account
-
!record {model: account.account, id: a_cash}:
code: X1015
name: Cash - (test)
user_type_id: account.data_account_type_liquidity
-
Create cash journal
-
!record {model: account.journal, id: j_cash}:
code: VCSH
name: Cash Journal - (test)
type: cash
default_debit_account_id: a_cash
default_credit_account_id: a_cash
@@ -1,30 +0,0 @@
-
Create a user as 'Accountant for account voucher'
-
!record {model: res.users, id: res_users_account_voucher_user, view: False}:
company_id: base.main_company
name: Voucher Accountant
login: vacc
email: accountant@yourcompany.com
-
I added groups to Accountant for account voucher.
-
!record {model: res.users, id: res_users_account_voucher_user}:
groups_id:
- base.group_partner_manager
- account.group_account_invoice
-
Create a user as 'Financial Manager for account voucher'
-
!record {model: res.users, id: res_users_account_voucher_manager, view: False}:
company_id: base.main_company
name: Financial Manager for voucher
login: fmv
email: finmanager@yourcompany.com
-
I added groups to Financial Manager for account voucher.
-
!record {model: res.users, id: res_users_account_voucher_manager}:
groups_id:
- base.group_partner_manager
- account.group_account_manager
@@ -1,25 +0,0 @@
-
Accountant can also be created receipt and validate it there for I checked it with that user who is accountant.
-
!context
uid: 'res_users_account_voucher_user'
-
Creating a Voucher Receipt for partner Seagate with amount 30000.0
-
!record {model: account.voucher, id: account_voucher_seagate_0, view: view_sale_receipt_form}:
account_id: a_recv
amount: 30000.0
company_id: base.main_company
journal_id: sales_journal
line_ids:
- account_id: a_sale
price_unit: 30000.0
name: Voucher Seagate
partner_id: base.res_partner_2
date: !eval time.strftime("%Y-%m-%d")
voucher_type: sale
-
I check that the voucher state is Draft
-
!assert {model: account.voucher, id: account_voucher_seagate_0}:
- state == 'draft'
+4
View File
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import test_account_voucher
@@ -0,0 +1,118 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import tools
from odoo.modules.module import get_resource_path
from odoo.tests import common
import time
class TestAccountVoucher(common.TransactionCase):
def _load(self, module, *args):
tools.convert_file(self.cr, 'account_voucher',
get_resource_path(module, *args),
{}, 'init', False, 'test', self.registry._assertion_report)
def test_00_account_voucher_flow(self):
""" Create Account Voucher for Customer and Vendor """
self._load('account', 'test', 'account_minimal_test.xml')
# Models
Voucher = self.env['account.voucher']
# User-groups and References
company_id = self.ref('base.main_company')
partner_id = self.ref('base.res_partner_12')
account_id = self.ref('account_voucher.cash')
cash_journal_id = self.ref('account_voucher.cash_journal')
sales_journal_id = self.ref('account_voucher.sales_journal')
account_receivable_id = self.ref('account_voucher.a_recv')
# Create a Account Voucher User
res_users_account_voucher_user = self.env['res.users'].create({
'name': 'Voucher Accountant',
'login': 'vacc',
'password': 'vacc',
'email': 'accountant@yourcompany.com',
'company_id': company_id,
'groups_id': [(6, 0, [
self.ref('base.group_partner_manager'),
self.ref('account.group_account_user'),
self.ref('account.group_account_invoice')
])]
})
# Create Customer Voucher
account_voucher_customer = Voucher.sudo(res_users_account_voucher_user).create({
'voucher_type': 'sale',
'partner_id': partner_id,
'company_id': company_id,
'account_id': account_id,
'journal_id': sales_journal_id,
'date': time.strftime('%Y-%m-%d'),
'name': 'Voucher for Axelor',
'amount': 1000.0,
'narration': 'Basic Pc',
'line_ids': [
(0, 0, {
'account_id': account_receivable_id,
'price_unit': 1000.0,
'name': 'Voucher for Axelor',
})]
})
# Check Customer Voucher status.
self.assertEquals(account_voucher_customer.state, 'draft', 'Initially customer voucher should be in the "Draft" state')
# Validate Customer voucher
account_voucher_customer.proforma_voucher()
# Check for Journal Entry of customer voucher
self.assertTrue(account_voucher_customer.move_id, 'No journal entry created !.')
# Find related account move line for Customer Voucher.
customer_voucher_move = account_voucher_customer.move_id
# Check state of Account move line.
self.assertEquals(customer_voucher_move.state, 'posted', 'Account move state is incorrect.')
# Check partner of Account move line.
self.assertEquals(customer_voucher_move.partner_id.id, partner_id, 'Partner is incorrect on account move.')
# Check journal in Account move line.
self.assertEquals(customer_voucher_move.journal_id.id, sales_journal_id, 'Journal is incorrect on account move.')
# Check amount in Account move line.
self.assertEquals(customer_voucher_move.amount, 1000.0, 'Amount is incorrect in account move.')
# Create Vendor Voucher
account_voucher_vendor = Voucher.sudo(res_users_account_voucher_user).create({
'voucher_type': 'purchase',
'partner_id': partner_id,
'company_id': company_id,
'account_id': account_id,
'journal_id': cash_journal_id,
'date': time.strftime('%Y-%m-%d'),
'name': 'Voucher Axelor',
'amount': 1000.0,
'narration': 'PC Assemble SC234',
'line_ids': [
(0, 0, {
'account_id': account_receivable_id,
'price_unit': 1000.0,
'name': 'Voucher Axelor',
})]
})
# Check Vendor Voucher status.
self.assertEquals(account_voucher_vendor.state, 'draft', 'Initially vendor voucher should be in the "Draft" state')
# Validate Vendor voucher
account_voucher_vendor.proforma_voucher()
# Check for Journal Entry of vendor voucher
self.assertTrue(account_voucher_vendor.move_id, 'No journal entry created !.')
# Find related account move line for Vendor Voucher.
vendor_voucher_move = account_voucher_vendor.move_id
# Check state of Account move line.
self.assertEquals(vendor_voucher_move.state, 'posted', 'Account move state is incorrect.')
# Check partner of Account move line.
self.assertEquals(vendor_voucher_move.partner_id.id, partner_id, 'Partner is incorrect on account move.')
# Check journal in Account move line.
self.assertEquals(vendor_voucher_move.journal_id.id, cash_journal_id, 'Journal is incorrect on account move.')
# Check amount in Account move line.
self.assertEquals(vendor_voucher_move.amount, 1000.0, 'Amount is incorrect in acccount move.')