Skip to content

Commit

Permalink
[MIG] account_invoice_import: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
V3st1g3 committed Nov 8, 2024
1 parent da4ab84 commit 57c161f
Show file tree
Hide file tree
Showing 10 changed files with 225 additions and 157 deletions.
10 changes: 5 additions & 5 deletions account_invoice_import/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Account Invoice Import
: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
:target: https://github.com/OCA/edi/tree/14.0/account_invoice_import
:target: https://github.com/OCA/edi/tree/16.0/account_invoice_import
:alt: OCA/edi
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/edi-14-0/edi-14-0-account_invoice_import
:target: https://translation.odoo-community.org/projects/edi-16-0/edi-16-0-account_invoice_import
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/edi&target_branch=14.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/edi&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -99,7 +99,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/edi/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/edi/issues/new?body=module:%20account_invoice_import%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/edi/issues/new?body=module:%20account_invoice_import%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand Down Expand Up @@ -142,6 +142,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-alexis-via|

This module is part of the `OCA/edi <https://github.com/OCA/edi/tree/14.0/account_invoice_import>`_ project on GitHub.
This module is part of the `OCA/edi <https://github.com/OCA/edi/tree/16.0/account_invoice_import>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion account_invoice_import/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{
"name": "Account Invoice Import",
"version": "14.0.3.4.0",
"version": "16.0.1.0.0",
"category": "Accounting & Finance",
"license": "AGPL-3",
"summary": "Import supplier invoices/refunds as PDF or XML files",
Expand Down
6 changes: 3 additions & 3 deletions account_invoice_import/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ <h1 class="title">Account Invoice Import</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:26f0853d4122605d020e48687fa420f66fdad1a6c7e41efe74059e0a845f5348
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/edi/tree/14.0/account_invoice_import"><img alt="OCA/edi" src="https://img.shields.io/badge/github-OCA%2Fedi-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/edi-14-0/edi-14-0-account_invoice_import"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/edi&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/edi/tree/16.0/account_invoice_import"><img alt="OCA/edi" src="https://img.shields.io/badge/github-OCA%2Fedi-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/edi-16-0/edi-16-0-account_invoice_import"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/edi&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module has been started by lazy accounting users who hate enter they vendor bills manually in Odoo. Almost all companies have several vendor bills to enter regularly in the system from the same vendors: phone bill, electricity bill, Internet access, train tickets, etc. Most of these invoices are available as PDF. If we are able to automatically extract from the PDF the required information to enter the invoice as vendor bill in Odoo, then this module will create it automatically. To know the full story behind the development of this module, read this <a class="reference external" href="http://www.akretion.com/blog/akretions-christmas-present-for-the-odoo-community">blog post</a>.</p>
<p>In order to reliably extract the required information from the invoice, two international standards exists to describe an Invoice in XML:</p>
<ul class="simple">
Expand Down Expand Up @@ -441,7 +441,7 @@ <h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/edi/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/edi/issues/new?body=module:%20account_invoice_import%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/edi/issues/new?body=module:%20account_invoice_import%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand Down Expand Up @@ -474,7 +474,7 @@ <h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/alexis-via"><img alt="alexis-via" src="https://github.com/alexis-via.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/edi/tree/14.0/account_invoice_import">OCA/edi</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/edi/tree/16.0/account_invoice_import">OCA/edi</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
138 changes: 77 additions & 61 deletions account_invoice_import/tests/test_invoice_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,50 @@
from unittest import mock

from odoo import fields
from odoo.tests.common import SavepointCase
from odoo.tests.common import TransactionCase
from odoo.tools import file_open, float_is_zero

logger = logging.getLogger(__name__)


class TestInvoiceImport(SavepointCase):
class TestInvoiceImport(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.company = cls.env.ref("base.main_company")
cls.company.invoice_import_email = "[email protected]"
cls.expense_account = cls.env["account.account"].create(
{
"code": "612AII",
"name": "expense account invoice import",
"user_type_id": cls.env.ref("account.data_account_type_expenses").id,
"company_id": cls.company.id,
}
[
{
"code": "612AII",
"name": "expense account invoice import",
"user_type_id": cls.env.ref(
"account.data_account_type_expenses"
).id,
"company_id": cls.company.id,
}
]
)
cls.income_account = cls.env["account.account"].create(
{
"code": "707AII",
"name": "revenue account invoice import",
"user_type_id": cls.env.ref("account.data_account_type_revenue").id,
"company_id": cls.company.id,
}
[
{
"code": "707AII",
"name": "revenue account invoice import",
"user_type_id": cls.env.ref("account.data_account_type_revenue").id,
"company_id": cls.company.id,
}
]
)
cls.adjustment_account = cls.env["account.account"].create(
{
"code": "Adjustment",
"name": "adjustment from invoice import",
"user_type_id": cls.env.ref(
"account.data_account_type_current_assets"
).id,
}
[
{
"code": "Adjustment",
"name": "adjustment from invoice import",
"user_type_id": cls.env.ref(
"account.data_account_type_current_assets"
).id,
}
]
)
purchase_tax_vals = {
"name": "Test 1% VAT Purchase",
Expand All @@ -58,7 +66,7 @@ def setUpClass(cls):
# "account_id": cls.expense_account.id,
# "refund_account_id": cls.expense_account.id,
}
cls.purchase_tax = cls.env["account.tax"].create(purchase_tax_vals)
cls.purchase_tax = cls.env["account.tax"].create([purchase_tax_vals])
sale_tax_vals = purchase_tax_vals.copy()
sale_tax_vals.update(
{
Expand All @@ -67,16 +75,18 @@ def setUpClass(cls):
"type_tax_use": "sale",
}
)
cls.sale_tax = cls.env["account.tax"].create(sale_tax_vals)
cls.sale_tax = cls.env["account.tax"].create([sale_tax_vals])
cls.product = cls.env["product.product"].create(
{
"name": "Expense product",
"default_code": "AII-TEST-PRODUCT",
"taxes_id": [(6, 0, [cls.sale_tax.id])],
"supplier_taxes_id": [(6, 0, [cls.purchase_tax.id])],
"property_account_income_id": cls.income_account.id,
"property_account_expense_id": cls.expense_account.id,
}
[
{
"name": "Expense product",
"default_code": "AII-TEST-PRODUCT",
"taxes_id": [(6, 0, [cls.sale_tax.id])],
"supplier_taxes_id": [(6, 0, [cls.purchase_tax.id])],
"property_account_income_id": cls.income_account.id,
"property_account_expense_id": cls.expense_account.id,
}
]
)
cls.all_import_config = [
{
Expand Down Expand Up @@ -117,33 +127,37 @@ def setUpClass(cls):
}
)
cls.partner_with_email = cls.env["res.partner"].create(
{
"is_company": True,
"name": "AgroMilk",
"email": "[email protected]",
"country_id": cls.env.ref("base.fr").id,
}
[
{
"is_company": True,
"name": "AgroMilk",
"email": "[email protected]",
"country_id": cls.env.ref("base.fr").id,
}
]
)
cls.partner_with_email_with_inv_config = cls.env["res.partner"].create(
{
"is_company": True,
"name": "Anevia",
"email": "[email protected]",
"country_id": cls.env.ref("base.fr").id,
"invoice_import_ids": [
(
0,
0,
{
"name": "Import config for Anevia",
"company_id": cls.company.id,
"invoice_line_method": "1line_static_product",
"static_product_id": cls.product.id,
"label": "Flamingo 220S",
},
)
],
}
[
{
"is_company": True,
"name": "Anevia",
"email": "[email protected]",
"country_id": cls.env.ref("base.fr").id,
"invoice_import_ids": [
(
0,
0,
{
"name": "Import config for Anevia",
"company_id": cls.company.id,
"invoice_line_method": "1line_static_product",
"static_product_id": cls.product.id,
"label": "Flamingo 220S",
},
)
],
}
]
)
company = cls.env.ref("base.main_company")
company.update(
Expand Down Expand Up @@ -366,10 +380,12 @@ def test_email_gateway(self):

def test_email_gateway_multi_comp_1_matching(self):
comp = self.env["res.company"].create(
{
"name": "Let it fail INC",
"invoice_import_email": "[email protected]",
}
[
{
"name": "Let it fail INC",
"invoice_import_email": "[email protected]",
}
]
)
logger_name = "odoo.addons.account_invoice_import.wizard.account_invoice_import"

Expand Down Expand Up @@ -408,7 +424,7 @@ def test_email_gateway_multi_comp_1_matching(self):
self.assertIn(msg, "\n".join(watcher.output))

def test_email_gateway_multi_comp_none_matching(self):
self.env["res.company"].create({"name": "Let it fail INC"})
self.env["res.company"].create([{"name": "Let it fail INC"}])
logger_name = "odoo.addons.account_invoice_import.wizard.account_invoice_import"
with self.assertLogs(logger_name, "ERROR") as watcher:
self.env["mail.thread"].with_context(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<group name="main">
<field name="name" />
<field name="partner_id" />
<field name="company_id" invisible="1" />
<field name="company_id" groups="base.group_multi_company" />
<field name="active" invisible="1" />
</group>
Expand Down
27 changes: 20 additions & 7 deletions account_invoice_import/views/account_journal_dashboard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,28 @@
<field name="model">account.journal</field>
<field name="inherit_id" ref="account.account_journal_dashboard_kanban_view" />
<field name="arch" type="xml">
<button
class="btn btn-primary o_button_upload_bill oe_kanban_action_button"
journal_type="purchase"
<widget
name="account_file_uploader"
btnClass="btn btn-primary oe_kanban_action_button"
position="attributes"
>
<attribute name="type">action</attribute>
<attribute name="name">%(account_invoice_import_action)d</attribute>
<attribute name="class">btn btn-primary</attribute>
</button>
<attribute name="invisible">1</attribute>
</widget>
<widget
name="account_file_uploader"
btnClass="btn btn-primary oe_kanban_action_button"
position="after"
>
<button
class="btn btn-primary"
groups="account.group_account_invoice"
journal_type="purchase"
name="%(account_invoice_import_action)d"
type="action"
>
<span>Upload</span>
</button>
</widget>
</field>
</record>
</odoo>
10 changes: 5 additions & 5 deletions account_invoice_import/views/res_partner.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
<record id="view_partner_property_form" model="ir.ui.view">
<field name="model">res.partner</field>
<field name="inherit_id" ref="account.view_partner_property_form" />
<field
name="groups_id"
eval="[(4, ref('account.group_account_invoice')), (4, ref('account.group_account_readonly'))]"
/>
<field name="arch" type="xml">
<button
name="%(base.action_res_partner_bank_account_form)d"
position="after"
>
<div name="invoice_import_configs" colspan="2">
<div
name="invoice_import_configs"
colspan="2"
groups="account.group_account_invoice,account.group_account_readonly"
>
<button
type="object"
class="btn-link"
Expand Down
Loading

0 comments on commit 57c161f

Please sign in to comment.