|
- """2026-10-05:13 → 18 指定修复的回归用例,使用独立事务。"""
- from odoo.tests import tagged
- from odoo.tests.common import TransactionCase
-
-
- @tagged('post_install', '-at_install', 'port_13_18')
- class TestPortCheckout(TransactionCase):
- def _checkout(self, month, account=None):
- period = self.env['finance.period'].create({'year': '2040', 'month': str(month)})
- day = '2040-%02d-28' % month
- if account:
- voucher = self.env['voucher'].create({'date': day, 'line_ids': [
- (0, 0, {'name': 'PORT', 'account_id': self.env.ref('finance.account_cash').id, 'debit': 100}),
- (0, 0, {'name': 'PORT', 'account_id': account.id, 'credit': 100}),
- ]})
- voucher.voucher_done()
- wizard = self.env['checkout.wizard'].create({'period_id': period.id, 'date': day})
- result = wizard.button_checkout()
- self.assertTrue(period.is_closed)
- vouchers = self.env['voucher'].search([('period_id', '=', period.id), ('is_checkout', '=', True)], order='create_date desc', limit=1)
- if vouchers:
- self.assertEqual(result['res_id'], vouchers.id)
- else:
- self.assertFalse(result)
-
- def test_monthly(self):
- self._checkout(6, self.env.ref('finance.account_income'))
-
- def test_annual_only(self):
- self._checkout(12, self.env.company.profit_account)
-
- def test_no_voucher(self):
- self._checkout(6)
|