-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] datev_export_xml: Automatic packaging into smaller zip files
- Loading branch information
1 parent
077a387
commit e1ebc4b
Showing
15 changed files
with
347 additions
and
185 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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# © 2023 initOS GmbH | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
import logging | ||
|
||
from odoo import SUPERUSER_ID, api | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
def migrate(cr, version): | ||
env = api.Environment(cr, SUPERUSER_ID, {}) | ||
|
||
query = """ | ||
SELECT id, attachment_id FROM datev_export_xml | ||
WHERE attachment_id IS NOT NULL | ||
""" | ||
env.cr.execute(query) | ||
|
||
for export_id, attachment_id in env.cr.fetchall(): | ||
export = env["datev.export.xml"].browse(export_id) | ||
attachment = env["ir.attachment"].browse(attachment_id) | ||
|
||
_logger.info(f"Migrating attachment of {export}") | ||
|
||
line = export.line_ids.create( | ||
{ | ||
"attachment_id": attachment_id, | ||
"export_id": export_id, | ||
"invoice_ids": [(6, 0, export.invoice_ids.ids)], | ||
} | ||
) | ||
|
||
attachment.write({"res_model": line._name, "res_id": line.id}) |
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.