summaryrefslogtreecommitdiff
path: root/addons/account_debit_note/tests
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/account_debit_note/tests
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/account_debit_note/tests')
-rw-r--r--addons/account_debit_note/tests/__init__.py3
-rw-r--r--addons/account_debit_note/tests/test_out_debit_note.py46
2 files changed, 49 insertions, 0 deletions
diff --git a/addons/account_debit_note/tests/__init__.py b/addons/account_debit_note/tests/__init__.py
new file mode 100644
index 00000000..2e857aca
--- /dev/null
+++ b/addons/account_debit_note/tests/__init__.py
@@ -0,0 +1,3 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+from . import test_out_debit_note \ No newline at end of file
diff --git a/addons/account_debit_note/tests/test_out_debit_note.py b/addons/account_debit_note/tests/test_out_debit_note.py
new file mode 100644
index 00000000..64746236
--- /dev/null
+++ b/addons/account_debit_note/tests/test_out_debit_note.py
@@ -0,0 +1,46 @@
+# -*- coding: utf-8 -*-
+from odoo.addons.account.tests.common import AccountTestInvoicingCommon
+from odoo.tests import tagged
+from odoo import fields
+
+
+@tagged('post_install', '-at_install')
+class TestAccountDebitNote(AccountTestInvoicingCommon):
+
+ def test_00_debit_note_out_invoice(self):
+ """ Debit Note of a regular Customer Invoice"""
+ invoice = self.init_invoice('out_invoice', products=self.product_a+self.product_b)
+ invoice.action_post()
+ move_debit_note_wiz = self.env['account.debit.note'].with_context(active_model="account.move",
+ active_ids=invoice.ids).create({
+ 'date': fields.Date.from_string('2019-02-01'),
+ 'reason': 'no reason',
+ 'copy_lines': True,
+ })
+ move_debit_note_wiz.create_debit()
+
+ # Search for the original invoice
+ debit_note = self.env['account.move'].search([('debit_origin_id', '=', invoice.id)])
+ debit_note.ensure_one()
+ self.assertEqual(len(debit_note.invoice_line_ids), 2, "Should have copied the invoice lines")
+ self.assertEqual(debit_note.move_type, 'out_invoice', 'Type of debit note should be the same as the original invoice')
+ self.assertEqual(debit_note.state, 'draft', 'We should create debit notes in draft state')
+
+ def test_10_debit_note_in_refund(self):
+ """ Debit Note of a vendor refund (is a regular vendor bill) """
+ invoice = self.init_invoice('in_refund', products=self.product_a+self.product_b)
+ invoice.action_post()
+ move_debit_note_wiz = self.env['account.debit.note'].with_context(active_model="account.move",
+ active_ids=invoice.ids).create({
+ 'date': fields.Date.from_string('2019-02-01'),
+ 'reason': 'in order to cancel refund',
+ })
+ move_debit_note_wiz.create_debit()
+
+ # Search for the original invoice
+ debit_note = self.env['account.move'].search([('debit_origin_id', '=', invoice.id)])
+ debit_note.ensure_one()
+
+ self.assertFalse(debit_note.invoice_line_ids, 'We should not copy lines by default on debit notes')
+ self.assertEqual(debit_note.move_type, 'in_invoice', 'Type of debit note should not be refund anymore')
+ self.assertEqual(debit_note.state, 'draft', 'We should create debit notes in draft state')