summaryrefslogtreecommitdiff
path: root/addons/account/tests/test_account_invoice_report.py
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/tests/test_account_invoice_report.py
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/account/tests/test_account_invoice_report.py')
-rw-r--r--addons/account/tests/test_account_invoice_report.py118
1 files changed, 118 insertions, 0 deletions
diff --git a/addons/account/tests/test_account_invoice_report.py b/addons/account/tests/test_account_invoice_report.py
new file mode 100644
index 00000000..e136ef71
--- /dev/null
+++ b/addons/account/tests/test_account_invoice_report.py
@@ -0,0 +1,118 @@
+# -*- 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 TestAccountInvoiceReport(AccountTestInvoicingCommon):
+
+ @classmethod
+ def setUpClass(cls, chart_template_ref=None):
+ super().setUpClass(chart_template_ref=chart_template_ref)
+
+ cls.invoices = cls.env['account.move'].create([
+ {
+ 'move_type': 'out_invoice',
+ 'partner_id': cls.partner_a.id,
+ 'invoice_date': fields.Date.from_string('2016-01-01'),
+ 'currency_id': cls.currency_data['currency'].id,
+ 'invoice_line_ids': [
+ (0, None, {
+ 'product_id': cls.product_a.id,
+ 'quantity': 3,
+ 'price_unit': 750,
+ }),
+ (0, None, {
+ 'product_id': cls.product_a.id,
+ 'quantity': 1,
+ 'price_unit': 3000,
+ }),
+ ]
+ },
+ {
+ 'move_type': 'out_receipt',
+ 'invoice_date': fields.Date.from_string('2016-01-01'),
+ 'currency_id': cls.currency_data['currency'].id,
+ 'invoice_line_ids': [
+ (0, None, {
+ 'product_id': cls.product_a.id,
+ 'quantity': 1,
+ 'price_unit': 6000,
+ }),
+ ]
+ },
+ {
+ 'move_type': 'out_refund',
+ 'partner_id': cls.partner_a.id,
+ 'invoice_date': fields.Date.from_string('2017-01-01'),
+ 'currency_id': cls.currency_data['currency'].id,
+ 'invoice_line_ids': [
+ (0, None, {
+ 'product_id': cls.product_a.id,
+ 'quantity': 1,
+ 'price_unit': 1200,
+ }),
+ ]
+ },
+ {
+ 'move_type': 'in_invoice',
+ 'partner_id': cls.partner_a.id,
+ 'invoice_date': fields.Date.from_string('2016-01-01'),
+ 'currency_id': cls.currency_data['currency'].id,
+ 'invoice_line_ids': [
+ (0, None, {
+ 'product_id': cls.product_a.id,
+ 'quantity': 1,
+ 'price_unit': 60,
+ }),
+ ]
+ },
+ {
+ 'move_type': 'in_receipt',
+ 'partner_id': cls.partner_a.id,
+ 'invoice_date': fields.Date.from_string('2016-01-01'),
+ 'currency_id': cls.currency_data['currency'].id,
+ 'invoice_line_ids': [
+ (0, None, {
+ 'product_id': cls.product_a.id,
+ 'quantity': 1,
+ 'price_unit': 60,
+ }),
+ ]
+ },
+ {
+ 'move_type': 'in_refund',
+ 'partner_id': cls.partner_a.id,
+ 'invoice_date': fields.Date.from_string('2017-01-01'),
+ 'currency_id': cls.currency_data['currency'].id,
+ 'invoice_line_ids': [
+ (0, None, {
+ 'product_id': cls.product_a.id,
+ 'quantity': 1,
+ 'price_unit': 12,
+ }),
+ ]
+ },
+ ])
+
+ def assertInvoiceReportValues(self, expected_values_list):
+ reports = self.env['account.invoice.report'].search([('company_id', '=', self.company_data['company'].id)], order='price_subtotal DESC, quantity ASC')
+ expected_values_dict = [{
+ 'price_average': vals[0],
+ 'price_subtotal': vals[1],
+ 'quantity': vals[2],
+ } for vals in expected_values_list]
+ self.assertRecordValues(reports, expected_values_dict)
+
+ def test_invoice_report_multiple_types(self):
+ self.assertInvoiceReportValues([
+ #price_average price_subtotal quantity
+ [2000, 2000, 1],
+ [1000, 1000, 1],
+ [250, 750, 3],
+ [6, 6, 1],
+ [-20, -20, -1],
+ [-20, -20, -1],
+ [-600, -600, -1],
+ ])