Skip to content

Commit

Permalink
[IMP] test converted from yaml to unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
Davide Corio authored and tafaRU committed May 2, 2017
1 parent bf708ea commit d1e1e52
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions account_invoice_force_number/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_account_force_number
46 changes: 46 additions & 0 deletions account_invoice_force_number/tests/test_account_force_number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Davide Corio - davidecorio.com
# Copyright 2017 Alex Comba - Agile Business Group
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp.tests.common import TransactionCase


class TestAccountForceNumber(TransactionCase):

def setUp(self):
super(TestAccountForceNumber, self).setUp()

def test_force_number(self):
# in order to test the correct assignment of the internal_number
# I create a customer invoice.
invoice_vals = [
(0, 0, {
'product_id': self.env.ref('product.product_product_3').id,
'quantity': 1.0,
'account_id': self.env['account.account'].search(
[('user_type_id', '=', self.env.ref(
'account.data_account_type_revenue').id)],
limit=1).id,
'name': '[PCSC234] PC Assemble SC234',
'price_unit': 450.00
})
]

invoice = self.env['account.invoice'].create({
'name': "Test Customer Invoice",
'journal_id': self.env['account.journal'].search(
[('type', '=', 'sale')])[0].id,
'partner_id': self.env.ref('base.res_partner_12').id,
'account_id': self.env['account.account'].search(
[('user_type_id', '=', self.env.ref(
'account.data_account_type_receivable').id)],
limit=1).id,
'invoice_line_ids': invoice_vals,
})
# I set the force number
invoice.move_name = '0001'
# I validate the invoice
invoice.action_invoice_open()

# I check that the invoice number is the one we expect
self.assertEqual(invoice.number, invoice.move_name, msg='Wrong number')

0 comments on commit d1e1e52

Please sign in to comment.