Skip to content

Commit

Permalink
[IMP] finance 提高期末调汇测试覆盖率
Browse files Browse the repository at this point in the history
  • Loading branch information
GoodERPJeff committed Jun 19, 2018
1 parent 50bb1db commit 36b627d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
3 changes: 1 addition & 2 deletions finance/models/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ def create_exchang_line(self, vals):
当有主营业务收入,结汇等不需要汇兑损益的科目出现后,汇兑损益将不平,就会出现财务费用汇兑损益,
'''
vouch_obj = vals.get('vouch_obj_id')
voucher = self.env['voucher'].search([('id', '=', vouch_obj),
('state', '=', 'done')])
voucher = self.env['voucher'].search([('id', '=', vouch_obj)])
voucher_lines = voucher.line_ids
account_id = self.env.ref('finance.account_exchange')
exp = 0
Expand Down
34 changes: 32 additions & 2 deletions finance/tests/test_exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,31 @@ def setUp(self):
})
# 借贷方为 外币 币别
# 2015年12月的凭证 2015-12-08
self.env.ref('core.jd').c_category_id.account_id.currency_id = self.env.ref('base.USD')
self.env.ref('core.jd').c_category_id.account_id.exchange = True
self.env.ref(
'finance.voucher_line_12_debit').account_id = self.usd_account
'finance.voucher_line_12_debit').parner_id = self.env.ref('core.jd')
self.env.ref(
'finance.voucher_line_12_credit').account_id = self.usd_account

self.env.ref('finance.voucher_12').voucher_done()

# 相反分录用于测试相反方向发生额
voucher = self.env['voucher'].create({
'date': '2015-12-01',
'line_ids': [(0, 0, {
'name': u'退投资', # 贷方行
'account_id': self.env.ref('core.jd').c_category_id.account_id.id,
'partner_id': self.env.ref('core.jd').id,
'debit': 1,
}),
(0, 0, {
'name': u'退投资', # 借方行
'account_id': self.usd_account.id,
'credit': 1,
})]
})
voucher.voucher_done()

def test_create_exchange_in(self):
'''测试 有辅助核算 余额方向为 借'''
self.create_exchange_wizard.create_exchange()
Expand All @@ -46,3 +66,13 @@ def test_create_exchange_no_auxiliary_financing_out(self):
self.usd_account.auxiliary_financing = False
self.usd_account.balance_directions = 'out'
self.create_exchange_wizard.create_exchange()

def test_default_wizard_date(self):
''' 测试向导上默认取当前日期 '''
date_wizard = self.create_exchange_wizard = self.env['create.exchange.wizard'].create({})
# 无期末调汇科目
self.usd_account.currency_id = False
self.env.ref('core.jd').c_category_id.account_id.currency_id = False
date_wizard.create_exchange()


0 comments on commit 36b627d

Please sign in to comment.