-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1559 from VoicuStefan2001/16.0-upd-deltatech_invo…
…ice_product_filter [16.0][UPD] deltatech_invoice_product_filter
- Loading branch information
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
73
deltatech_invoice_product_filter/tests/test_invoice_filter.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |