-
-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] account_invoice_import: Migration to 16.0
- Loading branch information
Showing
10 changed files
with
239 additions
and
171 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
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
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
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 |
---|---|---|
|
@@ -8,42 +8,46 @@ | |
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", | ||
"account_type": 'expense', | ||
"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", | ||
"account_type": 'income', | ||
"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", | ||
"account_type": 'asset_current', | ||
} | ||
] | ||
) | ||
purchase_tax_vals = { | ||
"name": "Test 1% VAT Purchase", | ||
|
@@ -58,7 +62,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( | ||
{ | ||
|
@@ -67,16 +71,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 = [ | ||
{ | ||
|
@@ -99,51 +105,59 @@ def setUpClass(cls): | |
# Deco Addict | ||
cls.env.ref("base.res_partner_2").customer_rank = 1 | ||
cls.pur_journal1 = cls.env["account.journal"].create( | ||
{ | ||
"type": "purchase", | ||
"code": "XXXP1", | ||
"name": "Test Purchase Journal 1", | ||
"sequence": 10, | ||
"company_id": cls.company.id, | ||
} | ||
[ | ||
{ | ||
"type": "purchase", | ||
"code": "XXXP1", | ||
"name": "Test Purchase Journal 1", | ||
"sequence": 10, | ||
"company_id": cls.company.id, | ||
} | ||
] | ||
) | ||
cls.pur_journal2 = cls.env["account.journal"].create( | ||
{ | ||
"type": "purchase", | ||
"code": "XXXP2", | ||
"name": "Test Purchase Journal 2", | ||
"sequence": 100, | ||
"company_id": cls.company.id, | ||
} | ||
[ | ||
{ | ||
"type": "purchase", | ||
"code": "XXXP2", | ||
"name": "Test Purchase Journal 2", | ||
"sequence": 100, | ||
"company_id": cls.company.id, | ||
} | ||
] | ||
) | ||
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( | ||
|
@@ -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" | ||
|
||
|
@@ -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( | ||
|
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
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
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
Oops, something went wrong.