Skip to content

Commit

Permalink
Merge pull request #1559 from VoicuStefan2001/16.0-upd-deltatech_invo…
Browse files Browse the repository at this point in the history
…ice_product_filter

[16.0][UPD] deltatech_invoice_product_filter
  • Loading branch information
VoicuStefan2001 authored Jul 15, 2024
2 parents 2605f74 + 6b6dd40 commit d64b9f9
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
1 change: 1 addition & 0 deletions deltatech_invoice_product_filter/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# © 2008-2021 Deltatech
# Dorin Hongu <dhongu(@)gmail(.)com
# See README.rst file on addons root folder for license details
from . import test_invoice_filter
73 changes: 73 additions & 0 deletions deltatech_invoice_product_filter/tests/test_invoice_filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
from odoo.tests.common import TransactionCase


class TestAccountInvoiceView(TransactionCase):
def setUp(self):
super().setUp()

# Create necessary records for the test
self.company = self.env["res.company"].create(
{
"name": "Test Company",
}
)

self.journal = self.env["account.journal"].create(
{
"name": "Test Journal",
"type": "general",
"code": "TJ",
"company_id": self.company.id,
}
)

self.product_a = self.env["product.product"].create(
{
"name": "Test A",
"type": "consu",
"company_id": self.company.id,
}
)

self.partner = self.env["res.partner"].create(
{
"name": "Test Partner",
"company_id": self.company.id,
}
)

self.account = self.env["account.account"].create(
{
"name": "Test Account",
"code": "TEST",
"company_id": self.company.id,
}
)

self.invoice_a = self.env["account.move"].create(
{
"partner_id": self.partner.id,
"company_id": self.company.id,
"journal_id": self.journal.id,
"invoice_line_ids": [
(
0,
0,
{
"product_id": self.product_a.id,
"quantity": 1,
"name": "Test A",
"price_unit": 1.0,
"account_id": self.account.id,
},
)
],
}
)

def test_product_filter(self):
# Use the product filter to search for invoices
invoices = self.env["account.move"].search([("line_ids.product_id", "ilike", "Test A")])

# Check that the correct invoice was found
self.assertEqual(invoices, self.invoice_a)

0 comments on commit d64b9f9

Please sign in to comment.