File tree Expand file tree Collapse file tree 2 files changed +25
-19
lines changed
l10n_it_edi_extension/tests Expand file tree Collapse file tree 2 files changed +25
-19
lines changed Original file line number Diff line number Diff line change 22# Copyright 2025 Simone Rubino
33# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
44
5+ import base64
56
6- from odoo .fields import Command
7+ from odoo import tools
8+ from odoo .fields import Command , Domain
79
810from odoo .addons .l10n_it_edi .tests .common import TestItEdi
911
@@ -91,3 +93,23 @@ def setUpClass(cls):
9193 }
9294 )
9395 )
96+
97+ def _import_moves_from_zip (self , zip_name ):
98+ path = f"{ self .module } /tests/import_xmls/{ zip_name } "
99+ with tools .file_open (path , mode = "rb" ) as file :
100+ encoded_file = base64 .encodebytes (file .read ())
101+
102+ wizard_attachment_import = (
103+ self .env ["l10n_it_edi.import_file_wizard" ]
104+ .with_company (self .company )
105+ .create (
106+ {
107+ "l10n_it_edi_attachment_filename" : zip_name ,
108+ "l10n_it_edi_attachment" : encoded_file ,
109+ }
110+ )
111+ )
112+ action = wizard_attachment_import .action_import ()
113+
114+ move_ids = action .get ("domain" , Domain ).value
115+ return self .env ["account.move" ].browse (move_ids )
Original file line number Diff line number Diff line change 88
99from odoo import tools
1010from odoo .exceptions import MissingError
11- from odoo .fields import Domain
1211
1312from .common import Common
1413
@@ -95,24 +94,9 @@ def test_04_xml_import(self):
9594 self .assertEqual (edi_attachment , orig_attachment_data )
9695
9796 def test_import_zip (self ):
98- path = "l10n_it_edi_extension/tests/import_xmls/xml_import.zip"
99- import_file_model = self .env ["l10n_it_edi.import_file_wizard" ].with_company (
100- self .company
101- )
102-
103- with tools .file_open (path , mode = "rb" ) as file :
104- encoded_file = base64 .encodebytes (file .read ())
105-
106- wizard_attachment_import = import_file_model .create (
107- {
108- "l10n_it_edi_attachment_filename" : "xml_import.zip" ,
109- "l10n_it_edi_attachment" : encoded_file ,
110- }
111- )
112- action = wizard_attachment_import .action_import ()
97+ zip_name = "xml_import.zip"
98+ moves = self ._import_moves_from_zip (zip_name )
11399
114- move_ids = action .get ("domain" , Domain ).value
115- moves = self .env ["account.move" ].browse (move_ids )
116100 out_moves = moves .filtered (lambda m : m .is_sale_document ())
117101 in_moves = moves .filtered (lambda m : m .is_purchase_document ())
118102 self .assertEqual (len (out_moves ), 6 )
You can’t perform that action at this time.
0 commit comments