-
-
Notifications
You must be signed in to change notification settings - Fork 333
[IMP] account_invoice_import: Add handling for line notes and section headers #1263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
OCA-git-bot
merged 1 commit into
OCA:16.0
from
MarwanBHL:16.0-imp-account_invoice_import-line-note-sectionheader
Dec 30, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,7 +1,3 @@ | ||
| .. image:: https://odoo-community.org/readme-banner-image | ||
| :target: https://odoo-community.org/get-involved?utm_source=readme | ||
| :alt: Odoo Community Association | ||
|
|
||
| ====================== | ||
| Account Invoice Import | ||
| ====================== | ||
|
|
@@ -17,7 +13,7 @@ Account Invoice Import | |
| .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
| :target: https://odoo-community.org/page/development-status | ||
| :alt: Beta | ||
| .. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png | ||
| .. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
| :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
| :alt: License: AGPL-3 | ||
| .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fedi-lightgray.png?logo=github | ||
|
|
@@ -123,6 +119,7 @@ Contributors | |
| * Yannick Vaucher <[email protected]> | ||
| * Ronald Portier <[email protected]> | ||
| * Simone Orsi <[email protected]> | ||
| * Marwan BEHILLIL <[email protected]> | ||
|
|
||
| Maintainers | ||
| ~~~~~~~~~~~ | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -4,3 +4,4 @@ | |
| * Yannick Vaucher <[email protected]> | ||
| * Ronald Portier <[email protected]> | ||
| * Simone Orsi <[email protected]> | ||
| * Marwan BEHILLIL <[email protected]> | ||
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -277,6 +277,80 @@ def test_import_out_invoice(self): | |
| fields.Date.to_string(inv.invoice_date), parsed_inv["date"] | ||
| ) | ||
|
|
||
| def test_import_in_invoice_special_display_types(self): | ||
| parsed_inv = { | ||
| "type": "in_invoice", | ||
| "journal": {"code": "XXXP2"}, | ||
| "amount_untaxed": 0.0, | ||
| "amount_total": 0.0, | ||
| "date": "2017-08-16", | ||
| "partner": {"name": "Wood Corner"}, | ||
| "lines": [ | ||
| {"line_note": "This is a line note"}, | ||
| {"sectionheader": "SECTION 1"}, | ||
| ], | ||
| } | ||
| import_config = {"company": self.company} | ||
| parsed_inv["invoice_number"] = "INV-%s" % randint(100000, 999999) | ||
| inv = self.env["account.invoice.import"].create_invoice( | ||
| parsed_inv, import_config | ||
| ) | ||
| # We expect two created invoice lines corresponding to the note and section | ||
| self.assertEqual(len(inv.invoice_line_ids), 2) | ||
| types = [line.display_type for line in inv.invoice_line_ids] | ||
| self.assertIn("line_note", types) | ||
| self.assertIn("line_section", types) | ||
| # Special display lines should not have a product linked | ||
| for line in inv.invoice_line_ids: | ||
| self.assertFalse(line.product_id) | ||
|
|
||
| def test_import_in_invoice_mixed_display_types_with_product(self): | ||
| parsed_inv = { | ||
| "type": "in_invoice", | ||
| "journal": {"code": "XXXP2"}, | ||
| "amount_untaxed": 100.0, | ||
| "amount_total": 101.0, | ||
| "date": "2017-08-16", | ||
| "partner": {"name": "Wood Corner"}, | ||
| "lines": [ | ||
| {"sectionheader": "SECTION 1"}, | ||
| {"line_note": "This is a line note"}, | ||
| { | ||
| "product": {"code": "AII-TEST-PRODUCT"}, | ||
| "name": "Super test product", | ||
| "qty": 2, | ||
| "price_unit": 50, | ||
| "taxes": [ | ||
| { | ||
| "amount_type": "percent", | ||
| "amount": 1.0, | ||
| "unece_type_code": "VAT", | ||
| "unece_categ_code": "S", | ||
| } | ||
| ], | ||
| }, | ||
| ], | ||
| } | ||
| import_config = {"company": self.company} | ||
| parsed_inv["invoice_number"] = "INV-%s" % randint(100000, 999999) | ||
| inv = self.env["account.invoice.import"].create_invoice( | ||
| parsed_inv, import_config | ||
| ) | ||
| # Expect three lines: section, note, and product | ||
| self.assertEqual(len(inv.invoice_line_ids), 3) | ||
| types = [line.display_type for line in inv.invoice_line_ids] | ||
| self.assertIn("line_section", types) | ||
| self.assertIn("line_note", types) | ||
| self.assertIn("product", types) | ||
| # Check product line exists and has correct product and qty | ||
| prod_lines = [ | ||
| line for line in inv.invoice_line_ids if line.display_type == "product" | ||
| ] | ||
| self.assertEqual(len(prod_lines), 1) | ||
| prod_line = prod_lines[0] | ||
| self.assertEqual(prod_line.product_id.id, self.product.id) | ||
| self.assertEqual(prod_line.quantity, 2) | ||
|
|
||
| _fake_email = """ | ||
| Received: by [email protected] | ||
| Message-Id: <[email protected]> | ||
|
|
||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.